11#include <boost/math/special_functions.hpp>
18 namespace ns_nlohmann_json
31 template <
class... t_Args>
51 namespace ns_nlohmann_json
71 impl_->document_ = ::nlohmann::ordered_json::parse(input_string);
83 const ::nlohmann::ordered_json &obj =
impl_->getRawNode();
84 const ::nlohmann::ordered_json::const_iterator child = obj.find(child_name);
86 if (obj.end() == child)
90 impl_->emplace(&child.value());
102 const std::size_t min,
103 const std::size_t max)
106 const ::nlohmann::ordered_json &obj =
impl_->getRawNode();
107 checkSize(limit_type, obj.size(), min, max);
110 if (
impl_->getRawNode().is_object())
112 impl_->iterator_stack_.push_back(obj.begin());
120 const auto ¤t_iter =
impl_->iterator_stack_.back();
121 if (current_iter !=
impl_->getRawNode().end())
123 impl_->emplace(¤t_iter.value());
124 entry_name = current_iter.key();
132 ++
impl_->iterator_stack_.back();
138 CPPUT_ASSERT(
impl_->iterator_stack_.back() ==
impl_->getRawNode().end(),
"End of iterated map has not been reached.");
139 impl_->iterator_stack_.pop_back();
145 const std::size_t size =
impl_->getRawNode().size();
146 impl_->emplace(0, size);
155 "Internal error: array has more elements than expected.");
173 element =
impl_->getRawNode().get<std::string>();
179 element =
impl_->getRawNode().get<
bool>();
185 float tmp_value = 0.0;
186 if (
impl_->getRawNode().is_string())
188 tmp_value = boost::lexical_cast<float>(
impl_->getRawNode().get<std::string>());
189 if (boost::math::isnan(tmp_value))
191 element = std::numeric_limits<float>::signaling_NaN();
194 if (boost::math::isinf(tmp_value))
202 tmp_value =
static_cast<float>(
impl_->getRawNode().get<
double>());
205 tmp_value <= std::numeric_limits<float>::max() && tmp_value >= -std::numeric_limits<float>::max(),
206 "Value is out of range.");
213 double tmp_value = 0.0;
214 if (
impl_->getRawNode().is_string())
216 tmp_value = boost::lexical_cast<double>(
impl_->getRawNode().get<std::string>());
217 if (boost::math::isnan(tmp_value))
219 element = std::numeric_limits<double>::signaling_NaN();
222 if (boost::math::isinf(tmp_value))
230 tmp_value =
impl_->getRawNode().get<
double>();
233 tmp_value <= std::numeric_limits<double>::max() && tmp_value >= -std::numeric_limits<double>::max(),
234 "Value is out of range.");
239#define ARILES2_BASIC_TYPE(type) \
240 void Reader::readElement(type &element) \
242 const int64_t tmp_value = impl_->getRawNode().get<int64_t>(); \
244 tmp_value <= std::numeric_limits<type>::max() && tmp_value >= std::numeric_limits<type>::min(), \
245 "Value is out of range."); \
246 element = static_cast<type>(tmp_value); \
251#undef ARILES2_BASIC_TYPE
254#define ARILES2_BASIC_TYPE(type) \
255 void Reader::readElement(type &element) \
257 const uint64_t tmp_value = impl_->getRawNode().get<uint64_t>(); \
258 CPPUT_ASSERT(tmp_value <= std::numeric_limits<type>::max(), "Value is too large."); \
259 element = static_cast<type>(tmp_value); \
264#undef ARILES2_BASIC_TYPE
::nlohmann::ordered_json document_
instance of the JSON value
bool startIteratedMapElement(std::string &entry_name)
bool startMapEntry(const std::string &child_name)
startMapEntry to the entry with the given name
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)
void endMapEntry()
endMapEntry from the current entry to its parent.
void constructFromString(const char *)
void endIteratedMapElement()
std::vector<::nlohmann::ordered_json::const_iterator > 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