yumapro
24.10-1
YumaPro SDK
|
Make sure to include "ncxtypes.h" and "ncx_num.h" to use the ncx_num APIs. More...
Functions | |
void | ncx_init_num (ncx_num_t *num) |
Init a ncx_num_t struct. More... | |
void | ncx_clean_num (ncx_btype_t btyp, ncx_num_t *num) |
Scrub the memory in a ncx_num_t by freeing all the sub-fields. More... | |
int32 | ncx_compare_nums (const ncx_num_t *num1, const ncx_num_t *num2, ncx_btype_t btyp) |
Compare 2 ncx_num_t union contents. More... | |
void | ncx_set_num_min (ncx_num_t *num, ncx_btype_t btyp) |
Set a number to the minimum value for its type. More... | |
void | ncx_set_num_max (ncx_num_t *num, ncx_btype_t btyp) |
Set a number to the maximum value for its type. More... | |
void | ncx_set_num_one (ncx_num_t *num, ncx_btype_t btyp) |
Set a number to one. More... | |
void | ncx_set_num_zero (ncx_num_t *num, ncx_btype_t btyp) |
Set a number to zero. More... | |
void | ncx_set_num_nan (ncx_num_t *num, ncx_btype_t btyp) |
Set a FP number to the Not a Number value. More... | |
boolean | ncx_num_is_nan (ncx_num_t *num, ncx_btype_t btyp) |
Check if a FP number is set to the Not a Number value. More... | |
boolean | ncx_num_zero (const ncx_num_t *num, ncx_btype_t btyp) |
Compare a ncx_num_t to zero. More... | |
status_t | ncx_convert_num (const xmlChar *numstr, ncx_numfmt_t numfmt, ncx_btype_t btyp, ncx_num_t *val) |
Convert a number string to a numeric type. More... | |
status_t | ncx_convert_dec64 (const xmlChar *numstr, ncx_numfmt_t numfmt, uint8 digits, ncx_num_t *val) |
Convert a number string to a decimal64 number. More... | |
status_t | ncx_convert_cbor_dec64 (int64 mantissa, int64 basenum, uint8 digits, ncx_num_t *val) |
Convert a CBOR decimal bignum to a decimal64 number. More... | |
status_t | ncx_decode_num (const xmlChar *numstr, ncx_btype_t btyp, ncx_num_t *retnum) |
Handle some sort of number string. More... | |
status_t | ncx_decode_num_ex (const xmlChar *numstr, ncx_btype_t btyp, ncx_num_t *retnum, typ_def_t *typdef) |
Handle some sort of number string EXTENDED. More... | |
status_t | ncx_decode_dec64 (const xmlChar *numstr, uint8 digits, ncx_num_t *retnum) |
Handle some sort of decimal64 number string (NCX_BT_DECIMAL64) More... | |
status_t | ncx_copy_num (const ncx_num_t *num1, ncx_num_t *num2, ncx_btype_t btyp) |
Copy the contents of num1 to num2. More... | |
status_t | ncx_cast_num (const ncx_num_t *num1, ncx_btype_t btyp1, ncx_num_t *num2, ncx_btype_t btyp2) |
Cast a number as another number type. More... | |
status_t | ncx_num_floor (const ncx_num_t *num1, ncx_num_t *num2, ncx_btype_t btyp) |
Get the floor value of a number. More... | |
status_t | ncx_num_ceiling (const ncx_num_t *num1, ncx_num_t *num2, ncx_btype_t btyp) |
Get the ceiling value of a number. More... | |
status_t | ncx_round_num (const ncx_num_t *num1, ncx_num_t *num2, ncx_btype_t btyp) |
Get the rounded value of a number. More... | |
boolean | ncx_num_is_integral (const ncx_num_t *num, ncx_btype_t btyp) |
Check if the number is integral or if it has a fractional part. More... | |
int64 | ncx_cvt_to_int64 (const ncx_num_t *num, ncx_btype_t btyp) |
Convert a number to an integer64; Use rounding for float64. More... | |
ncx_numfmt_t | ncx_get_numfmt (const xmlChar *numstr) |
Get the number format of the specified string. More... | |
void | ncx_printf_num (const ncx_num_t *num, ncx_btype_t btyp, log_debug_t level) |
Printf a ncx_num_t contents using logging functions. More... | |
void | ncx_printf_num_ex (const ncx_num_t *num, ncx_btype_t btyp, log_debug_t level, FILE *overrideOut) |
Printf a ncx_num_t contents (write to a file) More... | |
void | ncx_alt_printf_num (const ncx_num_t *num, ncx_btype_t btyp) |
Printf a ncx_num_t contents to the alternate log file. More... | |
void | ncx_audit_printf_num (const ncx_num_t *num, ncx_btype_t btyp) |
Printf a ncx_num_t contents to the audit log file. More... | |
status_t | ncx_sprintf_num (xmlChar *buff, const ncx_num_t *num, ncx_btype_t btyp, uint32 *len) |
Sprintf a ncx_num_t contents. More... | |
boolean | ncx_is_min (const ncx_num_t *num, ncx_btype_t btyp) |
Return TRUE if the specified number is the min value for its type. More... | |
boolean | ncx_is_max (const ncx_num_t *num, ncx_btype_t btyp) |
Return TRUE if the specified number is the max value for its type. More... | |
status_t | ncx_convert_tkcnum (tk_chain_t *tkc, ncx_btype_t btyp, ncx_num_t *val) |
Convert the current token in a token chain to a ncx_num_t struct. More... | |
status_t | ncx_convert_tkc_dec64 (tk_chain_t *tkc, uint8 digits, ncx_num_t *val) |
Convert the current token in a token chain to a ncx_num_t struct, expecting NCX_BT_DECIMAL64. More... | |
int64 | ncx_get_dec64_base (const ncx_num_t *num) |
Get the base part of a decimal64 number. More... | |
int64 | ncx_get_dec64_fraction (const ncx_num_t *num) |
Get the fraction part of a decimal64 number. More... | |
status_t | ncx_set_num_from_uint64 (ncx_num_t *retval, uint64 val, ncx_btype_t btyp, boolean is_neg) |
Set the number from a uint64 plus sign flag. More... | |
Make sure to include "ncxtypes.h" and "ncx_num.h" to use the ncx_num APIs.
void ncx_alt_printf_num | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Printf a ncx_num_t contents to the alternate log file.
num | number to printf |
btyp | number base type |
void ncx_audit_printf_num | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Printf a ncx_num_t contents to the audit log file.
num | number to printf |
btyp | number base type |
status_t ncx_cast_num | ( | const ncx_num_t * | num1, |
ncx_btype_t | btyp1, | ||
ncx_num_t * | num2, | ||
ncx_btype_t | btyp2 | ||
) |
Cast a number as another number type.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_FLOAT64
num1 | source number | |
btyp1 | expected data type of num1 | |
num2 | target number | |
[out] | btyp2 | desired data type of num2
|
void ncx_clean_num | ( | ncx_btype_t | btyp, |
ncx_num_t * | num | ||
) |
Scrub the memory in a ncx_num_t by freeing all the sub-fields.
DOES NOT free the entire struct itself The struct must be removed from any queue it is in before this function is called.
btyp | base type of number |
num | ncx_num_t data structure to clean |
int32 ncx_compare_nums | ( | const ncx_num_t * | num1, |
const ncx_num_t * | num2, | ||
ncx_btype_t | btyp | ||
) |
Compare 2 ncx_num_t union contents.
num1 | first number to compare |
num2 | second number to compare |
btyp | expected data type (NCX_BT_INT, UINT, REAL) |
-1 if num1 is < num2 0 if num1 == num2 1 if num1 is > num2
Convert a CBOR decimal bignum to a decimal64 number.
Special handling for decimal64 data type Convert a CBOR decimal fraction to a decimal64 number Received: Tag(4) [int64, int64] representing mantissa and base number
The CBOR representation must be converted to the internal dec64 representation. The saved shifted numer must have the same number of digits as the typedef
Checks for data type overflow, based on RFC 7950, sec. 9.3
mantissa | mantissa from CBOR array first number | |
basenum | base number from CBOR array second number | |
digits | number of fixed-point digits expected | |
[out] | val | pointer to ncx_num_t to hold result
|
status_t ncx_convert_dec64 | ( | const xmlChar * | numstr, |
ncx_numfmt_t | numfmt, | ||
uint8 | digits, | ||
ncx_num_t * | val | ||
) |
Convert a number string to a decimal64 number.
Special handling for decimal64 data type
numstr | number string | |
numfmt | number format used | |
digits | number of fixed-point digits expected | |
[out] | val | pointer to ncx_num_t to hold result
|
status_t ncx_convert_num | ( | const xmlChar * | numstr, |
ncx_numfmt_t | numfmt, | ||
ncx_btype_t | btyp, | ||
ncx_num_t * | val | ||
) |
Convert a number string to a numeric type.
Used by the XML and CLI parsers to convert numbers
numstr | number string to convert | |
numfmt | NCX_NF_OCTAL, NCX_NF_DEC, NCX_NF_HEX, or NCX_NF_REAL | |
btyp | desired number type (e.g., NCX_BT_INT32, NCX_BT_UINT32, NCX_BT_FLOAT64) | |
[out] | val | pointer to ncx_num_t to hold result
|
status_t ncx_convert_tkc_dec64 | ( | tk_chain_t * | tkc, |
uint8 | digits, | ||
ncx_num_t * | val | ||
) |
Convert the current token in a token chain to a ncx_num_t struct, expecting NCX_BT_DECIMAL64.
tkc | token chain; current token will be converted tkc->typ == TK_TT_DNUM, TK_TT_HNUM, TK_TT_RNUM | |
digits | number of expected decimal digits | |
[out] | val | address of return value
|
status_t ncx_convert_tkcnum | ( | tk_chain_t * | tkc, |
ncx_btype_t | btyp, | ||
ncx_num_t * | val | ||
) |
Convert the current token in a token chain to a ncx_num_t struct.
tkc | token chain; current token will be converted tkc->typ == TK_TT_DNUM, TK_TT_HNUM, TK_TT_RNUM | |
btyp | desired number type (e.g., NCX_BT_INT32, NCX_BT_UINT64, NCX_BT_FLOAT64) | |
[out] | val | address of return value
|
status_t ncx_copy_num | ( | const ncx_num_t * | num1, |
ncx_num_t * | num2, | ||
ncx_btype_t | btyp | ||
) |
Copy the contents of num1 to num2.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_DECIMAL64 NCX_BT_FLOAT64
num1 | source number |
num2 | destination number |
btyp | expected data type (NCX_BT_INT, UINT, REAL) |
int64 ncx_cvt_to_int64 | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Convert a number to an integer64; Use rounding for float64.
num | number to convert |
btyp | data type of num |
Handle some sort of decimal64 number string (NCX_BT_DECIMAL64)
numstr | number string | |
digits | number of expected digits for this decimal64 | |
[out] | retnum | pointer to initialized ncx_num_t to hold result
|
status_t ncx_decode_num | ( | const xmlChar * | numstr, |
ncx_btype_t | btyp, | ||
ncx_num_t * | retnum | ||
) |
Handle some sort of number string.
numstr | number string | |
btyp | desired number type | |
[out] | retnum | pointer to initialized ncx_num_t to hold result
|
status_t ncx_decode_num_ex | ( | const xmlChar * | numstr, |
ncx_btype_t | btyp, | ||
ncx_num_t * | retnum, | ||
typ_def_t * | typdef | ||
) |
Handle some sort of number string EXTENDED.
numstr | number string | |
btyp | desired number type | |
retnum | pointer to initialized ncx_num_t to hold result | |
[out] | typdef | number typedef
|
int64 ncx_get_dec64_base | ( | const ncx_num_t * | num | ) |
Get the base part of a decimal64 number.
num | number to check (expected to be NCX_BT_DECIMAL64) |
int64 ncx_get_dec64_fraction | ( | const ncx_num_t * | num | ) |
Get the fraction part of a decimal64 number.
num | number to check (expected to be NCX_BT_DECIMAL64) |
ncx_numfmt_t ncx_get_numfmt | ( | const xmlChar * | numstr | ) |
Get the number format of the specified string.
Does not check for valid format Just figures out which type it must be if it were valid
numstr | number string |
void ncx_init_num | ( | ncx_num_t * | num | ) |
Init a ncx_num_t struct.
num | number to initialize |
boolean ncx_is_max | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Return TRUE if the specified number is the max value for its type.
num | number to check |
btyp | data type of num |
boolean ncx_is_min | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Return TRUE if the specified number is the min value for its type.
num | number to check |
btyp | data type of num |
status_t ncx_num_ceiling | ( | const ncx_num_t * | num1, |
ncx_num_t * | num2, | ||
ncx_btype_t | btyp | ||
) |
Get the ceiling value of a number.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_DECIMAL64 NCX_BT_FLOAT64
num1 | source number | |
num2 | address of target number | |
[out] | btyp | expected data type of numbers
|
status_t ncx_num_floor | ( | const ncx_num_t * | num1, |
ncx_num_t * | num2, | ||
ncx_btype_t | btyp | ||
) |
Get the floor value of a number.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_DECIMAL64 NCX_BT_FLOAT64
num1 | source number | |
num2 | address of target number | |
[out] | btyp | expected data type of numbers
|
boolean ncx_num_is_integral | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Check if the number is integral or if it has a fractional part.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_DECIMAL64 NCX_BT_FLOAT64
num | number to check |
btyp | expected data type |
boolean ncx_num_is_nan | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Check if a FP number is set to the Not a Number value.
num | number to set |
btyp | expected data type |
boolean ncx_num_zero | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Compare a ncx_num_t to zero.
num | number to compare to zero |
btyp | expected data type (e.g., NCX_BT_INT32, NCX_BT_UINT64) |
void ncx_printf_num | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp, | ||
log_debug_t | level | ||
) |
Printf a ncx_num_t contents using logging functions.
num | number to printf |
btyp | number base type |
level | debug level for output |
void ncx_printf_num_ex | ( | const ncx_num_t * | num, |
ncx_btype_t | btyp, | ||
log_debug_t | level, | ||
FILE * | overrideOut | ||
) |
Printf a ncx_num_t contents (write to a file)
num | number to printf |
btyp | number base type |
level | debug level for output |
overrideOut | output file, or NULL for normal usage |
status_t ncx_round_num | ( | const ncx_num_t * | num1, |
ncx_num_t * | num2, | ||
ncx_btype_t | btyp | ||
) |
Get the rounded value of a number.
Supports all NCX numeric types: NCX_BT_INT* NCX_BT_UINT* NCX_BT_DECIMAL64 NCX_BT_FLOAT64
num1 | source number | |
num2 | address of target number | |
[out] | btyp | expected data type of numbers
|
status_t ncx_set_num_from_uint64 | ( | ncx_num_t * | retval, |
uint64 | val, | ||
ncx_btype_t | btyp, | ||
boolean | is_neg | ||
) |
Set the number from a uint64 plus sign flag.
Check the min and max values for the numeric base type
[in,out] | retval | address of number to fill in
|
val | value expressed as uint64 | |
btyp | base type of the number to set in the ncx_num_t struct | |
is_neg | if TRUE then number checked and saved is -1 * 'val' |
void ncx_set_num_max | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Set a number to the maximum value for its type.
num | number to set |
btyp | expected data type |
void ncx_set_num_min | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Set a number to the minimum value for its type.
num | number to set |
btyp | expected data type |
void ncx_set_num_nan | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Set a FP number to the Not a Number value.
num | number to set |
btyp | expected data type |
void ncx_set_num_one | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Set a number to one.
num | number to set |
btyp | expected data type |
void ncx_set_num_zero | ( | ncx_num_t * | num, |
ncx_btype_t | btyp | ||
) |
Set a number to zero.
num | number to set |
btyp | expected data type |
status_t ncx_sprintf_num | ( | xmlChar * | buff, |
const ncx_num_t * | num, | ||
ncx_btype_t | btyp, | ||
uint32 * | len | ||
) |
Sprintf a ncx_num_t contents.
buff | buffer to write; NULL means just get length | |
num | number to printf | |
btyp | number base type | |
[out] | len | address of return length
|