Flow123d
jenkins-Flow123d-linux-release-multijob-282
|
Accessor to the data with type Type::Record
.
More...
#include <accessors.hh>
Public Types | |
typedef ::Input::Type::Record | InputType |
Public Member Functions | |
Record () | |
Record (const Record &rec) | |
Record (const Address &address, const Type::Record type) | |
template<class Ret > | |
const Ret | val (const string &key) const |
template<class Ret > | |
const Ret | val (const string &key, const Ret default_val) const |
template<class Ret > | |
Iterator< Ret > | find (const string &key) const |
template<class Ret > | |
bool | opt_val (const string &key, Ret &value) const |
bool | is_empty () const |
EI_Address | ei_address () const |
string | address_string () const |
string | record_type_name () |
Protected Member Functions | |
void | set_address (const Address &address) |
Protected Attributes | |
Input::Type::Record | record_type_ |
Corresponding Type::Record object. More... | |
Address | address_ |
Contains address and relationships with record ancestor. More... | |
Friends | |
class | JSONToStorage |
class | AbstractRecord |
Accessor to the data with type Type::Record
.
This class provides access to the data through names – key of the data fields. It merge information from a Type::Record
object, which describes valid keys and their types, and reference into a StorageBase that provides access to actual values.
The keys that are obligatory or has specified default value can be read either by the method template val<OutputType>
which returns the value of type OutputType
that should be compatible with declared type (i.e. you can get unsigned int from an input value of type Type:Integer, but not from an input value of type Type::String).
The keys which are optional and has no default value you has to use the method template find<OutputType>
that returns an iterator to the type OutputType, which is invalid if the value is missing on the input and no the default string is provided.
Usage:
Definition at line 327 of file accessors.hh.
typedef ::Input::Type::Record Input::Record::InputType |
Definition at line 330 of file accessors.hh.
Input::Record::Record | ( | ) |
Default constructor.
Constructor uses empty Address which causes error in program, Address has to be filled.
Definition at line 167 of file accessors.cc.
Input::Record::Record | ( | const Record & | rec | ) |
Copy constructor.
Definition at line 173 of file accessors.cc.
Input::Record::Record | ( | const Address & | address, |
const Type::Record | type | ||
) |
Constructs the accessor providing pointer store
to storage node with list of data of the record and type specification of the record given by parameter type
.
Definition at line 179 of file accessors.cc.
string Input::Record::address_string | ( | ) | const |
Get address as string.
Definition at line 193 of file accessors.cc.
Input::EI_Address Input::Record::ei_address | ( | ) | const |
Returns address error info.
Definition at line 187 of file accessors.cc.
|
inline |
Returns iterator to the key if it exists or NULL Iterator if it doesn't. This method must be used for keys which are optional or has default value provided at read time.
Definition at line 83 of file accessors_impl.hh.
|
inline |
Returns true if the accessor is empty (after default constructor). TODO: have something similar for other accessors.
Definition at line 401 of file accessors.hh.
|
inline |
This has similar function as the previous method, but simpler usage in some cases. You has to provide reference to the variable value
where the value of an optional key
should be placed. If the key in not present in the input the value of value
is not changed and the method returns false. If the key has a value the method returns true. Typical usage:
Definition at line 99 of file accessors_impl.hh.
string Input::Record::record_type_name | ( | ) |
Get name of record_type_
Definition at line 198 of file accessors.cc.
|
protected |
Set address (currently necessary for creating root accessor)
|
inline |
Returns value of given key
if the declared key type (descendant of Input:Type:TypeBase
) is convertible to the C++ class type given as the template parameter. If the key has no defined value (either from input or a declared default value) it throws an exception. It throws also, if the declared type do not match desired C++ type.
This method can be used only for keys which are obligatory or has default value given at declaration. The optional keys must use method find
. Keys with default value at read time must use the overloaded variant of method val
or the method find
Definition at line 20 of file accessors_impl.hh.
|
inline |
Same as the previous, but you can specify default value default_val
that is used if the key is not specified at the input. This method can be used only for keys declared with Default::reat_time().
Definition at line 50 of file accessors_impl.hh.
|
friend |
Definition at line 430 of file accessors.hh.
|
friend |
Definition at line 426 of file accessors.hh.
|
protected |
Contains address and relationships with record ancestor.
Definition at line 433 of file accessors.hh.
|
protected |
Corresponding Type::Record object.
Definition at line 429 of file accessors.hh.