Flow123d
master-92884d111
|
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 |
virtual string | input_type_name () |
Protected Member Functions | |
void | set_address (const Address &address) |
virtual Type::Record::KeyIter | get_type_key_iterator (const string &key) const |
Return iterator to Type::Record key of given name. More... | |
Protected Attributes | |
Address | address_ |
Contains address and relationships with record ancestor. More... | |
Private Attributes | |
Input::Type::Record | record_type_ |
Corresponding Type::Record object. More... | |
Friends | |
class | ReaderToStorage |
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 291 of file accessors.hh.
typedef ::Input::Type::Record Input::Record::InputType |
Definition at line 294 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 158 of file accessors.cc.
Input::Record::Record | ( | const Record & | rec | ) |
Copy constructor.
Definition at line 164 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 170 of file accessors.cc.
string Input::Record::address_string | ( | ) | const |
Get address as string.
Definition at line 184 of file accessors.cc.
Input::EI_Address Input::Record::ei_address | ( | ) | const |
Returns address error info.
Definition at line 178 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 91 of file accessors_impl.hh.
|
protectedvirtual |
Return iterator to Type::Record key of given name.
Reimplemented in Input::Tuple.
Definition at line 195 of file accessors.cc.
|
virtual |
Get name of record_type_
Reimplemented in Input::Tuple.
Definition at line 189 of file accessors.cc.
|
inline |
Returns true if the accessor is empty (after default constructor). TODO: have something similar for other accessors.
Definition at line 365 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 107 of file accessors_impl.hh.
|
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 31 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 60 of file accessors_impl.hh.
|
friend |
Definition at line 401 of file accessors.hh.
|
friend |
Definition at line 390 of file accessors.hh.
|
protected |
Contains address and relationships with record ancestor.
Definition at line 396 of file accessors.hh.
|
private |
Corresponding Type::Record object.
Definition at line 400 of file accessors.hh.