libpaf 1.1.13
|
Pathfinder Service Properties API. More...
Go to the source code of this file.
Typedefs | |
typedef void(* | paf_props_foreach_cb) (const char *prop_name, const struct paf_value *prop_value, void *user) |
Functions | |
struct paf_props * | paf_props_create (void) |
void | paf_props_add (struct paf_props *props, const char *name, const struct paf_value *value) |
void | paf_props_add_int64 (struct paf_props *props, const char *name, int64_t value) |
void | paf_props_add_str (struct paf_props *props, const char *name, const char *value) |
size_t | paf_props_get (const struct paf_props *props, const char *prop_name, const struct paf_value **values, size_t capacity) |
const struct paf_value * | paf_props_get_one (const struct paf_props *props, const char *prop_name) |
void | paf_props_foreach (const struct paf_props *props, paf_props_foreach_cb cb, void *user) |
bool | paf_props_equal (const struct paf_props *props_a, const struct paf_props *props_b) |
size_t | paf_props_num_values (const struct paf_props *props) |
size_t | paf_props_num_names (const struct paf_props *props) |
struct paf_props * | paf_props_clone (const struct paf_props *orig) |
void | paf_props_destroy (struct paf_props *props) |
Pathfinder Service Properties API.
Service properties are a multimap. Thus, each property name may be assoicated to one or more values.
typedef void(* paf_props_foreach_cb) (const char *prop_name, const struct paf_value *prop_value, void *user) |
Callback function prototype used for iteration.
struct paf_props * paf_props_create | ( | void | ) |
Create a service properties instance.
void paf_props_add | ( | struct paf_props * | props, |
const char * | name, | ||
const struct paf_value * | value | ||
) |
Add a property.
This function adds a property to props
.
Both the name
and the value
will be copied, and thus will still be owned by the caller at call completion.
[in] | props | The service properties instance. |
[in] | name | The name of the property to be added. |
[in] | value | The value of the property to be added. |
void paf_props_add_int64 | ( | struct paf_props * | props, |
const char * | name, | ||
int64_t | value | ||
) |
Add a property with an integer value.
This function adds a property with an integer value to props
.
[in] | props | The service properties instance. |
[in] | name | The name of the property to be added. |
[in] | value | The value of the property to be added. |
void paf_props_add_str | ( | struct paf_props * | props, |
const char * | name, | ||
const char * | value | ||
) |
Add a property with a string value.
This function adds a property with a string value to props
.
[in] | props | The service properties instance. |
[in] | name | The name of the property to be added. |
[in] | value | The value of the property to be added. |
size_t paf_props_get | ( | const struct paf_props * | props, |
const char * | prop_name, | ||
const struct paf_value ** | values, | ||
size_t | capacity | ||
) |
Retrieve all values for a particular property.
This function retrieves the zero-or-more values associated with the supplied prop_name
, and stores them in values
.
If values'
capacity is to small to hold pointers to all values, as many values as can fit will be stored. The actual number of values present in props
will be returned regardless.
In case capacity
is 0, props
may be left NULL. Such a call may be useful to allow pre-allocation of a suitably-sized values
array, before the actual paf_props_get() call.
[in] | props | The service properties instance. |
[in] | prop_name | The name of the property whose values is to be retrieved. |
[out] | values | A pointer to an user-allocated array of paf_value pointers. |
[in] | capacity | The number of elements values can hold. |
prop_name
(even in the case this number is larger than capacity
). const struct paf_value * paf_props_get_one | ( | const struct paf_props * | props, |
const char * | prop_name | ||
) |
Retrieve a value for a particular property.
This function returns a value associated with the supplied prop_name
.
[in] | props | The service properties instance. |
[in] | prop_name | The name of the property whose value is to be retrieved. |
prop_name
, or NULL in case there is none. void paf_props_foreach | ( | const struct paf_props * | props, |
paf_props_foreach_cb | cb, | ||
void * | user | ||
) |
Iterate over all name-value pairs.
This function calls the supplied callback function cb
for each property name-value pair in props
.
props
may not be modified during the iteration.
[in] | props | The service properties instance. |
[in] | cb | The callback function. |
[in] | user | An opaque pointer, supplied back to the application in every cb call. |
bool paf_props_equal | ( | const struct paf_props * | props_a, |
const struct paf_props * | props_b | ||
) |
Compares two property multimaps for equality (by value).
[in] | props_a | A service properties instance. |
[in] | props_b | A service properties instance. |
props_a
and props_b
are equal, false otherwise. size_t paf_props_num_values | ( | const struct paf_props * | props | ) |
Returns the total number of property name-value pairs.
This function returns the total number of name-value pairs in the properties instance.
[in] | props | The service properties instance. |
size_t paf_props_num_names | ( | const struct paf_props * | props | ) |
Returns the total number of property names in the properties instance.
[in] | props | The service properties instance. |
struct paf_props * paf_props_clone | ( | const struct paf_props * | orig | ) |
Returns a copy of the supplied properties instance.
[in] | orig | The service properties instance to be copied. |
void paf_props_destroy | ( | struct paf_props * | props | ) |
Destroys a properties instance.
This function destroys the properties instance and frees all the resources associated with it.
[in] | props | The service properties instance. |