Dict class can be used to store objects of arbitrary type keyed by strings.
More...
#include <Dict.h>
Public Types | |
| typedef std::map< const std::string, boost::any > | DataType |
Public Member Functions | |
| Dict () | |
| Dict (const Dict &other) | |
| Dict & | operator= (const Dict &other) |
| bool | hasVal (const char *what) const |
| Returns whether or not the dictionary contains a particular key. | |
| bool | hasVal (const std::string &what) const |
| STR_VECT | keys () const |
| Returns the set of keys in the dictionary. | |
| template<typename T> | |
| void | getVal (const std::string &what, T &res) const |
| Gets the value associated with a particular key. | |
| template<typename T> | |
| T | getVal (const std::string &what) const |
| template<typename T> | |
| T | getVal (const char *what, T &res) const |
| template<typename T> | |
| T | getVal (const char *what) const |
| void | getVal (const std::string &what, std::string &res) const |
| template<typename T> | |
| void | setVal (const std::string &what, T &val) |
| Sets the value associated with a key. | |
| template<typename T> | |
| void | setVal (const char *what, T &val) |
| void | setVal (const std::string &what, const char *val) |
| void | clearVal (const std::string &what) |
| Clears the value associated with a particular key, removing the key from the dictionary. | |
| void | clearVal (const char *what) |
| void | reset () |
| Clears all keys (and values) from the dictionary. | |
| template<typename T> | |
| T | fromany (const boost::any &arg) const |
Converts a boost::any to type T. | |
| template<typename T> | |
| boost::any | toany (T arg) const |
Converts an instance of type T to boost::any. | |
Friends | |
| void | force_types () |
this function is used solely to force the instantiation of particular types of the Dict.toAny() and Dict.fromAny() methods in order to avoid link errors. | |
Dict class can be used to store objects of arbitrary type keyed by strings.
The actual storage is done using boost::any objects.
Definition at line 29 of file Dict.h.
| typedef std::map<const std::string, boost::any> RDKit::Dict::DataType |
| RDKit::Dict::Dict | ( | const Dict & | other | ) | [inline] |
| bool RDKit::Dict::hasVal | ( | const char * | what | ) | const [inline] |
Returns whether or not the dictionary contains a particular key.
Definition at line 52 of file Dict.h.
Referenced by clearVal(), RDKit::ROMol::hasProp(), RDKit::MolCatalogEntry::hasProp(), RDKit::FragCatalogEntry::hasProp(), RDKit::Bond::hasProp(), and RDKit::Atom::hasProp().
| bool RDKit::Dict::hasVal | ( | const std::string & | what | ) | const [inline] |
| STR_VECT RDKit::Dict::keys | ( | ) | const [inline] |
Returns the set of keys in the dictionary.
STR_VECT Definition at line 65 of file Dict.h.
Referenced by RDKit::ROMol::getPropList(), RDKit::Bond::getPropList(), and RDKit::Atom::getPropList().
| void RDKit::Dict::getVal | ( | const std::string & | what, | |
| T & | res | |||
| ) | const [inline] |
Gets the value associated with a particular key.
| what | the key to lookup | |
| res | a reference used to return the result |
res is a std::string, every effort will be made to convert the specified element to a string using the boost::lexical_cast machinery.what, a KeyErrorException will be thrown. Definition at line 88 of file Dict.h.
Referenced by RDKit::ROMol::getProp(), RDKit::MolCatalogEntry::getProp(), RDKit::FragCatalogEntry::getProp(), RDKit::Bond::getProp(), RDKit::Atom::getProp(), and getVal().
| T RDKit::Dict::getVal | ( | const std::string & | what | ) | const [inline] |
| T RDKit::Dict::getVal | ( | const char * | what, | |
| T & | res | |||
| ) | const [inline] |
| T RDKit::Dict::getVal | ( | const char * | what | ) | const [inline] |
| void RDKit::Dict::getVal | ( | const std::string & | what, | |
| std::string & | res | |||
| ) | const |
| void RDKit::Dict::setVal | ( | const std::string & | what, | |
| T & | val | |||
| ) | [inline] |
Sets the value associated with a key.
| what | the key to set | |
| val | the value to store |
val is a const char *, it will be converted to a std::string for storage.what, the value will be replaced. Definition at line 134 of file Dict.h.
References toany().
Referenced by RDKit::Bond::clearComputedProps(), RDKit::Atom::clearComputedProps(), RDKit::ROMol::clearProp(), RDKit::Bond::clearProp(), RDKit::Atom::clearProp(), RDKit::ROMol::setProp(), RDKit::MolCatalogEntry::setProp(), RDKit::FragCatalogEntry::setProp(), RDKit::Bond::setProp(), RDKit::Atom::setProp(), and setVal().
| void RDKit::Dict::setVal | ( | const char * | what, | |
| T & | val | |||
| ) | [inline] |
| void RDKit::Dict::setVal | ( | const std::string & | what, | |
| const char * | val | |||
| ) | [inline] |
| void RDKit::Dict::clearVal | ( | const std::string & | what | ) | [inline] |
Clears the value associated with a particular key, removing the key from the dictionary.
| what | the key to clear |
what, a KeyErrorException will be thrown. Definition at line 163 of file Dict.h.
References hasVal().
Referenced by RDKit::Bond::clearComputedProps(), RDKit::Atom::clearComputedProps(), RDKit::ROMol::clearProp(), RDKit::MolCatalogEntry::clearProp(), RDKit::FragCatalogEntry::clearProp(), RDKit::Bond::clearProp(), RDKit::Atom::clearProp(), and clearVal().
| void RDKit::Dict::clearVal | ( | const char * | what | ) | [inline] |
| void RDKit::Dict::reset | ( | ) | [inline] |
| T RDKit::Dict::fromany | ( | const boost::any & | arg | ) | const [inline] |
Converts a boost::any to type T.
| arg | a boost::any reference |
T | boost::any RDKit::Dict::toany | ( | T | arg | ) | const [inline] |
Converts an instance of type T to boost::any.
| arg | the object to be converted |
boost::any instance Referenced by setVal().
| void force_types | ( | ) | [friend] |
this function is used solely to force the instantiation of particular types of the Dict.toAny() and Dict.fromAny() methods in order to avoid link errors.
1.5.5