The class used to store and retrieve data for assemblying chemical systems. More...
#include <Data.hpp>
Classes | |
| struct | Decode |
| Used to allow conversion of Data objects to objects with custom types. More... | |
| struct | Encode |
| Used to allow conversion of objects with custom types to Data objects. More... | |
| struct | Opt |
| Used as the return type of method Data::optional. More... | |
Public Member Functions | |
| Data () | |
| Construct a default Data instance with null value. | |
| auto | asBoolean () const -> bool |
| Return this Data object as a boolean value. | |
| auto | asString () const -> String const & |
| Return this Data object as a string. | |
| auto | asInteger () const -> int |
| Return this Data object as an integer number. | |
| auto | asFloat () const -> double |
| Return this Data object as a float number. | |
| auto | asDict () const -> Dict< String, Data > const & |
| Return this Data object as a dictionary object. | |
| auto | asList () const -> Vec< Data > const & |
| Return this Data object as a list object. | |
| auto | asNull () const -> Nullptr |
| Return this Data object as a nullptr value. | |
| auto | isBoolean () const -> bool |
| Return true if this Data object is a boolean value. | |
| auto | isString () const -> bool |
| Return true if this Data object is a string. | |
| auto | isInteger () const -> bool |
| Return true if this Data object is an integer number. | |
| auto | isFloat () const -> bool |
| Return true if this Data object is a float number. | |
| auto | isDict () const -> bool |
| Return true if this Data object is a dictionary object. | |
| auto | isList () const -> bool |
| Return true if this Data object is a list object. | |
| auto | isNull () const -> bool |
| Return true if this Data object is a null value. | |
| auto | operator[] (String const &key) const -> Data const & |
| Return the child Data object with given key, presuming this Data object is a dictionary. More... | |
| auto | operator[] (Index const &index) const -> Data const & |
| Return the child Data object with given index, presuming this Data object is a list. More... | |
| auto | operator[] (String const &key) -> Data & |
| Return the child Data object with given key if, presuming this Data object is a dictionary. More... | |
| auto | operator[] (Index const &index) -> Data & |
| Return the child Data object with given index, presuming this Data object is a list. More... | |
| auto | at (String const &key) const -> Data const & |
| Return the child Data object with given key, presuming this Data object is a dictionary. More... | |
| auto | at (Index const &index) const -> Data const & |
| Return the child Data object with given index, presuming this Data object is a list. More... | |
| auto | optional (String const &key) const -> Opt |
| Return an optional child Data object with given key, presuming this Data object is a dictionary. More... | |
| auto | required (String const &key) const -> Data const & |
| Return a required to exist child Data object with given key, presuming this Data object is a dictionary. More... | |
| auto | with (String const &attribute, String const &value) const -> Data const & |
Return the child Data object whose attribute has a given value, presuming this Data object is a list. | |
| auto | add (Data data) -> void |
| Add a Data object to this Data object, which becomes a list if not already. | |
| auto | add (String const &key, Data data) -> void |
| Add a Data object with given key to this Data object, which becomes a dictionary if not already. | |
| auto | update (Data const &data) -> void |
| Update this Data object with data given in another, with key-value pairs being either added or overwritten. | |
| auto | reset () -> void |
| Reset this Data object to a null state, deleting its current stored data. | |
| auto | exists (String const &key) const -> bool |
| Return true if a child Data object exists with given key, presuming this Data object is a dictionary. | |
| auto | dump () const -> String |
| Return a YAML formatted string representing the state of this Data object. | |
| auto | dumpYaml () const -> String |
| Return a YAML formatted string representing the state of this Data object. | |
| auto | dumpJson () const -> String |
| Return a JSON formatted string representing the state of this Data object. | |
| auto | save (String const &filepath) const -> void |
| Save the state of this Data object into a YAML formatted file. | |
| auto | saveYaml (String const &filepath) const -> void |
| Save the state of this Data object into a YAML formatted file. | |
| auto | saveJson (String const &filepath) const -> void |
| Save the state of this Data object into a JSON formatted file. | |
| auto | repr () const -> String |
| Return a YAML formatted string representing the state of this Data object. | |
| template<typename T > | |
| auto | operator= (T const &obj) -> Data & |
Assign an object of type T to this Data object. | |
| template<typename T > | |
| operator T () const | |
Convert this Data object to one of type T. | |
| template<typename T > | |
| Data (T const &obj) | |
Construct a Data object from one of type T. | |
| template<typename T > | |
| auto | assign (T const &obj) -> void |
Assign an object of type T to this Data object. | |
| auto | assign (char obj) -> void |
| Assign a char to this Data object. | |
| auto | assign (Chars obj) -> void |
| Assign a raw string to this Data object. | |
| template<typename T > | |
| auto | as () const -> T |
Convert this Data object into an object of type T. | |
| template<typename T > | |
| auto | to (T &obj) const -> void |
Decode this Data object into an object of type T. | |
Static Public Member Functions | |
| static auto | parse (Chars text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parse (String const &text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parse (std::istream &text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parseYaml (Chars text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parseYaml (String const &text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parseYaml (std::istream &text) -> Data |
| Return a Data object by parsing an YAML formatted string. | |
| static auto | parseJson (Chars text) -> Data |
| Return a Data object by parsing a JSON formatted string. | |
| static auto | parseJson (String const &text) -> Data |
| Return a Data object by parsing a JSON formatted string. | |
| static auto | parseJson (std::istream &text) -> Data |
| Return a Data object by parsing a JSON formatted string. | |
| static auto | load (String const &path) -> Data |
| Return a Data object by parsing either an YAML or JSON formatted file at a given path. More... | |
| static auto | loadYaml (String const &path) -> Data |
| Return a Data object by parsing an YAML formatted file at a given path. | |
| static auto | loadJson (String const &path) -> Data |
| Return a Data object by parsing a JSON formatted file at a given path. | |
Detailed Description
The class used to store and retrieve data for assemblying chemical systems.
Member Function Documentation
◆ load()
Return a Data object by parsing either an YAML or JSON formatted file at a given path.
Ensure path terminates with extensions .yml, .yaml, or .json, which are used to identify the file format.
◆ operator[]() [1/4]
◆ operator[]() [2/4]
◆ operator[]() [3/4]
Return the child Data object with given key if, presuming this Data object is a dictionary.
If this Data object is null, this method converts it into a dictionary with one entry with given key whose associated value is null. If this Data object is a dictionary without an entry with given key, a new entry with given key is created whose associated value is null. Otherwise, a runtime error is thrown.
◆ operator[]() [4/4]
Return the child Data object with given index, presuming this Data object is a list.
If this Data object is null and index is 0, this method converts it into a list with one entry whose value is null. Otherwise, this method throws an error if this Data object is not a list or it is a list and given index is out of bounds.
◆ at() [1/2]
◆ at() [2/2]
◆ optional()
◆ required()
The documentation for this class was generated from the following file:
- Reaktoro/Core/Data.hpp