|
| bool | strscInt32 (strscan *sc, int32 *out, int base) |
| |
| bool | strscUInt32 (strscan *sc, uint32 *out, int base) |
| |
| bool | strscInt64 (strscan *sc, int64 *out, int base) |
| |
| bool | strscUInt64 (strscan *sc, uint64 *out, int base) |
| |
| bool | strscFloat32 (strscan *sc, float32 *out) |
| |
| bool | strscFloat64 (strscan *sc, float64 *out) |
| |
| bool | strscBool (strscan *sc, bool *out) |
| |
The numeric readers consume exactly what their own syntax allows and stop there, so "12," reads as 12 and leaves the comma at the cursor. None of them skip leading whitespace or accept a "0x" prefix - call strscWS() first if the grammar allows space there, and pass base 16 for hex.
◆ strscVal
| #define strscVal |
( |
|
sc, |
|
|
|
type, |
|
|
|
pval |
|
) |
| _strscVal(sc, stCheckedPtrArg(type, pval)) |
bool strscVal(strscan *sc, type, type *pval)
Reads a value of any type the type system knows how to build from a string.
Numbers and booleans read exactly as the functions above do. Every other type reads a whitespace-delimited word and converts it, which is how a scanner picks up SUIDs, enums, custom types and anything else with a string conversion.
- Parameters
-
| sc | Scanner to read from |
| type | Type name of the destination |
| pval | Pointer to the variable that receives the value |
- Returns
- true if a value was read and converted
Example:
int32 count;
bool strscWS1(strscan *sc)
#define strscVal(sc, type, pval)
128-bit sortable unique identifier
Definition at line 419 of file strscan.h.
◆ strscBool()
| bool strscBool |
( |
strscan * |
sc, |
|
|
bool * |
out |
|
) |
| |
Reads a boolean written as true/false, yes/no or 1/0.
The words are matched without regard to case.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
- Returns
- true if a boolean was read
◆ strscFloat32()
| bool strscFloat32 |
( |
strscan * |
sc, |
|
|
float32 * |
out |
|
) |
| |
Reads a floating point number, in decimal or scientific notation.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
- Returns
- true if a value was read
◆ strscFloat64()
| bool strscFloat64 |
( |
strscan * |
sc, |
|
|
float64 * |
out |
|
) |
| |
Reads a floating point number, in decimal or scientific notation.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
- Returns
- true if a value was read
◆ strscInt32()
| bool strscInt32 |
( |
strscan * |
sc, |
|
|
int32 * |
out, |
|
|
int |
base |
|
) |
| |
Reads a decimal or based integer.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
| base | Numeric base (2-36) |
- Returns
- true if a value in range was read
◆ strscInt64()
| bool strscInt64 |
( |
strscan * |
sc, |
|
|
int64 * |
out, |
|
|
int |
base |
|
) |
| |
Reads a 64-bit integer.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
| base | Numeric base (2-36) |
- Returns
- true if a value in range was read
◆ strscUInt32()
| bool strscUInt32 |
( |
strscan * |
sc, |
|
|
uint32 * |
out, |
|
|
int |
base |
|
) |
| |
Reads an unsigned integer. A sign is not accepted.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
| base | Numeric base (2-36) |
- Returns
- true if a value in range was read
◆ strscUInt64()
| bool strscUInt64 |
( |
strscan * |
sc, |
|
|
uint64 * |
out, |
|
|
int |
base |
|
) |
| |
Reads an unsigned 64-bit integer. A sign is not accepted.
- Parameters
-
| sc | Scanner to read from |
| out | Receives the value |
| base | Numeric base (2-36) |
- Returns
- true if a value in range was read