17 namespace ns_rapidjson
27 document_.ParseStream(isw);
28 ARILES_ASSERT(
false == document_.HasParseError(),
"Parsing failed");
39 namespace ns_rapidjson
43 std::ifstream config_ifs;
46 impl_->initialize(config_ifs);
53 impl_->initialize(input_stream);
60 impl_->document_.Parse(input_string);
66 return (
impl_->getRawNode().MemberCount());
73 const ::rapidjson::Value::ConstMemberIterator child =
impl_->getRawNode().FindMember(child_name.c_str());
75 if (
impl_->getRawNode().MemberEnd() == child)
89 impl_->node_stack_.pop_back();
95 const ::rapidjson::Value &selected_node =
impl_->getRawNode();
97 if (
false == selected_node.IsObject())
103 child_names.resize(selected_node.MemberCount());
106 for (::rapidjson::Value::ConstMemberIterator it = selected_node.MemberBegin();
107 it != selected_node.MemberEnd();
110 child_names[i] = it->name.GetString();
119 std::size_t size =
impl_->getRawNode().Size();
128 ARILES_ASSERT(
true ==
impl_->node_stack_.back().isArray(),
"Internal error: expected array.");
130 impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_,
131 "Internal error: array has more elements than expected.");
132 ++
impl_->node_stack_.back().index_;
138 impl_->node_stack_.pop_back();
142 void Reader::readElement(std::string &element)
144 element =
impl_->getRawNode().GetString();
148 void Reader::readElement(
bool &element)
150 element =
impl_->getRawNode().GetBool();
154 void Reader::readElement(
float &element)
157 if (
true ==
impl_->getRawNode().IsString())
159 tmp_value = boost::lexical_cast<float>(
impl_->getRawNode().GetString());
160 if (
true == ariles::isNaN(tmp_value))
162 element = std::numeric_limits<float>::signaling_NaN();
165 if (
true == ariles::isInfinity(tmp_value))
167 element = static_cast<float>(tmp_value);
173 tmp_value =
impl_->getRawNode().GetDouble();
177 tmp_value <= std::numeric_limits<float>::max() && tmp_value >= -std::numeric_limits<float>::max(),
178 "Value is out of range.");
179 element = static_cast<float>(tmp_value);
183 void Reader::readElement(
double &element)
186 if (
true ==
impl_->getRawNode().IsString())
188 tmp_value = boost::lexical_cast<double>(
impl_->getRawNode().GetString());
189 if (
true == ariles::isNaN(tmp_value))
191 element = std::numeric_limits<double>::signaling_NaN();
194 if (
true == ariles::isInfinity(tmp_value))
196 element = static_cast<double>(tmp_value);
202 tmp_value =
impl_->getRawNode().GetDouble();
205 tmp_value <= std::numeric_limits<double>::max() && tmp_value >= -std::numeric_limits<double>::max(),
206 "Value is out of range.");
207 element = static_cast<double>(tmp_value);
211 #define ARILES_BASIC_TYPE(type) \ 212 void Reader::readElement(type &element) \ 214 int64_t tmp_value = impl_->getRawNode().GetInt64(); \ 216 tmp_value <= std::numeric_limits<type>::max() && tmp_value >= std::numeric_limits<type>::min(), \ 217 "Value is out of range."); \ 218 element = static_cast<type>(tmp_value); \ 223 #undef ARILES_BASIC_TYPE 226 #define ARILES_BASIC_TYPE(type) \ 227 void Reader::readElement(type &element) \ 229 uint64_t tmp_value = impl_->getRawNode().GetUint64(); \ 230 ARILES_ASSERT(tmp_value <= std::numeric_limits<type>::max(), "Value is too large."); \ 231 element = static_cast<type>(tmp_value); \ 236 #undef ARILES_BASIC_TYPE
bool descend(const std::string &child_name)
void constructFromString(const char *)
#define ARILES_BASIC_UNSIGNED_INTEGER_TYPES_LIST
std::size_t getMapSize(const bool)
void initialize(std::istream &input_stream)
static void openFile(std::ifstream &config_ifs, const std::string &file_name)
open configuration file
ARILES_SHARED_PTR< t_Implementation > ImplPtr
#define ARILES_BASIC_SIGNED_INTEGER_TYPES_LIST
Reader(const Flags &flags=Flags::DEFAULT)
ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_SIGNED_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_UNSIGNED_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_REAL_TYPES_LIST) void Reader
bool getMapEntryNames(std::vector< std::string > &child_names)
Wrapper of std::basic_istream into RapidJSON's Stream concept.
#define ARILES_VISIBILITY_ATTRIBUTE