Flow123d  jenkins-Flow123d-windows32-release-multijob-51
Public Types | Public Member Functions | Private Attributes | List of all members
Input::JSONPath Class Reference

Class used by JSONToStorage class to iterate over the JSON tree provided by json_spirit library. More...

#include <json_to_storage.hh>

Collaboration diagram for Input::JSONPath:
Collaboration graph
[legend]

Public Types

typedef json_spirit::mValue Node
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_ErrorAddress, JSONPath)
 
 TYPEDEF_ERR_INFO (EI_RefAddress, JSONPath)
 
 TYPEDEF_ERR_INFO (EI_JsonFile, const string)
 
 TYPEDEF_ERR_INFO (EI_RefStr, const string)
 
 TYPEDEF_ERR_INFO (EI_Specification, const string)
 
 DECLARE_INPUT_EXCEPTION (ExcRefOfWrongType,<< "Reference at address "<< EI_ErrorAddress::qval<< " has wrong type, should by string.")
 
 DECLARE_INPUT_EXCEPTION (ExcReferenceNotFound,<< "Error in input file: "<< EI_JsonFile::qval<< "\nReference {REF=\""<< EI_RefStr::val<< "\"} at address "<< EI_RefAddress::qval<< " not found.\n"<< "failed to follow at address: "<< EI_ErrorAddress::qval<< " because "<< EI_Specification::val)
 
 JSONPath (const Node &root_node)
 
const Nodedown (unsigned int index)
 
const Nodedown (const string &key)
 
void up ()
 
void go_to_root ()
 
const Nodehead () const
 
int level () const
 
bool get_ref_from_head (string &ref_address)
 
JSONPath find_ref_node (const string &ref_address)
 
void output (ostream &stream) const
 
string str ()
 
void put_address ()
 

Private Attributes

vector< pair< int, string > > path_
 
vector< const Node * > nodes_
 
std::set< string > previous_references_
 

Detailed Description

Class used by JSONToStorage class to iterate over the JSON tree provided by json_spirit library.

This class keeps whole path from the root of the JSON tree to the current node. We store nodes along path in nodes_ and address of the node in path_.

The class also contains methods for processing of special keys 'REF' and 'TYPE'. The reference is record with only one key 'REF' with a string value that contains address of the reference. The string with the address is extracted by JSONToStorage::get_ref_from_head then the JSONPath corresponding to the address is provided by method JSONtoStorage::find_ref_node.

Definition at line 50 of file json_to_storage.hh.

Member Typedef Documentation

Definition at line 70 of file json_to_storage.hh.

Constructor & Destructor Documentation

Input::JSONPath::JSONPath ( const Node root_node)

Definition at line 27 of file json_to_storage.cc.

Member Function Documentation

Input::JSONPath::DECLARE_INPUT_EXCEPTION ( ExcRefOfWrongType  ,
<< "Reference at address "<< EI_ErrorAddress::qval<< " has wrong  type,
should by string."   
)
Input::JSONPath::DECLARE_INPUT_EXCEPTION ( ExcReferenceNotFound  ,
<< "Error in input file: "<< EI_JsonFile::qval<< "\nReference {REF=\""<< EI_RefStr::val<< "\"} at address "<< EI_RefAddress::qval<< " not found.\n"<< "failed to follow at address: "<< EI_ErrorAddress::qval<< " because "<< EI_Specification::val   
)
const JSONPath::Node * Input::JSONPath::down ( unsigned int  index)

Dive into json_spirit hierarchy. Store current path and returns pointer to new json_spirit node. If the json_spirit type do not match returns NULL.

Definition at line 33 of file json_to_storage.cc.

Here is the caller graph for this function:

const JSONPath::Node * Input::JSONPath::down ( const string &  key)

Definition at line 46 of file json_to_storage.cc.

JSONPath Input::JSONPath::find_ref_node ( const string &  ref_address)

Creates a new JSONPath object given by address string possibly relative to the current path.

This returns path to reference given by address in ref_address.

Definition at line 98 of file json_to_storage.cc.

Here is the caller graph for this function:

bool Input::JSONPath::get_ref_from_head ( string &  ref_address)

Check if current head node is a JSON Object containing one key REF of type string. If yes, returns the string through reference ref_address.

Definition at line 76 of file json_to_storage.cc.

Here is the caller graph for this function:

void Input::JSONPath::go_to_root ( )

Move to root node.

Definition at line 70 of file json_to_storage.cc.

Here is the caller graph for this function:

const Node* Input::JSONPath::head ( ) const
inline

Pointer to JSON Value object at current path.

Definition at line 94 of file json_to_storage.hh.

Here is the caller graph for this function:

int Input::JSONPath::level ( ) const
inline

Returns level of actual path. Root has level == 0.

Definition at line 100 of file json_to_storage.hh.

Here is the caller graph for this function:

void Input::JSONPath::output ( ostream &  stream) const

Output to the given stream.

Definition at line 162 of file json_to_storage.cc.

Here is the caller graph for this function:

void Input::JSONPath::put_address ( )

Put actual address to previous_references_ set

Definition at line 187 of file json_to_storage.cc.

string Input::JSONPath::str ( )

Returns string address of current position.

Definition at line 179 of file json_to_storage.cc.

Here is the caller graph for this function:

Input::JSONPath::TYPEDEF_ERR_INFO ( EI_ErrorAddress  ,
JSONPath   
)

Thrown if a reference in the input file

Input::JSONPath::TYPEDEF_ERR_INFO ( EI_RefAddress  ,
JSONPath   
)
Input::JSONPath::TYPEDEF_ERR_INFO ( EI_JsonFile  ,
const string   
)
Input::JSONPath::TYPEDEF_ERR_INFO ( EI_RefStr  ,
const string   
)
Input::JSONPath::TYPEDEF_ERR_INFO ( EI_Specification  ,
const string   
)
void Input::JSONPath::up ( )

Return one level up in the hierrarchy.

Definition at line 62 of file json_to_storage.cc.

Here is the caller graph for this function:

Member Data Documentation

vector<const Node *> Input::JSONPath::nodes_
private

Definition at line 137 of file json_to_storage.hh.

vector< pair<int, string> > Input::JSONPath::path_
private

One level of the path_ is either index (nonnegative int) in array or string key in a json object. For the first type we save index into first part of the pair and empty string to the second. For the later type of level, we save -1 for index and the key into the secodn part of the pair.

Definition at line 136 of file json_to_storage.hh.

std::set<string> Input::JSONPath::previous_references_
private

Definition at line 138 of file json_to_storage.hh.


The documentation for this class was generated from the following files: