CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Typed Values

Macros

#define strscVal(sc, type, pval)   _strscVal(sc, stCheckedPtrArg(type, pval))
 

Functions

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)
 

Detailed Description

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.

Macro Definition Documentation

◆ 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
scScanner to read from
typeType name of the destination
pvalPointer to the variable that receives the value
Returns
true if a value was read and converted

Example:

int32 count;
SUID id;
strscVal(&sc, int32, &count);
strscWS1(&sc);
strscVal(&sc, suid, &id);
bool strscWS1(strscan *sc)
#define strscVal(sc, type, pval)
Definition strscan.h:419
128-bit sortable unique identifier
Definition suid.h:47

Definition at line 419 of file strscan.h.

Function Documentation

◆ 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
scScanner to read from
outReceives 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
scScanner to read from
outReceives 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
scScanner to read from
outReceives 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
scScanner to read from
outReceives the value
baseNumeric 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
scScanner to read from
outReceives the value
baseNumeric 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
scScanner to read from
outReceives the value
baseNumeric 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
scScanner to read from
outReceives the value
baseNumeric base (2-36)
Returns
true if a value in range was read