126 bool Equals(const
Base& other) const noexcept override;
212 case ContainerType::Group:
return {
'{',
'}'};
213 case ContainerType::List:
return {
'[',
']'};
214 default:
return {
'\0',
'\0'};
225 case ContainerType::Group:
return '}';
226 case ContainerType::List:
return ']';
227 default:
return '\0';
241 constexpr
std::string_view ContainerTypeToString() const noexcept {
250 return Item::Type::Container;
265 return Add(std::move(*item.
Clone()), on_existing);
275 return Add(item.Move(), on_existing);
284 return Add(std::move(*item.
Clone()), m_on_existing_action);
293 return Add(item.Move(), m_on_existing_action);
302 return Add(item, m_on_existing_action);
330 inline
bool Exists(
std::string_view path)
const {
353 inline void Remove(std::string_view path) {
361 constexpr std::span<const Base::PointerType>
Items() noexcept {
362 return std::span<const Base::PointerType>(m_items);
369 constexpr std::span<const Base::PointerType>
Items() const noexcept {
370 return std::span<const Base::PointerType>(m_items);
395 m_on_existing_action = action;
403 return m_on_existing_action;
446 const Base& LookUp(std::queue<StormByte::String::String>& path)
const;
452 void Remove(std::queue<StormByte::String::String>& path);
virtual PointerType Clone() const=0
Configuration document (text or versioned binary).
Definition config.hxx:77
Base class for all configuration items.
Definition base.hxx:66
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:292
Container()
Constructs an empty Container.
constexpr Item::Type Type() const noexcept override
Gets the item type.
Definition container.hxx:249
constexpr std::span< const Base::PointerType > Items() noexcept
Items in this level.
Definition container.hxx:361
Base & operator[](std::string_view path)
Gets a reference to an item by a path view.
Definition container.hxx:169
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:264
Base & Add(const Base &item)
Adds an item using the container's current OnExistingAction policy.
Definition container.hxx:283
Container(StormByte::String::String &&name)
Constructs a Container with the given name (move).
Container(const StormByte::String::String &name)
Constructs a Container with the given name.
StormByte::Config::OnExistingAction GetOnExistingAction() const noexcept
Gets the current OnExistingAction policy.
Definition container.hxx:402
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:274
static constexpr const char EndCharacter(const ContainerType &type) noexcept
Returns the closing character for a given container type.
Definition container.hxx:223
const Base & operator[](std::string_view path) const
Gets a const reference to an item by a path view.
Definition container.hxx:178
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:210
Base & Add(Base::PointerType item)
Adds an item to the container using current policy.
Definition container.hxx:301
constexpr std::span< const Base::PointerType > Items() const noexcept
Items in this level.
Definition container.hxx:369
Container(Container &&base) noexcept
Move constructor.
Container & operator=(const Container &base)
Copy assignment operator.
std::vector< Base::PointerType > m_items
Items stored in the container.
Definition container.hxx:408
virtual constexpr Item::ContainerType ContainerType() const noexcept=0
Gets the container type.
void Remove(const StormByte::Size &index)
Removes an item by index.
Container & operator=(Container &&base) noexcept
Move assignment operator.
bool operator==(const Container &container) const noexcept
Equality operator.
virtual ~Container() noexcept override
Destructor.
Base & Add(Base::PointerType item, const StormByte::Config::OnExistingAction &on_existing)
Adds an item to the container.
StormByte::String::String Serialize(const int &indent_level) const noexcept override
Serializes the container to a string.
void Remove(std::string_view path)
Removes an item by a path view.
Definition container.hxx:353
void Remove(const StormByte::String::String &path)
Removes an item by path.
bool operator!=(const Container &container) const noexcept
Inequality operator.
Definition container.hxx:194
Configuration items (values, comments, groups, lists).
Definition hook.hxx:50
Type
Node kind in the document tree.
Definition type.hxx:57
ContainerType
Group ({}) or list ([]).
Definition type.hxx:115
OnExistingAction
Forward declaration of the configuration document.
Definition typedefs.hxx:56
@ ThrowException
Throw an exception to indicate the conflict.
bool operator==(std::span< const std::byte > bytes, const BinaryData &data) noexcept
#define STORMBYTE_CONFIG_PUBLIC
Definition visibility.h:53