|
Click
|
A fixed database mapping names to 4-byte integer values. More...
Public Member Functions | |
| StaticNameDB (uint32_t type, const String &context, const Entry *entry, size_t nentry) | |
| Construct a static name database. | |
| bool | query (const String &name, void *value, size_t value_size) |
| Query this database for a given name. | |
| String | revquery (const void *value, size_t value_size) |
| Query this database for a given value. | |
Public Member Functions inherited from NameDB | |
| NameDB (uint32_t type, const String &context, size_t value_size) | |
| Construct a database. | |
| virtual | ~NameDB () |
| Destroy a database. | |
| uint32_t | type () const |
| Return the database type. | |
| const String & | context () const |
| Return the database's compound element context as a string. | |
| NameDB * | context_parent () const |
| Return the contextual parent database, if any. | |
| size_t | value_size () const |
| Return the database's value size. | |
| virtual bool | define (const String &name, const void *value, size_t value_size) |
| Define a name in this database to a given value. | |
| bool | define_int (const String &name, int32_t value) |
| Define a name in this database to a 32-bit integer value. | |
A fixed database mapping names to 4-byte integer values.
StaticNameDB is a NameDB database that maps names to 4-byte integer values. The database contents are taken from an array of Entry structures passed in to the constructor. Each Entry specifies a name-value definition. The entries must be sorted by name. This is the most space-efficient way to implement a static name database for integers.
StaticNameDB define() operations always fail.
|
inline |
Construct a static name database.
| type | database type |
| context | database compound element context, as a String |
| entry | pointer to static entry list |
| nentry | number of entries |
The entry array specifies the contents of the database. It must be sorted by name: entry[i].name < entry[i+1].name for all 0 <= i < nentry-1. The entry array must also persist as long as the database is in use; the database doesn't copy the entry array into its own memory, but continues to use the array passed in. The resulting database has value_size() 4.
|
virtual |
Query this database for a given name.
| name | name to look up |
| value | points to value storage |
| value_size | size of value storage |
The value_size parameter must equal 4.
Implements NameDB.
|
virtual |
Query this database for a given value.
| value | points to value to look up |
| value_size | size of value storage |
The value_size parameter must equal 4.
Reimplemented from NameDB.