23 #include <boost/algorithm/string/replace.hpp> 24 #include <boost/iostreams/filtering_stream.hpp> 25 #include <boost/iostreams/concepts.hpp> 26 #include <boost/iostreams/operations.hpp> 31 #include <boost/regex.hpp> 67 lower = array.
data_->lower_bound_;
68 upper = array.
data_->upper_bound_;
74 arr_type = array.
data_->type_of_values_;
80 return rec->
data_->description_;
92 parent_vec = rec.
data_->parent_vec_;
98 value = it->default_.value_;
99 if ( it->default_.is_obligatory() ) {
101 }
else if ( it->default_.is_optional() ) {
103 }
else if ( it->default_.has_value_at_read_time() ) {
104 type =
"value at read time";
106 type =
"value at declaration";
113 return sel->
data_->description_;
132 print_base(stream, gen_type);
140 print_generic<Tuple>(stream, type);
141 print_impl(stream, static_cast<const Type::Record *>(type) );
144 print_generic<Record>(stream, type);
145 print_impl(stream, static_cast<const Type::Record *>(type) );
148 print_impl(stream, static_cast<const Type::Array *>(type) );
151 print_impl(stream, static_cast<const Type::Abstract *>(type) );
154 print_impl(stream, static_cast<const Type::AdHocAbstract *>(type) );
157 print_impl(stream, static_cast<const Type::Selection *>(type) );
160 print_impl(stream, static_cast<const Type::Integer *>(type) );
163 print_impl(stream, static_cast<const Type::Double *>(type) );
166 print_impl(stream, static_cast<const Type::Bool *>(type) );
169 print_impl(stream, static_cast<const Type::Parameter *>(type) );
172 if (file_name_type != NULL ) {
173 print_impl(stream, file_name_type );
178 if (string_type != NULL ) {
179 print_impl(stream, string_type );
184 THROW( Type::ExcUnknownDescendant() << Type::EI_TypeName(
typeid(type).name()) );
191 stream <<
"<" << dft.
value() <<
">";
193 stream <<
"\"" << dft.
value() <<
"\"";
198 unsigned int padding,
unsigned int hash_count) {
200 boost::replace_all(s,
"\\$",
"$");
202 boost::tokenizer<boost::char_separator<char> > line_tokenizer(s, boost::char_separator<char>(
"\n"));
203 boost::tokenizer<boost::char_separator<char> >::iterator
it;
206 for(it = line_tokenizer.begin(); it != line_tokenizer.end(); ++it) {
208 stream << setw(padding) <<
"";
209 stream << std::setfill(
'#') << setw(hash_count) <<
"" << std::setfill(
' ') <<
" " << *it;
215 processed_types_hash_.clear();
222 bool in_set = ( processed_types_hash_.find(hash) != processed_types_hash_.end() );
223 if (! in_set) processed_types_hash_.insert(hash);
244 doc_type_ = full_record;
245 clear_processed_types();
247 print_base(stream, type_);
259 if (! was_written(hash)) {
272 if (key_it != type->
end()) {
273 stream <<
", reducible to key '" << key_it->key_ <<
"'";
275 stream <<
"" <<
" (" << type->
size() <<
" keys).";
278 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') << endl;
280 doc_type_ = key_record;
282 size_setw_ =
it->key_.size() + 3;
283 stream << setw(padding_size) <<
"" <<
it->key_ <<
" = ";
284 write_default_value(stream,
it->default_);
286 stream << setw(padding_size + size_setw_) <<
"" <<
"#### is ";
287 print_base(stream,
it->type_.get());
288 write_description(stream,
it->description_, padding_size+size_setw_);
291 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') <<
" " << type->
type_name() << endl;
293 doc_type_ = full_record;
300 get_array_type(*type, array_type);
303 unsigned int lower_size, upper_size;
304 get_array_sizes(*type, lower_size, upper_size);
305 stream <<
"Array, size limits: [" << lower_size <<
", " << upper_size <<
"] of type: " << endl;
306 stream << setw(padding_size + size_setw_) <<
"" <<
"#### ";
307 print_base(stream, array_type.get());
310 print_base(stream, array_type.get());
320 stream <<
"Abstract '" << type->
type_name() <<
"' with "<< type->
child_size() <<
" descendants.";
324 if (! was_written(hash) ) {
327 stream <<
"" <<
"Abstract '" << type->
type_name() <<
"' with " << type->
child_size() <<
" descendants.";
330 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') << endl;
332 doc_type_ = key_record;
335 stream << setw(padding_size) <<
"";
336 stream <<
"" <<
"Record '" << (*it).type_name() <<
"'";
340 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') <<
" " << type->
type_name() << endl;
342 doc_type_ = full_record;
351 if (doc_type_ == key_record) {
352 stream <<
"AdHocAbstract";
378 stream <<
"Selection '" << type->
type_name() <<
"' of " << type->
size() <<
" values.";
382 if (! was_written(hash) ) {
383 stream << endl <<
"Selection '" << type->
type_name() <<
"' of " << type->
size() <<
" values.";
386 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') << endl;
389 stream << setw(padding_size) <<
"" <<
it->key_ <<
" = " <<
it->value;
390 if (
it->description_ !=
"") {
392 stream << setw(padding_size +
it->key_.size() + 3) <<
"" <<
"# " <<
it->description_ <<
"";
396 stream <<
"" << std::setfill(
'-') << setw(10) <<
"" << std::setfill(
' ') <<
" " << type->
type_name() << endl;
402 if (doc_type_ == key_record) {
403 int lower_bound, upper_bound;
404 get_integer_bounds(*type, lower_bound, upper_bound);
405 stream <<
"Integer in [" << lower_bound <<
", " << upper_bound <<
"]";
409 if (doc_type_ == key_record) {
410 double lower_bound, upper_bound;
411 get_double_bounds(*type, lower_bound, upper_bound);
412 stream <<
"Double in [" << lower_bound <<
", " << upper_bound <<
"]";
416 if (doc_type_ == key_record) {
421 if (doc_type_ == key_record) {
422 stream <<
"String (generic)";
426 if (doc_type_ == key_record) {
427 stream <<
"FileName of ";
429 case ::FilePath::input_file:
430 stream <<
"input file";
432 case ::FilePath::output_file:
433 stream <<
"output file";
436 stream <<
"file with unknown type";
445 ASSERT_DBG(
false).error(
"Parameter appears in the IST. Check where Instance is missing.");
479 {boost::regex(
"\\\\"),
"\\\\\\\\"},
481 {boost::regex(
"\\\""),
"\\\\\""},
483 {boost::regex(
"\\n"),
"\\\\n"},
484 {boost::regex(
"\\t"),
"\\\\t"},
485 {boost::regex(
"\\r"),
"\\\\r"}
489 std::string tmp = std::string(desc);
491 for (
auto rewrite_rule : rewrite_rules) {
492 tmp = boost::regex_replace(tmp, rewrite_rule.first, rewrite_rule.second);
531 if (attribute_map.size() == 0)
return "\"attributes\" : {}";
533 stream <<
"\"attributes\" : {" << endl;
534 for (
auto it=attribute_map.begin();
it!=attribute_map.end(); ++
it) {
535 if (
it != attribute_map.begin()) {
536 stream <<
"," << endl;
538 stream <<
"\"" <<
it->first <<
"\" : " <<
it->second;
540 stream << endl <<
"}";
547 stream <<
"{" << endl;
548 stream <<
"\"id\" : " << type->
hash_str() <<
"," << endl;
549 stream <<
"\"input_type\" : \"" + type->
class_name() +
"\"," << endl;
550 stream <<
"\"name\" : \"" << type->
type_name() <<
"\"," << endl;
558 if (generic_type_hash) {
559 stream <<
"\"generic_type\" : " <<
TypeBase::hash_str(generic_type_hash) <<
"," << endl;
561 if (parameter_map_to_json.size()) {
562 stream <<
"\"parameters\" : " << parameter_map_to_json <<
"," << endl;
574 stream <<
"," << endl <<
"\"description\" : \"" <<
580 if (parent_vec.size()) {
581 stream <<
"\"implements\" : [ ";
582 bool add_comma =
false;
583 for (
auto &parent : parent_vec) {
584 if (add_comma) stream <<
", ";
585 else add_comma =
true;
586 stream << parent->hash_str();
588 stream <<
" ]," << endl;
593 if (key_it != type->
end()) {
594 stream <<
"\"reducible_to_key\" : \"" << key_it->key_ <<
"\"," << endl;
597 stream <<
"\"keys\" : [" << endl;
601 string dft_type, dft_value;
603 if (dft_type !=
"value at declaration")
607 stream <<
"," << endl;
609 stream <<
"{ \"key\" : \"" <<
it->key_ <<
"\"," << endl;
610 stream <<
"\"description\" : \"" <<
612 stream <<
"\"default\" : { " 613 <<
"\"type\" : \"" << dft_type <<
"\"," << endl
614 <<
"\"value\" : " << dft_value <<
" }," << endl;
615 stream <<
"\"type\" : " <<
it->type_->hash_str() <<
"," << endl;
620 stream <<
"]" << endl;
638 unsigned int lower_size, upper_size;
645 stream <<
"," << endl;
646 stream <<
"\"range\" : [" << lower_size <<
", " << upper_size <<
"]," << endl;
647 stream <<
"\"subtype\" : " << array_type->hash_str() << endl;
648 stream <<
"}," << endl;
658 print_generic<Abstract>(stream, type);
664 stream <<
"," << endl;
665 stream <<
"\"description\" : \"" <<
680 print_generic<AdHocAbstract>(stream, type);
688 stream <<
"," << endl;
708 stream <<
"\"default_descendant\" : " << desc->
hash_str() <<
"," << endl;
710 stream <<
"\"implementations\" : [" << endl;
713 stream <<
"," << endl;
714 stream <<
"" <<
it->hash_str() <<
"";
725 print_generic<Selection>(stream, type);
731 stream <<
"," << endl;
732 stream <<
"\"description\" : \"" <<
735 stream <<
"\"values\" : [" << endl;
738 stream <<
"," << endl;
740 stream <<
"{ \"name\" : \"" <<
it->key_ <<
"\"," << endl;
746 stream <<
"]" << endl;
761 stream <<
"," << endl;
762 stream <<
"\"range\" : [" << lower <<
", " << upper <<
"]" << endl;
777 stream <<
"," << endl;
778 stream <<
"\"range\" : [" << lower <<
", " << upper <<
"]" << endl;
812 stream <<
"," << endl;
813 stream <<
"\"file_mode\" : \"";
815 case ::FilePath::input_file:
818 case ::FilePath::output_file:
819 stream <<
"output\"";
823 stream << endl <<
"},";
835 stream << endl <<
"},";
843 string build_date = string(__DATE__) +
", " + string(__TIME__);
845 stream <<
"{" << endl;
848 stream <<
"\"date\" : \"" << build_date <<
"\"" << endl;
864 return type_output.
print(stream) << endl;
869 return type_output.
print(stream) << endl;
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
void print_impl(ostream &stream, const Record *type)
Implements printout of Record type.
static constexpr bool value
ostream & print(ostream &stream) override
Performs output of the documentation into given stream.
Class for create text documentation.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.