46#include <StormByte/size.hxx>
47#include <StormByte/safe/queue.hxx>
48#include <StormByte/safe/string.hxx>
49#include <StormByte/safe/vector.hxx>
160 const
Base& operator[](
std::string_view path) const;
167 bool operator==(const
Container& container) const noexcept;
174 inline
bool operator!=(const
Container& container) const noexcept {
194 default:
return {
'\0',
'\0'};
207 default:
return '\0';
245 return Add(std::move(*item.
Clone()), on_existing);
255 return Add(item.Move(), on_existing);
Configuration document (text or versioned binary).
Definition config.hxx:79
Base() noexcept
Constructor.
Holds child items.
Definition container.hxx:62
Base & Add(Base &&item)
Adds an item using the container's current OnExistingAction policy (move).
Definition container.hxx:272
Container()
Constructs an empty Container.
bool Equals(const Base &other) const noexcept override
Polymorphic equality comparison.
void SetOnExistingAction(StormByte::Config::OnExistingAction action) noexcept
Sets the action to take when an item with the same identity already exists.
Definition container.hxx:357
constexpr Item::Type Type() const noexcept override
Gets the item type.
Definition container.hxx:229
StormByte::Safe::String Serialize(const int &indent_level) const noexcept override
Serializes the container to a string.
const StormByte::Safe::Vector< Base::PointerType > & Items() const noexcept
Items in this level.
Definition container.hxx:332
Container(const Container &base)
Copy constructor.
virtual Base::PointerType BeforeAdditionActions(Base::PointerType item, const StormByte::Config::OnExistingAction onexisting)=0
Actions performed before adding an item.
Base & Add(const Base &item, const StormByte::Config::OnExistingAction &on_existing)
Adds an item (const reference) using an explicit policy.
Definition container.hxx:244
Base & Add(const Base &item)
Adds an item using the container's current OnExistingAction policy.
Definition container.hxx:263
StormByte::Config::OnExistingAction GetOnExistingAction() const noexcept
Gets the current OnExistingAction policy.
Definition container.hxx:365
StormByte::Size Size() const noexcept
Gets the number of items in the current level.
void Clear() noexcept
Clears all items from the container.
Base & Add(Base &&item, const StormByte::Config::OnExistingAction &on_existing)
Adds an item (rvalue) using an explicit policy.
Definition container.hxx:254
static constexpr const char EndCharacter(const ContainerType &type) noexcept
Returns the closing character for a given container type.
Definition container.hxx:203
StormByte::Safe::Vector< Base::PointerType > m_items
Items stored in the container.
Definition container.hxx:371
const StormByte::Safe::Vector< Base::PointerType > & Items() noexcept
Items in this level.
Definition container.hxx:324
Container(const StormByte::Safe::String &name)
Constructs a Container with the given name.
static constexpr std::pair< const char, const char > EnclosureCharacters(const ContainerType &type) noexcept
Returns the enclosure characters for a given container type.
Definition container.hxx:190
Base & Add(Base::PointerType item)
Adds an item to the container using current policy.
Definition container.hxx:281
Container(StormByte::Safe::String &&name)
Constructs a Container with the given name (move).
Container(Container &&base) noexcept
Move constructor.
Container & operator=(const Container &base)
Copy assignment operator.
virtual constexpr Item::ContainerType ContainerType() const noexcept=0
Gets the container type.
bool Exists(std::string_view path) const
Checks if an item exists by path.
void Remove(const StormByte::Size &index)
Removes an item by index.
StormByte::Size Count() const noexcept
Gets the total number of items including nested ones.
Container & operator=(Container &&base) noexcept
Move assignment operator.
bool operator==(const Container &container) const noexcept
Equality operator.
constexpr std::string_view ContainerTypeToString() const noexcept
Gets the container type as string.
Definition container.hxx:221
virtual ~Container() noexcept override
Destructor.
Base & Add(Base::PointerType item, const StormByte::Config::OnExistingAction &on_existing)
Adds an item to the container.
StormByte::Config::OnExistingAction m_on_existing_action
Collision policy.
Definition container.hxx:372
virtual PointerType Clone() const=0
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Config::Config)
Configuration document items.
Definition base.hxx:55
Type
Node kind in the document tree.
Definition type.hxx:57
@ Container
Group or list.
Definition type.hxx:60
static constexpr std::string_view TypeToString(const Type &t) noexcept
Converts a Type to its string representation.
Definition type.hxx:73
ContainerType
Group ({}) or list ([]).
Definition type.hxx:115
@ Group
Group of named items.
Definition type.hxx:116
@ List
List of unnamed items.
Definition type.hxx:117
OnExistingAction
Forward declaration of the configuration document.
Definition typedefs.hxx:56
@ ThrowException
Throw an exception to indicate the conflict.
Definition typedefs.hxx:59
Root namespace of the StormByte suite.
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:53