StormByte C++ Library: Config module 0.0.9999
StormByte-Config is a StormByte library module for parsing configuration files
|
Abstract class representing a configuration file. More...
#include <config.hxx>
Public Member Functions | |
Config () | |
Config (const Config &config)=default | |
Config (Config &&config) noexcept=default | |
Config & | operator= (const Config &config)=default |
Config & | operator= (Config &&config) noexcept=default |
virtual | ~Config ()=default |
Item::Base & | operator[] (const std::string &path) |
const Item::Base & | operator[] (const std::string &path) const |
Item::Base & | operator[] (const size_t &index) |
const Item::Base & | operator[] (const size_t &index) const |
bool | operator== (const Config &config) const noexcept |
bool | operator!= (const Config &config) const noexcept |
Config & | operator<< (const Config &source) |
void | operator<< (std::istream &istream) |
void | operator<< (const std::string &str) |
Config & | operator>> (Config &dest) const |
std::ostream & | operator>> (std::ostream &ostream) const |
std::string & | operator>> (std::string &str) const |
operator std::string () const | |
Item::Base & | Add (const Item::Base &item) |
Adds an item to the configuration. | |
Item::Base & | Add (Item::Base &&item) |
void | Clear () noexcept |
bool | Exists (const std::string &path) const |
void | Remove (const std::string &path) |
void | Remove (const size_t &path) |
constexpr void | OnExistingAction (const OnExistingAction &on_existing) |
constexpr void | OnParseFailure (OnFailureHook hook) |
constexpr void | AddHookBeforeRead (HookFunction hook) |
constexpr void | AddHookAfterRead (HookFunction hook) |
virtual constexpr size_t | Size () const noexcept |
virtual size_t | Count () const noexcept |
constexpr std::span< Item::Base::PointerType > | Items () noexcept |
constexpr std::span< const Item::Base::PointerType > | Items () const noexcept |
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 |
Action to take when item name already exists. | |
Friends | |
class | StormByte::Serializable< Config > |
STORMBYTE_CONFIG_PUBLIC Config & | operator>> (std::istream &istream, Config &file) |
STORMBYTE_CONFIG_PUBLIC Config & | operator>> (const std::string &str, Config &file) |
STORMBYTE_CONFIG_PUBLIC std::ostream & | operator<< (std::ostream &ostream, const Config &file) |
STORMBYTE_CONFIG_PUBLIC std::string & | operator<< (std::string &, const Config &) |
Abstract class representing a configuration file.
A configuration file can contain various elements, including:
StormByte::Config::Config::Config | ( | ) |
Constructor
|
default |
Copy constructor
config | configuration to copy |
|
defaultnoexcept |
Move constructor
config | configuration to move |
|
virtualdefault |
Destructor
|
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 container
item | item to add |
ItemNameAlreadyExists | if item name already exists |
|
inlineconstexpr |
Adds a hook which will take Config as parameter and will be executed on successful read Hooks will be executed in order
|
inlineconstexpr |
Adds a hook which will take Config as parameter and will be executed before read start Hooks will be executed in order
|
inlinenoexcept |
Clears all configuration items
|
inlinevirtualnoexcept |
Gets the full number of items
|
inline |
Checks if item exists by path
path | path to item |
|
inlineconstexprnoexcept |
Gets the items in the current level
|
inlineconstexprnoexcept |
Gets the items in the current level
|
inlineconstexpr |
Sets a function to execute on name collission when inserting
on_existing | function to select element on collission |
|
inlineconstexpr |
Sets a function to execute on failure
hook | function to execute |
StormByte::Config::Config::operator std::string | ( | ) | const |
Converts current configuration to string
|
inlinenoexcept |
Inequality operator
config | configuration to compare |
Take data from another configuration
source | source configuration to import |
void StormByte::Config::Config::operator<< | ( | const std::string & | str | ) |
Initialize configuration with a string
str | input string |
void StormByte::Config::Config::operator<< | ( | std::istream & | istream | ) |
Initialize configuration with an input stream
istream | input stream |
Move assignment operator
config | configuration to move |
Assignment operator
config | configuration to assign |
|
inlinenoexcept |
Equality operator
config | configuration to compare |
Outut current configuration to another configuration
dest | configuration destination |
std::ostream & StormByte::Config::Config::operator>> | ( | std::ostream & | ostream | ) | const |
Output configuration serialized to output stream
ostream | output stream |
std::string & StormByte::Config::Config::operator>> | ( | std::string & | str | ) | const |
Output configuration serialized to string
str | output string |
|
inline |
Gets a reference to item by index
index | index of item |
OutOfBounds | if index is out of bounds |
|
inline |
Gets a const reference to item by index
index | index of item |
OutOfBounds | if index is out of bounds |
|
inline |
Gets a reference to item by path
path | path to item |
|
inline |
Gets a const reference to item by path
path | path to item |
|
inline |
Removes an item by position
path | item path |
OutOfBounds | if index is out of bounds |
|
inline |
|
inlineconstexprvirtualnoexcept |
Gets the number of items in the current level
|
friend |
Output configuration serialized to output stream (when output stream is in the left part)
ostream | output stream |
file | Config to get data from |
|
friend |
Output configuration serialized to string (when string is in the left part)
str | output string |
file | Config to get data from |
Initializes configuration with string (when string is in the left part)
str | input string |
file | Config to put data to |
Initializes configuration with istream (when istream is in the left part)
istream | input stream |
file | Config to put data to |
|
protected |
Hooks executed before reading.
Ordered hook list which will be executed sequentially in their corresponding event
|
protected |
Action to take when item name already exists.
Function to override the default action when duplicate name is found when inserting Takes 3 parameters: current configuration, existing item and new item and will return the item to be inserted (or might throw to cancel the insert)