16 #include <msgpack.hpp>
23 namespace ns_msgpack_compact
32 namespace ns_msgpack_compact
55 std::stringstream str_stream;
56 str_stream << input_stream.rdbuf();
57 buffer_ = str_stream.str();
61 unpack(handle_, buffer_.data(), buffer_.size(), NULL);
64 catch (
const std::exception &e)
66 ARILES2_THROW(std::string(
"Failed to parse the configuration file: ") + e.what());
76 const ::msgpack::object &
getRawNode(
const std::size_t depth)
78 if (node_stack_[depth].isArray())
80 return (getRawNode(depth - 1).via.array.ptr[node_stack_[depth].index_]);
82 return (*node_stack_[depth].node_);
88 return (getRawNode(node_stack_.size() - 1));
99 namespace ns_msgpack_compact
103 std::ifstream config_ifs;
106 impl_->initialize(config_ifs);
113 impl_->initialize(input_stream);
119 const std::size_t size =
impl_->getRawNode().via.array.size;
126 if (
true ==
impl_->node_stack_.back().isArray())
135 if (
true ==
impl_->node_stack_.back().isArray())
144 true ==
impl_->node_stack_.back().isAllParsed(),
145 "Some entries were not parsed, which is not allowed by this visitor.");
146 impl_->node_stack_.pop_back();
152 std::size_t size =
impl_->getRawNode().via.array.size;
161 impl_->node_stack_.pop_back();
168 impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_,
169 "Internal error: namevalue.has more elements than expected.");
175 ARILES2_ASSERT(
true ==
impl_->node_stack_.back().isArray(),
"Internal error: expected array.");
176 ++
impl_->node_stack_.back().index_;
180 #define ARILES2_BASIC_TYPE(type) \
181 void Reader::readElement(type &element) \
183 impl_->getRawNode() >> element; \
188 #undef ARILES2_BASIC_TYPE