![]() |
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 |
| using | const_iterator = DataType::const_iterator |
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 |
| std::size_t | size () const |
| Returns the number of entries in the dictionary. | |
| bool | empty () const |
| Returns whether the dictionary is empty. | |
| const_iterator | begin () const |
| const_iterator | end () const |
| void | insert (Pair &&pair) |
| Appends a populated Pair to the dictionary. | |
| void | extend (std::vector< Pair > &&pairs) |
| Bulk-appends a vector of Pairs, moving them into the dictionary. | |
| const RDValue & | getRDValue (const std::string_view what) const |
| Returns a const reference to the RDValue for a key. Throws KeyErrorException if the key is not found. | |
| bool | hasVal (const std::string_view 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_view what, T &res) const |
| Gets the value associated with a particular key. | |
| template<typename T> | |
| T | getVal (const std::string_view 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_view 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_view 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_view 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_view what, T &val) |
| Sets the value associated with a key. | |
| template<typename T> | |
| void | setPODVal (const std::string_view what, T val) |
| void | setVal (const std::string_view what, bool val) |
| void | setVal (const std::string_view what, double val) |
| void | setVal (const std::string_view what, float val) |
| void | setVal (const std::string_view what, int val) |
| void | setVal (const std::string_view what, unsigned int val) |
| void | setVal (const std::string_view 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_view 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.
| using RDKit::Dict::const_iterator = DataType::const_iterator |
| typedef std::vector<Pair> RDKit::Dict::DataType |
|
inline |
Definition at line 54 of file Dict.h.
Referenced by Dict(), Dict(), operator=(), operator=(), and update().
|
inline |
|
defaultnoexcept |
References Dict().
|
inline |
|
inline |
Clears the value associated with a particular key, removing the key from the dictionary.
| what | the key to clear |
Definition at line 377 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
|
inline |
|
inline |
|
inline |
|
inline |
Returns a const reference to the RDValue for a key. Throws KeyErrorException if the key is not found.
|
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 221 of file Dict.h.
References RDKit::from_rdvalue().
|
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 231 of file Dict.h.
References RDKit::rdvalue_tostring().
|
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 215 of file Dict.h.
References getVal().
Referenced by RDKit::Dict::getVal< std::string >(), and getVal().
|
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 267 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 256 of file Dict.h.
References RDKit::from_rdvalue().
|
inline |
|
inline |
|
inline |
Definition at line 102 of file Dict.h.
References RDKit::copy_rdvalue(), Dict(), and reset().
|
inline |
Clears all keys (and values) from the dictionary.
Definition at line 392 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
Referenced by operator=(), operator=(), and ~Dict().
|
inline |
|
inline |
Definition at line 326 of file Dict.h.
References setPODVal().
|
inline |
|
inline |
Definition at line 333 of file Dict.h.
References setPODVal().
|
inline |
Definition at line 340 of file Dict.h.
References setPODVal().
|
inline |
Definition at line 346 of file Dict.h.
References setPODVal().
|
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 291 of file Dict.h.
References RDKit::RDValue::cleanup_rdvalue().
Referenced by setVal().
|
inline |
Definition at line 353 of file Dict.h.
References setPODVal().
|
inline |
|
inline |
Definition at line 74 of file Dict.h.
References RDKit::copy_rdvalue(), Dict(), and RDKit::Dict::Pair::val.