 |
RDKit
Open-source cheminformatics and machine learning.
|
Go to the documentation of this file.
2 #ifndef RDKIT_RDPROPS_H
3 #define RDKIT_RDPROPS_H
6 #include <boost/foreach.hpp>
21 if (
this == &rhs)
return *
this;
37 bool includeComputed =
true)
const {
40 if (!includeComputed &&
45 STR_VECT::const_iterator pos = tmp.begin();
46 while (pos != tmp.end()) {
47 if ((includePrivate || (*pos)[0] !=
'_') &&
48 std::find(computed.begin(), computed.end(), *pos) == computed.end()) {
68 void setProp(
const std::string &key, T val,
bool computed =
false)
const {
72 if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
73 compLst.push_back(key);
99 void getProp(
const std::string &key, T &res)
const {
104 template <
typename T>
112 template <
typename T>
132 STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
133 if (svi != compLst.end()) {
145 BOOST_FOREACH (
const std::string &sv, compLst) {
d_props.
clearVal(sv); }
The Dict class can be used to store objects of arbitrary type keyed by strings.
const Dict & getDict() const
gets the underlying Dictionary
void update(const Dict &other, bool preserveExisting=false)
void getProp(const std::string &key, T &res) const
allows retrieval of a particular property value
STR_VECT getPropList(bool includePrivate=true, bool includeComputed=true) const
returns a list with the names of our properties
T getProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setProp(const std::string &key, T val, bool computed=false) const
sets a property value
bool hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
std::vector< std::string > STR_VECT
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.
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
bool getPropIfPresent(const std::string &key, T &res) const
RDProps(const RDProps &rhs)
void reset()
Clears all keys (and values) from the dictionary.
const RDKIT_RDGENERAL_EXPORT std::string computedPropName
void clearComputedProps() const
clears all of our computed properties
STR_VECT keys() const
Returns the set of keys in the dictionary.
void updateProps(const RDProps &source, bool preserveExisting=false)
update the properties from another
std::vector< std::string >::iterator STR_VECT_I
RDProps & operator=(const RDProps &rhs)
bool hasProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clearProp(const std::string &key) const
clears the value of a property