|
votca 2025.1-dev
|
class to manage program options with xml serialization functionality More...
#include <property.h>

Public Types | |
| using | iterator = std::vector<Property>::iterator |
| iterator to iterate over properties | |
| using | const_iterator = std::vector<Property>::const_iterator |
| typedef std::map< std::string, std::string >::iterator | AttributeIterator |
| typedef std::map< std::string, std::string >::const_iterator | const_AttributeIterator |
Public Member Functions | |
| Property ()=default | |
| Property (const std::string &name, const std::string &value, const std::string &path) | |
| Property & | add (const std::string &key, const std::string &value) |
| add a new property to structure | |
| Property & | add (const Property &other) |
| add a copy of an existing property to a property | |
| Property & | addTree (const std::string &key, const std::string &value) |
| add a new property tree to structure | |
| Property & | addTree (const std::vector< std::string > &key, const std::string &value) |
| Property & | set (const std::string &key, const std::string &value) |
| set value of existing property | |
| Property & | get (const std::string &key) |
| get existing property | |
| const Property & | get (const std::string &key) const |
| Property & | getOradd (const std::string &key) |
| adds new or gets existing property | |
| bool | exists (const std::string &key) const |
| check whether property exists | |
| template<typename T> | |
| T | ifExistsReturnElseReturnDefault (const std::string &key, T defaultvalue) const |
| std::vector< Property * > | Select (const std::string &filter) |
| select property based on a filter | |
| std::vector< const Property * > | Select (const std::string &filter) const |
| std::string & | value () |
| reference to value of property | |
| const std::string & | value () const |
| std::string & | name () |
| name of property | |
| const std::string & | name () const |
| std::string & | path () |
| full path of property (including parents) | |
| const std::string & | path () const |
| template<typename T> | |
| T | as () const |
| return value as type | |
| bool | HasChildren () const |
| does the property have children? | |
| iterator | begin () |
| iterator to first child property | |
| const_iterator | begin () const |
| iterator | end () |
| end iterator for child properties | |
| const_iterator | end () const |
| Index | size () const |
| number of child properties | |
| template<class cond> | |
| void | deleteChildren (cond condition) |
| deletes all children that fulfill a condition | |
| template<typename T> | |
| T | getAttribute (const std::string &attribute) const |
| return attribute as type | |
| template<typename T> | |
| void | setAttribute (const std::string &attribute, const T &value) |
| set an attribute | |
| void | deleteAttribute (const std::string &attribute) |
| deletes an attribute | |
| bool | hasAttributes () const |
| return true if a node has attributes | |
| bool | hasAttribute (const std::string &attribute) const |
| return true if an attribute exists | |
| AttributeIterator | findAttribute (const std::string &attribute) |
| returns an iterator to an attribute | |
| const_AttributeIterator | findAttribute (const std::string &attribute) const |
| AttributeIterator | firstAttribute () |
| returns an iterator to the first attribute | |
| const_AttributeIterator | firstAttribute () const |
| AttributeIterator | lastAttribute () |
| returns an iterator to the last attribute | |
| const_AttributeIterator | lastAttribute () const |
| template<typename T> | |
| T | getAttribute (AttributeIterator it) |
| return attribute as type | |
| template<typename T> | |
| T | getAttribute (const_AttributeIterator it) const |
| void | LoadFromXML (std::string filename) |
| template<typename T> | |
| T | getAttribute (std::map< std::string, std::string >::const_iterator it) const |
| template<> | |
| std::string | ifExistsReturnElseReturnDefault (const std::string &key, std::string defaultvalue) const |
Static Public Member Functions | |
| static Index | getIOindex () |
Private Attributes | |
| std::map< std::string, std::vector< Index > > | map_ |
| std::map< std::string, std::string > | attributes_ |
| std::vector< Property > | properties_ |
| std::string | name_ = "" |
| std::string | value_ = "" |
| std::string | path_ = "" |
Static Private Attributes | |
| static const Index | IOindex = std::ios_base::xalloc() |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const Property &p) |
| outputs the property to the ostream | |
class to manage program options with xml serialization functionality
This class stores tags and content in a hierarchical (tree) structure similar to the one used in the XML format. The structure can be either filled manually or read in from an XML file using load_property_from_xml. The supported XML constructs are TAGS, ATTRIBUTES, and CONTENT. The property object can be output to an ostream using format modifiers: cout << XML << property; Supported formats are XML, TXT, HLP
Definition at line 55 of file property.h.
| typedef std::map<std::string,std::string>::iterator votca::tools::Property::AttributeIterator |
for iterator-based access of Attributes
Definition at line 232 of file property.h.
| typedef std::map<std::string,std::string>::const_iterator votca::tools::Property::const_AttributeIterator |
Definition at line 234 of file property.h.
| using votca::tools::Property::const_iterator = std::vector<Property>::const_iterator |
Definition at line 186 of file property.h.
| using votca::tools::Property::iterator = std::vector<Property>::iterator |
iterator to iterate over properties
Definition at line 185 of file property.h.
|
default |
|
inline |
Definition at line 62 of file property.h.
add a copy of an existing property to a property
| other | other property |
Definition at line 142 of file property.cc.
| Property & votca::tools::Property::add | ( | const std::string & | key, |
| const std::string & | value ) |
add a new property to structure
| key | identifier |
| value | value |
Definition at line 108 of file property.cc.
| Property & votca::tools::Property::addTree | ( | const std::string & | key, |
| const std::string & | value ) |
add a new property tree to structure
| key | identifier |
| value | value |
Definition at line 89 of file property.cc.
| Property & votca::tools::Property::addTree | ( | const std::vector< std::string > & | key, |
| const std::string & | value ) |
Definition at line 93 of file property.cc.
|
inline |
return value as type
returns the value after type conversion, e.g. p.as<Index>() returns an integer
Definition at line 283 of file property.h.
|
inline |
iterator to first child property
Definition at line 188 of file property.h.
|
inline |
Definition at line 189 of file property.h.
| void votca::tools::Property::deleteAttribute | ( | const std::string & | attribute | ) |
deletes an attribute
Definition at line 206 of file property.cc.
| void votca::tools::Property::deleteChildren | ( | cond | condition | ) |
deletes all children that fulfill a condition
| condition | unary function which takes a const reference to a property and returns a bool |
Definition at line 348 of file property.h.
|
inline |
end iterator for child properties
Definition at line 191 of file property.h.
|
inline |
Definition at line 192 of file property.h.
| bool votca::tools::Property::exists | ( | const std::string & | key | ) | const |
check whether property exists
| key | identifier |
Definition at line 122 of file property.cc.
|
inline |
returns an iterator to an attribute
Definition at line 238 of file property.h.
|
inline |
Definition at line 241 of file property.h.
|
inline |
returns an iterator to the first attribute
Definition at line 247 of file property.h.
|
inline |
Definition at line 248 of file property.h.
| Property & votca::tools::Property::get | ( | const std::string & | key | ) |
get existing property
| key | identifier |
This function tries to find a property specified by key separated by "." to step down hierarchy. If the property is not found a runtime_exception is thrown. If more than property with this name exists, return the last added one.
Definition at line 79 of file property.cc.
| const Property & votca::tools::Property::get | ( | const std::string & | key | ) | const |
Definition at line 48 of file property.cc.
| T votca::tools::Property::getAttribute | ( | AttributeIterator | it | ) |
return attribute as type
returns an attribute after type conversion, e.g. p.getAttribute<Index>() returns an integer
|
inline |
return attribute as type
returns an attribute after type conversion, e.g. p.getAttribute<Index>() returns an integer
Definition at line 308 of file property.h.
| T votca::tools::Property::getAttribute | ( | const_AttributeIterator | it | ) | const |
|
inline |
Definition at line 295 of file property.h.
|
inlinestatic |
Definition at line 268 of file property.h.
| Property & votca::tools::Property::getOradd | ( | const std::string & | key | ) |
adds new or gets existing property
| key | identifier |
This function tries to find a property specified by key separated by "." to step down hierarchy. If the property is not found a property with that name is added and returned. If more than property with this name exists, return the last added one.
Definition at line 156 of file property.cc.
| bool votca::tools::Property::hasAttribute | ( | const std::string & | attribute | ) | const |
return true if an attribute exists
Definition at line 118 of file property.cc.
|
inline |
return true if a node has attributes
Definition at line 226 of file property.h.
|
inline |
|
inline |
Definition at line 333 of file property.h.
|
inline |
Definition at line 321 of file property.h.
|
inline |
returns an iterator to the last attribute
Definition at line 252 of file property.h.
|
inline |
Definition at line 253 of file property.h.
| void votca::tools::Property::LoadFromXML | ( | std::string | filename | ) |
Definition at line 238 of file property.cc.
|
inline |
|
inline |
Definition at line 160 of file property.h.
|
inline |
full path of property (including parents)
e.g. cg.inverse.value
Definition at line 167 of file property.h.
|
inline |
Definition at line 168 of file property.h.
| std::vector< Property * > votca::tools::Property::Select | ( | const std::string & | filter | ) |
select property based on a filter
| filter |
returns a list of properties that match the key criteria including wildcard "*". Example: "base.item*.value"
Definition at line 185 of file property.cc.
| std::vector< const Property * > votca::tools::Property::Select | ( | const std::string & | filter | ) | const |
Definition at line 164 of file property.cc.
| Property & votca::tools::Property::set | ( | const std::string & | key, |
| const std::string & | value ) |
set value of existing property
| key | identifier |
| value | value |
Definition at line 83 of file property.cc.
|
inline |
set an attribute
Definition at line 314 of file property.h.
|
inline |
number of child properties
Definition at line 194 of file property.h.
|
inline |
reference to value of property
Definition at line 153 of file property.h.
|
inline |
Definition at line 154 of file property.h.
|
friend |
outputs the property to the ostream
Definition at line 440 of file property.cc.
|
private |
Definition at line 272 of file property.h.
|
staticprivate |
Definition at line 279 of file property.h.
|
private |
Definition at line 271 of file property.h.
|
private |
Definition at line 275 of file property.h.
|
private |
Definition at line 277 of file property.h.
|
private |
Definition at line 273 of file property.h.
|
private |
Definition at line 276 of file property.h.