From b69a3c17a72202f6137688166f9c66ba52ecaea9 Mon Sep 17 00:00:00 2001 From: Florian Prill Date: Thu, 12 Oct 2006 15:52:46 +0000 Subject: [PATCH] Added new ParameterHandler output style for command line description of available parameters. git-svn-id: https://svn.dealii.org/trunk@13995 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/parameter_handler.h | 6 ++ deal.II/base/source/parameter_handler.cc | 55 ++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/deal.II/base/include/base/parameter_handler.h b/deal.II/base/include/base/parameter_handler.h index 6251372ad4..dc5494632d 100644 --- a/deal.II/base/include/base/parameter_handler.h +++ b/deal.II/base/include/base/parameter_handler.h @@ -1250,6 +1250,12 @@ class ParameterHandler : public Subscriptor * LaTeX table. */ LaTeX = 2, + /** + * Write out declared parameters + * with description and possible + * values. + */ + Description = 3, /** * Write input for * ParameterHandler without diff --git a/deal.II/base/source/parameter_handler.cc b/deal.II/base/source/parameter_handler.cc index 4f61d1d17e..2863452985 100644 --- a/deal.II/base/source/parameter_handler.cc +++ b/deal.II/base/source/parameter_handler.cc @@ -871,6 +871,9 @@ ParameterHandler::print_parameters (std::ostream &out, out << "\\begin{itemize}" << std::endl; break; + case Description: + out << "Listing of Parameters:" << std::endl << std::endl; + break; case ShortText: break; default: @@ -883,6 +886,7 @@ ParameterHandler::print_parameters (std::ostream &out, switch (style) { case Text: + case Description: case ShortText: break; case LaTeX: @@ -1044,6 +1048,50 @@ ParameterHandler::print_parameters_section (std::ostream &out, break; } + case Description: + { + // first find out the longest + // entry name to be able to + // align the equal signs + unsigned int longest_name = 0; + for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr) + if (ptr->first.length() > longest_name) + longest_name = ptr->first.length(); + + // print entries one by one + for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr) + { + // print name and value + out << std::setw(indent_level*2) << "" + << "set " + << ptr->first + << std::setw(longest_name-ptr->first.length()+1) << " " + << " = "; + + // print possible values: + const std::vector description_str + = Utilities::break_text_into_lines (pd->entries[ptr->first].pattern->description(), + 78 - indent_level*2 - 2, '|'); + if (description_str.size() > 1) + { + out << std::endl; + for (unsigned int i=0; ientries[ptr->first].documentation.length() != 0) + out << std::setw(indent_level*2 + longest_name + 10) << "" + << "(" << pd->entries[ptr->first].documentation << ")" << std::endl; + } + break; + } + default: Assert (false, ExcNotImplemented()); } @@ -1055,7 +1103,9 @@ ParameterHandler::print_parameters_section (std::ostream &out, // subsection; also make sure that the // subsections will be printed at all // (i.e. at least one of them is non-empty) - if ((!(style & 128)) + if ((style != Description) + && + (!(style & 128)) && (pd->entries.size() != 0) && @@ -1076,6 +1126,7 @@ ParameterHandler::print_parameters_section (std::ostream &out, switch (style) { case Text: + case Description: case ShortText: out << std::setw(indent_level*2) << "" << "subsection " << ptrss->first << std::endl; @@ -1115,6 +1166,8 @@ ParameterHandler::print_parameters_section (std::ostream &out, out << std::endl; break; + case Description: + break; case ShortText: // write end of // subsection. -- 2.39.5