2 #ifndef RDKIT_RDPROPS_H 3 #define RDKIT_RDPROPS_H 6 #include <boost/foreach.hpp> 36 bool includeComputed =
true)
const {
39 if (!includeComputed &&
44 STR_VECT::const_iterator pos = tmp.begin();
45 while (pos != tmp.end()) {
46 if ((includePrivate || (*pos)[0] !=
'_') &&
47 std::find(computed.begin(), computed.end(), *pos) == computed.end()) {
67 void setProp(
const std::string &key, T val,
bool computed =
false)
const {
71 if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
72 compLst.push_back(key);
98 void getProp(
const std::string &key, T &res)
const {
103 template <
typename T>
105 return dp_props.
getVal<T>(key);
111 template <
typename T>
117 bool hasProp(
const std::string &key)
const {
return dp_props.
hasVal(key); };
131 STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
132 if (svi != compLst.end()) {
144 BOOST_FOREACH (
const std::string &sv, compLst) { dp_props.
clearVal(sv); }
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
void updateProps(const RDProps &source, bool preserveExisting=false)
update the properties from another
RDProps & operator=(const RDProps &rhs)
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 hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
RDKIT_RDGENERAL_EXPORT const std::string computedPropName
T getProp(const std::string &key) const
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.
void clearProp(const std::string &key) const
clears the value of a property
RDProps(const RDProps &rhs)
const Dict & getDict() const
gets the underlying Dictionary
STR_VECT keys() const
Returns the set of keys in the dictionary.
bool hasProp(const std::string &key) const
void getProp(const std::string &key, T &res) const
allows retrieval of a particular property value
void setProp(const std::string &key, T val, bool computed=false) const
sets a property value
STR_VECT getPropList(bool includePrivate=true, bool includeComputed=true) const
returns a list with the names of our properties
void update(const Dict &other, bool preserveExisting=false)
void clearComputedProps() const
clears all of our computed properties
std::vector< std::string >::iterator STR_VECT_I
void reset()
Clears all keys (and values) from the dictionary.
bool getPropIfPresent(const std::string &key, T &res) const
The Dict class can be used to store objects of arbitrary type keyed by strings.
std::vector< std::string > STR_VECT