![]() |
RDKit
Open-source cheminformatics and machine learning.
|
The Dict
class can be used to store objects of arbitrary type keyed by strings
.
More...
#include <Dict.h>
Classes | |
struct | Pair |
Public Types | |
typedef std::vector< Pair > | DataType |
Public Member Functions | |
Dict () | |
Dict (const Dict &other) | |
~Dict () | |
void | update (const Dict &other, bool preserveExisting=false) |
Dict & | operator= (const Dict &other) |
const DataType & | getData () const |
Access to the underlying data. More... | |
DataType & | getData () |
bool | hasVal (const std::string &what) const |
Returns whether or not the dictionary contains a particular key. More... | |
STR_VECT | keys () const |
Returns the set of keys in the dictionary. More... | |
template<typename T > | |
void | getVal (const std::string &what, T &res) const |
Gets the value associated with a particular key. More... | |
template<typename T > | |
T | getVal (const std::string &what) const |
void | getVal (const std::string &what, std::string &res) const |
template<typename T > | |
bool | getValIfPresent (const std::string &what, T &res) const |
Potentially gets the value associated with a particular key returns true on success/false on failure. More... | |
bool | getValIfPresent (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. More... | |
template<typename T > | |
void | setPODVal (const std::string &what, T val) |
void | setVal (const std::string &what, bool val) |
void | setVal (const std::string &what, double val) |
void | setVal (const std::string &what, float val) |
void | setVal (const std::string &what, int val) |
void | setVal (const std::string &what, unsigned int 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. More... | |
void | reset () |
Clears all keys (and values) from the dictionary. More... | |
The Dict
class can be used to store objects of arbitrary type keyed by strings
.
The actual storage is done using RDValue
objects.
typedef std::vector<Pair> RDKit::Dict::DataType |
|
inline |
Definition at line 51 of file Dict.h.
References RDKit::copy_rdvalue().
|
inline |
Clears the value associated with a particular key, removing the key from the dictionary.
what | the key to clear |
Notes:
what
, a KeyErrorException will be thrown. Definition at line 270 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
Referenced by RDKit::RDProps::clearComputedProps(), RDKit::RDProps::clearProp(), and RDKit::FilterCatalogEntry::clearProp().
|
inline |
Access to the underlying data.
Definition at line 114 of file Dict.h.
Referenced by RDKit::streamReadProps().
|
inline |
Gets the value associated with a particular key.
what | the key to lookup |
res | a reference used to return the result |
Notes:
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 156 of file Dict.h.
Referenced by RDKit::RDProps::getProp(), and RDKit::FilterCatalogEntry::getProp().
|
inline |
void RDKit::Dict::getVal | ( | const std::string & | what, |
std::string & | res | ||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Potentially gets the value associated with a particular key returns true on success/false on failure.
what | the key to lookup |
res | a reference used to return the result |
Notes:
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 189 of file Dict.h.
Referenced by RDKit::RDProps::getPropIfPresent(), RDKit::FilterCatalogEntry::getPropIfPresent(), and RDKit::FilterCatalogEntry::hasFilterMatch().
bool RDKit::Dict::getValIfPresent | ( | const std::string & | what, |
std::string & | res | ||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Returns whether or not the dictionary contains a particular key.
Definition at line 121 of file Dict.h.
Referenced by RDKit::RDProps::hasProp(), and RDKit::FilterCatalogEntry::hasProp().
|
inline |
Returns the set of keys in the dictionary.
STR_VECT
Definition at line 133 of file Dict.h.
Referenced by RDKit::RDProps::getPropList(), RDKit::FilterCatalogEntry::getPropList(), and RDKit::FilterCatalogEntry::hasFilterMatch().
Definition at line 94 of file Dict.h.
References RDKit::copy_rdvalue().
|
inline |
Clears all keys (and values) from the dictionary.
Definition at line 286 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
Referenced by RDKit::RDProps::clear(), and RDKit::FilterCatalogEntry::hasFilterMatch().
|
inline |
Definition at line 229 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
|
inline |
Sets the value associated with a key.
what | the key to set |
val | the value to store |
Notes:
val
is a const char *
, it will be converted to a std::string
for storage.what
, the value will be replaced. Definition at line 216 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
Referenced by RDKit::RDProps::clearComputedProps(), RDKit::RDProps::clearProp(), RDKit::FilterCatalogEntry::hasFilterMatch(), RDKit::RDProps::setProp(), and RDKit::FilterCatalogEntry::setProp().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 67 of file Dict.h.
References RDKit::copy_rdvalue(), RDKit::Dict::Pair::key, and RDKit::Dict::Pair::val.
Referenced by RDKit::RDProps::updateProps().