string format util
More...
Go to the source code of this file.
◆ zfstr()
string format util
usage:
void zfstringAppend(zfstring &s, const zfchar *fmt)
see zfstr
Definition zfstr.h:66
const zfchar * zfstr(const zfchar *fmt=0)
string format util
Definition zfstr.h:59
it's ensured type safe, you may simply use s
everywhere, but for convenient, we also support these tokens:
- "b": zfbool (e.g. true)
- "zi": zfindex (e.g. 13579)
- "d" or "i": zfint (e.g. -13579)
- "u": zfuint (e.g. 13579)
- "o": zfuint, in octal (e.g. 01234567)
- "x": zfuint, in heximal, lowercase (e.g. 0x1234abcd)
- "X": zfuint, in heximal, uppercase (e.g. 0x1234ABCD)
- "f": zffloat, accuracy is not ensured (e.g. 13.579)
- "p": pointer value (e.g. 0x1234ABCD)
- "c" or "C": char
- "s" or "S": zfchar string
- "%": % itself
extra format tokens can be added before any of those listed above (except "%"), similar to printf, they are:
- "-": left justify
- "0": leading zero fill
- "+": print plus if positive number
- " ": print space if positive number
- "m": minimum width
- ".n": decimal width for float types or max width for string types
note:
- support up to 16 params
- it's safe to pass any type that registered by ZFOUTPUT_TYPE, and you must register you custom type before calling this method with your custom type
- params are converted to string before extra parsing (such as convert to
x
), when not able to perform conversion, it's ensured no error would occur for safety and convenient
- when params less than
s
token, the exceed s
token would be processed as empty string was passed
- when params more than
s
token, the exceed param would be discarded