Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StaticNameDB Class Reference

A fixed database mapping names to 4-byte integer values. More...

Inheritance diagram for StaticNameDB:
NameDB

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.
 

Detailed Description

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.

See also
NameInfo, NameDB

Constructor & Destructor Documentation

◆ StaticNameDB()

StaticNameDB::StaticNameDB ( uint32_t  type,
const String &  context,
const Entry *  entry,
size_t  nentry 
)
inline

Construct a static name database.

Parameters
typedatabase type
contextdatabase compound element context, as a String
entrypointer to static entry list
nentrynumber 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.

Member Function Documentation

◆ query()

bool StaticNameDB::query ( const String &  name,
void *  value,
size_t  value_size 
)
virtual

Query this database for a given name.

Parameters
namename to look up
valuepoints to value storage
value_sizesize of value storage
Returns
true iff the query succeeded

The value_size parameter must equal 4.

Implements NameDB.

◆ revquery()

String StaticNameDB::revquery ( const void *  value,
size_t  value_size 
)
virtual

Query this database for a given value.

Parameters
valuepoints to value to look up
value_sizesize of value storage
Returns
the name for the given value, or an empty string if the value has not been defined

The value_size parameter must equal 4.

Reimplemented from NameDB.


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