Go to the documentation of this file.
26 #include <boost/iostreams/device/file.hpp>
27 #include <boost/iostreams/filtering_stream.hpp>
28 #include <boost/algorithm/string.hpp>
38 io::filtering_istream filter_in;
43 root_node_ = std::make_shared<Node>();
48 THROW( ReaderInternalBase::ExcNotJSONFormat() << ReaderInternalBase::EI_JSONLine(e.
line_) << ReaderInternalBase::EI_JSONColumn(e.
column_)
49 << ReaderInternalBase::EI_JSONReason(e.
reason_));
52 nodes_.push_back( root_node_.get() );
85 path_.push_back( make_pair( index,
string(
"") ) );
96 json_spirit::mObject::const_iterator
it = obj.find(key);
97 if (
it == obj.end()) {
100 path_.push_back( make_pair( index, key) );
101 nodes_.push_back( &(
it->second ) );
109 if (
path_.size() > 1) {
122 namespace ba = boost::algorithm;
127 if (obj.size() != 1)
return NULL;
128 if (obj.begin()->first !=
"REF")
return NULL;
130 const Node &ref_node = obj.begin()->second;
132 THROW( ExcRefOfWrongType() << EI_ErrorAddress(this->
as_string()) );
135 string ref_address = ref_node.
get_str();
138 string::size_type pos = 0;
139 string::size_type new_pos = 0;
140 string address = ref_address +
'/';
142 bool relative_ref =
false;
148 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
149 << EI_Specification(
"cannot follow reference") );
152 while ( ( new_pos=address.find(
'/',pos) ) != string::npos ) {
153 tmp_str = address.substr(pos, new_pos - pos);
154 if (pos==0 && tmp_str ==
"") {
158 }
else if (
ba::all( tmp_str, ba::is_digit()) ) {
161 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
162 << EI_Specification(
"there should be Array") );
165 if ( !ref_path->
down( atoi(tmp_str.c_str()) ) ) {
166 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
167 << EI_Specification(
"index out of size of Array") );
170 }
else if (tmp_str ==
"..") {
172 if (ref_path->
level() <= 0 ) {
173 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
174 << EI_Specification(
"can not go up from root") );
180 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
181 << EI_Specification(
"there should be Record") );
182 if ( !ref_path->
down(tmp_str) )
183 THROW( ExcReferenceNotFound() << EI_RefAddress(this->
as_string()) << EI_ErrorAddress(ref_path->
as_string()) << EI_RefStr(ref_address)
184 << EI_Specification(
"key '"+tmp_str+
"' not found") );
205 THROW( ReaderInternalBase::ExcInputError() );
216 THROW( ReaderInternalBase::ExcInputError() );
229 THROW( ReaderInternalBase::ExcInputError() );
240 THROW( ReaderInternalBase::ExcInputError() );
256 json_spirit::mObject::const_iterator map_it;
257 std::set<string>::iterator set_it;
259 for( map_it = j_map.begin(); map_it != j_map.end(); ++map_it) {
260 keys_list.insert(map_it->first);
274 return j_array.size();
301 std::string tag_value;
304 if ( type_path.
down(
"TYPE") ) {
const Array & get_array() const
const Object & get_obj() const
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
void read_or_throw(const std::string &s, mValue &value)
boost::int64_t get_int64() const
unsigned int size() const
const String_type & get_str() const
#define MessageOut()
Macro defining 'message' record of log.