![]() |
smax-clib v1.0
A C/C++ client library for SMA-X
|
A set of functions for simplified access to SMA-X for specific variable types. More...
Functions | |
| XField * | smaxCreate1DField (const char *name, XType type, int size, const void *value) |
| XField * | smaxCreateBooleanField (const char *name, boolean value) |
| XField * | smaxCreateDoubleField (const char *name, double value) |
| XField * | smaxCreateIntField (const char *name, int value) |
| XField * | smaxCreateLongField (const char *name, long long value) |
| XField * | smaxCreateScalarField (const char *name, XType type, const void *value) |
| XField * | smaxCreateStringField (const char *name, const char *value) |
| int | smaxGetArrayField (const XStructure *s, const char *name, void *dst, XType type, int count) |
| boolean | smaxGetBooleanField (const XStructure *s, const char *name, boolean defaultValue) |
| double | smaxGetDoubleField (const XStructure *s, const char *name, double defaultValue) |
| long long | smaxGetLongField (const XStructure *s, const char *name, long long defaultValue) |
| char * | smaxGetRawField (const XStructure *s, const char *name, char *defaultValue) |
| double | smaxPullDouble (const char *table, const char *key) |
| double | smaxPullDoubleDefault (const char *table, const char *key, double defaultValue) |
| double * | smaxPullDoubles (const char *table, const char *key, XMeta *meta, int *n) |
| XField * | smaxPullField (const char *id, XMeta *meta, int *status) |
| int | smaxPullInt (const char *table, const char *key, int defaultValue) |
| int * | smaxPullInts (const char *table, const char *key, XMeta *meta, int *n) |
| long long | smaxPullLong (const char *table, const char *key, long long defaultValue) |
| long long * | smaxPullLongs (const char *table, const char *key, XMeta *meta, int *n) |
| char * | smaxPullRaw (const char *table, const char *key, XMeta *meta, int *status) |
| char * | smaxPullString (const char *table, const char *key) |
| char ** | smaxPullStrings (const char *table, const char *key, XMeta *meta, int *n) |
| XStructure * | smaxPullStruct (const char *id, XMeta *meta, int *status) |
| int | smaxShareBoolean (const char *table, const char *key, boolean value) |
| int | smaxShareBooleans (const char *table, const char *key, const boolean *values, int n) |
| int | smaxShareByte (const char *table, const char *key, signed char value) |
| int | smaxShareBytes (const char *table, const char *key, const signed char *values, int n) |
| int | smaxShareDouble (const char *table, const char *key, double value) |
| int | smaxShareDoubles (const char *table, const char *key, const double *values, int n) |
| int | smaxShareFloats (const char *table, const char *key, const float *values, int n) |
| int | smaxShareInt (const char *table, const char *key, int value) |
| int | smaxShareInts (const char *table, const char *key, const int *values, int n) |
| int | smaxShareLLongs (const char *table, const char *key, const long long *values, int n) |
| int | smaxShareLong (const char *table, const char *key, long long value) |
| int | smaxShareLongs (const char *table, const char *key, const long *values, int n) |
| int | smaxShareShort (const char *table, const char *key, short value) |
| int | smaxShareShorts (const char *table, const char *key, const short *values, int n) |
| int | smaxShareString (const char *table, const char *key, const char *sValue) |
| int | smaxShareStrings (const char *table, const char *key, const char **sValues, int n) |
A set of functions for simplified access to SMA-X for specific variable types.
Creates a field for 1-D array of a given name and type using specified native values. It is like xCreate1DField() except that the field is created in serialized form.
| name | Field name |
| type | Storage type, e.g. X_INT. |
| size | Array size. |
| value | Pointer to the native array in memory. |
References smaxCreateField().
Creates a field holding a single boolean value. It is like xCreateBooleanField() except that the field is created in serialized form.
| name | Field name |
| value | Associated value |
References smaxCreateScalarField().
| XField * smaxCreateDoubleField | ( | const char * | name, |
| double | value ) |
Creates a field holding a single double-precision value. It is like xCreateDoubleField() except that the field is created in serialized form.
| name | Field name |
| value | Associated value |
References smaxCreateScalarField().
| XField * smaxCreateIntField | ( | const char * | name, |
| int | value ) |
Creates a field holding a single integer value. It is like xCreateIntField() except that the field is created in serialized form.
| name | Field name |
| value | Associated value |
References smaxCreateScalarField().
| XField * smaxCreateLongField | ( | const char * | name, |
| long long | value ) |
Creates a field holding a single wide (64-bit) integer value. It is like xCreateLongField() except that the field is created in serialized form.
| name | Field name |
| value | Associated value |
References smaxCreateScalarField().
Creates a scalar field of a given name and type using the specified native value. It is like xCreateScalarField() except that the field is created in serialized form.
| name | Field name |
| type | Storage type, e.g. X_INT. |
| value | Pointer to the native data location in memory. |
References smaxCreate1DField().
| XField * smaxCreateStringField | ( | const char * | name, |
| const char * | value ) |
Creates a field holding a single string value. It is like xCreateStringField() except that the field is created in serialized form.
| name | Field name |
| value | Associated value |
References smaxCreateScalarField().
| int smaxGetArrayField | ( | const XStructure * | s, |
| const char * | name, | ||
| void * | dst, | ||
| XType | type, | ||
| int | count ) |
Gets the data of an SMA-X structure field as an array of values of the specified type and element count. The field's data will be truncated or padded with zeroes to provide the requested element count always.
| s | Pointer to SMA-X structure | |
| name | Field name | |
| [out] | dst | Array to return values in. |
| type | Type of data. | |
| count | Number of elements in return array. The field data will be truncated or padded as necessary. |
References smaxStringToValues().
| boolean smaxGetBooleanField | ( | const XStructure * | s, |
| const char * | name, | ||
| boolean | defaultValue ) |
Returns the first value in a structure's field as an integer, or the specified default value if there is no such field in the structure, or the content cannot be parse into an integer.
| s | Pointer to the XStructure. |
| name | Field name |
| defaultValue | Value to return if no corresponding integer field value. |
| double smaxGetDoubleField | ( | const XStructure * | s, |
| const char * | name, | ||
| double | defaultValue ) |
Returns the first value in a structure's field as a double precision float, or the specified default value if there is no such field in the structure, or the content cannot be parse into an double.
| s | Pointer to the XStructure. |
| name | Field name |
| defaultValue | Value to return if no corresponding integer field value. |
| long long smaxGetLongField | ( | const XStructure * | s, |
| const char * | name, | ||
| long long | defaultValue ) |
Returns the first value in a structure's field as an integer, or the specified default value if there is no such field in the structure, or the content cannot be parse into an integer.
| s | Pointer to the XStructure. |
| name | Field name |
| defaultValue | Value to return if no corresponding integer field value. |
| char * smaxGetRawField | ( | const XStructure * | s, |
| const char * | name, | ||
| char * | defaultValue ) |
Returns the string value in a structure's field, or the specified default value if there is no such field in the structure.
| s | Pointer to the XStructure. |
| name | Field name |
| defaultValue | Value to return if no corresponding integer field value. |
| double smaxPullDouble | ( | const char * | table, |
| const char * | key ) |
Returns a single floating-point value for a given SMA-X variable, or a NAN if the value could not be retrieved.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
References smaxPullDoubleDefault().
| double smaxPullDoubleDefault | ( | const char * | table, |
| const char * | key, | ||
| double | defaultValue ) |
Returns a single floating-point value for a given SMA-X variable, or a specified default value if the SMA-X value could not be retrieved.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| defaultValue | The value to return in case of an error. |
References smaxPull().
| double * smaxPullDoubles | ( | const char * | table, |
| const char * | key, | ||
| XMeta * | meta, | ||
| int * | n ) |
Returns a dynamically allocated array of doubles stored in an SMA-X variable.
| [in] | table | The hash table name. |
| [in] | key | The variable name under which the data is stored. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | n | Pointer to which the number of double is returned (if *n > 0) or else an error code. |
Returns a dynamically allocated deserialized XField for the specified node in SMA-X. You should use this function with great care, as it might retrieve very large data from SMA-X, and therefore block access to the database for a long time. It's OK to use to retrieve data for smaller sub-hierarchies, but you should probably stay away from using to to pull large hierarchies.
| id | The aggregate SMA-X ID of the node | |
| [out] | meta | Pointer to where to return metadata, or NULL if metadata is not required. |
| [out] | status | Pointer to integer in which to return status, or NULL if not required. |
References smax2xField(), SMAX_DIMS, SMAX_TYPES, smaxGetRedis(), smaxPull(), and smaxTypeForString().
| int smaxPullInt | ( | const char * | table, |
| const char * | key, | ||
| int | defaultValue ) |
Returns a single integer value for a given SMA-X variable, or a default value if the value could not be retrieved.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| defaultValue | The value to return in case of an error. |
References smaxPull().
| int * smaxPullInts | ( | const char * | table, |
| const char * | key, | ||
| XMeta * | meta, | ||
| int * | n ) |
Returns a dynamically allocated array of integers stored in an SMA-X variable.
| [in] | table | The hash table name. |
| [in] | key | The variable name under which the data is stored. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | n | Pointer to which the number of integers is returned (if *n > 0) or else an error code. |
| long long smaxPullLong | ( | const char * | table, |
| const char * | key, | ||
| long long | defaultValue ) |
Returns a single integer value for a given SMA-X variable, or a default value if the value could not be retrieved.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| defaultValue | The value to return in case of an error. |
References smaxPull().
| long long * smaxPullLongs | ( | const char * | table, |
| const char * | key, | ||
| XMeta * | meta, | ||
| int * | n ) |
Returns a dynamically allocated array of long long (int64) integers stored in an SMA-X variable.
| [in] | table | The hash table name. |
| [in] | key | The variable name under which the data is stored. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | n | Pointer to which the number of integers is returned (if *n > 0) or else an error code. |
| char * smaxPullRaw | ( | const char * | table, |
| const char * | key, | ||
| XMeta * | meta, | ||
| int * | status ) |
Returns a dynamically allocated buffer with the raw string value stored in SMA-X. This call can also be used to get single string values from SMA-X, since for single string the stored raw value is simply the string itself. However, to properly retrieve string arrays, you want to use smaxPullStrings() instead.
| [in] | table | The hash table name. |
| [in] | key | The variable name under which the data is stored. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | status | Pointer int which an error status is returned. |
References smaxPull().
| char * smaxPullString | ( | const char * | table, |
| const char * | key ) |
Returns a single string value for a given SMA-X variable, or a NULL if the value could not be retrieved.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
References smaxPull().
| char ** smaxPullStrings | ( | const char * | table, |
| const char * | key, | ||
| XMeta * | meta, | ||
| int * | n ) |
Returns an array of pointers to individuals strings inside the retrieved contiguous data buffer. Thus, to discard the returned data after use, you must first discard the underlying buffer (as pointed by the first element) before discarding the array of pointers themselves. E.g.:
char **array = smaxPullStrings("mygroup", "myfield", &meta);
...
if(array != NULL) {
free(array[0]); // discards the underlying contiguous buffer
free(array); // discards the array of pointers.
}
| [in] | table | The hash table name. |
| [in] | key | The variable name under which the data is stored. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | n | Pointer to which the number of double is returned (if *n > 0) or else an error code. |
References smaxGetMetaCount(), smaxPullRaw(), XMeta::storeBytes, and X_META_INIT.
| XStructure * smaxPullStruct | ( | const char * | id, |
| XMeta * | meta, | ||
| int * | status ) |
Returns a dynamically allocated XStrucure for the specified hashtable in SMA-X.
| [in] | id | Aggregated structure ID. |
| [out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
| [out] | status | Pointer int which an error status is returned. |
References smaxPull().
| int smaxShareBoolean | ( | const char * | table, |
| const char * | key, | ||
| boolean | value ) |
Shares a single boolean value to SMA-X. All non-zero values are mapped to "1".
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| value | A boolean value. |
References smaxShareBooleans().
| int smaxShareBooleans | ( | const char * | table, |
| const char * | key, | ||
| const boolean * | values, | ||
| int | n ) |
Shares an array of boolean values to SMA-X. All non-zero values are mapped to "1".
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| values | Pointer to boolean[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareByte | ( | const char * | table, |
| const char * | key, | ||
| signed char | value ) |
Shares a single signed byte value to SMA-X.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| value | Integer value. |
References smaxShareBytes().
| int smaxShareBytes | ( | const char * | table, |
| const char * | key, | ||
| const signed char * | values, | ||
| int | n ) |
Shares a binary sequence to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | pointer to the byte buffer. |
| n | Number of bytes in buffer to share. |
References smaxShare().
| int smaxShareDouble | ( | const char * | table, |
| const char * | key, | ||
| double | value ) |
Shares a single floating point value to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| value | floating-point value. |
References smaxShareDoubles().
| int smaxShareDoubles | ( | const char * | table, |
| const char * | key, | ||
| const double * | values, | ||
| int | n ) |
Shares an array of doubles to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to double[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareFloats | ( | const char * | table, |
| const char * | key, | ||
| const float * | values, | ||
| int | n ) |
Shares an array of floats to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to float[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareInt | ( | const char * | table, |
| const char * | key, | ||
| int | value ) |
Shares a single integer value to SMA-X.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| value | Integer value. |
References smaxShareInts().
| int smaxShareInts | ( | const char * | table, |
| const char * | key, | ||
| const int * | values, | ||
| int | n ) |
Shares an array of long integers to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to int[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareLLongs | ( | const char * | table, |
| const char * | key, | ||
| const long long * | values, | ||
| int | n ) |
Shares an array of long long integers to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to long long[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareLong | ( | const char * | table, |
| const char * | key, | ||
| long long | value ) |
Shares a single 64-bit integer value to SMA-X.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| value | Integer value. |
References smaxShareLLongs().
| int smaxShareLongs | ( | const char * | table, |
| const char * | key, | ||
| const long * | values, | ||
| int | n ) |
Shares an array of long integers to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to long[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareShort | ( | const char * | table, |
| const char * | key, | ||
| short | value ) |
Shares a single short integer value to SMA-X.
| table | Hash table name. |
| key | Variable name under which the data is stored. |
| value | Integer value. |
References smaxShareShorts().
| int smaxShareShorts | ( | const char * | table, |
| const char * | key, | ||
| const short * | values, | ||
| int | n ) |
Shares an array of shorts to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| values | Pointer to short[] array. |
| n | Number of elements in array to share. |
References smaxShare().
| int smaxShareString | ( | const char * | table, |
| const char * | key, | ||
| const char * | sValue ) |
Shares a single string value to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| sValue | Pointer to string. |
References smaxShare().
| int smaxShareStrings | ( | const char * | table, |
| const char * | key, | ||
| const char ** | sValues, | ||
| int | n ) |
Shares an array of strings to SMA-X.
| table | The hash table name. |
| key | The variable name under which the data is stored. |
| sValues | Pointer to array of string pointers. |
| n | Number of elements in array to share. |
References smaxShare().