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 (Dict &&other) noexcept=default | |
~Dict () | |
void | update (const Dict &other, bool preserveExisting=false) |
Dict & | operator= (const Dict &other) |
Dict & | operator= (Dict &&other) noexcept |
bool & | getNonPODStatus () |
Access to the underlying non-POD containment flag This is meant to be used only in bulk updates of _data. | |
const DataType & | getData () const |
Access to the underlying data. | |
DataType & | getData () |
bool | hasVal (const std::string &what) const |
Returns whether or not the dictionary contains a particular key. | |
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 |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | 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. | |
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. | |
bool | 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. | |
template<typename T > | |
void | setVal (const std::string &what, T &val) |
Sets the value associated with a key. | |
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) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | clearVal (const std::string &what) |
Clears the value associated with a particular key, removing the key from the dictionary. | |
void | reset () |
Clears all keys (and values) from the dictionary. | |
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 |
Definition at line 51 of file Dict.h.
References RDKit::copy_rdvalue().
|
defaultnoexcept |
Clears the value associated with a particular key, removing the key from the dictionary.
what | the key to clear |
Definition at line 314 of file Dict.h.
Referenced by RDKit::RDProps::clearComputedProps(), RDKit::FilterCatalogEntry::clearProp(), and RDKit::RDProps::clearProp().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 199 of file Dict.h.
References RDKit::rdvalue_tostring().
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 183 of file Dict.h.
Referenced by RDKit::FilterCatalogEntry::getProp(), RDKit::FilterCatalogEntry::getProp(), RDKit::FilterCatalogEntry::getProp(), RDKit::RDProps::getProp(), RDKit::FilterCatalogEntry::getProp(), and RDKit::RDProps::getProp().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 235 of file Dict.h.
References RDKit::rdvalue_tostring().
|
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 224 of file Dict.h.
Referenced by RDKit::FilterCatalogEntry::getPropIfPresent(), RDKit::FilterCatalogEntry::getPropIfPresent(), and RDKit::RDProps::getPropIfPresent().
Returns whether or not the dictionary contains a particular key.
Definition at line 146 of file Dict.h.
Referenced by RDKit::FilterCatalogEntry::hasProp(), RDKit::FilterCatalogEntry::hasProp(), and RDKit::RDProps::hasProp().
|
inline |
Returns the set of keys in the dictionary.
STR_VECT
Definition at line 160 of file Dict.h.
Referenced by RDKit::FilterCatalogEntry::getPropList(), and RDKit::RDProps::getPropList().
Definition at line 97 of file Dict.h.
References RDKit::copy_rdvalue().
|
inline |
Clears all keys (and values) from the dictionary.
Definition at line 329 of file Dict.h.
Referenced by RDKit::RDProps::clear().
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 259 of file Dict.h.
Referenced by RDKit::RDProps::clearComputedProps(), RDKit::RDProps::clearProp(), RDKit::FilterCatalogEntry::setProp(), and RDKit::RDProps::setProp().
Definition at line 69 of file Dict.h.
References RDKit::copy_rdvalue(), and RDKit::Dict::Pair::val.
Referenced by RDKit::RDProps::updateProps().