Flow123d
3.9.0-91c6c0b35
|
Base abstract class used by ReaderToStorage class to iterate over the input tree. More...
#include <path_base.hh>
Public Member Functions | |
TYPEDEF_ERR_INFO (EI_ErrorAddress, std::string) | |
TYPEDEF_ERR_INFO (EI_RefAddress, std::string) | |
TYPEDEF_ERR_INFO (EI_JsonFile, std::string) | |
TYPEDEF_ERR_INFO (EI_RefStr, std::string) | |
TYPEDEF_ERR_INFO (EI_Specification, std::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) | |
virtual | ~PathBase () |
Must have virtual destructor to call the right one form child. More... | |
virtual int | level () const =0 |
Returns level of actual path. More... | |
virtual PathBase * | find_ref_node ()=0 |
Check if current head node is containing one key REF of type string. More... | |
virtual PathBase * | clone () const =0 |
Create copy of derived class. More... | |
void | output (std::ostream &stream) const |
Output to the given stream. More... | |
virtual bool | is_null_type () const =0 |
Check if type of head node is null. More... | |
virtual bool | get_bool_value () const =0 |
Get boolean value of head node or throw exception. More... | |
virtual std::int64_t | get_int_value () const =0 |
Get integer value of head node or throw exception. More... | |
virtual double | get_double_value () const =0 |
Get double value of head node or throw exception. More... | |
virtual std::string | get_string_value () const =0 |
Get string value of head node or throw exception. More... | |
std::string | get_node_type (unsigned int type_idx) const |
Get short string description of node type, method is used for printout of messages. More... | |
virtual unsigned int | get_node_type_index () const =0 |
Get index of head type, value corresponds with order in json_type_names vector. More... | |
virtual bool | get_record_key_set (std::set< std::string > &) const =0 |
Get set of keys of head type record, if head type is not record return false. More... | |
virtual bool | is_effectively_null () const =0 |
Check empty Input Type Record, necessary for correct proccess of YAML output, for JSON has no effect. More... | |
virtual int | get_array_size () const =0 |
Get size of array (sequence type), if object is not array return -1. More... | |
virtual bool | is_record_type () const =0 |
Check if type of head node is record. More... | |
virtual bool | is_array_type () const =0 |
Check if type of head node is array. More... | |
virtual bool | down (unsigned int index)=0 |
Dive one level down into path hierarchy. More... | |
virtual bool | down (const std::string &key, int index=-1)=0 |
Dive one level down into path hierarchy. More... | |
virtual void | up ()=0 |
Return one level up in the hierarchy. More... | |
void | go_to_root () |
Move to root node. More... | |
std::string | as_string () const |
Returns string address of current position. More... | |
virtual std::string | get_record_tag () const =0 |
Gets value of the record tag, which determines its type. More... | |
Protected Member Functions | |
PathBase () | |
Forbid default constructor. More... | |
Protected Attributes | |
std::vector< std::pair< int, std::string > > | path_ |
One level of the path_ is either index (nonnegative int) in array or string key in a json object. More... | |
std::vector< std::string > | json_type_names |
Names of all possible node types in parsed input tree. More... | |
Friends | |
class | ReaderInternalCsvInclude |
Base abstract class used by ReaderToStorage class to iterate over the input tree.
Currently this class has two descendants
Definition at line 41 of file path_base.hh.
|
inlinevirtual |
Must have virtual destructor to call the right one form child.
Definition at line 60 of file path_base.hh.
|
protected |
Forbid default constructor.
Definition at line 26 of file path_base.cc.
string Input::PathBase::as_string | ( | ) | const |
Returns string address of current position.
Definition at line 48 of file path_base.cc.
|
pure virtual |
Create copy of derived class.
Implemented in Input::PathYAML, and Input::PathJSON.
Input::PathBase::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 | |||
) |
Input::PathBase::DECLARE_INPUT_EXCEPTION | ( | ExcRefOfWrongType | , |
<< "Reference at address "<< EI_ErrorAddress::qval<< " has wrong | type, | ||
should by string." | |||
) |
|
pure virtual |
Dive one level down into path hierarchy.
Store current path and returns true if pointer to new node is not NULL.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Dive one level down into path hierarchy.
Store current path and returns true if pointer to new node is not NULL.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Check if current head node is containing one key REF of type string.
If yes, creates a new path object given by address string possibly relative to the current path. In other else return NULL.
This method has the meaning only for JSON. For YAML (YAML has native references) return always NULL.
Implemented in Input::PathJSON, and Input::PathYAML.
|
pure virtual |
Get size of array (sequence type), if object is not array return -1.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Get boolean value of head node or throw exception.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Get double value of head node or throw exception.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Get integer value of head node or throw exception.
Implemented in Input::PathYAML, and Input::PathJSON.
std::string Input::PathBase::get_node_type | ( | unsigned int | type_idx | ) | const |
Get short string description of node type, method is used for printout of messages.
Definition at line 64 of file path_base.cc.
|
pure virtual |
Get index of head type, value corresponds with order in json_type_names
vector.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Get set of keys of head type record, if head type is not record return false.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Gets value of the record tag, which determines its type.
Typically is used for getting descendant or for include of other input file.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Get string value of head node or throw exception.
Implemented in Input::PathYAML, and Input::PathJSON.
void Input::PathBase::go_to_root | ( | ) |
Move to root node.
Definition at line 56 of file path_base.cc.
|
pure virtual |
Check if type of head node is array.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Check empty Input Type Record, necessary for correct proccess of YAML output, for JSON has no effect.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Check if type of head node is null.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Check if type of head node is record.
Implemented in Input::PathYAML, and Input::PathJSON.
|
pure virtual |
Returns level of actual path.
Root has level == 0.
Implemented in Input::PathJSON, and Input::PathYAML.
void Input::PathBase::output | ( | std::ostream & | stream | ) | const |
Output to the given stream.
Definition at line 31 of file path_base.cc.
Input::PathBase::TYPEDEF_ERR_INFO | ( | EI_ErrorAddress | , |
std::string | |||
) |
Thrown if a reference in the input file
Input::PathBase::TYPEDEF_ERR_INFO | ( | EI_JsonFile | , |
std::string | |||
) |
Input::PathBase::TYPEDEF_ERR_INFO | ( | EI_RefAddress | , |
std::string | |||
) |
Input::PathBase::TYPEDEF_ERR_INFO | ( | EI_RefStr | , |
std::string | |||
) |
Input::PathBase::TYPEDEF_ERR_INFO | ( | EI_Specification | , |
std::string | |||
) |
|
pure virtual |
Return one level up in the hierarchy.
Implemented in Input::PathYAML, and Input::PathJSON.
|
friend |
Definition at line 177 of file path_base.hh.
|
protected |
Names of all possible node types in parsed input tree.
Names are provided by JSON Spirit or YAML-cpp library. Initialized in constructor.
Definition at line 175 of file path_base.hh.
|
protected |
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 166 of file path_base.hh.