Flow123d
master-f44eb46
|
Reader for (slightly) modified input files. More...
#include <reader_to_storage.hh>
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 > | |
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 | |
StorageBase * | get_storage () |
Getter for root of the storage tree. More... | |
Protected Attributes | |
StorageBase * | storage_ |
Storage of the read and checked input data. More... | |
const Type::TypeBase * | root_type_ |
Root of the declaration tree of the data in the storage. More... | |
Friends | |
class | Type::Default |
class | ReaderInternalBase |
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:
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.
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.
T Input::ReaderToStorage::get_root_interface |
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.
|
protected |
Getter for root of the storage tree.
Definition at line 103 of file reader_to_storage.cc.
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.
|
friend |
Definition at line 146 of file reader_to_storage.hh.
|
friend |
Definition at line 145 of file reader_to_storage.hh.
|
protected |
Root of the declaration tree of the data in the storage.
Definition at line 143 of file reader_to_storage.hh.
|
protected |
Storage of the read and checked input data.
Definition at line 140 of file reader_to_storage.hh.