Om
1.0.0
A universal framework for multimedia simulation
|
A HashMap-based data structure which associates string keys with values of different types. More...
#include <omDataStore.h>
Public Member Functions | |
DataStore () | |
Create a new empty data store. More... | |
DataStore (const DataStore &other) | |
Create a copy of the specified data store, copying all of its internal data. More... | |
~DataStore () | |
Destroy the data store object, releasing all internal resources. More... | |
DataStore & | operator= (const DataStore &other) |
Assign the contents of another data store object to this one, replacing all previous contents. More... | |
Size | getSize () const |
Return the total number of key-value pairs that are stored in this DataStore. More... | |
template<typename T > | |
T * | get (const String &key) |
Return a pointer to the value stored in this data store associated with the given key. More... | |
template<typename T > | |
const T * | get (const String &key) const |
Return a const pointer to the value stored in this data store associated with the given key. More... | |
Bool | set (const String &key, Bool value) |
Store the specified boolean value, associating it with the key string. More... | |
Bool | set (const String &key, Int32 value) |
Store the specified signed 32-bit integer, associating it with the key string. More... | |
Bool | set (const String &key, UInt32 value) |
Store the specified unsigned 32-bit integer, associating it with the key string. More... | |
Bool | set (const String &key, Int64 value) |
Store the specified signed 64-bit integer, associating it with the key string. More... | |
Bool | set (const String &key, UInt64 value) |
Store the specified unsigned 64-bit integer, associating it with the key string. More... | |
Bool | set (const String &key, Float32 value) |
Store the specified 32-bit floating point value, associating it with the key string. More... | |
Bool | set (const String &key, Float64 value) |
Store the specified 64-bit floating point value, associating it with the key string. More... | |
Bool | set (const String &key, const UTF8String &string) |
Store the specified UTF-8 encoded string, associating it with the key string. More... | |
Bool | set (const String &key, const Data &data) |
Store the specified data object, associating it with the key string. More... | |
Bool | set (const String &key, const UByte *bytes, Size numBytes) |
Store the specified array of bytes, associating it with the key string. More... | |
Bool | set (const String &key, const DataStore &dataStore) |
Store the specified DataStore object, associating it with the key string. More... | |
Bool | remove (const String &key) |
Remove any data stored that is associated with the specified string key. More... | |
void | clear () |
Clear all of the previously stored contents from this data store. More... | |
A HashMap-based data structure which associates string keys with values of different types.
This class can be used to store arbitrary data in a dictionary format where data values are stored and accessed using a string key. This can be used to easily serialize an object's state to an intermediate format (the DataStore), which can then be easily written to disc in an automated process.
om::data::DataStore::DataStore | ( | ) |
Create a new empty data store.
om::data::DataStore::DataStore | ( | const DataStore & | other | ) |
Create a copy of the specified data store, copying all of its internal data.
om::data::DataStore::~DataStore | ( | ) |
Destroy the data store object, releasing all internal resources.
This destructor invalidates all iterators and pointers to internal data.
Assign the contents of another data store object to this one, replacing all previous contents.
The contents of the other data store are deep-copied to this data store. This operator invalidates all iterators and pointers to internal data.
|
inline |
Return the total number of key-value pairs that are stored in this DataStore.
T* om::data::DataStore::get | ( | const String & | key | ) |
Return a pointer to the value stored in this data store associated with the given key.
This method attempts to access the value for the given key and template data type. If the key does not have an associated value, or if the requested template return type is not compatible with the stored value, the method returns a NULL pointer. Otherwise, if the return value is non-NULL, the method succeeds.
const T* om::data::DataStore::get | ( | const String & | key | ) | const |
Return a const pointer to the value stored in this data store associated with the given key.
This method attempts to access the value for the given key and template data type. If the key does not have an associated value, or if the requested template return type is not compatible with the stored value, the method returns a NULL pointer. Otherwise, if the return value is non-NULL, the method succeeds.
Store the specified boolean value, associating it with the key string.
Store the specified signed 32-bit integer, associating it with the key string.
Store the specified unsigned 32-bit integer, associating it with the key string.
Store the specified signed 64-bit integer, associating it with the key string.
Store the specified unsigned 64-bit integer, associating it with the key string.
Store the specified 32-bit floating point value, associating it with the key string.
Store the specified 64-bit floating point value, associating it with the key string.
Bool om::data::DataStore::set | ( | const String & | key, |
const UTF8String & | string | ||
) |
Store the specified UTF-8 encoded string, associating it with the key string.
Store the specified data object, associating it with the key string.
Store the specified array of bytes, associating it with the key string.
The specified number of bytes are copied from of the byte pointer and stored internally. The method returns whether or not the operation was successful. The method can fail if the byte pointer is NULL or if the number of bytes to store is 0.
Store the specified DataStore object, associating it with the key string.
This method copies the specified DataStore object and all of its contents to an internal location. This allows hierarchical structures to be created using DataStore objects that can contain other DataStore objects. The method returns whether or not the operation was successful.
Remove any data stored that is associated with the specified string key.
The method returns whether or not any stored entry for that key was removed successfully.
void om::data::DataStore::clear | ( | ) |
Clear all of the previously stored contents from this data store.