15 #include <msgpack.hpp>
39 std::vector<std::shared_ptr<::msgpack::object_handle>>
handles_;
45 template <
class... t_Args>
58 std::stringstream str_stream;
66 std::size_t buffer_offset = 0;
68 while (buffer_offset !=
buffer_.size())
70 handles_.push_back(std::make_shared<::msgpack::object_handle>());
75 catch (
const std::exception &e)
77 CPPUT_THROW(
"Failed to parse the configuration file: ", e.what());
89 const ::msgpack::object &
getRawNode(
const std::size_t depth)
130 checkSize(limit_type,
impl_->getRawNode().via.map.size, min, max);
141 for (std::size_t i = 0; i <
impl_->handles_.size(); ++i)
143 if (::msgpack::type::MAP ==
impl_->handles_[i]->get().type)
145 if (child_name ==
impl_->handles_[i]->get().via.map.ptr[0].key.as<std::string>())
147 if (::msgpack::type::MAP ==
impl_->handles_[i]->get().via.map.ptr[0].val.type)
149 impl_->emplace(&(
impl_->handles_[i]->get().via.map.ptr[0].val));
158 if (::msgpack::type::MAP ==
impl_->getRawNode().type)
160 for (std::size_t i = 0; i <
impl_->getRawNode().via.map.size; ++i)
162 if (child_name ==
impl_->getRawNode().via.map.ptr[i].key.as<std::string>())
164 impl_->emplace(&(
impl_->getRawNode().via.map.ptr[i].val));
185 const std::size_t size =
impl_->getRawNode().via.array.size;
186 impl_->emplace(0, size);
203 "Internal error: array has more elements than expected.");
220 0 ==
impl_->nameless_counter_,
221 "Multiple nameless root entries are not supported, specify root names explicitly.");
222 ++
impl_->nameless_counter_;
235 #define ARILES2_BASIC_TYPE(type) \
236 void Reader::readElement(type &element) \
238 CPPUT_TRACE_FUNCTION; \
239 impl_->getRawNode() >> element; \
244 #undef ARILES2_BASIC_TYPE
void endMapEntry()
endMapEntry from the current entry to its parent.
bool startRoot(const std::string &name)
bool startMapEntry(const std::string &child_name)
startMapEntry to the entry with the given name
void startMap(const SizeLimitEnforcementType limit_type=SIZE_LIMIT_NONE, const std::size_t min=0, const std::size_t max=0)
void endRoot(const std::string &name)
Reader(const std::string &file_name)
Constructor.
std::size_t nameless_counter_
const ::msgpack::object & getRawNode(const std::size_t depth)
Get current node.
const ::msgpack::object & getRawNode()
void initialize()
open configuration file
std::vector< std::shared_ptr<::msgpack::object_handle > > handles_
std::istream * input_stream_
FileVisitorImplementation()=default
void checkSize(const SizeLimitEnforcementType limit_type, const std::size_t size=0, const std::size_t min=0, const std::size_t max=0) const
std::vector< NodeWrapper > node_stack_
void makeImplPtr(t_Args &&...args)
#define CPPUT_ASSERT(condition,...)
#define ARILES2_BASIC_TYPES_LIST
#define CPPUT_MACRO_SUBSTITUTE(macro)
#define CPPUT_TRACE_FUNCTION
#define CPPUT_TRACE_VALUE(value)