Flow123d
JS_before_hm-978-gf0793cd
|
Class Input::Type::Default
specifies default value of keys of a Input::Type::Record
.
More...
#include <type_record.hh>
Public Member Functions | |
Default (const std::string &value) | |
Constructor with given default value (at declaration time) More... | |
TypeBase::TypeHash | content_hash () const |
Hash of the Default specification, counted of type_ and value_. More... | |
bool | has_value_at_read_time () const |
Returns true if the default value is or will be available when someone tries to read the value. More... | |
bool | has_value_at_declaration () const |
Returns true if the default value is or will be available when someone tries to read the value. More... | |
bool | is_obligatory () const |
Returns true if the key is obligatory and thus must be specified on input. No default value is given. More... | |
bool | is_optional () const |
Returns true if the key is optional. More... | |
const string & | value () const |
Returns stored value. Possibly empty string. More... | |
bool | has_same_type (const Default &other) const |
Compares values type_ of two Default objects. More... | |
bool | check_validity (std::shared_ptr< TypeBase > type) const |
Check validity of value_ using the JSON reader if default type is default_at_declaration. More... | |
Input::StorageBase * | get_storage (std::shared_ptr< TypeBase > type) const |
Return storage_ , if storage_ is NULL, call check_validity method. More... | |
Static Public Member Functions | |
static Default | read_time (const std::string &description) |
The factory function to make an default value that will be specified at the time when a key will be read. More... | |
static Default | obligatory () |
The factory function to make an empty default value which is obligatory. More... | |
static Default | optional () |
The factory function to make an empty default value which is optional. More... | |
Private Types | |
enum | DefaultType { default_at_declaration, default_at_read_time, no_default_optional_type, no_default_obligatory_type } |
Possible types of default values. More... | |
Private Member Functions | |
Default () | |
Forbids default constructor. More... | |
Default (enum DefaultType type, const std::string &value) | |
Constructor for other types then 'declaration'. More... | |
Private Attributes | |
string | value_ |
Stored value. More... | |
enum DefaultType | type_ |
Type of the Default. More... | |
Input::StorageBase * | storage_ |
Storage of default value read by reader. More... | |
Friends | |
class | Record |
class | OutputBase |
Class Input::Type::Default
specifies default value of keys of a Input::Type::Record
.
It contains type of default value and possibly the value itself stored as std::string
. Currently we distinguish four cases:
Input::Type
specification. This should be preferred way to give the default value since it can by documented as part of Record type specification.Definition at line 61 of file type_record.hh.
|
private |
Possible types of default values.
Enumerator | |
---|---|
default_at_declaration |
Default value given at declaration time. |
default_at_read_time |
Some default value will be given when the key is read. The description of this value should be provided. |
no_default_optional_type |
No default value, optional key. This is default type of the Default. |
no_default_obligatory_type |
No default value, obligatory key. |
Definition at line 67 of file type_record.hh.
Input::Type::Default::Default | ( | const std::string & | value | ) |
Constructor with given default value (at declaration time)
Definition at line 42 of file type_record.cc.
|
private |
Forbids default constructor.
Definition at line 38 of file type_record.cc.
|
private |
Constructor for other types then 'declaration'.
Definition at line 50 of file type_record.cc.
bool Input::Type::Default::check_validity | ( | std::shared_ptr< TypeBase > | type | ) | const |
Check validity of value_
using the JSON reader if default type is default_at_declaration.
Definition at line 63 of file type_record.cc.
TypeBase::TypeHash Input::Type::Default::content_hash | ( | ) | const |
Hash of the Default specification, counted of type_ and value_.
Definition at line 54 of file type_record.cc.
Input::StorageBase * Input::Type::Default::get_storage | ( | std::shared_ptr< TypeBase > | type | ) | const |
Return storage_
, if storage_ is NULL, call check_validity method.
Definition at line 86 of file type_record.cc.
|
inline |
Compares values type_ of two Default objects.
Definition at line 149 of file type_record.hh.
|
inline |
Returns true if the default value is or will be available when someone tries to read the value.
Definition at line 132 of file type_record.hh.
|
inline |
Returns true if the default value is or will be available when someone tries to read the value.
Definition at line 128 of file type_record.hh.
|
inline |
Returns true if the key is obligatory and thus must be specified on input. No default value is given.
Definition at line 137 of file type_record.hh.
|
inline |
Returns true if the key is optional.
Definition at line 141 of file type_record.hh.
|
inlinestatic |
The factory function to make an empty default value which is obligatory.
This and following factory functions should be used instead of private constructors.
Example of usage:
Definition at line 110 of file type_record.hh.
|
inlinestatic |
The factory function to make an empty default value which is optional.
To get the value of such key from the input you have to use non-throwing variant of the method Input::Record::key, which returns the value through reference and allows checking presence of the key on the input.
Example of usage:
Definition at line 124 of file type_record.hh.
|
inlinestatic |
The factory function to make an default value that will be specified at the time when a key will be read.
You have to provide a string with description of the default value used at the read time., e.g. the key time_governer
of an equation can specify default value as
To get the value of such key from the input you have to use non-throwing variant of the method Input::Record::key, which returns the value through reference and allows checking presence of the key on the input.
Example of usage:
Definition at line 97 of file type_record.hh.
|
inline |
Returns stored value. Possibly empty string.
Definition at line 145 of file type_record.hh.
|
friend |
Definition at line 63 of file type_record.hh.
|
friend |
Definition at line 62 of file type_record.hh.
|
mutableprivate |
Storage of default value read by reader.
Definition at line 161 of file type_record.hh.
|
private |
Definition at line 160 of file type_record.hh.
|
private |
Stored value.
Definition at line 159 of file type_record.hh.