RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
RDKit::RDProps Class Reference

#include <RDProps.h>

Inheritance diagram for RDKit::RDProps:
RDKit::Atom RDKit::Bond RDKit::ChemicalReaction RDKit::Conformer RDKit::MolBundle RDKit::ROMol RDKit::SubstanceGroup RDKit::QueryAtom RDKit::QueryBond RDKit::FixedMolSizeMolBundle RDKit::RWMol

Public Member Functions

 RDProps ()
 
 RDProps (const RDProps &rhs)
 
RDPropsoperator= (const RDProps &rhs)
 
 RDProps (RDProps &&o) noexcept=default
 
RDPropsoperator= (RDProps &&rhs) noexcept=default
 
void clear ()
 
const DictgetDict () const
 gets the underlying Dictionary
 
DictgetDict ()
 
STR_VECT getPropList (bool includePrivate=true, bool includeComputed=true) const
 returns a list with the names of our properties
 
template<typename T >
void setProp (const std::string &key, T val, bool computed=false) const
 sets a property value
 
template<typename T >
void getProp (const std::string &key, T &res) const
 allows retrieval of a particular property value
 
template<typename T >
getProp (const std::string &key) 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 getPropIfPresent (const std::string &key, T &res) const
 
bool hasProp (const std::string &key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void clearProp (const std::string &key) const
 clears the value of a property
 
void clearComputedProps () const
 clears all of our computed properties
 
void updateProps (const RDProps &source, bool preserveExisting=false)
 update the properties from another
 

Protected Attributes

Dict d_props
 

Detailed Description

Definition at line 14 of file RDProps.h.

Constructor & Destructor Documentation

◆ RDProps() [1/3]

RDKit::RDProps::RDProps ( )
inline

Definition at line 22 of file RDProps.h.

◆ RDProps() [2/3]

RDKit::RDProps::RDProps ( const RDProps & rhs)
inline

Definition at line 23 of file RDProps.h.

◆ RDProps() [3/3]

RDKit::RDProps::RDProps ( RDProps && o)
defaultnoexcept

Member Function Documentation

◆ clear()

void RDKit::RDProps::clear ( )
inline

Definition at line 34 of file RDProps.h.

References d_props, and RDKit::Dict::reset().

Referenced by RDKit::ROMol::ROMol().

◆ clearComputedProps()

void RDKit::RDProps::clearComputedProps ( ) const
inline

clears all of our computed properties

Definition at line 149 of file RDProps.h.

References RDKit::Dict::clearVal(), RDKit::detail::computedPropName, d_props, getPropIfPresent(), RDKit::rdvalue_is(), and RDKit::Dict::setVal().

◆ clearProp()

void RDKit::RDProps::clearProp ( const std::string & key) const
inline

clears the value of a property

Notes:

  • if no property with name key exists, this will be a no-op.
  • if the property is marked as computed, it will also be removed from our list of computedProperties 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 136 of file RDProps.h.

References RDKit::Dict::clearVal(), RDKit::detail::computedPropName, d_props, getPropIfPresent(), RDKit::rdvalue_is(), and RDKit::Dict::setVal().

◆ getDict() [1/2]

Dict & RDKit::RDProps::getDict ( )
inline

Definition at line 37 of file RDProps.h.

References d_props.

◆ getDict() [2/2]

const Dict & RDKit::RDProps::getDict ( ) const
inline

gets the underlying Dictionary

Definition at line 36 of file RDProps.h.

References d_props.

◆ getProp() [1/2]

template<typename T >
T RDKit::RDProps::getProp ( const std::string & key) 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 113 of file RDProps.h.

References d_props, and RDKit::Dict::getVal().

◆ getProp() [2/2]

template<typename T >
void RDKit::RDProps::getProp ( const std::string & key,
T & res ) const
inline

allows retrieval of a particular property value

Parameters
keythe name under which the property should be stored. If a property is already stored under this name, it will be replaced.
resa reference to the storage location for the value.

Notes:

  • if no property with name key exists, a KeyErrorException will be thrown.
  • the boost::lexical_cast machinery is used to attempt type conversions. If this fails, a boost::bad_lexical_cast exception will be thrown. 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 107 of file RDProps.h.

References d_props, RDKit::Dict::getVal(), and RDKit::rdvalue_is().

Referenced by RDKit::FileParserUtils::applyMolListPropToAtoms().

◆ getPropIfPresent()

template<typename T >
bool RDKit::RDProps::getPropIfPresent ( const std::string & key,
T & res ) const
inline

returns whether or not we have a property with name key and assigns the value if we do 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 121 of file RDProps.h.

References d_props, RDKit::Dict::getValIfPresent(), and RDKit::rdvalue_is().

Referenced by clearComputedProps(), clearProp(), RDKit::MolEnumerator::utils::getMolLinkNodes(), getPropList(), and setProp().

◆ getPropList()

STR_VECT RDKit::RDProps::getPropList ( bool includePrivate = true,
bool includeComputed = true ) const
inline

◆ hasProp()

bool RDKit::RDProps::hasProp ( const std::string & key) 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 126 of file RDProps.h.

References d_props, and RDKit::Dict::hasVal().

Referenced by RDKit::MolDraw2D_detail::addAtomIndices(), RDKit::MolDraw2D_detail::addBondIndices(), and RDKit::queryAtomMissingChiralTag().

◆ operator=() [1/2]

RDProps & RDKit::RDProps::operator= ( const RDProps & rhs)
inline

Definition at line 24 of file RDProps.h.

References d_props, and RDKit::rdvalue_is().

◆ operator=() [2/2]

RDProps & RDKit::RDProps::operator= ( RDProps && rhs)
defaultnoexcept

◆ setProp()

template<typename T >
void RDKit::RDProps::setProp ( const std::string & key,
T val,
bool computed = false ) const
inline

sets a property value

Parameters
keythe name under which the property should be stored. If a property is already stored under this name, it will be replaced.
valthe value to be stored
computed(optional) allows the property to be flagged computed. 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 77 of file RDProps.h.

References RDKit::detail::computedPropName, d_props, getPropIfPresent(), RDKit::rdvalue_is(), and RDKit::Dict::setVal().

Referenced by RDKit::MolDraw2D_detail::addAtomIndices(), RDKit::MolDraw2D_detail::addBondIndices(), RDKit::FileParserUtils::applyMolListPropToAtoms(), RDKit::FileParserUtils::createAtomBoolPropertyList(), RDKit::FileParserUtils::createAtomDoublePropertyList(), RDKit::FileParserUtils::createAtomIntPropertyList(), and RDKit::FileParserUtils::createAtomStringPropertyList().

◆ updateProps()

void RDKit::RDProps::updateProps ( const RDProps & source,
bool preserveExisting = false )
inline

update the properties from another

Definition at line 166 of file RDProps.h.

References d_props, RDKit::rdvalue_is(), and RDKit::Dict::update().

Member Data Documentation

◆ d_props

Dict RDKit::RDProps::d_props
mutableprotected

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