11 #include <boost/math/special_functions.hpp>
18 namespace ns_rapidjson
31 template <
class... t_Args>
53 namespace ns_rapidjson
70 impl_->document_.Parse(input_string);
77 checkSize(limit_type,
impl_->getRawNode().MemberCount(), min, max);
82 const ::rapidjson::Value::ConstMemberIterator child =
impl_->getRawNode().FindMember(child_name.c_str());
84 if (
impl_->getRawNode().MemberEnd() == child)
88 impl_->emplace(&(child->value));
100 const std::size_t min,
101 const std::size_t max)
104 checkSize(limit_type,
impl_->getRawNode().MemberCount(), min, max);
107 const ::rapidjson::Value &selected_node =
impl_->getRawNode();
109 if (selected_node.IsObject())
111 impl_->iterator_stack_.push_back(selected_node.MemberBegin());
119 if (
impl_->iterator_stack_.back() !=
impl_->getRawNode().MemberEnd())
121 impl_->emplace(&(
impl_->iterator_stack_.back()->value));
122 entry_name =
impl_->iterator_stack_.back()->name.GetString();
130 ++
impl_->iterator_stack_.back();
137 impl_->iterator_stack_.back() ==
impl_->getRawNode().MemberEnd(),
138 "End of iterated map has not been reached.");
139 impl_->iterator_stack_.pop_back();
147 std::size_t size =
impl_->getRawNode().Size();
148 impl_->emplace(0, size);
158 "Internal error: array has more elements than expected.");
176 element =
impl_->getRawNode().GetString();
182 element =
impl_->getRawNode().GetBool();
188 float tmp_value = 0.0;
189 if (
impl_->getRawNode().IsString())
191 tmp_value = boost::lexical_cast<float>(
impl_->getRawNode().GetString());
192 if (boost::math::isnan(tmp_value))
194 element = std::numeric_limits<float>::signaling_NaN();
197 if (boost::math::isinf(tmp_value))
199 element =
static_cast<float>(tmp_value);
205 tmp_value =
static_cast<float>(
impl_->getRawNode().GetDouble());
209 tmp_value <= std::numeric_limits<float>::max() && tmp_value >= -std::numeric_limits<float>::max(),
210 "Value is out of range.");
211 element =
static_cast<float>(tmp_value);
217 double tmp_value = 0.0;
218 if (
impl_->getRawNode().IsString())
220 tmp_value = boost::lexical_cast<double>(
impl_->getRawNode().GetString());
221 if (boost::math::isnan(tmp_value))
223 element = std::numeric_limits<double>::signaling_NaN();
226 if (boost::math::isinf(tmp_value))
228 element =
static_cast<double>(tmp_value);
234 tmp_value =
impl_->getRawNode().GetDouble();
237 tmp_value <= std::numeric_limits<double>::max() && tmp_value >= -std::numeric_limits<double>::max(),
238 "Value is out of range.");
239 element =
static_cast<double>(tmp_value);
243 #define ARILES2_BASIC_TYPE(type) \
244 void Reader::readElement(type &element) \
246 int64_t tmp_value = impl_->getRawNode().GetInt64(); \
248 tmp_value <= std::numeric_limits<type>::max() && tmp_value >= std::numeric_limits<type>::min(), \
249 "Value is out of range."); \
250 element = static_cast<type>(tmp_value); \
255 #undef ARILES2_BASIC_TYPE
258 #define ARILES2_BASIC_TYPE(type) \
259 void Reader::readElement(type &element) \
261 uint64_t tmp_value = impl_->getRawNode().GetUint64(); \
262 CPPUT_ASSERT(tmp_value <= std::numeric_limits<type>::max(), "Value is too large."); \
263 element = static_cast<type>(tmp_value); \
268 #undef ARILES2_BASIC_TYPE
Wrapper of std::basic_istream into RapidJSON's Stream concept.
::rapidjson::Document document_
instance of the parser
bool startIteratedMapElement(std::string &entry_name)
void endIteratedMapElement()
void endMapEntry()
endMapEntry from the current entry to its parent.
bool startIteratedMap(const SizeLimitEnforcementType=SIZE_LIMIT_NONE, const std::size_t=0, const std::size_t=0)
void startMap(const SizeLimitEnforcementType limit_type=SIZE_LIMIT_NONE, const std::size_t min=0, const std::size_t max=0)
bool startMapEntry(const std::string &child_name)
startMapEntry to the entry with the given name
void constructFromString(const char *)
std::vector<::rapidjson::Value::ConstMemberIterator > iterator_stack_
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
void readElement(std::complex< t_Scalar > &entry)
void makeImplPtr(t_Args &&...args)
#define CPPUT_ASSERT(condition,...)
#define ARILES2_BASIC_UNSIGNED_INTEGER_TYPES_LIST
#define ARILES2_BASIC_SIGNED_INTEGER_TYPES_LIST
#define CPPUT_MACRO_SUBSTITUTE(macro)
#define CPPUT_TRACE_FUNCTION