18 #ifndef TYPE_RECORD_HH_
19 #define TYPE_RECORD_HH_
26 namespace Input {
class StorageBase; }
71 no_default_obligatory_type
98 {
return Default(default_at_read_time, description ); }
111 {
return Default(no_default_obligatory_type,
"OBLIGATORY"); }
125 {
return Default(no_default_optional_type,
"OPTIONAL"); }
129 {
return (type_ == default_at_read_time); }
133 {
return (type_ == default_at_declaration); }
138 {
return (type_ == no_default_obligatory_type); }
142 {
return (type_ == no_default_optional_type); }
150 {
return type_ == other.
type_; }
153 bool check_validity(std::shared_ptr<TypeBase> type)
const;
193 DECLARE_EXCEPTION( ExcRecordKeyNotFound, <<
"Key " << EI_KeyName::qval <<
" not found in Record:\n" << EI_Record::val );
234 Record(
const string & type_name_in,
const string & description);
242 virtual TypeHash content_hash()
const override;
276 virtual Record &allow_auto_conversion(
const string &from_key);
293 Record &declare_key(
const string &key, std::shared_ptr<TypeBase> type,
294 const Default &default_value,
const string &description,
304 template <
class KeyType>
305 Record &declare_key(
const string &key,
const KeyType &type,
307 const string &description,
316 template <
class KeyType>
317 Record &declare_key(
const string &key,
const KeyType &type,
318 const string &description,
340 bool is_finished()
const override;
343 bool is_closed()
const override;
350 string type_name()
const override;
352 virtual string class_name()
const override;
364 inline unsigned int key_index(
const string& key)
const;
367 inline KeyIter key_iterator(
const string& key)
const;
374 KeyIter auto_conversion_key_iter()
const;
377 inline bool has_key_iterator(
const string& key,
KeyIter &
it)
const;
394 inline bool has_key(
const string& key)
const;
397 inline unsigned int size()
const;
426 virtual Record &root_of_generic_subtree();
433 ASSERT(is_finished())(this->type_name()).error();
437 void make_copy_keys(
Record &origin);
470 RecordData(
const string & type_name_in,
const string & description);
480 void declare_key(
const string &key,
481 std::shared_ptr<TypeBase> type,
483 const string &description,
546 if (
it != data_->key_to_index.end())
return it->second;
548 THROW( ExcRecordKeyNotFound() << EI_KeyName(key) << EI_Record(*
this) );
559 return begin() + key_index(key);
569 if (data_it == data_->key_to_index.end()) {
572 it = begin()+data_it->second;
582 return data_->keys.begin();
590 return data_->keys.end();
597 return key_iterator(key) != end();
603 ASSERT(is_closed())(this->type_name()).error();
604 ASSERT_EQ(data_->keys.size(), data_->key_to_index.size()).error();
605 return data_->keys.size();
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
static constexpr bool value
bool operator==(const Null &, const Null &)