Holds child items. More...
#include <StormByte/config/item/container.hxx>


Public Member Functions | |
Construction | |
| Container () | |
| Constructs an empty Container. | |
| Container (const StormByte::String::String &name) | |
| Constructs a Container with the given name. | |
| Container (StormByte::String::String &&name) | |
| Constructs a Container with the given name (move). | |
| Container (const Container &base) | |
| Copy constructor. | |
| Container (Container &&base) noexcept | |
| Move constructor. | |
| Container & | operator= (const Container &base) |
| Copy assignment operator. | |
| Container & | operator= (Container &&base) noexcept |
| Move assignment operator. | |
| virtual | ~Container () noexcept override |
| Destructor. | |
Items | |
| Base & | Add (const Base &item, const StormByte::Config::OnExistingAction &on_existing) |
| Adds an item (const reference) using an explicit policy. | |
| Base & | Add (Base &&item, const StormByte::Config::OnExistingAction &on_existing) |
| Adds an item (rvalue) using an explicit policy. | |
| Base & | Add (const Base &item) |
| Adds an item using the container's current OnExistingAction policy. | |
| Base & | Add (Base &&item) |
| Adds an item using the container's current OnExistingAction policy (move). | |
| Base & | Add (Base::PointerType item) |
| Adds an item to the container using current policy. | |
| Base & | Add (Base::PointerType item, const StormByte::Config::OnExistingAction &on_existing) |
| Adds an item to the container. | |
| void | Clear () noexcept |
| Clears all items from the container. | |
| bool | Exists (const StormByte::String::String &path) const |
| Checks if an item exists by path. | |
| bool | Exists (std::string_view path) const |
| Checks if an item exists by a path view. | |
| void | Remove (const StormByte::Size &index) |
| Removes an item by index. | |
| void | Remove (const StormByte::String::String &path) |
| Removes an item by path. | |
| void | Remove (std::string_view path) |
| Removes an item by a path view. | |
| constexpr std::span< const Base::PointerType > | Items () noexcept |
| Items in this level. | |
| constexpr std::span< const Base::PointerType > | Items () const noexcept |
| Items in this level. | |
| StormByte::Size | Size () const noexcept |
| Gets the number of items in the current level. | |
| StormByte::Size | Count () const noexcept |
| Gets the total number of items including nested ones. | |
Policy | |
| void | SetOnExistingAction (StormByte::Config::OnExistingAction action) noexcept |
| Sets the action to take when an item with the same identity already exists. | |
| StormByte::Config::OnExistingAction | GetOnExistingAction () const noexcept |
| Gets the current OnExistingAction policy. | |
Public Member Functions inherited from StormByte::Config::Item::Base | |
| Base () noexcept | |
| Constructor. | |
| Base (const StormByte::String::String &name) | |
| Constructor. | |
| Base (const Base &base) noexcept=default | |
| Copy constructor. | |
| Base (Base &&base) noexcept=default | |
| Move constructor. | |
| Base & | operator= (const Base &base) noexcept=default |
| Assignment operator. | |
| Base & | operator= (Base &&base) noexcept=default |
| Move assignment operator. | |
| ~Base () noexcept override | |
| Destructor. | |
| bool | operator== (const Base &base) const noexcept |
| Compares two items. | |
| bool | operator!= (const Base &base) const noexcept |
| Compares two items. | |
| constexpr const StormByte::String::String & | Name () const noexcept |
| Gets the name of the item. | |
| constexpr void | Name (const StormByte::String::String &name) |
| Sets the name of the item. | |
| void | Name (std::string_view name) |
| Sets the name of the item. | |
| constexpr std::string_view | TypeToString () const noexcept |
| Gets the type as string. | |
| template<class T > | |
| decltype(auto) | As () |
| Typed view of this item. | |
| template<class T > | |
| decltype(auto) | As () const |
| Typed view of this item. | |
Public Member Functions inherited from StormByte::Clonable< Base, StormByte::Shared< Base > > | |
| constexpr | Clonable ()=default |
| constexpr | Clonable (const Clonable &)=default |
| constexpr | Clonable (Clonable &&) noexcept=default |
| constexpr Clonable & | operator= (const Clonable &)=default |
| constexpr Clonable & | operator= (Clonable &&) noexcept=default |
| virtual constexpr | ~Clonable () noexcept=default |
| virtual PointerType | Clone () const =0 |
| virtual PointerType | Move ()=0 |
Protected Member Functions | |
| virtual Base::PointerType | BeforeAdditionActions (Base::PointerType item, const StormByte::Config::OnExistingAction onexisting)=0 |
| Actions performed before adding an item. | |
Protected Attributes | |
| std::vector< Base::PointerType > | m_items |
| Items stored in the container. | |
| StormByte::Config::OnExistingAction | m_on_existing_action = StormByte::Config::OnExistingAction::ThrowException |
| Collision policy. | |
Protected Attributes inherited from StormByte::Config::Item::Base | |
| StormByte::String::String | m_name |
| Name of the item. | |
Access | |
| bool | Equals (const Base &other) const noexcept override |
| Polymorphic equality comparison. | |
| Base & | operator[] (const StormByte::Size &index) |
| Gets a reference to an item by index. | |
| const Base & | operator[] (const StormByte::Size &index) const |
| Gets a const reference to an item by index. | |
| Base & | operator[] (const StormByte::String::String &path) |
| Gets a reference to an item by path. | |
| const Base & | operator[] (const StormByte::String::String &path) const |
| Gets a const reference to an item by path. | |
| Base & | operator[] (std::string_view path) |
| Gets a reference to an item by a path view. | |
| const Base & | operator[] (std::string_view path) const |
| Gets a const reference to an item by a path view. | |
| bool | operator== (const Container &container) const noexcept |
| Equality operator. | |
| bool | operator!= (const Container &container) const noexcept |
| Inequality operator. | |
| StormByte::String::String | Serialize (const int &indent_level) const noexcept override |
| Serializes the container to a string. | |
| virtual constexpr Item::ContainerType | ContainerType () const noexcept=0 |
| Gets the container type. | |
| constexpr std::string_view | ContainerTypeToString () const noexcept |
| Gets the container type as string. | |
| constexpr Item::Type | Type () const noexcept override |
| Gets the item type. | |
| static constexpr std::pair< const char, const char > | EnclosureCharacters (const ContainerType &type) noexcept |
| Returns the enclosure characters for a given container type. | |
| static constexpr const char | EndCharacter (const ContainerType &type) noexcept |
| Returns the closing character for a given container type. | |
Additional Inherited Members | |
Public Types inherited from StormByte::Clonable< Base, StormByte::Shared< Base > > | |
| typedef SmartPointer | PointerType |
Static Public Member Functions inherited from StormByte::Config::Item::Base | |
| static bool | IsNameValid (const StormByte::String::String &name) noexcept |
| Checks if name is valid. | |
| static bool | IsNameValid (std::string_view name) noexcept |
| Checks if name is valid. | |
Static Public Member Functions inherited from StormByte::Clonable< Base, StormByte::Shared< Base > > | |
| static PointerType | MakePointer (Args &&... args) |
| StormByte::Config::Item::Container::Container | ( | ) |
Constructs an empty Container.
| StormByte::Config::Item::Container::Container | ( | const StormByte::String::String & | name | ) |
Constructs a Container with the given name.
| name | The name of the container. |
| StormByte::Config::Item::Container::Container | ( | StormByte::String::String && | name | ) |
Constructs a Container with the given name (move).
| name | The name of the container. |
| StormByte::Config::Item::Container::Container | ( | const Container & | base | ) |
Copy constructor.
| base | Container to copy. |
|
noexcept |
Move constructor.
| base | Container to move. |
|
overridevirtualnoexcept |
Destructor.
Defined in this module so catch matches across a DLL.
Adds an item using the container's current OnExistingAction policy (move).
| item | Item to add. |
|
inline |
Adds an item (rvalue) using an explicit policy.
| item | Item to add. |
| on_existing | Action to take if the item already exists. |
|
inline |
Adds an item to the container using current policy.
| item | The item to add. |
| Base & StormByte::Config::Item::Container::Add | ( | Base::PointerType | item, |
| const StormByte::Config::OnExistingAction & | on_existing | ||
| ) |
Adds an item to the container.
| item | The item to add. |
| on_existing | The action to take if the item already exists. |
Adds an item using the container's current OnExistingAction policy.
| item | Item to add. |
|
inline |
Adds an item (const reference) using an explicit policy.
| item | Item to add. |
| on_existing | Action to take if the item already exists. |
|
protectedpure virtual |
Actions performed before adding an item.
| item | Item to check. |
| onexisting | Action to take if the item already exists. |
Implemented in StormByte::Config::Item::Group, and StormByte::Config::Item::List.
|
noexcept |
Clears all items from the container.
|
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 total number of items including nested ones.
|
inlinestaticconstexprnoexcept |
Returns the enclosure characters for a given container type.
| type | Container type. |
|
inlinestaticconstexprnoexcept |
Returns the closing character for a given container type.
| type | Container type. |
|
overridevirtualnoexcept |
Polymorphic equality comparison.
| other | The other item to compare against. |
Implements StormByte::Config::Item::Base.
| bool StormByte::Config::Item::Container::Exists | ( | const StormByte::String::String & | path | ) | const |
Checks if an item exists by path.
| path | Path to the item. |
|
inline |
Checks if an item exists by a path view.
| path | Path to the item. |
|
inlinenoexcept |
Gets the current OnExistingAction policy.
|
inlineconstexprnoexcept |
Items in this level.
|
inlineconstexprnoexcept |
Items in this level.
The span cannot reseat or grow the store; each pointer's item is mutable.
|
inlinenoexcept |
|
noexcept |
| Base & StormByte::Config::Item::Container::operator[] | ( | const StormByte::Size & | index | ) |
Gets a reference to an item by index.
| index | Index of the item. |
| OutOfBounds | if index is out of bounds. |
| const Base & StormByte::Config::Item::Container::operator[] | ( | const StormByte::Size & | index | ) | const |
Gets a const reference to an item by index.
| index | Index of the item. |
| OutOfBounds | if index is out of bounds. |
| Base & StormByte::Config::Item::Container::operator[] | ( | const StormByte::String::String & | path | ) |
Gets a reference to an item by path.
| path | Path to the item. |
| InvalidPath | if path is invalid. |
| ItemNotFound | if item is not found. |
|
inline |
Gets a const reference to an item by path.
| path | Path to the item. |
| InvalidPath | if path is invalid. |
| ItemNotFound | if item is not found. |
|
inline |
Gets a reference to an item by a path view.
| path | Path to the item. |
|
inline |
Gets a const reference to an item by a path view.
| path | Path to the item. |
| void StormByte::Config::Item::Container::Remove | ( | const StormByte::Size & | index | ) |
Removes an item by index.
| index | Index of the item to remove. |
| OutOfBounds | if index is out of bounds. |
| void StormByte::Config::Item::Container::Remove | ( | const StormByte::String::String & | path | ) |
Removes an item by path.
| path | Path to the item to remove. |
| InvalidPath | if path is invalid. |
| ItemNotFound | if item is not found. |
|
inline |
Removes an item by a path view.
| path | Path to the item to remove. |
|
overridevirtualnoexcept |
Serializes the container to a string.
| indent_level | Indentation level. |
Reimplemented from StormByte::Config::Item::Base.
|
inlinenoexcept |
Sets the action to take when an item with the same identity already exists.
| action | The policy to apply on name/identity collision. |
|
noexcept |
Gets the number of items in the current level.
|
inlineconstexproverridevirtualnoexcept |
Gets the item type.
Implements StormByte::Config::Item::Base.
Reimplemented in StormByte::Config::Item::Group, and StormByte::Config::Item::List.
|
protected |
Items stored in the container.
|
protected |
Collision policy.