yumapro  20.10-10
YumaPro SDK
YANG Number (ncx_num_t)

Make sure to include "ncxtypes.h" and "ncx_num.h" to use the ncx_num APIs. More...

Collaboration diagram for YANG Number (ncx_num_t):

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_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...
 

Detailed Description

Make sure to include "ncxtypes.h" and "ncx_num.h" to use the ncx_num APIs.

Function Documentation

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.

Parameters
numnumber to printf
btypnumber base type

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
numnumber to printf
btypnumber base type

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
num1source number
btyp1expected data type of num1
num2target number
btyp2desired data type of num2
Return values
*num2set to cast value of num1
Returns
status

Here is the caller graph for this function:

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.

Parameters
btypbase type of number
numncx_num_t data structure to clean

Here is the caller graph for this function:

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.

Parameters
num1first number to compare
num2second number to compare
btypexpected data type (NCX_BT_INT, UINT, REAL)
Returns
compare value
      -1 if num1 is < num2
       0 if num1 == num2
       1 if num1 is > num2

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters
numstrnumber string
numfmtnumber format used
digitsnumber of fixed-point digits expected
valpointer to ncx_num_t to hold result
Return values
*valconverted number value
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters
numstrnumber string to convert
numfmtNCX_NF_OCTAL, NCX_NF_DEC, NCX_NF_HEX, or NCX_NF_REAL
btypdesired number type (e.g., NCX_BT_INT32, NCX_BT_UINT32, NCX_BT_FLOAT64)
valpointer to ncx_num_t to hold result
Return values
*valconverted number value
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
tkctoken chain; current token will be converted tkc->typ == TK_TT_DNUM, TK_TT_HNUM, TK_TT_RNUM
digitsnumber of expected decimal digits
valaddress of return value
Return values
*valconverted number value, if NO_ERR
Returns
status

Here is the call graph for this function:

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.

Parameters
tkctoken chain; current token will be converted tkc->typ == TK_TT_DNUM, TK_TT_HNUM, TK_TT_RNUM
btypdesired number type (e.g., NCX_BT_INT32, NCX_BT_UINT64, NCX_BT_FLOAT64)
valaddress of return value
Return values
*valconverted number value (0..2G-1), if NO_ERR
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
num1source number
num2destination number
btypexpected data type (NCX_BT_INT, UINT, REAL)
Returns
status

Here is the caller graph for this function:

int64 ncx_cvt_to_int64 ( const ncx_num_t num,
ncx_btype_t  btyp 
)

Convert a number to an integer64; Use rounding for float64.

Parameters
numnumber to convert
btypdata type of num
Returns
int64 representation
status_t ncx_decode_dec64 ( const xmlChar *  numstr,
uint8  digits,
ncx_num_t retnum 
)

Handle some sort of decimal64 number string (NCX_BT_DECIMAL64)

Parameters
numstrnumber string
digitsnumber of expected digits for this decimal64
retnumpointer to initialized ncx_num_t to hold result
Return values
*retnumconverted number
Returns
status of the operation

Here is the call graph for this function:

Here is the caller graph for this function:

status_t ncx_decode_num ( const xmlChar *  numstr,
ncx_btype_t  btyp,
ncx_num_t retnum 
)

Handle some sort of number string.

Parameters
numstrnumber string
btypdesired number type
retnumpointer to initialized ncx_num_t to hold result
Return values
*retnumconverted number
Returns
status of the operation

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
numstrnumber string
btypdesired number type
retnumpointer to initialized ncx_num_t to hold result
typdefnumber typedef
Return values
*retnumconverted number
Returns
status of the operation

Here is the call graph for this function:

Here is the caller graph for this function:

int64 ncx_get_dec64_base ( const ncx_num_t num)

Get the base part of a decimal64 number.

Parameters
numnumber to check (expected to be NCX_BT_DECIMAL64)
Returns
base part of the number

Here is the caller graph for this function:

int64 ncx_get_dec64_fraction ( const ncx_num_t num)

Get the fraction part of a decimal64 number.

Parameters
numnumber to check (expected to be NCX_BT_DECIMAL64)
Returns
fraction part of the number

Here is the caller graph for this function:

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

Parameters
numstrnumber string
Returns
NCX_NF_NONE, NCX_NF_DEC, NCX_NF_HEX, or NCX_NF_REAL

Here is the caller graph for this function:

void ncx_init_num ( ncx_num_t num)

Init a ncx_num_t struct.

Parameters
numnumber to initialize

Here is the caller graph for this function:

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.

Parameters
numnumber to check
btypdata type of num
Returns
TRUE if this is the maximum value; FALSE otherwise
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.

Parameters
numnumber to check
btypdata type of num
Returns
TRUE if this is the minimum value; FALSE otherwise
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
Parameters
num1source number
num2address of target number
btypexpected data type of numbers
Return values
*num2set to ceiling of num1
Returns
status
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
Parameters
num1source number
num2address of target number
btypexpected data type of numbers
Return values
*num2set to floor of num1
Returns
status
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
Parameters
numnumber to check
btypexpected data type
Returns
TRUE if integral, FALSE if not
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.

Parameters
numnumber to set
btypexpected data type
Returns
TRUE if number is not-a-number (NaN); FALSE otherwise
boolean ncx_num_zero ( const ncx_num_t num,
ncx_btype_t  btyp 
)

Compare a ncx_num_t to zero.

Parameters
numnumber to compare to zero
btypexpected data type (e.g., NCX_BT_INT32, NCX_BT_UINT64)
Returns
TRUE if value is equal to zero; FALSE if value is not equal to zero

Here is the caller graph for this function:

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.

Parameters
numnumber to printf
btypnumber base type
leveldebug level for output

Here is the call graph for this function:

Here is the caller graph for this function:

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)

Parameters
numnumber to printf
btypnumber base type
leveldebug level for output
overrideOutoutput file, or NULL for normal usage

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
num1source number
num2address of target number
btypexpected data type of numbers
Return values
*num2set to round of num1
Returns
status
void ncx_set_num_max ( ncx_num_t num,
ncx_btype_t  btyp 
)

Set a number to the maximum value for its type.

Parameters
numnumber to set
btypexpected 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.

Parameters
numnumber to set
btypexpected 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.

Parameters
numnumber to set
btypexpected data type

Here is the caller graph for this function:

void ncx_set_num_one ( ncx_num_t num,
ncx_btype_t  btyp 
)

Set a number to one.

Parameters
numnumber to set
btypexpected data type

Here is the caller graph for this function:

void ncx_set_num_zero ( ncx_num_t num,
ncx_btype_t  btyp 
)

Set a number to zero.

Parameters
numnumber to set
btypexpected data type

Here is the caller graph for this function:

status_t ncx_sprintf_num ( xmlChar *  buff,
const ncx_num_t num,
ncx_btype_t  btyp,
uint32 *  len 
)

Sprintf a ncx_num_t contents.

Parameters
buffbuffer to write; NULL means just get length
numnumber to printf
btypnumber base type
lenaddress of return length
Return values
*lennumber of bytes written (or would have been) to buff
Returns
status

Here is the call graph for this function:

Here is the caller graph for this function: