Low-level function to convert a string to ints, floats or bools.
This function is the low-level high-performance parsing function. This function does not trim any data from input before parsing.
Supported types are signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, bool.
signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long and unsigned long long parsing support decimal, hexadecimal (0x{value} or 0X{value}), octal (0o{value} or 0O{value}) and binary (0b{value} or 0B{value}) integers. Overflow will return an error.
Limitations:
- When parsing a hexadecimal, octal or binary number, if a leading
- is parsed, it will return an error. When parsing a signed type, hexadecimal, octal or binary number parsing uses the unsigned variant of the type, then reinterpreted to the signed type. For example parsing "0xFF" to a int8_t will parse -1.
- Octal old format (
0{value}) is not supported.
- When parsing a unsigned type, if a leading
- is parsed, it will return an error.
- Leading
+ is not supported and will return an error.
float, double parsing always uses '.' as separator of the integer and decimal part of a number. Scientific format is supported, both e and E are supported. nan and [-]inf are supported and case insensitive.
Limitations:
- Leading
+ is not supported and will return an error.
bool parsing supports the following syntaxes: "0", "1", "false", "False", "true" and "True".
- Parameters
-
| begin | Begin of the range to convert |
| end | End of the range to convert |
| output | Variable to write output to. If parsing failed, output is left unmodified. |
- Returns
- The number of consumed characters. 0 is returned to indicate failure, or empty range. If 0 is returned, output is not modified, otherwise it contains the parsed value.