ECSTASY
All in the name
Loading...
Searching...
No Matches
TomlObjectNode.hpp
Go to the documentation of this file.
1
11
12#ifndef UTIL_SERIALIZATION_TOML_TOMLOBJECTNODE_HPP_
13#define UTIL_SERIALIZATION_TOML_TOMLOBJECTNODE_HPP_
14
15#include "TomlNode.hpp"
17
18namespace util::serialization
19{
26 class TomlObjectNode : public TomlNode<toml::table>, public IObjectNode {
27 public:
29 TomlObjectNode() = default;
30
39 TomlObjectNode(const toml::table &table);
40
42 [[nodiscard]] NodeCView get(std::string_view key) const override final;
43
45 [[nodiscard]] NodeView get(std::string_view key) override final;
46
48 [[nodiscard]] NodeCView tryGet(std::string_view key) const noexcept override final;
49
51 [[nodiscard]] NodeView tryGet(std::string_view key) noexcept override final;
52
54 bool insert(std::string_view key, const INode &value) override final;
55
57 bool insertOrAssign(std::string_view key, const INode &value) override final;
58
60 void erase(std::string_view key) override final;
61
63 void clear() noexcept override final;
64
66 [[nodiscard]] bool empty() const noexcept override final;
67
69 [[nodiscard]] size_t size() const noexcept override final;
70
72 [[nodiscard]] bool contains(std::string_view key) const noexcept override final;
73
75 [[nodiscard]] const_iterator cbegin() const noexcept override final;
76
78 [[nodiscard]] const_iterator begin() const noexcept override final;
79
81 [[nodiscard]] iterator begin() noexcept override final;
82
84 [[nodiscard]] const_iterator cend() const noexcept override final;
85
87 [[nodiscard]] const_iterator end() const noexcept override final;
88
90 [[nodiscard]] iterator end() noexcept override final;
91
92 private:
99 std::map<std::string, NodePtr, std::less<>> _nodes;
100 };
101} // namespace util::serialization
102
103#endif /* !UTIL_SERIALIZATION_TOML_TOMLOBJECTNODE_HPP_ */
Object node interface.
Toml node implementation.
Serialization node.
Definition INode.hpp:32
Polymorphism iterator for value T.
Serialization node.
Definition TomlNode.hpp:29
const_iterator cbegin() const noexcept override final
Get the start iterator of the internal nodes.
const_iterator end() const noexcept override final
Get the end iterator of the internal nodes.
bool insertOrAssign(std::string_view key, const INode &value) override final
Try to insert a new node at key or replace the existing one.
NodeCView get(std::string_view key) const override final
Get the node matching key if existing.
void clear() noexcept override final
Remove all the internal nodes.
std::map< std::string, NodePtr, std::less<> > _nodes
Internal nodes map.
void erase(std::string_view key) override final
Erase the node identified by key.
bool contains(std::string_view key) const noexcept override final
Check if key match a node.
bool empty() const noexcept override final
Check if the object is empty.
TomlObjectNode()=default
Default constructor.
bool insert(std::string_view key, const INode &value) override final
Try to insert a new node at key.
size_t size() const noexcept override final
Get the number of node in this.
const_iterator cend() const noexcept override final
Get the end iterator of the internal nodes.
const_iterator begin() const noexcept override final
Get the start iterator of the internal nodes.
NodeCView tryGet(std::string_view key) const noexcept override final
Get the node matching key.