Flow123d  JS_before_hm-978-gf0793cd
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Input::PathBase Class Referenceabstract

Base abstract class used by ReaderToStorage class to iterate over the input tree. More...

#include <path_base.hh>

Inheritance diagram for Input::PathBase:
Inheritance graph
[legend]
Collaboration diagram for Input::PathBase:
Collaboration graph
[legend]

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 PathBasefind_ref_node ()=0
 Check if current head node is containing one key REF of type string. More...
 
virtual PathBaseclone () 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
 

Detailed Description

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.

Constructor & Destructor Documentation

virtual Input::PathBase::~PathBase ( )
inlinevirtual

Must have virtual destructor to call the right one form child.

Definition at line 60 of file path_base.hh.

Input::PathBase::PathBase ( )
protected

Forbid default constructor.

Definition at line 26 of file path_base.cc.

Here is the caller graph for this function:

Member Function Documentation

string Input::PathBase::as_string ( ) const

Returns string address of current position.

Definition at line 48 of file path_base.cc.

Here is the caller graph for this function:

virtual PathBase* Input::PathBase::clone ( ) const
pure virtual

Create copy of derived class.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

Input::PathBase::DECLARE_INPUT_EXCEPTION ( ExcRefOfWrongType  ,
<< "Reference at address "<< EI_ErrorAddress::qval<< " has wrong  type,
should by string."   
)
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   
)
virtual bool Input::PathBase::down ( unsigned int  index)
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.

Here is the caller graph for this function:

virtual bool Input::PathBase::down ( const std::string &  key,
int  index = -1 
)
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.

virtual PathBase* Input::PathBase::find_ref_node ( )
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.

Here is the caller graph for this function:

virtual int Input::PathBase::get_array_size ( ) const
pure virtual

Get size of array (sequence type), if object is not array return -1.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual bool Input::PathBase::get_bool_value ( ) const
pure virtual

Get boolean value of head node or throw exception.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual double Input::PathBase::get_double_value ( ) const
pure virtual

Get double value of head node or throw exception.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual std::int64_t Input::PathBase::get_int_value ( ) const
pure virtual

Get integer value of head node or throw exception.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

virtual unsigned int Input::PathBase::get_node_type_index ( ) const
pure virtual

Get index of head type, value corresponds with order in json_type_names vector.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual bool Input::PathBase::get_record_key_set ( std::set< std::string > &  ) const
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.

Here is the caller graph for this function:

virtual std::string Input::PathBase::get_record_tag ( ) const
pure virtual

Gets value of the record tag, which determines its type.

  • for JSON gets value of TYPE key
  • for YAML gets value of tag

Typically is used for getting descendant or for include of other input file.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual std::string Input::PathBase::get_string_value ( ) const
pure virtual

Get string value of head node or throw exception.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

void Input::PathBase::go_to_root ( )

Move to root node.

Definition at line 56 of file path_base.cc.

Here is the caller graph for this function:

virtual bool Input::PathBase::is_array_type ( ) const
pure virtual

Check if type of head node is array.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual bool Input::PathBase::is_effectively_null ( ) const
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.

Here is the caller graph for this function:

virtual bool Input::PathBase::is_null_type ( ) const
pure virtual

Check if type of head node is null.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual bool Input::PathBase::is_record_type ( ) const
pure virtual

Check if type of head node is record.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

virtual int Input::PathBase::level ( ) const
pure virtual

Returns level of actual path.

Root has level == 0.

Implemented in Input::PathJSON, and Input::PathYAML.

Here is the caller graph for this function:

void Input::PathBase::output ( std::ostream &  stream) const

Output to the given stream.

Definition at line 31 of file path_base.cc.

Here is the caller graph for this function:

Input::PathBase::TYPEDEF_ERR_INFO ( EI_ErrorAddress  ,
std::string   
)

Thrown if a reference in the input file

Input::PathBase::TYPEDEF_ERR_INFO ( EI_RefAddress  ,
std::string   
)
Input::PathBase::TYPEDEF_ERR_INFO ( EI_JsonFile  ,
std::string   
)
Input::PathBase::TYPEDEF_ERR_INFO ( EI_RefStr  ,
std::string   
)
Input::PathBase::TYPEDEF_ERR_INFO ( EI_Specification  ,
std::string   
)
virtual void Input::PathBase::up ( )
pure virtual

Return one level up in the hierarchy.

Implemented in Input::PathYAML, and Input::PathJSON.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ReaderInternalCsvInclude
friend

Definition at line 177 of file path_base.hh.

Member Data Documentation

std::vector<std::string> Input::PathBase::json_type_names
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.

std::vector< std::pair<int, std::string> > Input::PathBase::path_
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.


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