Attribute/Value Sets
[libbu (utility functions)]

Collaboration diagram for Attribute/Value Sets:


Files

file  avs.c
 Routines to manage attribute/value sets.

Data Structures

struct  bu_attribute_value_pair
struct  bu_attribute_value_set

Defines

#define BU_AVS_MAGIC   0x41765321
#define BU_CK_AVS(_avp)   BU_CKMAG(_avp, BU_AVS_MAGIC, "bu_attribute_value_set")
#define BU_AVS_FOR(_pp, _avp)   (_pp) = &(_avp)->avp[(_avp)->count-1]; (_pp) >= (_avp)->avp; (_pp)--
#define AVS_IS_FREEABLE(_avsp, _p)

Functions

void bu_avs_init (struct bu_attribute_value_set *avsp, int len, const char *str)
 initialize avs with storage for len entries
void bu_avs_init_empty (struct bu_attribute_value_set *avsp)
 initialize an empty avs
bu_attribute_value_setbu_avs_new (int len, const char *str)
 Allocate storage for a new attribute/value set, with at least 'len' slots pre-allocated.
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_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'.
const char * bu_avs_get (const struct bu_attribute_value_set *avp, const char *attribute)
int bu_avs_remove (struct bu_attribute_value_set *avsp, const char *attribute)
 Remove the given attribute from the set.
void bu_avs_free (struct bu_attribute_value_set *avp)
void bu_avs_print (const struct bu_attribute_value_set *avp, const char *title)
void bu_avs_add_nonunique (struct bu_attribute_value_set *avsp, char *attribute, char *value)
 Add a name/value pair even if the name already exists in this AVS.

Define Documentation

#define BU_AVS_MAGIC   0x41765321
 

Definition at line 1148 of file bu.h.

Referenced by bu_avs_init(), bu_avs_init_empty(), bu_identify_magic(), rt_comb_export5(), rt_db_external5_to_internal5(), rt_db_free_internal(), rt_extrude_xform(), and rt_generic_xform().

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

Definition at line 1149 of file bu.h.

Referenced by bu_avs_add(), bu_avs_add_nonunique(), bu_avs_add_vls(), bu_avs_free(), bu_avs_get(), bu_avs_merge(), bu_avs_print(), bu_avs_remove(), db5_export_attributes(), db5_replace_attributes(), db5_update_attributes(), db_dirbuild(), and db_lookup_by_attr().

#define BU_AVS_FOR _pp,
_avp   )     (_pp) = &(_avp)->avp[(_avp)->count-1]; (_pp) >= (_avp)->avp; (_pp)--
 

Definition at line 1151 of file bu.h.

Referenced by bu_avs_add(), bu_avs_free(), bu_avs_get(), bu_avs_merge(), bu_avs_remove(), and wdb_do_list().

#define AVS_IS_FREEABLE _avsp,
_p   ) 
 

Value:

( (_avsp)->readonly_max == NULL || \
            ((genptr_t)(_p) < (genptr_t)(_avsp)->readonly_min || (genptr_t)(_p) > (genptr_t)(_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 1160 of file bu.h.

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


Function Documentation

void bu_avs_init struct bu_attribute_value_set avsp,
int  len,
const char *  str
 

initialize avs with storage for len entries

B U _ A V S _ I N I T

Definition at line 75 of file avs.c.

References bu_attribute_value_set::avp, BU_AVS_MAGIC, bu_calloc(), bu_debug, BU_DEBUG_AVS, bu_log(), bu_attribute_value_set::count, bu_attribute_value_set::magic, bu_attribute_value_set::max, NULL, bu_attribute_value_set::readonly_max, and bu_attribute_value_set::readonly_min.

Referenced by bu_avs_new(), db5_fwrite_ident(), db5_import_attributes(), db5_update_attribute(), db5_update_attributes(), db5_update_ident(), db_create_inmem(), db_dup_db_tree_state(), rt_ars_prep(), rt_comb_export5(), rt_extrude_xform(), rt_generic_xform(), rt_gettrees_muves(), and wdb_ls_cmd().

Here is the call graph for this function:

void bu_avs_init_empty struct bu_attribute_value_set avsp  ) 
 

initialize an empty avs

B U _ A V S _ I N I T _ E M P T Y

Definition at line 59 of file avs.c.

References bu_attribute_value_set::avp, BU_AVS_MAGIC, bu_attribute_value_set::count, bu_attribute_value_set::magic, bu_attribute_value_set::max, NULL, bu_attribute_value_set::readonly_max, and bu_attribute_value_set::readonly_min.

Referenced by db5_diradd(), db_dirbuild(), db_dup_db_tree_state(), db_flags_raw_internal(), db_init_db_tree_state(), rt_db_external5_to_internal5(), rt_db_get_internal(), rt_gettrees_muves(), wdb_attr_cmd(), and wdb_do_list().

struct bu_attribute_value_set * bu_avs_new int  len,
const char *  str
 

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

B U _ A V S _ N E W

Definition at line 96 of file avs.c.

References bu_avs_init(), bu_debug, BU_DEBUG_AVS, BU_GETSTRUCT, and bu_log().

Here is the call graph for this function:

int bu_avs_add struct bu_attribute_value_set avsp,
const char *  attribute,
const char *  value
 

B U _ A V S _ A D D

If the given attribute exists it will recieve the new value, othwise the set will be extended to have a new attribute/value pair.

Returns - 1 existing attribute updated with new value 2 set extended with new attribute/value pair

Definition at line 120 of file avs.c.

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

Referenced by bu_avs_add_vls(), bu_avs_merge(), db5_fwrite_ident(), db5_import_attributes(), db5_update_attribute(), db5_update_ident(), db_create_inmem(), db_dup_db_tree_state(), rt_comb_export5(), rt_gettrees_muves(), and wdb_ls_cmd().

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
 

Definition at line 166 of file avs.c.

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

Referenced by rt_comb_export5().

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

B U _ A V S _ M E R G E

Definition at line 181 of file avs.c.

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

Referenced by db5_update_attributes(), db_recurse(), rt_extrude_xform(), and rt_generic_xform().

Here is the call graph for this function:

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

Definition at line 199 of file avs.c.

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

Referenced by db5_diradd(), db_diradd5(), db_dirbuild(), db_flags_raw_internal(), and wdb_attr_cmd().

int bu_avs_remove struct bu_attribute_value_set avsp,
const char *  attribute
 

Remove the given attribute from the set.

B U _ A V S _ R E M O V E

Returns:
-1 attribute not found in set

0 OK

Definition at line 227 of file avs.c.

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

Referenced by rt_comb_export5().

Here is the call graph for this function:

void bu_avs_free struct bu_attribute_value_set avp  ) 
 

Definition at line 260 of file avs.c.

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

Referenced by db5_diradd(), db5_fwrite_ident(), db5_replace_attributes(), db5_update_attributes(), db_create_inmem(), db_dirbuild(), db_free_db_tree_state(), rt_db_free_internal(), rt_generic_xform(), rt_gettrees_muves(), and wdb_attr_cmd().

Here is the call graph for this function:

void bu_avs_print const struct bu_attribute_value_set avp,
const char *  title
 

Definition at line 294 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:

void bu_avs_add_nonunique struct bu_attribute_value_set avsp,
char *  attribute,
char *  value
 

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

B U _ A V S _ A D D _ N O N U N I Q U E

Definition at line 316 of file avs.c.

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

Referenced by wdb_ls_cmd().

Here is the call graph for this function:


Generated on Mon Sep 18 01:25:19 2006 for BRL-CAD by  doxygen 1.4.6