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>
28 #include <boost/algorithm/string.hpp>
59 TypeBase::LazyObjectsSet::iterator it =set.find(
this);
60 ASSERT( it != set.end(),
"Missing pointer in lazy_object_set to '%s'.\n", this->type_name().c_str());
66 namespace ba = boost::algorithm;
67 return ba::all( key, ba::is_lower() || ba::is_digit() || ba::is_any_of(
"_") );
81 return lazy_type_list;
90 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++) {
91 if (boost::dynamic_pointer_cast<Selection>(*it) == 0) {
97 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++)
99 boost::shared_ptr<AbstractRecord> a_rec_ptr = boost::dynamic_pointer_cast<
AbstractRecord>(*it);
104 for (LazyTypeVector::iterator it=lazy_type_list().begin(); it!=lazy_type_list().end(); it++) {
105 if (! (*it)->finish())
xprintf(
PrgErr,
"Can not finish '%s' during lazy_finish.\n", (*it)->type_name().c_str() );
108 lazy_type_list().clear();
123 return lazy_object_set().find(ptr) != lazy_object_set().end();
140 return data_->finish();
147 if (finished)
return true;
149 if (p_type_of_values != 0)
151 if (! was_constructed(p_type_of_values) )
return false;
153 if (dynamic_cast<const AbstractRecord *>(p_type_of_values) != 0)
156 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const AbstractRecord>(*ar);
157 type_of_values_ = type_copy;
158 p_type_of_values = 0;
160 else if (dynamic_cast<const Record *>(p_type_of_values) != 0)
162 Record *r = (
Record *)dynamic_cast<const Record *>(p_type_of_values);
163 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const Record>(*r);
164 type_of_values_ = type_copy;
165 p_type_of_values = 0;
167 else if (dynamic_cast<const Selection *>(p_type_of_values) != 0)
170 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<const Selection>(*s);
171 type_of_values_ = type_copy;
172 p_type_of_values = 0;
174 else if (dynamic_cast<const Array *>(p_type_of_values) != 0)
184 return (finished =
true);
190 return "array_of_" + data_->type_of_values_->type_name();
194 return "array_of_" + data_->type_of_values_->type_name();
200 return typeid(*this) ==
typeid(other) &&
201 (*data_->type_of_values_ == static_cast<const Array *>(&other)->get_sub_type() );
207 if ( this->match_size( 1 ) ) {
208 return get_sub_type().valid_default( str );
210 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(type_name()));
219 template <
class ValueType>
220 Array::Array(
const ValueType &type,
unsigned int min_size,
unsigned int max_size)
221 : data_(boost::make_shared<
ArrayData>(min_size, max_size))
224 BOOST_STATIC_ASSERT( (boost::is_base_of<TypeBase, ValueType >::value) );
225 ASSERT( min_size <= max_size,
"Wrong limits for size of Input::Type::Array, min: %d, max: %d\n", min_size, max_size);
230 if ( (boost::is_base_of<Record, ValueType>::value ||
231 boost::is_base_of<Selection, ValueType>::value)
235 data_->p_type_of_values = &type;
238 data_->p_type_of_values = NULL;
239 boost::shared_ptr<const TypeBase> type_copy = boost::make_shared<ValueType>(type);
240 data_->type_of_values_ = type_copy;
241 data_->finished=
true;
247 #define ARRAY_CONSTRUCT(TYPE) \
248 template Array::Array(const TYPE &type, unsigned int min_size, unsigned int max_size)
282 if (str ==
"true" ) {
285 if (str ==
"false") {
288 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
309 std::istringstream stream(str);
313 if (stream && stream.eof() &&
match(value)) {
316 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
346 std::istringstream stream(str);
350 if (stream && stream.eof() &&
match(value)) {
353 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));
400 case ::FilePath::input_file:
401 return "FileName_input";
402 case ::FilePath::output_file:
403 return "FileName_output";
431 THROW( ExcWrongDefault() << EI_DefaultStr( str ) << EI_TypeName(
type_name()));