any.h - Man Page

Opaque handler to pass different types of values to the API.

Synopsis

#include 'dmlite/common/config.h'
#include <stddef.h>
#include <stdint.h>

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_long (long l)
Creates a new dmlite_any.
dmlite_any * dmlite_any_new_s64 (int64_t i)
Creates a new dmlite_any from an int64_t type.
dmlite_any * dmlite_any_new_u64 (uint64_t i)
Creates a new dmlite_any from an uint64_t type.
dmlite_any * dmlite_any_new_string_array (unsigned n, const char **strv)
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.
int64_t dmlite_any_to_s64 (const dmlite_any *any)
Returns the int64_t interpretation of they dmlite_any.
uint64_t dmlite_any_to_u64 (const dmlite_any *any)
Returns the uint64_t 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.

Detailed Description

Opaque handler to pass different types of values to the API.

Author

Alejandro Álvarez Ayllon aalvarez@cern.ch

Note

Basically it wraps boost::any and dmlite::Extensible.

Typedef Documentation

typedef struct dmlite_any dmlite_any

Used to pass configuration values.

typedef struct dmlite_any_dict dmlite_any_dict

Handles key->value pairs.

Function Documentation

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.

Parameters

dict The original

Returns

A newly allocated copy of dict.

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.

Parameters

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.

Returns

NULL if not found.

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.

Parameters

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.

Parameters

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.

Parameters

n The number of keys in **keys
keys The array of keys.

dmlite_any_dict * dmlite_any_dict_new ()

Created a new generic dictionary.

Returns

A newly allocated dmlite_any_dict.

char * dmlite_any_dict_to_json (const dmlite_any_dict * d, char * buffer, size_t bsize)

Generates a JSON serialization of the dictionary.

Returns

The same pointer as buffer.

void dmlite_any_free (dmlite_any * any)

Frees a dmlite_any.

Parameters

any The dmlite_any to destroy.

dmlite_any * dmlite_any_new_long (long l)

Creates a new dmlite_any.

Parameters

l The long that will be wrapped.

Returns

A newly allocated dmlite_any.

dmlite_any * dmlite_any_new_long_array (unsigned n, long * lv)

Creates a new dmlite_any.

Parameters

n The number of elements.
lv The longs that will be wrapped.

Returns

A newly allocated dmlite_any.

Deprecated

Use dmlite_set_array instead.

dmlite_any * dmlite_any_new_s64 (int64_t i)

Creates a new dmlite_any from an int64_t type.

Parameters

i The int64_t value.

Returns

A newly allocated dmlite_any.

dmlite_any * dmlite_any_new_string (const char * str)

Creates a new dmlite_any.

Parameters

str The string that will be wrapped. It is safe to free afterwards.

Returns

A newly allocated dmlite_any.

dmlite_any * dmlite_any_new_string_array (unsigned n, const char ** strv)

Creates a new dmlite_any.

Parameters

n The number of elements.
strv The strings that will be wrapped. It is safe to free afterwards.

Returns

A newly allocated dmlite_any.

Deprecated

Use dmlite_set_array instead.

dmlite_any * dmlite_any_new_u64 (uint64_t i)

Creates a new dmlite_any from an uint64_t type.

Parameters

i The uint64_t value.

Returns

A newly allocated dmlite_any.

long dmlite_any_to_long (const dmlite_any * any)

Returns the long interpretation of they dmlite_any. Defaults to 0.

Parameters

any The dmlite_any to convert.

int64_t dmlite_any_to_s64 (const dmlite_any * any)

Returns the int64_t interpretation of they dmlite_any. Defaults to 0.

Parameters

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

Parameters

any The dmlite_any to convert.
buffer Where to put the string.
bsize The size of the buffer.

uint64_t dmlite_any_to_u64 (const dmlite_any * any)

Returns the uint64_t interpretation of they dmlite_any. Defaults to 0.

Parameters

any The dmlite_any to convert.

Author

Generated automatically by Doxygen for dmlite from the source code.

Info

Wed Jan 24 2024 00:00:00 Version 0.6 dmlite