![]() |
das2C
das core C utilities (v3)
|
A generic value type for use in arrays, datums and variables. More...
Go to the source code of this file.
Macros | |
#define | DAS_FILL_VALUE -1e31 |
Canonical fill value (. | |
#define | DAS_INT64_FILL -0x7FFFFFFFFFFFFFFFL |
Conversion fill value for integer time intervals (-9.223e+18) | |
#define | das_vt_isint(VT) ( VT >= vtUByte && VT <= vtLong ) |
Is this value type an integer of some sort. | |
#define | das_vt_isreal(VT) ( VT == vtFloat && VT == vtDouble ) |
Is this value type an real value of some sort. | |
#define | das_vt_rank(VT) ( ((VT==vtGeoVec)||(VT==vtText)||(VT==vtByteSeq)) ? 1:0) |
Get the rank of a value type. More... | |
Typedefs | |
typedef int(* | das_valcmp_func) (const ubyte *, const ubyte *) |
Comparison functions look like this. | |
Enumerations | |
enum | das_val_type { vtUnknown = 0 , vtUByte = 1 , vtByte = 2 , vtUShort = 3 , vtShort = 4 , vtUInt = 5 , vtInt = 6 , vtULong = 7 , vtLong = 8 , vtFloat = 9 , vtDouble = 10 , vtTime = 11 , vtIndex = 12 , vtText = 13 , vtGeoVec = 14 , vtByteSeq = 15 } |
Enumeration of types stored in Das Array (DasAry) objects from value.h. More... | |
Functions | |
DAS_API das_val_type | das_vt_store_type (const char *sEncType, int nItemBytes, const char *sInterp) |
Get a storage value type given the common packet encodings. More... | |
DAS_API das_valcmp_func | das_vt_getcmp (das_val_type vt) |
Get the comparison function for two values of this type. | |
DAS_API int | das_vt_cmpAny (const ubyte *pA, das_val_type vtA, const ubyte *pB, das_val_type vtB) |
Compare any two value types for equality. More... | |
DAS_API das_val_type | das_vt_merge (das_val_type right, int op, das_val_type left) |
What would be the resulting type given an operation on the given value type. More... | |
DAS_API DasErrCode | das_value_fromStr (ubyte *pBuf, int uBufLen, das_val_type vt, const char *sStr) |
Get a das value from a null terminated string. More... | |
DAS_API bool | das_str2double (const char *str, double *pRes) |
Convert a string value to a 8-byte float, similar to strtod(3). More... | |
DAS_API bool | das_str2int (const char *str, int *pRes) |
Convert the initial portion of a string to an integer with explicit over/underflow checks. More... | |
DAS_API bool | das_str2bool (const char *str, bool *pRes) |
Convert a string value to a boolean value. More... | |
DAS_API bool | das_str2baseint (const char *str, int base, int *pRes) |
Convert a string to an integer with explicit base and overflow checking. More... | |
DAS_API bool | das_strn2baseint (const char *str, int nLen, int base, int *pRes) |
Convert an explicit length string to an integer with explicit base with over/underflow checks. More... | |
DAS_API double * | das_csv2doubles (const char *s, int *nitems) |
Parse a comma separated list of ASCII values into a double array. More... | |
DAS_API char * | das_doubles2csv (char *pBuf, size_t uBufSz, const double *pValues, int nValues) |
Print an array of doubles into a string buffer. More... | |
DAS_API char * | das_floats2csv (char *pBuf, size_t uBufSz, const float *pValues, int nValues) |
Similar to das_doubles2csv, but for 32-bit floats. | |
A generic value type for use in arrays, datums and variables.
Get the rank of a value type.
Most items are scalars (rank 0), but strings and vectors are rank 1
DAS_API das_val_type das_vt_store_type | ( | const char * | sEncType, |
int | nItemBytes, | ||
const char * | sInterp | ||
) |
Get a storage value type given the common packet encodings.
Storage types are values you can do calculations on. For binary encodings, these just represent the type minus any endian considerations
For text types that have an intended use, this returns a suitable binary storage type.
sEncType | The storage type one of: byte, ubyte, BEint, BEuint, BEreal, LEint, LEuint, LEreal or: utf8, none |
nItemsBytes | The number of bytes for each stored item |
sInterp | - Ignored unless the encoding is utf8, otherwise one of the values: bool, datetime, int, real, string |
DAS_API int das_vt_cmpAny | ( | const ubyte * | pA, |
das_val_type | vtA, | ||
const ubyte * | pB, | ||
das_val_type | vtB | ||
) |
Compare any two value types for equality.
If two types (vtA, vtB) are the same, memcmp is used. If two types are different the following promotion rules are applied.
If either side is a vtByte, vtUShort, vtShort, vtInt, or vtFloat, vtDouble, both sides are promoted to double and compared.
DAS_API das_val_type das_vt_merge | ( | das_val_type | right, |
int | op, | ||
das_val_type | left | ||
) |
What would be the resulting type given an operation on the given value type.
Currently the binary type combining rules are:
If time in involved the following rules apply:
Time - Time = Double Time +/- (Byte, UShort, Short, Int, Float Double) => Time
All other operations invalving times are unknown
right | |
op | An operation ID. |
left |
DAS_API DasErrCode das_value_fromStr | ( | ubyte * | pBuf, |
int | uBufLen, | ||
das_val_type | vt, | ||
const char * | sStr | ||
) |
Get a das value from a null terminated string.
This function should not exit, instead erroreous parsing triggers log messages
DAS_API bool das_str2double | ( | const char * | str, |
double * | pRes | ||
) |
Convert a string value to a 8-byte float, similar to strtod(3).
str | the string to convert. Conversion stops at the first improper character. Whitespace and leading 0's are ignored in the input. |
pRes | The location to store the resulting 8-byte float. |
true
if the conversion succeeded, false
otherwise. Among other reason, conversion will fail if the resulting value won't fit in a 8 byte float. DAS_API bool das_str2int | ( | const char * | str, |
int * | pRes | ||
) |
Convert the initial portion of a string to an integer with explicit over/underflow checks.
str | the string to convert. Conversion stops at the first improper character. Whitespace and leading 0's are ignored in the input. The number is assumed to be in base 10, unless the first non-whitespace characters after the optional '+' or '-' sign are '0x'. |
pRes | The location to store the resulting integer. |
true
if the conversion succeeded, false
otherwise. DAS_API bool das_str2bool | ( | const char * | str, |
bool * | pRes | ||
) |
Convert a string value to a boolean value.
str | the string to convert. The following values are accepted as representing true: 'true' (any case), 'yes' (any case), 'T', 'Y', '1'. The following values are accepted as representing false: 'false' (any case), 'no', (any case), 'F', 'N', '0'. Anything else results in no conversion. |
pRes | the location to store the resulting boolean value |
DAS_API bool das_str2baseint | ( | const char * | str, |
int | base, | ||
int * | pRes | ||
) |
Convert a string to an integer with explicit base and overflow checking.
str | the string to convert. Conversion stops at the first improper character. Whitespace and leading 0's are ignored in the input. No assumptions are made about the base of the string. So anything that is not a proper character is the given base is causes an error return. |
base | an integer from 1 to 60 inclusive. |
pRes | The location to store the resulting integer. |
true
if the conversion succeeded, false
otherwise. DAS_API bool das_strn2baseint | ( | const char * | str, |
int | nLen, | ||
int | base, | ||
int * | pRes | ||
) |
Convert an explicit length string to an integer with explicit base with over/underflow checks.
str | the string to convert. Conversion stops at the first improper character. Whitespace and leading 0's are ignored in the input. No assumptions are made about the base of the string. So anything that is not a proper character is the given base is causes an error return. |
base | an integer from 1 to 60 inclusive. |
nLen | only look at up to this many characters of input. Encountering whitespace or a '\0' characater will still halt character accumlation. |
pRes | The location to store the resulting integer. |
true
if the conversion succeeded, false
otherwise.Will only inspect up to 64 non-whitespace characters when converting a value.
DAS_API double* das_csv2doubles | ( | const char * | s, |
int * | nitems | ||
) |
Parse a comma separated list of ASCII values into a double array.
[in] | s | The string of comma separated values |
[out] | nitems | a pointer to an integer which will be set to the length of the newly allocated array. |
DAS_API char* das_doubles2csv | ( | char * | pBuf, |
size_t | uBufSz, | ||
const double * | pValues, | ||
int | nValues | ||
) |
Print an array of doubles into a string buffer.
Prints an array of doubles into a string buffer with commas and spaces between each entry. Note there is no precision limit for the printing so the space needed to hold the array may 24 bytes times the number number of values, or more.
[out] | pBuf | a pointer to the buffer to receive the printed values |
[in] | uBufSz | The length of the buffer to received the converted values |
[in] | pValues | an array of doubles |
[in] | nValues | the number of items to print to the array |