19 #include <boost/type_traits.hpp>
20 #include <boost/tokenizer.hpp>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/make_shared.hpp>
23 #include <boost/algorithm/string.hpp>
24 #include <boost/functional/hash.hpp>
30 #include <boost/algorithm/string.hpp>
61 TypeBase::LazyObjectsSet::iterator it =set.find(
this);
62 ASSERT( it != set.end(),
"Missing pointer in lazy_object_set to '%s'.\n", this->type_name().c_str());
68 namespace ba = boost::algorithm;
69 return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of(
"_") );
83 return lazy_type_list;
92 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++) {
93 if (boost::dynamic_pointer_cast<Selection>(*it) == 0) {
99 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++)
101 boost::shared_ptr<AbstractRecord> a_rec_ptr = boost::dynamic_pointer_cast<
AbstractRecord>(*it);
106 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++) {
107 if (! (*it)->finish())
xprintf(
PrgErr,
"Can not finish '%s' during lazy_finish.\n", (*it)->type_name().c_str() );
110 lazy_type_list().clear();
125 return lazy_object_set().find(ptr) != lazy_object_set().end();
143 boost::hash_combine(seed, type_name());
144 boost::hash_combine(seed, data_->lower_bound_);
145 boost::hash_combine(seed, data_->upper_bound_);
146 boost::hash_combine(seed, data_->type_of_values_->content_hash() );
152 return data_->finish();
159 if (finished)
return true;
161 if (p_type_of_values != 0)
163 if (! was_constructed(p_type_of_values) )
return false;
165 if (dynamic_cast<const AbstractRecord *>(p_type_of_values) != 0)
168 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const AbstractRecord>(*ar);
169 type_of_values_ = type_copy;
170 p_type_of_values = 0;
172 else if (dynamic_cast<const Record *>(p_type_of_values) != 0)
174 Record *r = (
Record *)dynamic_cast<const Record *>(p_type_of_values);
175 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const Record>(*r);
176 type_of_values_ = type_copy;
177 p_type_of_values = 0;
179 else if (dynamic_cast<const Selection *>(p_type_of_values) != 0)
182 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const Selection>(*s);
183 type_of_values_ = type_copy;
184 p_type_of_values = 0;
186 else if (dynamic_cast<const Array *>(p_type_of_values) != 0)
190 return (finished =
true);
196 return "array_of_" + data_->type_of_values_->type_name();
200 return "array_of_" + data_->type_of_values_->type_name();
206 return typeid(*this) ==
typeid(other) &&
207 (*data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
213 if ( this->match_size( 1 ) ) {
214 return get_sub_type().valid_default( str );
216 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(type_name()));
225 template <
class ValueType>
226 Array::Array(
const ValueType &type,
unsigned int min_size,
unsigned int max_size)
227 : data_(boost::make_shared<
ArrayData>(min_size, max_size))
230 BOOST_STATIC_ASSERT( (boost::is_base_of<TypeBase, ValueType >::value) );
231 ASSERT( min_size <= max_size,
"Wrong limits for size of Input::Type::Array, min: %d, max: %d\n", min_size, max_size);
236 if ( (boost::is_base_of<Record, ValueType>::value ||
237 boost::is_base_of<Selection, ValueType>::value)
239 data_->p_type_of_values = &type;
242 data_->p_type_of_values = NULL;
243 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<ValueType>(type);
244 data_->type_of_values_ = type_copy;
245 data_->finished=
true;
251 #define ARRAY_CONSTRUCT(TYPE) \
252 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size)
294 if (str ==
"true" ) {
297 if (str ==
"false") {
300 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
332 std::istringstream stream(str);
336 if (stream && stream.eof() &&
match(value)) {
339 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
381 std::istringstream stream(str);
385 if (stream && stream.eof() &&
match(value)) {
388 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
416 boost::hash_combine(seed,
type_);
426 case ::FilePath::input_file:
427 return "FileName_input";
428 case ::FilePath::output_file:
429 return "FileName_output";
465 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
Class for create text documentation.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.