Opaque handler to pass different types of values to the API. More...
#include <stddef.h>

Go to the source code of this file.
Typedefs | |
| typedef struct dmlite_any | dmlite_any |
| Used to pass configuration values. | |
| typedef struct dmlite_any_dict | dmlite_any_dict |
| Handles key->value pairs. | |
Functions | |
| dmlite_any * | dmlite_any_new_string (const char *str) |
| Creates a new dmlite_any. | |
| dmlite_any * | dmlite_any_new_string_array (unsigned n, const char **strv) |
| Creates a new dmlite_any. | |
| dmlite_any * | dmlite_any_new_long (long l) |
| Creates a new dmlite_any. | |
| dmlite_any * | dmlite_any_new_long_array (unsigned n, long *lv) |
| Creates a new dmlite_any. | |
| void | dmlite_any_free (dmlite_any *any) |
| Frees a dmlite_any. | |
| void | dmlite_any_to_string (const dmlite_any *any, char *buffer, size_t bsize) |
| Gets the string interpretation of the dmlite_any. | |
| long | dmlite_any_to_long (const dmlite_any *any) |
| Returns the long interpretation of they dmlite_any. | |
| dmlite_any_dict * | dmlite_any_dict_new () |
| Created a new generic dictionary. | |
| dmlite_any_dict * | dmlite_any_dict_copy (const dmlite_any_dict *dict) |
| Make a copy of the dictionary. | |
| void | dmlite_any_dict_free (dmlite_any_dict *d) |
| Frees a dmlite_any_dict. | |
| void | dmlite_any_dict_clear (dmlite_any_dict *d) |
| Clears the dictionary. | |
| void | dmlite_any_dict_insert (dmlite_any_dict *d, const char *k, const dmlite_any *v) |
| Insert a new dmlite_any value into the dictionary. | |
| unsigned long | dmlite_any_dict_count (const dmlite_any_dict *d) |
| Returns how many elements there are in a specific dictionary. | |
| dmlite_any * | dmlite_any_dict_get (const dmlite_any_dict *d, const char *k) |
| Returns the value associated with the key k. | |
| void | dmlite_any_dict_erase (dmlite_any_dict *d, const char *k) |
| Removes a key-value from the dictionary. | |
| char * | dmlite_any_dict_to_json (const dmlite_any_dict *d, char *buffer, size_t bsize) |
| Generates a JSON serialization of the dictionary. | |
| dmlite_any_dict * | dmlite_any_dict_from_json (const char *json) |
| Populates a dmlite_any_dict from a JSON string. | |
| void | dmlite_any_dict_keys (const dmlite_any_dict *d, unsigned *nkeys, char ***keys) |
| Puts in keys a pointer to an array of strings with all the available keys in d. | |
| void | dmlite_any_dict_keys_free (unsigned n, char **keys) |
| Frees an array of strings allocated by dmlite_any_dict_keys. | |
Opaque handler to pass different types of values to the API.
| typedef struct dmlite_any dmlite_any |
Used to pass configuration values.
| typedef struct dmlite_any_dict dmlite_any_dict |
Handles key->value pairs.
| void dmlite_any_dict_clear | ( | dmlite_any_dict * | d | ) |
Clears the dictionary.
| dmlite_any_dict* dmlite_any_dict_copy | ( | const dmlite_any_dict * | dict | ) |
Make a copy of the dictionary.
| dict | The original |
| unsigned long dmlite_any_dict_count | ( | const dmlite_any_dict * | d | ) |
Returns how many elements there are in a specific dictionary.
| void dmlite_any_dict_erase | ( | dmlite_any_dict * | d, | |
| const char * | k | |||
| ) |
Removes a key-value from the dictionary.
| d | The dictionary. | |
| k | The key to be removed. |
| void dmlite_any_dict_free | ( | dmlite_any_dict * | d | ) |
Frees a dmlite_any_dict.
| dmlite_any_dict* dmlite_any_dict_from_json | ( | const char * | json | ) |
Populates a dmlite_any_dict from a JSON string.
| dmlite_any* dmlite_any_dict_get | ( | const dmlite_any_dict * | d, | |
| const char * | k | |||
| ) |
Returns the value associated with the key k.
| void dmlite_any_dict_insert | ( | dmlite_any_dict * | d, | |
| const char * | k, | |||
| const dmlite_any * | v | |||
| ) |
Insert a new dmlite_any value into the dictionary.
Replaces if already present.
| d | The dictionary. | |
| k | The key. | |
| v | The value. |
| void dmlite_any_dict_keys | ( | const dmlite_any_dict * | d, | |
| unsigned * | nkeys, | |||
| char *** | keys | |||
| ) |
Puts in keys a pointer to an array of strings with all the available keys in d.
Use dmlite_any_dict_keys_free to free.
| d | The Dictionary. | |
| nkeys | Will be set to the number of stored keys. |
| void dmlite_any_dict_keys_free | ( | unsigned | n, | |
| char ** | keys | |||
| ) |
Frees an array of strings allocated by dmlite_any_dict_keys.
| n | The number of keys in **keys | |
| keys | The array of keys. |
| dmlite_any_dict* dmlite_any_dict_new | ( | ) |
Created a new generic dictionary.
| char* dmlite_any_dict_to_json | ( | const dmlite_any_dict * | d, | |
| char * | buffer, | |||
| size_t | bsize | |||
| ) |
Generates a JSON serialization of the dictionary.
| void dmlite_any_free | ( | dmlite_any * | any | ) |
Frees a dmlite_any.
| any | The dmlite_any to destroy. |
| dmlite_any* dmlite_any_new_long | ( | long | l | ) |
Creates a new dmlite_any.
| l | The long that will be wrapped. |
| dmlite_any* dmlite_any_new_long_array | ( | unsigned | n, | |
| long * | lv | |||
| ) |
Creates a new dmlite_any.
| n | The number of elements. | |
| lv | The longs that will be wrapped. |
| dmlite_any* dmlite_any_new_string | ( | const char * | str | ) |
Creates a new dmlite_any.
| str | The string that will be wrapped. It is safe to free afterwards. |
| dmlite_any* dmlite_any_new_string_array | ( | unsigned | n, | |
| const char ** | strv | |||
| ) |
Creates a new dmlite_any.
| n | The number of elements. | |
| strv | The strings that will be wrapped. It is safe to free afterwards. |
| long dmlite_any_to_long | ( | const dmlite_any * | any | ) |
Returns the long interpretation of they dmlite_any.
Defaults to 0.
| any | The dmlite_any to convert. |
| void dmlite_any_to_string | ( | const dmlite_any * | any, | |
| char * | buffer, | |||
| size_t | bsize | |||
| ) |
Gets the string interpretation of the dmlite_any.
Defaults to "".
| any | The dmlite_any to convert. | |
| buffer | Where to put the string. | |
| bsize | The size of the buffer. |
1.6.1