StormByte C++ Library: Config module 0.0.9999
StormByte-Config is a StormByte library module for parsing configuration files
|
Represents a container that can hold multiple configuration items. More...
#include <container.hxx>
Public Member Functions | |
Container ()=default | |
Constructs an empty Container. | |
Container (const std::string &name) | |
Container (std::string &&name) | |
Container (const Container &base)=default | |
Container (Container &&base) noexcept=default | |
Container & | operator= (const Container &base)=default |
Container & | operator= (Container &&base) noexcept=default |
virtual | ~Container () noexcept override=default |
Base & | operator[] (const size_t &index) |
const Base & | operator[] (const size_t &index) const |
Base & | operator[] (const std::string &path) |
const Base & | operator[] (const std::string &path) const |
bool | operator== (const Container &container) const noexcept |
bool | operator!= (const Container &container) const noexcept |
Base & | Add (const Base &item, const OnExistingAction &on_existing=OnExistingAction::ThrowException) |
Base & | Add (Base &&item, const OnExistingAction &on_existing=OnExistingAction::ThrowException) |
Base & | Add (Base::PointerType item, const OnExistingAction &on_existing) |
Adds an item to the container. | |
void | Clear () noexcept |
bool | Exists (const std::string &path) const |
void | Remove (const size_t &index) |
void | Remove (const std::string &path) |
std::string | Serialize (const int &indent_level) const noexcept override |
constexpr std::span< Base::PointerType > | Items () noexcept |
constexpr std::span< const Base::PointerType > | Items () const noexcept |
virtual constexpr Item::ContainerType | ContainerType () const noexcept=0 |
constexpr std::string | ContainerTypeToString () const noexcept |
constexpr Item::Type | Type () const noexcept override |
constexpr size_t | Size () const noexcept |
size_t | Count () const noexcept |
![]() | |
Base ()=default | |
Constructs a Base item with an optional name. | |
Base (const std::string &name) | |
Constructs a Base item with an optional name. | |
Base (const Base &base)=default | |
Base (Base &&base) noexcept=default | |
Base & | operator= (const Base &base)=default |
Base & | operator= (Base &&base) noexcept=default |
virtual | ~Base () noexcept=default |
bool | operator== (const Base &base) const noexcept |
bool | operator!= (const Base &base) const noexcept |
constexpr const std::optional< std::string > & | Name () const noexcept |
Gets the name of the item. | |
constexpr void | Name (const std::string &name) noexcept |
bool | IsNameValid () const noexcept |
constexpr std::string | TypeToString () const noexcept |
operator std::string () const | |
template<typename T > | |
const T & | Value () const |
template<typename T > | |
T & | Value () |
Static Public Member Functions | |
static constexpr std::pair< const char, const char > | EnclosureCharacters (const ContainerType &type) noexcept |
static constexpr const char | EndCharacter (const ContainerType &type) noexcept |
Protected Member Functions | |
virtual Base::PointerType | BeforeAdditionActions (Base::PointerType item, const OnExistingAction onexisting)=0 |
Protected Attributes | |
std::vector< Base::PointerType > | m_items |
Items in container. | |
![]() | |
std::optional< std::string > | m_name |
Item name. | |
Represents a container that can hold multiple configuration items.
T | container type |
StormByte::Config::Item::Container::Container | ( | const std::string & | name | ) |
Constructor
name | container name |
StormByte::Config::Item::Container::Container | ( | std::string && | name | ) |
Constructor
name | container name |
|
default |
Copy constructor
base | container to copy |
|
defaultnoexcept |
Move constructor
base | container to move |
|
overridevirtualdefaultnoexcept |
Destructor
|
inline |
Adds an item to the container (rvalue reference)
item | item to add |
on_existing | action to take if item name already exists |
ItemNameAlreadyExists | if item name already exists |
Base & StormByte::Config::Item::Container::Add | ( | Base::PointerType | item, |
const OnExistingAction & | on_existing | ||
) |
Adds an item to the container.
item | The item to add. |
on_existing | The action to take if the item name already exists. |
|
inline |
Adds an item to the container (const reference)
item | item to add |
on_existing | action to take if item name already exists |
InvalidName | if item name is not allowed |
ItemNameAlreadyExists | if item name already exists |
|
protectedpure virtual |
Actions to be done before adding an item
item | item to check |
onexisting | action to take if item name already exists |
ItemNameAlreadyExists | if item name already exists |
|
inlinenoexcept |
Clears all items
|
constexprpure virtualnoexcept |
Gets the container type
Implemented in StormByte::Config::Item::Group, and StormByte::Config::Item::List.
|
inlineconstexprnoexcept |
Gets the container type as string
|
noexcept |
Gets the full number of items
|
inlinestaticconstexprnoexcept |
Gets the start character for the container type
type | container type |
|
inlinestaticconstexprnoexcept |
Gets the end character for the container type
type | container type |
bool StormByte::Config::Item::Container::Exists | ( | const std::string & | path | ) | const |
Checks if item exists by path
path | path to item |
|
inlineconstexprnoexcept |
Get all items in the container
|
inlineconstexprnoexcept |
Get all items in the container
|
inlinenoexcept |
Inequality operator
container | container to compare |
Assignment operator
base | container to copy |
Move assignment operator
base | container to move |
|
noexcept |
Equality operator
container | container to compare |
Base & StormByte::Config::Item::Container::operator[] | ( | const size_t & | index | ) |
Gets a reference to Item by index
OutOfBounds | if index is out of bounds |
const Base & StormByte::Config::Item::Container::operator[] | ( | const size_t & | index | ) | const |
Gets a const reference to Item by index
OutOfBounds | if index is out of bounds |
Base & StormByte::Config::Item::Container::operator[] | ( | const std::string & | path | ) |
Gets a reference to Item by path
path | path to item |
InvalidPath | if path is invalid |
ItemNotFound | if item is not found |
|
inline |
Gets a const reference to Item by path
path | path to item |
InvalidPath | if path is invalid |
ItemNotFound | if item is not found |
void StormByte::Config::Item::Container::Remove | ( | const size_t & | index | ) |
Removes an item by index
index | index to item |
OutOfBounds | if index is out of bounds |
void StormByte::Config::Item::Container::Remove | ( | const std::string & | path | ) |
Removes an item by path
path | path to item |
InvalidPath | if path is invalid |
ItemNotFound | if item is not found |
|
overridevirtualnoexcept |
Returns a string representation of the container
Reimplemented from StormByte::Config::Item::Base.
|
inlineconstexprnoexcept |
Gets the number of items in the current level
|
inlineconstexproverridevirtualnoexcept |