125 bool Equals(const
Base& other) const noexcept override;
211 case ContainerType::Group:
return {
'{',
'}'};
212 case ContainerType::List:
return {
'[',
']'};
213 default:
return {
'\0',
'\0'};
224 case ContainerType::Group:
return '}';
225 case ContainerType::List:
return ']';
226 default:
return '\0';
240 constexpr
std::string_view ContainerTypeToString() const noexcept {
249 return Item::Type::Container;
264 return Add(std::move(*item.
Clone()), on_existing);
274 return Add(item.Move(), on_existing);
283 return Add(std::move(*item.
Clone()), m_on_existing_action);
292 return Add(item.Move(), m_on_existing_action);
301 return Add(item, m_on_existing_action);
329 inline
bool Exists(
std::string_view path)
const {
352 inline void Remove(std::string_view path) {
360 constexpr std::span<const Base::PointerType>
Items() noexcept {
361 return std::span<const Base::PointerType>(m_items);
368 constexpr std::span<const Base::PointerType>
Items() const noexcept {
369 return std::span<const Base::PointerType>(m_items);
394 m_on_existing_action = action;
402 return m_on_existing_action;
445 const Base& LookUp(std::queue<StormByte::Safe::String>& path)
const;
451 void Remove(std::queue<StormByte::Safe::String>& path);
Configuration document (text or versioned binary).
Definition config.hxx:76
Base class for all configuration items.
Definition base.hxx:65
Holds child items.
Definition container.hxx:61
Base & Add(Base &&item)
Adds an item using the container's current OnExistingAction policy (move).
Definition container.hxx:291
Container()
Constructs an empty Container.
constexpr Item::Type Type() const noexcept override
Gets the item type.
Definition container.hxx:248
StormByte::Safe::String Serialize(const int &indent_level) const noexcept override
Serializes the container to a string.
constexpr std::span< const Base::PointerType > Items() noexcept
Items in this level.
Definition container.hxx:360
Base & operator[](std::string_view path)
Gets a reference to an item by a path view.
Definition container.hxx:168
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:263
Base & Add(const Base &item)
Adds an item using the container's current OnExistingAction policy.
Definition container.hxx:282
StormByte::Config::OnExistingAction GetOnExistingAction() const noexcept
Gets the current OnExistingAction policy.
Definition container.hxx:401
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:273
static constexpr const char EndCharacter(const ContainerType &type) noexcept
Returns the closing character for a given container type.
Definition container.hxx:222
const Base & operator[](std::string_view path) const
Gets a const reference to an item by a path view.
Definition container.hxx:177
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:209
Base & Add(Base::PointerType item)
Adds an item to the container using current policy.
Definition container.hxx:300
Container(StormByte::Safe::String &&name)
Constructs a Container with the given name (move).
constexpr std::span< const Base::PointerType > Items() const noexcept
Items in this level.
Definition container.hxx:368
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:407
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.
void Remove(const StormByte::Safe::String &path)
Removes an item by path.
virtual ~Container() noexcept override
Destructor.
Base & Add(Base::PointerType item, const StormByte::Config::OnExistingAction &on_existing)
Adds an item to the container.
void Remove(std::string_view path)
Removes an item by a path view.
Definition container.hxx:352
bool operator!=(const Container &container) const noexcept
Inequality operator.
Definition container.hxx:193
virtual PointerType Clone() const=0
Configuration items (values, comments, groups, lists).
Definition hook.hxx:49
Type
Node kind in the document tree.
Definition type.hxx:56
ContainerType
Group ({}) or list ([]).
Definition type.hxx:114
OnExistingAction
Forward declaration of the configuration document.
Definition typedefs.hxx:55
@ 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:52