imAttribTable Class Reference
[Utilities]

Attributes Table. More...

Public Member Functions

 imAttribTable (int hash_size)
 ~imAttribTable ()
int Count () const
void RemoveAll ()
void CopyFrom (const imAttribTable &table)
void Set (const char *name, int data_type, int count, const void *data)
void UnSet (const char *name)
const void * Get (const char *name, int *data_type=0, int *count=0) const
void ForEach (void *user_data, imAttribTableCallback attrib_func) const

Detailed Description

All the attributes have a name, a type, a count and the data.
Names are usually strings with less that 30 chars.
Attributes are stored in a hash table for fast access.
We use the hash function described in "The Pratice of Programming" of Kernighan & Pike.

Constructor & Destructor Documentation

imAttribTable::imAttribTable ( int  hash_size  )  [inline]

Creates an empty table. If size is zero the default size of 101 is used. Size must be a prime number. Other common values are 67, 599 and 1499.

00030     { ptable = imAttribTableCreate(hash_size); }

imAttribTable::~imAttribTable (  )  [inline]

Destroys the table and all the attributes.

00034     { imAttribTableDestroy(ptable); ptable = 0; }


Member Function Documentation

int imAttribTable::Count (  )  const [inline]

Returns the number of elements in the table.

00038     { return imAttribTableCount(ptable); }

void imAttribTable::RemoveAll (  )  [inline]

Removes all the attributes in the table

00042     { imAttribTableRemoveAll(ptable); }

void imAttribTable::CopyFrom ( const imAttribTable table  )  [inline]

Copies the contents of the given table into this table.

00046     { imAttribTableCopyFrom(ptable, table.ptable); }

void imAttribTable::Set ( const char *  name,
int  data_type,
int  count,
const void *  data 
) [inline]

Inserts an attribute into the table.
If data_type is BYTE then count can be -1 to indicate a NULL terminated string. Data is duplicated if not NULL, else data is initialized with zeros. See also imDataType.

00053     { imAttribTableSet(ptable, name, data_type, count, data); }

void imAttribTable::UnSet ( const char *  name  )  [inline]

Removes an attribute from the table given its name.

00057     { imAttribTableUnSet(ptable, name); }

const void* imAttribTable::Get ( const char *  name,
int *  data_type = 0,
int *  count = 0 
) const [inline]

Finds an attribute in the table. Returns the attribute if found, NULL otherwise. See also imDataType.

00063     { return imAttribTableGet(ptable, name, data_type, count); }

void imAttribTable::ForEach ( void *  user_data,
imAttribTableCallback  attrib_func 
) const [inline]

For each attribute calls the user callback. If the callback returns 0 the function returns.

00067     { imAttribTableForEach(ptable, user_data, attrib_func); }


The documentation for this class was generated from the following file:

Generated on Thu Oct 1 11:40:08 2009 for IM by  doxygen 1.6.1