RDKit::Dict Class Reference

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)
bool & | getNonPODStatus ()
| Access to the underlying non-POD containment flag This is meant to be used only in bulk updates of _data. More...
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
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
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. More...
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
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
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)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
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...

## Detailed Description

The `Dict` class can be used to store objects of arbitrary type keyed by `strings`.

The actual storage is done using `RDValue` objects.

Definition at line 36 of file Dict.h.

## Member Typedef Documentation

## DataType

typedef std::vector<Pair> RDKit::Dict::DataType

Definition at line 47 of file Dict.h.

## Constructor & Destructor Documentation

## Dict() [1/2]

RDKit::Dict::Dict | ( |  | ) |

inline

Definition at line 49 of file Dict.h.

## Dict() [2/2]

RDKit::Dict::Dict | ( | const Dict & | other | ) |

inline

Definition at line 51 of file Dict.h.

References RDKit::copy_rdvalue().

## ~Dict()

RDKit::Dict::~Dict | ( |  | ) |

inline

Definition at line 63 of file Dict.h.

## Member Function Documentation

## clearVal()

void RDKit::Dict::clearVal | ( | const std::string & | what | ) |

inline

Clears the value associated with a particular key, removing the key from the dictionary.

Parameters

  what | the key to clear

Notes:

- If the dictionary does not contain the key `what`, a KeyErrorException will be thrown.

Definition at line 275 of file Dict.h.

References RDKit::RDValue::cleanup_rdvalue().

Referenced by RDKit::RDProps::clearComputedProps(), RDKit::RDProps::clearProp(), and RDKit::FilterCatalogEntry::clearProp().

## getData() [1/2]

DataType& RDKit::Dict::getData | ( |  | ) |

inline

Definition at line 120 of file Dict.h.

## getData() [2/2]

const DataType& RDKit::Dict::getData | ( |  | ) | const

inline

Access to the underlying data.

Definition at line 119 of file Dict.h.

## getNonPODStatus()

bool& RDKit::Dict::getNonPODStatus | ( |  | ) |

inline

Access to the underlying non-POD containment flag This is meant to be used only in bulk updates of _data.

Definition at line 115 of file Dict.h.

## getVal() [1/3]

template<typename T >

T RDKit::Dict::getVal | ( | const std::string & | what | ) | const

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 166 of file Dict.h.

## getVal() [2/3]

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.

## getVal() [3/3]

template<typename T >

void RDKit::Dict::getVal | ( | const std::string & | what,
|  | T & | res
| ) |  | const

inline

Gets the value associated with a particular key.

Parameters

  what | the key to lookup
  res | a reference used to return the result

Notes:

- If `res` is a `std::string`, every effort will be made to convert the specified element to a string using the `boost::lexical_cast` machinery.
- If the dictionary does not contain the key `what`, a KeyErrorException will be thrown.

Definition at line 161 of file Dict.h.

Referenced by RDKit::RDProps::getProp(), and RDKit::FilterCatalogEntry::getProp().

## getValIfPresent() [1/2]

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.

## getValIfPresent() [2/2]

template<typename T >

bool RDKit::Dict::getValIfPresent | ( | const std::string & | what,
|  | T & | res
| ) |  | const

inline

Potentially gets the value associated with a particular key returns true on success/false on failure.

Parameters

  what | the key to lookup
  res | a reference used to return the result

Notes:

- If `res` is a `std::string`, every effort will be made to convert the specified element to a string using the `boost::lexical_cast` machinery.
- If the dictionary does not contain the key `what`, a KeyErrorException will be thrown.

Definition at line 194 of file Dict.h.

Referenced by RDKit::RDProps::getPropIfPresent(), and RDKit::FilterCatalogEntry::getPropIfPresent().

## hasVal()

bool RDKit::Dict::hasVal | ( | const std::string & | what | ) | const

inline

Returns whether or not the dictionary contains a particular key.

Definition at line 126 of file Dict.h.

Referenced by RDKit::RDProps::hasProp(), and RDKit::FilterCatalogEntry::hasProp().

## keys()

STR_VECT RDKit::Dict::keys | ( |  | ) | const

inline

Returns the set of keys in the dictionary.

Returns
  a `STR_VECT`

Definition at line 138 of file Dict.h.

Referenced by RDKit::RDProps::getPropList(), and RDKit::FilterCatalogEntry::getPropList().

## operator=()

Dict& RDKit::Dict::operator= | ( | const Dict & | other | ) |

inline

Definition at line 94 of file Dict.h.

References RDKit::copy_rdvalue().

## reset()

void RDKit::Dict::reset | ( |  | ) |

inline

Clears all keys (and values) from the dictionary.

Definition at line 291 of file Dict.h.

References RDKit::RDValue::cleanup_rdvalue().

Referenced by RDKit::RDProps::clear().

## setPODVal()

template<typename T >

void RDKit::Dict::setPODVal | ( | const std::string & | what,
|  | T | val
| ) |  |

inline

Definition at line 234 of file Dict.h.

References RDKit::RDValue::cleanup_rdvalue().

## setVal() [1/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | bool | val
| ) |  |

inline

Definition at line 246 of file Dict.h.

## setVal() [2/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | const char * | val
| ) |  |

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 259 of file Dict.h.

## setVal() [3/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | double | val
| ) |  |

inline

Definition at line 248 of file Dict.h.

## setVal() [4/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | float | val
| ) |  |

inline

Definition at line 250 of file Dict.h.

## setVal() [5/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | int | val
| ) |  |

inline

Definition at line 252 of file Dict.h.

## setVal() [6/7]

template<typename T >

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | T & | val
| ) |  |

inline

Sets the value associated with a key.

Parameters

  what | the key to set
  val | the value to store

Notes:

- If `val` is a `const char *`, it will be converted to a `std::string` for storage.
- If the dictionary already contains the key `what`, the value will be replaced.

Definition at line 221 of file Dict.h.

References RDKit::RDValue::cleanup_rdvalue().

Referenced by RDKit::RDProps::clearComputedProps(), RDKit::RDProps::clearProp(), RDKit::RDProps::setProp(), and RDKit::FilterCatalogEntry::setProp().

## setVal() [7/7]

void RDKit::Dict::setVal | ( | const std::string & | what,
|  | unsigned int | val
| ) |  |

inline

Definition at line 254 of file Dict.h.

## update()

void RDKit::Dict::update | ( | const Dict & | other,
|  | bool | preserveExisting = `false`
| ) |  |

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().

The documentation for this class was generated from the following file:

- Dict.h