ZFFramework
 
Loading...
Searching...
No Matches
ZFIOCallback_util.h File Reference

common callback defines More...

Go to the source code of this file.

Functions

zfindex ZFInputReadChar (zfchar *buf, const ZFInput &input)
 read single logic char to buf, return count of sizoef(zfchar) if success, or 0 if fail
 
zfindex ZFInputReadChar (zfstring &buf, const ZFInput &input)
 see ZFInputReadChar
 
zfindex ZFInputSkipChars (zfchar *buf, const ZFInput &input, const zfchar *charSet=" \t\r\n")
 util method to skip chars in set
 
zfindex ZFInputReadUntil (zfstring &ret, const ZFInput &input, const zfchar *charSet=" \t\r\n", zfindex maxCount=((zfindex) -1), zfchar *firstMatchedChar=zft_zfnull)
 read until any char in charSet shows up, or reached maxCount, return count read so far
 
zfindex ZFInputCheckMatch (const zfchar **tokens, zfindex tokenCount, const ZFInput &input)
 util method to check whether the input match the tokens
 
zfindex ZFInputRead (const ZFOutput &output, const ZFInput &input, zfindex size=((zfindex) -1))
 util method to read contents of input to output
 
zfindex ZFInputRead (zfstring &ret, const ZFInput &input, zfindex size=((zfindex) -1))
 util method to read contents from input to string
 
zfindex ZFInputReadLine (const ZFOutput &output, const ZFInput &input)
 util method to read one line
 
zfindex ZFInputReadLine (zfstring &output, const ZFInput &input)
 util method to read one line
 
void ZFOutputRepeat (const ZFOutput &output, const zfchar *token, zfindex count)
 repeat output
 
ZFOutput ZFOutputChain (const ZFOutput &o0, const ZFOutput &o1, const ZFOutput &o2=zft_zfnull, const ZFOutput &o3=zft_zfnull, const ZFOutput &o4=zft_zfnull, const ZFOutput &o5=zft_zfnull, const ZFOutput &o6=zft_zfnull, const ZFOutput &o7=zft_zfnull)
 util to create a chained output
 
ZFOutput ZFOutputChain (const ZFCoreArray< ZFOutput > &o)
 util to create a chained output
 

Detailed Description

common callback defines

Function Documentation

◆ ZFInputReadChar()

zfindex ZFInputReadChar ( zfchar * buf,
const ZFInput & input )
extern

read single logic char to buf, return count of sizoef(zfchar) if success, or 0 if fail

since UTF-8 has variable logic char size, use this method to read a single logic char
note: result may have more than one char for invalid encoding, and buf size must at least 9 byte size

◆ ZFInputSkipChars()

zfindex ZFInputSkipChars ( zfchar * buf,
const ZFInput & input,
const zfchar * charSet = " \t\r\n" )
extern

util method to skip chars in set

return 0 if all chars are skipped before end, other wise, buf stores the first logic char (see ZFInputReadChar)

◆ ZFInputReadUntil()

zfindex ZFInputReadUntil ( zfstring & ret,
const ZFInput & input,
const zfchar * charSet = " \t\r\n",
zfindex maxCount = ((zfindex) -1),
zfchar * firstMatchedChar = zft_zfnull )
extern

read until any char in charSet shows up, or reached maxCount, return count read so far

the first char matched charSet would be read and discarded, and you may check it by firstMatchedChar, if reached end or maxCount before matched charSet, 0 would be returned to firstMatchedChar

◆ ZFInputCheckMatch()

zfindex ZFInputCheckMatch ( const zfchar ** tokens,
zfindex tokenCount,
const ZFInput & input )
extern

util method to check whether the input match the tokens

return token's index if match or zfindexMax() if no match or error, header white spaces would be skipped automatically
if no match, this method would try to restore the callback state by ioSeek to original position

◆ ZFInputRead() [1/2]

zfindex ZFInputRead ( const ZFOutput & output,
const ZFInput & input,
zfindex size = ((zfindex) -1) )
extern

util method to read contents of input to output

return size already written to output even if error occurred

◆ ZFInputRead() [2/2]

zfindex ZFInputRead ( zfstring & ret,
const ZFInput & input,
zfindex size = ((zfindex) -1) )
extern

util method to read contents from input to string

return size appended to string

◆ ZFInputReadLine() [1/2]

zfindex ZFInputReadLine ( const ZFOutput & output,
const ZFInput & input )
extern

util method to read one line

return size read for the line (excluding the endl), or 0 for empty line, or zfindexMax if failed

◆ ZFInputReadLine() [2/2]

zfindex ZFInputReadLine ( zfstring & output,
const ZFInput & input )
extern

util method to read one line

return size read for the line (excluding the endl), or 0 for empty line, or zfindexMax if failed
note the result would be appended to the string

◆ ZFOutputChain()

ZFOutput ZFOutputChain ( const ZFOutput & o0,
const ZFOutput & o1,
const ZFOutput & o2 = zft_zfnull,
const ZFOutput & o3 = zft_zfnull,
const ZFOutput & o4 = zft_zfnull,
const ZFOutput & o5 = zft_zfnull,
const ZFOutput & o6 = zft_zfnull,
const ZFOutput & o7 = zft_zfnull )
extern

util to create a chained output

typical usage:

, ZFOutputForFile('/path/to/log/file')
))
ZFOutput ZFOutputChain(const ZFOutput &o0, const ZFOutput &o1, const ZFOutput &o2=zft_zfnull, const ZFOutput &o3=zft_zfnull, const ZFOutput &o4=zft_zfnull, const ZFOutput &o5=zft_zfnull, const ZFOutput &o6=zft_zfnull, const ZFOutput &o7=zft_zfnull)
util to create a chained output
const ZFOutput & ZFOutputDefault(void)
default output callback, output source must be zfchar *string
ZFOutput & ZFOutputForConsole(void)
default output callback to output to console, source must be zfchar *string
Definition ZFOutputForConsole.h:27
ZFOutput ZFOutputForFile(const zfchar *filePath, ZFFileOpenOptionFlags flags=(v_ZFFileOpenOption::e_Create))
util to create a file output callback
Definition ZFPathType_file.h:55