BRL-CAD
Collaboration diagram for Attribute/Value Sets:

Files

file  avs.c
 

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

Detailed Description

Macro Definition Documentation

#define BU_AVS_NULL   ((struct bu_attribute_value_set *)0)

Definition at line 92 of file avs.h.

#define BU_CK_AVS (   _ap)    BU_CKMAG(_ap, BU_AVS_MAGIC, "bu_attribute_value_set")
#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; \
}
#define BU_AVS_MAGIC
Definition: magic.h:46
oldeumate l2 magic
Definition: nmg_mod.c:3843

initialize a bu_attribute_value_set struct without allocating any memory.

Definition at line 102 of file avs.h.

Referenced by db5_get_attributes(), get_diff_components(), and tcl_list_to_avs().

#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 112 of file avs.h.

Referenced by constraint_set().

#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 118 of file avs.h.

Referenced by tcl_list_to_avs().

#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:

1 void
2 print_avs(struct bu_attribute_value_set *avs) {
3  struct bu_attribute_value_pair *avpp;
4 
5  for (BU_AVS_FOR(avpp, avs)) {
6  bu_log("key=%s, value=%s\n", avpp->name, avpp->value);
7  }
8 }

Definition at line 141 of file avs.h.

Referenced by _ged_do_list(), _rt_gettree_region_end(), avs_check(), bu_avs_add(), bu_avs_free(), bu_avs_get(), bu_avs_merge(), bu_avs_remove(), db5_standardize_avs(), db_avs_diff(), db_avs_diff3(), and f_stdattr().

#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 150 of file avs.h.

Referenced by bu_avs_add(), bu_avs_free(), and bu_avs_remove().

Typedef Documentation

Definition at line 91 of file avs.h.

Enumeration Type Documentation

for attr and avs use.

Enumerator
BU_ATTR_CREATED 
BU_ATTR_MODIFIED 

Definition at line 44 of file avs.h.

Function Documentation

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

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

Definition at line 63 of file avs.c.

References BU_ALLOC, bu_avs_init(), bu_debug, BU_DEBUG_AVS, bu_log(), and UNLIKELY.

Here is the call graph for this function:

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

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

Definition at line 78 of file avs.c.

References bu_attribute_value_set::avp, AVS_ALLOCATION_INCREMENT, AVS_IS_FREEABLE, BU_AVS_FOR, bu_calloc(), BU_CK_AVS, bu_free(), bu_log(), bu_realloc(), BU_STR_EQUAL, bu_strdup, bu_attribute_value_set::count, bu_attribute_value_set::max, bu_attribute_value_pair::name, UNLIKELY, and bu_attribute_value_pair::value.

Referenced by _rt_gettree_region_end(), attr_add(), bu_avs_add_vls(), bu_avs_merge(), build_comb(), constraint_set(), db5_fwrite_ident(), db5_import_attributes(), db5_sync_comb_to_attr(), db5_update_attribute(), db5_update_ident(), db_create_inmem(), db_dup_db_tree_state(), ged_attr(), ged_draw_guts(), ged_erase(), ged_ls(), get_diff_components(), region_flag_set(), rt_comb_export5(), rt_gettrees_muves(), rt_load_attrs(), and tcl_list_to_avs().

Here is the call graph for this function:

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

Add a bu_vls string as an attribute to a given attribute set, updating the value if it already exists.

Definition at line 144 of file avs.c.

References bu_avs_add(), BU_CK_AVS, BU_CK_VLS, and bu_vls_addr().

Referenced by db5_sync_comb_to_attr(), ged_attr(), and rt_comb_export5().

Here is the call graph for this function:

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.

Definition at line 287 of file avs.c.

References bu_attribute_value_set::avp, AVS_ALLOCATION_INCREMENT, BU_CK_AVS, bu_log(), bu_malloc(), bu_realloc(), bu_strdup, bu_attribute_value_set::count, bu_attribute_value_set::max, bu_attribute_value_pair::name, UNLIKELY, and bu_attribute_value_pair::value.

Referenced by ged_draw_guts(), ged_erase(), and ged_ls().

Here is the call graph for this function:

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

Take all the attributes from 'src' and merge them into 'dest' by replacing an attribute if it already exists in the set.

Definition at line 154 of file avs.c.

References bu_avs_add(), BU_AVS_FOR, BU_CK_AVS, bu_attribute_value_set::count, bu_attribute_value_pair::name, and bu_attribute_value_pair::value.

Referenced by db5_standardize_avs(), db5_update_attributes(), db_recurse(), ged_attr(), get_diff_components(), rt_bot_xform(), rt_extrude_xform(), rt_generic_xform(), rt_hlf_xform(), and rt_revolve_xform().

Here is the call graph for this function:

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

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.

Definition at line 172 of file avs.c.

References BU_AVS_FOR, BU_CK_AVS, BU_STR_EQUAL, bu_attribute_value_set::count, bu_attribute_value_pair::name, and bu_attribute_value_pair::value.

Referenced by _rt_gettree_region_end(), db5_diradd(), db5_standardize_avs(), db5_sync_attr_to_comb(), db_avs_diff(), db_avs_diff3(), db_diradd5(), db_dirbuild(), db_flags_raw_internal(), ged_attr(), ged_concat(), ged_dbcopy(), rt_comb_import5(), rt_load_attrs(), and write_comb().

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

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

Returns
-1 attribute not found in set
0 OK

Definition at line 195 of file avs.c.

References bu_attribute_value_set::avp, AVS_IS_FREEABLE, BU_AVS_FOR, BU_CK_AVS, bu_free(), BU_STR_EQUAL, bu_attribute_value_set::count, bu_attribute_value_pair::name, UNLIKELY, and bu_attribute_value_pair::value.

Referenced by attr_add(), color_shader_clear(), db5_sync_comb_to_attr(), ged_attr(), ged_concat(), region_flag_clear(), and rt_comb_export5().

Here is the call graph for this function:

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

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

Definition at line 266 of file avs.c.

References bu_attribute_value_set::avp, BU_CK_AVS, bu_log(), bu_attribute_value_set::count, bu_attribute_value_pair::name, and bu_attribute_value_pair::value.

Referenced by db5_export_attributes(), db5_import_attributes(), db5_replace_attributes(), and db5_update_attributes().

Here is the call graph for this function: