18 #ifndef TYPE_RECORD_HH_ 19 #define TYPE_RECORD_HH_ 22 #include <boost/exception/detail/error_info_impl.hpp> 23 #include <boost/exception/info.hpp> 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);
289 Record &declare_key(
const string &key, std::shared_ptr<TypeBase> type,
290 const Default &default_value,
const string &description,
300 template <
class KeyType>
301 Record &declare_key(
const string &key,
const KeyType &type,
303 const string &description,
312 template <
class KeyType>
313 Record &declare_key(
const string &key,
const KeyType &type,
314 const string &description,
336 bool is_finished()
const override;
339 bool is_closed()
const override;
346 string type_name()
const override;
348 virtual string class_name()
const override;
360 inline unsigned int key_index(
const string& key)
const;
363 inline KeyIter key_iterator(
const string& key)
const;
370 KeyIter auto_conversion_key_iter()
const;
373 inline bool has_key_iterator(
const string& key, KeyIter &
it)
const;
380 inline KeyIter begin()
const;
387 inline KeyIter end()
const;
390 inline bool has_key(
const string& key)
const;
393 inline unsigned int size()
const;
422 virtual Record &root_of_generic_subtree();
429 ASSERT(is_finished())(this->type_name()).error();
433 void make_copy_keys(
Record &origin);
466 RecordData(
const string & type_name_in,
const string & description);
476 void declare_key(
const string &key,
477 std::shared_ptr<TypeBase> type,
479 const string &description,
542 if (it != data_->key_to_index.end())
return it->second;
544 THROW( ExcRecordKeyNotFound() << EI_KeyName(key) << EI_Record(*
this) );
555 return begin() + key_index(key);
565 if (data_it == data_->key_to_index.end()) {
568 it = begin()+data_it->second;
578 return data_->keys.begin();
586 return data_->keys.end();
593 return key_iterator(key) != end();
599 ASSERT(is_closed())(this->type_name()).error();
600 ASSERT_EQ(data_->keys.size(), data_->key_to_index.size()).error();
601 return data_->keys.size();
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
static constexpr bool value
bool operator==(const Null &, const Null &)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)