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> 55 : attributes_(
std::make_shared<
attribute_map>() ), root_of_generic_subtree_(false),
56 generic_type_hash_(0) {}
70 namespace ba = boost::algorithm;
71 return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of(
"_") );
103 ss <<
"\"" <<
std::hex << hash <<
"\"";
112 (*attributes_)[name] = val;
128 std::stringstream ss;
130 for (ParameterMap::iterator
it=parameter_map.begin();
it!=parameter_map.end();
it++) {
131 if (
it != parameter_map.begin()) ss <<
"," << endl;
141 for (ParameterMap::iterator
it=parameter_map.begin();
it!=parameter_map.end();
it++) {
142 if (
it != parameter_map.begin()) ss <<
", ";
143 ss <<
"\"" <<
it->first <<
"\"";
151 if (parameter_map.size() > 0)
160 for(
auto &item : other_attributes) {
161 if (item.first[0] !=
'_')
199 return typeid(*this) ==
typeid(other);
203 return ! (*
this == other);
229 boost::hash_combine(seed, data_->lower_bound_);
230 boost::hash_combine(seed, data_->upper_bound_);
231 boost::hash_combine(seed, data_->type_of_values_->content_hash() );
237 return data_->finish(finish_type);
275 return "array_of_" +
data_->type_of_values_->type_name();
287 return typeid(*this) ==
typeid(other) &&
288 (*
data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
298 arr.
data_->type_of_values_ = inst.first;
305 ASSERT(this->
validate_json(val))(val).error(
"Invalid JSON format of attribute 'parameters'.");
309 return std::make_pair( std::make_shared<Array>(arr), parameter_map );
315 arr.
data_ = std::make_shared<Array::ArrayData>(*this->
data_);
321 Array::Array(std::shared_ptr<TypeBase> type,
unsigned int min_size,
unsigned int max_size)
324 ASSERT_LE(min_size, max_size).error(
"Wrong limits for size of Input::Type::Array");
325 ASSERT(type->is_closed()).error();
327 data_->type_of_values_ = type;
333 return data_->finish_status; }
345 template <
class ValueType>
346 Array::Array(
const ValueType &type,
unsigned int min_size,
unsigned int max_size)
347 :
Array(
std::static_pointer_cast<
TypeBase>(
std::make_shared<ValueType>(type) ), min_size, max_size)
355 #define ARRAY_CONSTRUCT(TYPE) \ 356 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size) 400 return std::make_pair( std::make_shared<Bool>(*
this),
ParameterMap() );
408 : lower_bound_(lower_bound), upper_bound_(upper_bound)
441 return std::make_pair( std::make_shared<Integer>(*
this),
ParameterMap() );
483 return std::make_pair( std::make_shared<Double>(*
this),
ParameterMap() );
519 boost::hash_combine(seed,
type_);
529 case ::FilePath::input_file:
530 return "FileName_input";
531 case ::FilePath::output_file:
532 return "FileName_output";
552 return std::make_pair( std::make_shared<FileName>(*
this),
ParameterMap() );
566 return typeid(*this) ==
typeid(other) &&
567 (
type_== static_cast<const FileName *>(&other)->get_file_type() );
604 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.