|
StormByte C++ Library: Config module 1.0.1.9999
StormByte-Config is the configuration module of the StormByte C++ suite.
|
Configuration document (text or versioned binary). More...
#include <config.hxx>

Public Member Functions | |
Construction | |
| Config () | |
| Default constructor. | |
| Config (const Config &config)=default | |
| Copy constructor. | |
| Config (Config &&config) noexcept=default | |
| Move constructor. | |
| Config & | operator= (const Config &config)=default |
| Copy assignment operator. | |
| Config & | operator= (Config &&config) noexcept=default |
| Move assignment operator. | |
| virtual | ~Config ()=default |
| Destructor. | |
Access | |
| Item::Base & | operator[] (const std::string &path) |
| Gets a reference to an item by path. | |
| const Item::Base & | operator[] (const std::string &path) const |
| Gets a const reference to an item by path. | |
| Item::Base & | operator[] (const size_t &index) |
| Gets a reference to an item by index. | |
| const Item::Base & | operator[] (const size_t &index) const |
| Gets a const reference to an item by index. | |
| bool | operator== (const Config &config) const noexcept |
| Equality operator. | |
| bool | operator!= (const Config &config) const noexcept |
| Inequality operator. | |
Items | |
| Item::Base & | Add (const Item::Base &item) |
| Adds an item to the configuration. | |
| Item::Base & | Add (Item::Base &&item) |
| Adds an item to the configuration (move). | |
| void | Clear () noexcept |
| Clears all configuration items. | |
| bool | Exists (const std::string &path) const |
| Checks if an item exists by path. | |
| void | Remove (const std::string &path) |
| Removes an item by path. | |
| void | Remove (const size_t &index) |
| Removes an item by index. | |
| virtual constexpr size_t | Size () const noexcept |
| Gets the number of items in the current level. | |
| virtual size_t | Count () const noexcept |
| Gets the full number of items (including nested). | |
| constexpr std::span< Item::Base::PointerType > | Items () noexcept |
| Gets the items in the current level. | |
| constexpr std::span< const Item::Base::PointerType > | Items () const noexcept |
| Gets the items in the current level (const). | |
Policy | |
| void | OnExistingAction (const OnExistingAction &on_existing) |
| Sets the action to take when an item name/identity collision occurs. The policy is applied to the root container and will be inherited by all nested containers. | |
| constexpr void | OnParseFailure (OnFailureHook hook) |
| Sets a function to execute on parse failure. | |
| constexpr void | AddHookBeforeRead (HookFunction hook) |
| Adds a hook executed before reading starts. Hooks run in order. | |
| constexpr void | AddHookAfterRead (HookFunction hook) |
| Adds a hook executed after a successful read. Hooks run in order. | |
Protected Attributes | |
| Item::Group | m_root |
| Root group. | |
| HookFunctions | m_before_read_hooks |
| Hooks executed before reading. | |
| HookFunctions | m_after_read_hooks |
| Hooks executed after successful reading. | |
| OptionalFailureHook | m_on_parse_failure_hook |
| Hook executed on failure. | |
| StormByte::Config::OnExistingAction | m_on_existing_action |
| Collision policy. | |
Friends | |
| class | Binary::Reader |
| class | Binary::Writer |
Input | |
| STORMBYTE_CONFIG_PUBLIC Config & | operator>> (std::istream &istream, Config &file) |
| Initializes configuration when istream is on the left-hand side. | |
| STORMBYTE_CONFIG_PUBLIC Config & | operator>> (const std::string &str, Config &file) |
| Initializes configuration when string is on the left-hand side. | |
| Config & | operator<< (const Config &source) |
| Import data from another configuration. | |
| void | operator<< (std::istream &istream) |
| Initialize configuration from an input stream (text mode). | |
| void | operator<< (const std::string &str) |
| Initialize configuration from a string (text mode). | |
Output | |
| STORMBYTE_CONFIG_PUBLIC std::ostream & | operator<< (std::ostream &ostream, const Config &file) |
| Output configuration when ostream is on the left-hand side. | |
| STORMBYTE_CONFIG_PUBLIC std::string & | operator<< (std::string &, const Config &) |
| Output configuration when string is on the left-hand side. | |
| Config & | operator>> (Config &dest) const |
| Output current configuration into another configuration. | |
| std::ostream & | operator>> (std::ostream &ostream) const |
| Output configuration serialized to an output stream (text). | |
| std::string & | operator>> (std::string &str) const |
| Output configuration serialized to a string (text). | |
| operator std::string () const | |
| Converts the current configuration to a string (text form). | |
| void | Save (std::ostream &stream, Mode mode=Mode::Text) const |
| Write this document to an output stream. | |
| static ExpectedConfig | Load (std::istream &stream, Mode mode=Mode::Text) |
| Read a document from an input stream. | |
Configuration document (text or versioned binary).
A document holds:
|
default |
Copy constructor.
| config | Configuration to copy. |
|
defaultnoexcept |
Move constructor.
| config | Configuration to move. |
|
inline |
Adds an item to the configuration.
| item | The item to add. |
| ItemNameAlreadyExists | if the item's name already exists. |
|
inline |
Adds an item to the configuration (move).
| item | Item to add. |
| ItemNameAlreadyExists | if item name already exists. |
|
inlineconstexpr |
Adds a hook executed after a successful read. Hooks run in order.
| hook | Hook function. |
|
inlineconstexpr |
Adds a hook executed before reading starts. Hooks run in order.
| hook | Hook function. |
|
inlinevirtualnoexcept |
Gets the full number of items (including nested).
|
inline |
Checks if an item exists by path.
| path | Path to the item. |
|
inlineconstexprnoexcept |
Gets the items in the current level (const).
|
inlineconstexprnoexcept |
Gets the items in the current level.
|
static |
Read a document from an input stream.
| stream | Source (file, stringstream, etc.). |
| mode | Text (default): config syntax; Binary: versioned wire format. |
|
inline |
Sets the action to take when an item name/identity collision occurs. The policy is applied to the root container and will be inherited by all nested containers.
| on_existing | The policy to use. |
|
inlineconstexpr |
Sets a function to execute on parse failure.
| hook | Function to execute. |
| StormByte::Config::Config::operator std::string | ( | ) | const |
Converts the current configuration to a string (text form).
|
inlinenoexcept |
Inequality operator.
| config | Configuration to compare. |
Import data from another configuration.
| source | Source configuration to import. |
| void StormByte::Config::Config::operator<< | ( | const std::string & | str | ) |
Initialize configuration from a string (text mode).
| str | Input string. |
| void StormByte::Config::Config::operator<< | ( | std::istream & | istream | ) |
Initialize configuration from an input stream (text mode).
| istream | Input stream. |
Copy assignment operator.
| config | Configuration to assign. |
|
inlinenoexcept |
Equality operator.
| config | Configuration to compare. |
Output current configuration into another configuration.
| dest | Destination configuration. |
| std::ostream & StormByte::Config::Config::operator>> | ( | std::ostream & | ostream | ) | const |
Output configuration serialized to an output stream (text).
| ostream | Output stream. |
| std::string & StormByte::Config::Config::operator>> | ( | std::string & | str | ) | const |
Output configuration serialized to a string (text).
| str | Output string. |
|
inline |
Gets a reference to an item by index.
| index | Index of the item. |
| OutOfBounds | if index is out of bounds. |
|
inline |
Gets a const reference to an item by index.
| index | Index of the item. |
| OutOfBounds | if index is out of bounds. |
|
inline |
|
inline |
Gets a const reference to an item by path.
| path | Path to the item. |
|
inline |
Removes an item by index.
| index | Index of the item. |
| OutOfBounds | if index is out of bounds. |
|
inline |
| void StormByte::Config::Config::Save | ( | std::ostream & | stream, |
| Mode | mode = Mode::Text |
||
| ) | const |
Write this document to an output stream.
| stream | Destination (file, stringstream, etc.). |
| mode | Text (default): config syntax; Binary: versioned wire format. |
|
inlineconstexprvirtualnoexcept |
Gets the number of items in the current level.
|
friend |
Output configuration when ostream is on the left-hand side.
| ostream | Output stream. |
| file | Config to get data from. |
|
friend |
Output configuration when string is on the left-hand side.
| str | Output string. |
| file | Config to get data from. |