#include <VMap.h>
Inheritance diagram for rel::VMap:
Public Types | |
typedef SmartPtr< VMap > | Ptr |
enum | ErrorCode { Success = 0, TypeMismatch = 1, NotFound = 2, AlreadyExists = 3, NotPermitted = 4, Unsupported = 5, ArgumentError = 6, BackendError } |
enum | DirFlags { NoFlags = 0x00, FindOrCreate } |
Public Methods | |
virtual | ~VMap () |
virtual Ptr | findDirectory (const string &name, int flags=NoFlags) |
virtual Ptr | findDirectory (const TypeStream &path, int flags=NoFlags) |
virtual Ptr | createDirectory (const string &name) |
virtual Ptr | createDirectory (const TypeStream &path) |
virtual OpaqueValue | find (const string &name) |
virtual OpaqueValue | find (const TypeStream &path) |
virtual VMapIterator | begin () |
virtual VMapIterator | end () |
virtual VMapIterator | at (const string &name) |
virtual ErrorCode | insert (const string &name, const OpaqueValue &value) |
virtual ErrorCode | insert (const TypeStream &path, const OpaqueValue &value, int flags=FindOrCreate) |
virtual ErrorCode | assign (const string &name, const OpaqueValue &value) |
virtual ErrorCode | assign (const TypeStream &path, const OpaqueValue &value) |
virtual ErrorCode | erase (const string &name) |
virtual ErrorCode | erase (const TypeStream &path) |
virtual ErrorCode | clear () |
Protected Methods | |
virtual void | advanceIterator (const OpaqueValue &) const |
virtual bool | equalIteratorData (const OpaqueValue &a, const OpaqueValue &b) const |
virtual void | assignIteratorData (const OpaqueValue &src, const OpaqueValue &dest) const |
virtual void | getKeyValue (const OpaqueValue &iteratorData, std::pair< std::string, OpaqueValue > *result) |
Protected Attributes | |
friend | VMapIterator |
Related Functions | |
(Note that these are not member functions.) | |
OpaqueValue | findFirst (VMapPtr &map, const TypeStream &path, const string &key) |
OpaqueValue | findDeepest (VMapPtr &map, const TypeStream &path, const string &key) |
The values are stored as an OpaqueValue - which can be converted to the appropriate SmartPtr<> type using operator=.
For example, to store an integer pointer, and then pull it back out:
// create a new map (a VMemMap - memory based storage) VMapPtr testMap(new VMemMap); // insert the value 42 into the map testMap->insert("test value", SmartPtr<int>(new int(42))); // This would also work - as the smart pointer can store by-value as well // as a pointer to a value.. // testMap->insert("test value", SmartPtr<int>(int(42))); // pull out the value and print it SmartPtr<int> result = testMap->find("test value"); cout << "result = " << *result << endl;
|
Special flags for some operations - such as findDirectory(). This can be used to tell findDirectory to create the directory if it doesn't exist, or to return failure. |
|
Error codes returned by various VMap operations. These are returned when a return value can be used instead of having to throw an error. For calls which cannot return an error code, or for errors for which there is no matching code, an error may be thrown.
|
|
All elements in the map are released. Since all elements are smart pointers (OpaqueValue), then if that was the last reference, they will be destroyed by whatever means the smart pointer provides.
|
|
Remove (and destroy) all elements in the map. Reimplemented in rel::VMemMap. |
|
create directory using a direct name. throws VMap_unsupported if not implemented Reimplemented in rel::VMemMap. |
|
search for [sub]directory using a multi-part name. This can contain one or more directory names, which results in a sequencial search. This is convenient when dealing with nested values -- for example:
// search inside the directory "a" for an entry "b". OpaqueValue result = testMap->find(Path("a/b")); // equivelent code: VMapPtr subDir = testMap->find("a"); if(subDir.get()) result = subDir->find("b");
|
|
search for [sub]directory using a direct name
|
|
Search down the tree for the deepest occurance of the key. Returns the value if any.
|
|
Search down the tree for the first occurance of the key. Returns the value, if any.
|