29 #include <boost/type_traits.hpp> 30 #include <boost/tokenizer.hpp> 31 #include <boost/shared_ptr.hpp> 32 #include <boost/make_shared.hpp> 33 #include <boost/algorithm/string.hpp> 59 DECLARE_EXCEPTION( ExcWrongDefaultJSON, <<
"Consistency Error: Not valid JSON of Default value " 60 << EI_DefaultStr::qval <<
" of type " << EI_TypeName::qval <<
";\n" 61 <<
"During declaration of the key: " << EI_KeyName::qval );
62 DECLARE_EXCEPTION( ExcWrongDefault, <<
"Consistency Error: " << EI_Desc::val <<
"Default value " 63 << EI_DefaultStr::qval <<
" do not match type: " << EI_TypeName::qval <<
";\n" 64 <<
"During declaration of the key: " << EI_KeyName::qval );
65 DECLARE_EXCEPTION( ExcUnknownDescendant, <<
"Unknown descendant of TypeBase class, name: " << EI_TypeName::qval );
90 typedef std::pair< std::string, std::shared_ptr<TypeBase> >
ParameterPair;
148 {
return typeid(*this) ==
typeid(other); }
152 {
return ! (*
this == other); }
167 static void lazy_finish();
182 virtual bool finish(
bool is_generic =
false)
192 virtual TypeHash content_hash()
const =0;
199 static std::string hash_str(TypeHash hash);
203 return hash_str(content_hash());
211 virtual MakeInstanceReturnType make_instance(ParameterVector vec = ParameterVector()) =0;
215 return root_of_generic_subtree_;
231 void add_attribute_(std::string name, json_string val);
243 inline static KeyHash
key_hash(
const string &str) {
253 static bool is_valid_identifier(
const string& key);
256 bool validate_json(json_string str)
const;
259 json_string print_parameter_map_to_json(ParameterMap parameter_map)
const;
265 json_string print_parameter_map_keys_to_json(ParameterMap param_map)
const;
271 void set_generic_attributes(ParameterMap param_map);
276 void copy_attributes(attribute_map other_attributes);
334 : lower_bound_(min_size), upper_bound_(max_size), finished(false)
337 bool finish(
bool is_generic =
false);
356 template <
class ValueType>
357 Array(
const ValueType &type,
unsigned int min_size=0,
unsigned int max_size=std::numeric_limits<unsigned int>::max() );
362 Array(std::shared_ptr<TypeBase> type,
unsigned int min_size=0,
unsigned int max_size=std::numeric_limits<unsigned int>::max() );
369 TypeHash content_hash()
const override;
372 bool finish(
bool is_generic =
false)
override;
376 return data_->finished; }
380 return *data_->type_of_values_; }
384 return size >=data_->lower_bound_ && size<=data_->upper_bound_; }
391 string type_name()
const override;
406 Array deep_copy()
const;
441 TypeHash content_hash()
const override;
449 string type_name()
const override;
474 Integer(
int lower_bound=std::numeric_limits<int>::min(),
int upper_bound=std::numeric_limits<int>::max())
475 : lower_bound_(lower_bound), upper_bound_(upper_bound)
483 TypeHash content_hash()
const override;
490 bool match(std::int64_t value)
const;
497 string type_name()
const override;
527 Double(
double lower_bound= -std::numeric_limits<double>::max(),
double upper_bound=std::numeric_limits<double>::max())
528 : lower_bound_(lower_bound), upper_bound_(upper_bound)
536 TypeHash content_hash()
const override;
539 bool match(
double value)
const;
546 string type_name()
const override;
575 virtual string type_name()
const override;
580 TypeHash content_hash()
const override;
583 virtual bool match(
const string &value)
const;
601 TypeHash content_hash()
const override;
620 string type_name()
const override;
626 {
return typeid(*this) ==
typeid(other) &&
627 (type_== static_cast<const FileName *>(&other)->get_file_type() );
631 bool match(
const string &str)
const;
FileType
Possible types of file.
bool operator==(const Null &, const Null &)
Global macros to enhance readability and debugging, general constants.