Flow123d  JS_before_hm-989-g79825ac
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Input::ReaderToStorage Class Reference

Reader for (slightly) modified input files. More...

#include <reader_to_storage.hh>

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

Public Member Functions

 ReaderToStorage (const FilePath &in_file, Type::TypeBase &root_type)
 Read a storage from input stream. More...
 
 ReaderToStorage (const string &default_str, Type::TypeBase &root_type, FileFormat format)
 Read a storage from string (e.g. complex default value). More...
 
template<class T >
get_root_interface () const
 Returns the root accessor. More...
 
 ReaderToStorage ()
 Default constructor. More...
 
void read_stream (istream &in, const Type::TypeBase &root_type, FileFormat format)
 This method actually reads the given stream in. More...
 

Protected Member Functions

StorageBaseget_storage ()
 Getter for root of the storage tree. More...
 

Protected Attributes

StorageBasestorage_
 Storage of the read and checked input data. More...
 
const Type::TypeBaseroot_type_
 Root of the declaration tree of the data in the storage. More...
 

Friends

class Type::Default
 
class ReaderInternalBase
 

Detailed Description

Reader for (slightly) modified input files.

This class implements a reader of modified input file format (JSON or YAML). The modifications include shell-like comments (using hash '#' character), this is implemented in comment_filter.hh, optional quoting of keys in JSON objects that do not contain spaces, and possibility to use '=' instead of ':'. So you can write:

{ key1="text", key2=2, "key 3"=4 }

Note, however, that our input interface allows only C identifiers for keys. The reader use json_spirit library (based on Spirit parser from Boost) with slightly modified grammar.

The input file is at first read and parsed by json_spirit. Then ReaderToStorage pass through tree with parsed data along with passing through declaration tree. The input data are check against declaration and stored in the Storage tree.

Accessor to the root record is provided by ReaderToStorage::get_root_interface<T> method template.

Definition at line 96 of file reader_to_storage.hh.

Constructor & Destructor Documentation

Input::ReaderToStorage::ReaderToStorage ( const FilePath in_file,
Type::TypeBase root_type 
)

Read a storage from input stream.

Parameter root_type provides input type tree declaration. See read_from_stream for details.

Definition at line 58 of file reader_to_storage.cc.

Input::ReaderToStorage::ReaderToStorage ( const string &  default_str,
Type::TypeBase root_type,
FileFormat  format 
)

Read a storage from string (e.g. complex default value).

Definition at line 87 of file reader_to_storage.cc.

Input::ReaderToStorage::ReaderToStorage ( )

Default constructor.

Provides common initialization for public constructors.

Definition at line 51 of file reader_to_storage.cc.

Member Function Documentation

template<class T >
T Input::ReaderToStorage::get_root_interface ( ) const

Returns the root accessor.

The template type T should correspond to the kind of the input type at root of the declaration tree.

Definition at line 150 of file reader_to_storage.cc.

Here is the caller graph for this function:

StorageBase * Input::ReaderToStorage::get_storage ( )
protected

Getter for root of the storage tree.

Definition at line 103 of file reader_to_storage.cc.

Here is the caller graph for this function:

void Input::ReaderToStorage::read_stream ( istream &  in,
const Type::TypeBase root_type,
FileFormat  format 
)

This method actually reads the given stream in.

Checks the data just read against the declaration tree given by root_type, and store the data into private storage tree using StorageBase classes.

Definition at line 110 of file reader_to_storage.cc.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ReaderInternalBase
friend

Definition at line 146 of file reader_to_storage.hh.

friend class Type::Default
friend

Definition at line 145 of file reader_to_storage.hh.

Member Data Documentation

const Type::TypeBase* Input::ReaderToStorage::root_type_
protected

Root of the declaration tree of the data in the storage.

Definition at line 143 of file reader_to_storage.hh.

StorageBase* Input::ReaderToStorage::storage_
protected

Storage of the read and checked input data.

Definition at line 140 of file reader_to_storage.hh.


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