27 #include <boost/type_traits.hpp>
28 #include <boost/tokenizer.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/make_shared.hpp>
31 #include <boost/algorithm/string.hpp>
32 #include <boost/functional/hash.hpp>
33 #include <boost/pointer_cast.hpp>
57 : attributes_( std::make_shared<
attribute_map>() ), root_of_generic_subtree_(false),
58 generic_type_hash_(0) {}
63 : attributes_(other.attributes_), root_of_generic_subtree_(other.root_of_generic_subtree_),
64 generic_type_hash_(other.generic_type_hash_), parameter_map_(other.parameter_map_) {}
72 namespace ba = boost::algorithm;
73 return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of(
"_") );
99 ss <<
"\"" <<
std::hex << hash <<
"\"";
108 (*attributes_)[name] = val;
124 std::stringstream ss;
126 for (ParameterMap::iterator it=parameter_map.begin(); it!=parameter_map.end(); it++) {
127 if (it != parameter_map.begin()) ss <<
"," << endl;
137 for (ParameterMap::iterator it=parameter_map.begin(); it!=parameter_map.end(); it++) {
138 if (it != parameter_map.begin()) ss <<
", ";
139 ss <<
"\"" << it->first <<
"\"";
147 if (parameter_map.size() > 0)
156 for(
auto &item : other_attributes) {
157 if (item.first[0] !=
'_')
183 boost::hash_combine(seed,
data_->lower_bound_);
184 boost::hash_combine(seed,
data_->upper_bound_);
185 boost::hash_combine(seed,
data_->type_of_values_->content_hash() );
191 return data_->finish(is_generic);
209 return "array_of_" +
data_->type_of_values_->type_name();
215 return typeid(*this) ==
typeid(other) &&
216 (*
data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
226 arr.
data_->type_of_values_ = inst.first;
233 ASSERT(this->
validate_json(val))(val).error(
"Invalid JSON format of attribute 'parameters'.");
237 return std::make_pair( std::make_shared<Array>(arr), parameter_map );
243 arr.
data_ = std::make_shared<Array::ArrayData>(*this->
data_);
244 arr.
data_->finished =
false;
249 Array::Array(std::shared_ptr<TypeBase> type,
unsigned int min_size,
unsigned int max_size)
252 ASSERT_LE(min_size, max_size).error(
"Wrong limits for size of Input::Type::Array");
253 ASSERT(type->is_closed()).error();
255 data_->type_of_values_ = type;
263 template <
class ValueType>
264 Array::Array(
const ValueType &type,
unsigned int min_size,
unsigned int max_size)
265 :
Array(std::static_pointer_cast<
TypeBase>( std::make_shared<ValueType>(type) ), min_size, max_size)
268 BOOST_STATIC_ASSERT( (boost::is_base_of<TypeBase, ValueType >::value) );
273 #define ARRAY_CONSTRUCT(TYPE) \
274 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size)
312 return std::make_pair( std::make_shared<Bool>(*
this),
ParameterMap() );
342 return std::make_pair( std::make_shared<Integer>(*
this),
ParameterMap() );
374 return std::make_pair( std::make_shared<Double>(*
this),
ParameterMap() );
386 boost::hash_combine(seed,
type_);
396 case ::FilePath::input_file:
397 return "FileName_input";
398 case ::FilePath::output_file:
399 return "FileName_output";
414 return std::make_pair( std::make_shared<FileName>(*
this),
ParameterMap() );
446 return std::make_pair( std::make_shared<String>(*
this),
ParameterMap() );
IntFormatSpec< int, TypeSpec<'x'> > hex(int value)
#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)
Class for create text documentation.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.