27 #include <boost/type_traits.hpp> 28 #include <boost/tokenizer.hpp> 29 #include <boost/algorithm/string.hpp> 30 #include <boost/functional/hash.hpp> 31 #include <boost/pointer_cast.hpp> 41 #include <boost/algorithm/string.hpp> 42 #include <boost/exception/detail/error_info_impl.hpp> 43 #include <boost/exception/info.hpp> 44 #include <boost/functional/hash/hash.hpp> 45 #include <boost/static_assert.hpp> 46 #include <boost/type_traits/is_base_of.hpp> 59 namespace Input {
namespace Type {
class Abstract; } }
60 namespace Input {
namespace Type {
class Record; } }
61 namespace Input {
namespace Type {
class Selection; } }
62 namespace Input {
namespace Type {
class Tuple; } }
80 : attributes_(
std::make_shared<
attribute_map>() ), root_of_generic_subtree_(false),
81 generic_type_hash_(
TypeBase::none_hash) {}
95 namespace ba = boost::algorithm;
96 return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of(
"_") );
128 ss <<
"\"" <<
std::hex << hash <<
"\"";
137 (*attributes_)[name] = val;
153 std::stringstream ss;
155 for (ParameterMap::iterator
it=parameter_map.begin();
it!=parameter_map.end();
it++) {
156 if (
it != parameter_map.begin()) ss <<
"," << endl;
166 for (ParameterMap::iterator
it=parameter_map.begin();
it!=parameter_map.end();
it++) {
167 if (
it != parameter_map.begin()) ss <<
", ";
168 ss <<
"\"" <<
it->first <<
"\"";
176 if (parameter_map.size() > 0)
185 for(
auto &item : other_attributes) {
186 if (item.first[0] !=
'_')
224 return typeid(*this) ==
typeid(other);
228 return ! (*
this == other);
254 boost::hash_combine(seed, data_->lower_bound_);
255 boost::hash_combine(seed, data_->upper_bound_);
256 boost::hash_combine(seed, data_->type_of_values_->content_hash() );
262 return data_->finish(finish_type);
300 return "array_of_" +
data_->type_of_values_->type_name();
312 return typeid(*this) ==
typeid(other) &&
313 (*
data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
323 arr.
data_->type_of_values_ = inst.first;
330 ASSERT(this->
validate_json(val))(val).error(
"Invalid JSON format of attribute 'parameters'.");
334 return std::make_pair( std::make_shared<Array>(arr), parameter_map );
340 arr.
data_ = std::make_shared<Array::ArrayData>(*this->
data_);
346 Array::Array(std::shared_ptr<TypeBase> type,
unsigned int min_size,
unsigned int max_size)
349 ASSERT_LE(min_size, max_size).error(
"Wrong limits for size of Input::Type::Array");
350 ASSERT(type->is_closed()).error();
352 data_->type_of_values_ = type;
358 return data_->finish_status; }
370 template <
class ValueType>
371 Array::Array(
const ValueType &type,
unsigned int min_size,
unsigned int max_size)
372 :
Array(
std::static_pointer_cast<
TypeBase>(
std::make_shared<ValueType>(type) ), min_size, max_size)
380 #define ARRAY_CONSTRUCT(TYPE) \ 381 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size) 425 return std::make_pair( std::make_shared<Bool>(*
this),
ParameterMap() );
433 : lower_bound_(lower_bound), upper_bound_(upper_bound)
466 return std::make_pair( std::make_shared<Integer>(*
this),
ParameterMap() );
508 return std::make_pair( std::make_shared<Double>(*
this),
ParameterMap() );
544 boost::hash_combine(seed,
type_);
554 case ::FilePath::input_file:
555 return "FileName_input";
556 case ::FilePath::output_file:
557 return "FileName_output";
577 return std::make_pair( std::make_shared<FileName>(*
this),
ParameterMap() );
591 return typeid(*this) ==
typeid(other) &&
592 (
type_== static_cast<const FileName *>(&other)->get_file_type() );
629 return std::make_pair( std::make_shared<String>(*
this),
ParameterMap() );
IntFormatSpec< int, TypeSpec<'x'> > hex(int value)
FileType
Possible types of file.
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
void read_or_throw(const std::string &s, mValue &value)
static constexpr bool value
Class for create text documentation.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.