Routines to manage attribute/value sets.
More...
|
void | bu_avs_init (struct bu_attribute_value_set *avp, size_t len, const char *str) |
|
void | bu_avs_init_empty (struct bu_attribute_value_set *avp) |
|
struct bu_attribute_value_set * | bu_avs_new (size_t len, const char *str) |
|
int | bu_avs_add (struct bu_attribute_value_set *avp, const char *attribute, const char *value) |
|
int | bu_avs_add_vls (struct bu_attribute_value_set *avp, const char *attribute, const struct bu_vls *value_vls) |
|
void | bu_avs_add_nonunique (struct bu_attribute_value_set *avsp, const char *attribute, const char *value) |
|
void | bu_avs_merge (struct bu_attribute_value_set *dest, const struct bu_attribute_value_set *src) |
|
const char * | bu_avs_get (const struct bu_attribute_value_set *avp, const char *attribute) |
|
int | bu_avs_remove (struct bu_attribute_value_set *avp, const char *attribute) |
|
void | bu_avs_free (struct bu_attribute_value_set *avp) |
|
void | bu_avs_print (const struct bu_attribute_value_set *avp, const char *title) |
|
Routines to manage attribute/value sets.
◆ BU_AVS_NULL
Definition at line 98 of file avs.h.
◆ BU_CK_AVS
◆ BU_AVS_INIT
#define BU_AVS_INIT |
( |
|
_ap | ) |
|
Value: { \
(_ap)->count = (_ap)->max = 0; \
(_ap)->readonly_min = (_ap)->readonly_max = (_ap)->avp = NULL; \
}
initialize a bu_attribute_value_set struct without allocating any memory.
Definition at line 108 of file avs.h.
◆ BU_AVS_INIT_ZERO
#define BU_AVS_INIT_ZERO { BU_AVS_MAGIC, 0, 0, NULL, NULL, NULL } |
macro suitable for declaration statement initialization of a bu_attribute_value_set struct. does not allocate memory.
Definition at line 118 of file avs.h.
◆ BU_AVS_IS_INITIALIZED
◆ BU_AVS_FOR
#define BU_AVS_FOR |
( |
|
_pp, |
|
|
|
_avp |
|
) |
| (_pp) = ((const void *)(_avp) != (const void *)NULL) ? ((_avp)->count > 0 ? &(_avp)->avp[(_avp)->count-1] : NULL) : NULL; ((const void *)(_pp) != (const void *)NULL) && ((const void *)(_avp) != (const void *)NULL) && (_avp)->avp && (_pp) >= (_avp)->avp; (_pp)-- |
For loop iterator for avs structures.
Provide an attribute value pair struct pointer and an attribute value set, and this will iterate over all entries. iteration order is not defined but should iterate over each AVS entry once.
Example Use:
void
}
}
#define BU_AVS_FOR(_pp, _avp)
int bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition at line 147 of file avs.h.
◆ AVS_IS_FREEABLE
#define AVS_IS_FREEABLE |
( |
|
_avsp, |
|
|
|
_p |
|
) |
| |
Value: ((_avsp)->readonly_max == NULL \
|| (const void *)(_p) < (_avsp)->readonly_min \
|| (const void *)(_p) > (_avsp)->readonly_max)
Some (but not all) attribute name and value string pointers are taken from an on-disk format bu_external block, while others have been bu_strdup()ed and need to be freed. This macro indicates whether the pointer needs to be freed or not.
Definition at line 156 of file avs.h.
◆ bu_avs_t
Definition at line 97 of file avs.h.
◆ bu_attr_time_t
for attr and avs use.
Enumerator |
---|
BU_ATTR_CREATED | |
BU_ATTR_MODIFIED | |
Definition at line 50 of file avs.h.
◆ bu_avs_init()
Initialize avs with storage for len entries.
◆ bu_avs_init_empty()
◆ bu_avs_new()
Allocate storage for a new attribute/value set, with at least 'len' slots pre-allocated.
◆ bu_avs_add()
If the given attribute exists it will receive the new value, otherwise the set will be extended to have a new attribute/value pair.
Returns - 0 some error occurred 1 existing attribute updated with new value 2 set extended with new attribute/value pair
◆ bu_avs_add_vls()
Add a bu_vls string as an attribute to a given attribute set, updating the value if it already exists.
◆ bu_avs_add_nonunique()
void bu_avs_add_nonunique |
( |
struct bu_attribute_value_set * |
avsp, |
|
|
const char * |
attribute, |
|
|
const char * |
value |
|
) |
| |
Add a name/value pair even if the name already exists in the set.
◆ bu_avs_merge()
Take all the attributes from 'src' and merge them into 'dest' by replacing an attribute if it already exists in the set.
◆ bu_avs_get()
Get the value of a given attribute from an attribute set. The behavior is not currently well-defined for AVS containing non-unique attributes, but presently returns the first encountered. Returns NULL if the requested attribute is not present in the set.
◆ bu_avs_remove()
Remove all occurrences of an attribute from the provided attribute set.
- Returns
- -1 attribute not found in set
-
0 OK
◆ bu_avs_free()
Release all attributes in the provided attribute set.
◆ bu_avs_print()
Print all attributes in an attribute set in "name = value" form, using the provided title.