BRL-CAD
Loading...
Searching...
No Matches

Routines to manage attribute/value sets. More...

Collaboration diagram for Attribute/Value Sets:

Files

file  avs.h
 

Data Structures

struct  bu_attribute_value_pair
 
struct  bu_attribute_value_set
 

Macros

#define BU_AVS_NULL   ((struct bu_attribute_value_set *)0)
 
#define BU_CK_AVS(_ap)   BU_CKMAG(_ap, BU_AVS_MAGIC, "bu_attribute_value_set")
 
#define BU_AVS_INIT(_ap)
 
#define BU_AVS_INIT_ZERO   { BU_AVS_MAGIC, 0, 0, NULL, NULL, NULL }
 
#define BU_AVS_IS_INITIALIZED(_ap)   (((struct bu_attribute_value_set *)(_ap) != BU_AVS_NULL) && LIKELY((_ap)->magic == BU_AVS_MAGIC))
 
#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)--
 
#define AVS_IS_FREEABLE(_avsp, _p)
 

Typedefs

typedef struct bu_attribute_value_set bu_avs_t
 

Enumerations

enum  bu_attr_time_t { BU_ATTR_CREATED , BU_ATTR_MODIFIED }
 

Functions

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_setbu_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 charbu_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)
 

Detailed Description

Routines to manage attribute/value sets.

Macro Definition Documentation

◆ BU_AVS_NULL

#define BU_AVS_NULL   ((struct bu_attribute_value_set *)0)

Definition at line 99 of file avs.h.

◆ BU_CK_AVS

#define BU_CK_AVS (   _ap)    BU_CKMAG(_ap, BU_AVS_MAGIC, "bu_attribute_value_set")

assert the integrity of a non-head node bu_attribute_value_set struct.

Definition at line 104 of file avs.h.

◆ BU_AVS_INIT

#define BU_AVS_INIT (   _ap)
Value:
{ \
(_ap)->magic = BU_AVS_MAGIC; \
(_ap)->count = (_ap)->max = 0; \
(_ap)->readonly_min = (_ap)->readonly_max = (_ap)->avp = NULL; \
}
Definition dvec.h:74
#define BU_AVS_MAGIC
Definition magic.h:55

initialize a bu_attribute_value_set struct without allocating any memory.

Definition at line 109 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 119 of file avs.h.

◆ BU_AVS_IS_INITIALIZED

#define BU_AVS_IS_INITIALIZED (   _ap)    (((struct bu_attribute_value_set *)(_ap) != BU_AVS_NULL) && LIKELY((_ap)->magic == BU_AVS_MAGIC))

returns truthfully whether a bu_attribute_value_set has been initialized via BU_AVS_INIT() or BU_AVS_INIT_ZERO.

Definition at line 125 of file avs.h.

◆ 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
for (BU_AVS_FOR(avpp, avs)) {
bu_log("key=%s, value=%s\n", avpp->name, avpp->value);
}
}
#define BU_AVS_FOR(_pp, _avp)
Definition avs.h:148
int bu_log(const char *,...) _BU_ATTR_PRINTF12

Definition at line 148 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 157 of file avs.h.

Typedef Documentation

◆ bu_avs_t

Definition at line 98 of file avs.h.

Enumeration Type Documentation

◆ bu_attr_time_t

for attr and avs use.

Enumerator
BU_ATTR_CREATED 
BU_ATTR_MODIFIED 

Definition at line 50 of file avs.h.

Function Documentation

◆ bu_avs_init()

void bu_avs_init ( struct bu_attribute_value_set avp,
size_t  len,
const char str 
)
extern

Initialize avs with storage for len entries.

◆ bu_avs_init_empty()

void bu_avs_init_empty ( struct bu_attribute_value_set avp)
extern

Initialize an empty avs.

◆ bu_avs_new()

struct bu_attribute_value_set * bu_avs_new ( size_t  len,
const char str 
)
extern

Allocate storage for a new attribute/value set, with at least 'len' slots pre-allocated.

◆ bu_avs_add()

int bu_avs_add ( struct bu_attribute_value_set avp,
const char attribute,
const char value 
)
extern

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()

int bu_avs_add_vls ( struct bu_attribute_value_set avp,
const char attribute,
const struct bu_vls value_vls 
)
extern

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 
)
extern

Add a name/value pair even if the name already exists in the set.

◆ bu_avs_merge()

void bu_avs_merge ( struct bu_attribute_value_set dest,
const struct bu_attribute_value_set src 
)
extern

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()

const char * bu_avs_get ( const struct bu_attribute_value_set avp,
const char attribute 
)
extern

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()

int bu_avs_remove ( struct bu_attribute_value_set avp,
const char attribute 
)
extern

Remove all occurrences of an attribute from the provided attribute set.

Returns
-1 attribute not found in set
0 OK

◆ bu_avs_free()

void bu_avs_free ( struct bu_attribute_value_set avp)
extern

Release all attributes in the provided attribute set.

◆ bu_avs_print()

void bu_avs_print ( const struct bu_attribute_value_set avp,
const char title 
)
extern

Print all attributes in an attribute set in "name = value" form, using the provided title.