11 #include <boost/math/special_functions.hpp>
18 namespace ns_rapidjson
31 document_.ParseStream(isw);
32 ARILES2_ASSERT(
false == document_.HasParseError(),
"Parsing failed");
43 namespace ns_rapidjson
47 std::ifstream config_ifs;
50 impl_->initialize(config_ifs);
57 impl_->initialize(input_stream);
64 impl_->document_.Parse(input_string);
70 ARILES2_TRACE_FUNCTION;
71 checkSize(limit_type,
impl_->getRawNode().MemberCount(), min, max);
76 const ::rapidjson::Value::ConstMemberIterator child =
impl_->getRawNode().FindMember(child_name.c_str());
78 if (
impl_->getRawNode().MemberEnd() == child)
88 impl_->node_stack_.pop_back();
94 const std::size_t min,
95 const std::size_t max)
97 ARILES2_TRACE_FUNCTION;
98 checkSize(limit_type,
impl_->getRawNode().MemberCount(), min, max);
101 const ::rapidjson::Value &selected_node =
impl_->getRawNode();
103 if (
true == selected_node.IsObject())
105 impl_->iterator_stack_.push_back(selected_node.MemberBegin());
113 if (
impl_->iterator_stack_.back() !=
impl_->getRawNode().MemberEnd())
116 entry_name =
impl_->iterator_stack_.back()->name.GetString();
124 ++
impl_->iterator_stack_.back();
125 impl_->node_stack_.pop_back();
131 impl_->iterator_stack_.back() ==
impl_->getRawNode().MemberEnd(),
132 "End of iterated map has not been reached.");
133 impl_->iterator_stack_.pop_back();
139 ARILES2_ASSERT(
impl_->getRawNode().IsArray(),
"Internal error: expected array.");
141 std::size_t size =
impl_->getRawNode().Size();
151 impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_,
152 "Internal error: namevalue.has more elements than expected.");
158 ARILES2_ASSERT(
true ==
impl_->node_stack_.back().isArray(),
"Internal error: expected array.");
159 ++
impl_->node_stack_.back().index_;
165 impl_->node_stack_.pop_back();
171 element =
impl_->getRawNode().GetString();
177 element =
impl_->getRawNode().GetBool();
183 float tmp_value = 0.0;
184 if (
true ==
impl_->getRawNode().IsString())
186 tmp_value = boost::lexical_cast<float>(
impl_->getRawNode().GetString());
187 if (
true == boost::math::isnan(tmp_value))
189 element = std::numeric_limits<float>::signaling_NaN();
192 if (
true == boost::math::isinf(tmp_value))
194 element =
static_cast<float>(tmp_value);
200 tmp_value =
static_cast<float>(
impl_->getRawNode().GetDouble());
204 tmp_value <= std::numeric_limits<float>::max() && tmp_value >= -std::numeric_limits<float>::max(),
205 "Value is out of range.");
206 element =
static_cast<float>(tmp_value);
212 double tmp_value = 0.0;
213 if (
true ==
impl_->getRawNode().IsString())
215 tmp_value = boost::lexical_cast<double>(
impl_->getRawNode().GetString());
216 if (
true == boost::math::isnan(tmp_value))
218 element = std::numeric_limits<double>::signaling_NaN();
221 if (
true == boost::math::isinf(tmp_value))
223 element =
static_cast<double>(tmp_value);
229 tmp_value =
impl_->getRawNode().GetDouble();
232 tmp_value <= std::numeric_limits<double>::max() && tmp_value >= -std::numeric_limits<double>::max(),
233 "Value is out of range.");
234 element =
static_cast<double>(tmp_value);
238 #define ARILES2_BASIC_TYPE(type) \
239 void Reader::readElement(type &element) \
241 int64_t tmp_value = impl_->getRawNode().GetInt64(); \
243 tmp_value <= std::numeric_limits<type>::max() && tmp_value >= std::numeric_limits<type>::min(), \
244 "Value is out of range."); \
245 element = static_cast<type>(tmp_value); \
250 #undef ARILES2_BASIC_TYPE
253 #define ARILES2_BASIC_TYPE(type) \
254 void Reader::readElement(type &element) \
256 uint64_t tmp_value = impl_->getRawNode().GetUint64(); \
257 ARILES2_ASSERT(tmp_value <= std::numeric_limits<type>::max(), "Value is too large."); \
258 element = static_cast<type>(tmp_value); \
263 #undef ARILES2_BASIC_TYPE