From: Daniel Arndt Date: Thu, 26 Mar 2020 16:08:55 +0000 (-0400) Subject: Remove ParameterHandler::print_section X-Git-Tag: v9.2.0-rc1~352^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=823ee4c5a62b616ac91b73391ea17bd3185bc69f;p=dealii.git Remove ParameterHandler::print_section --- diff --git a/doc/news/changes/incompatibilities/20200326DanielArndt-2 b/doc/news/changes/incompatibilities/20200326DanielArndt-2 new file mode 100644 index 0000000000..990745af0e --- /dev/null +++ b/doc/news/changes/incompatibilities/20200326DanielArndt-2 @@ -0,0 +1,3 @@ +Removed: ParameterHandler::print_parameters_section been removed. +
+(Daniel Arndt, 2020/03/26) diff --git a/include/deal.II/base/parameter_handler.h b/include/deal.II/base/parameter_handler.h index 483e79a5f5..22fc86705e 100644 --- a/include/deal.II/base/parameter_handler.h +++ b/include/deal.II/base/parameter_handler.h @@ -1409,37 +1409,6 @@ public: const OutputStyle style, const bool sort_alphabetical = true) const; - /** - * Print out the parameters of the present subsection as given by the - * subsection_path member variable. This variable is controlled by - * entering and leaving subsections through the enter_subsection() and - * leave_subsection() functions. - * - * If include_top_level_elements is true, also the higher - * subsection elements are printed. In XML format this is required - * to get a valid XML document and output starts with one root element - * ParameterHandler. - * - * Before printing, all parameters and subsections of the present subsection - * are sorted alphabetically by default. - * This behavior can be disabled setting the last parameter @p sort_alphabetical - * to @p false: in this case entries are printed in the same order - * as they have been declared. - * - * In most cases, you will not want to use this function directly, but have - * it called recursively by the previous function. - * - * @deprecated This function is deprecated because, even though it only - * outputs information, it is not a const function. - */ - DEAL_II_DEPRECATED - void - print_parameters_section(std::ostream & out, - const OutputStyle style, - const unsigned int indent_level, - const bool include_top_level_elements = false, - const bool sort_alphabetical = true); - /** * Print parameters to a logstream. This function allows to print all * parameters into a log-file. Sections will be indented in the usual log- diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index bbe09a7b13..9e7c5c0e12 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -1630,468 +1630,6 @@ ParameterHandler::recursively_print_parameters( } } -// Print a section in the desired style. The styles are separated into -// several verbosity classes depending on the higher bits. -// -// If bit 7 (128) is set, comments are not printed. -// If bit 6 (64) is set, default values after change are not printed. -void -ParameterHandler::print_parameters_section( - std::ostream & out, - const OutputStyle style, - const unsigned int indent_level, - const bool include_top_level_elements, - const bool sort_alphabetical) -{ - AssertThrow(out, ExcIO()); - - // Create entries copy and sort it, if needed. - // In this way we ensure that the class state is never - // modified by this function. - boost::property_tree::ptree sorted_entries; - boost::property_tree::ptree *current_entries = entries.get(); - - // Sort parameters alphabetically, if needed. - if (sort_alphabetical) - { - sorted_entries = *entries; - current_entries = &sorted_entries; - - // Dive recursively into the subsections, - // starting from current level. - recursively_sort_parameters(path_separator, - subsection_path, - sorted_entries); - } - - const boost::property_tree::ptree ¤t_section = - current_entries->get_child(get_current_path()); - - unsigned int overall_indent_level = indent_level; - - switch (style) - { - case XML: - { - if (include_top_level_elements) - { - // call the writer function and exit as there is nothing - // further to do down in this function - // - // XML has a requirement that there can only be one single - // top-level entry, but a section has multiple entries and - // sections. we work around this by creating a tree just for - // this purpose with the single top-level node - // "ParameterHandler" and assign the full path of down to - // the current section under it - boost::property_tree::ptree single_node_tree; - - // if there is no subsection selected, add the whole tree of - // entries, otherwise add a root element and the selected - // subsection under it - if (subsection_path.size() == 0) - { - single_node_tree.add_child("ParameterHandler", - *current_entries); - } - else - { - std::string path("ParameterHandler"); - - single_node_tree.add_child(path, - boost::property_tree::ptree()); - - path += path_separator + get_current_path(); - single_node_tree.add_child(path, current_section); - } - - write_xml(out, single_node_tree); - } - else - Assert(false, ExcNotImplemented()); - - break; - } - case Text: - case ShortText: - { - // if there are top level elements to print, do it - if (include_top_level_elements && (subsection_path.size() > 0)) - for (const auto &path : subsection_path) - { - out << std::setw(overall_indent_level * 2) << "" - << "subsection " << demangle(path) << std::endl; - overall_indent_level += 1; - } - - // first find out the longest entry name to be able to align the - // equal signs to do this loop over all nodes of the current - // tree, select the parameter nodes (and discard sub-tree nodes) - // and take the maximum of their lengths - std::size_t longest_name = 0; - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - longest_name = std::max(longest_name, demangle(p.first).length()); - - // likewise find the longest actual value string to make sure we - // can align the default and documentation strings - std::size_t longest_value = 0; - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - longest_value = - std::max(longest_value, - p.second.get("value").length()); - - - // print entries one by one - bool first_entry = true; - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - { - const std::string value = p.second.get("value"); - - // if there is documentation, then add an empty line - // (unless this is the first entry in a subsection), print - // the documentation, and then the actual entry; break the - // documentation into readable chunks such that the whole - // thing is at most 78 characters wide - if ((!(style & 128)) && - !p.second.get("documentation").empty()) - { - if (first_entry == false) - out << std::endl; - else - first_entry = false; - - const std::vector doc_lines = - Utilities::break_text_into_lines( - p.second.get("documentation"), - 78 - overall_indent_level * 2 - 2); - - for (const auto &doc_line : doc_lines) - out << std::setw(overall_indent_level * 2) << "" - << "# " << doc_line << std::endl; - } - - - - // print name and value of this entry - out << std::setw(overall_indent_level * 2) << "" - << "set " << demangle(p.first) - << std::setw(longest_name - demangle(p.first).length() + 1) - << " " - << "= " << value; - - // finally print the default value, but only if it differs - // from the actual value - if ((!(style & 64)) && - value != p.second.get("default_value")) - { - out << std::setw(longest_value - value.length() + 1) << ' ' - << "# "; - out << "default: " - << p.second.get("default_value"); - } - - out << std::endl; - } - - break; - } - - case LaTeX: - { - auto escape = [](const std::string &input) { - return Patterns::internal::escape(input, - Patterns::PatternBase::LaTeX); - }; - - // if there are any parameters in this section then print them - // as an itemized list - bool parameters_exist_here = false; - for (const auto &p : current_section) - if ((is_parameter_node(p.second) == true) || - (is_alias_node(p.second) == true)) - { - parameters_exist_here = true; - break; - } - - if (parameters_exist_here) - { - out << "\\begin{itemize}" << std::endl; - - // print entries one by one - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - { - const std::string value = - p.second.get("value"); - - // print name - out << "\\item {\\it Parameter name:} {\\tt " - << escape(demangle(p.first)) << "}\n" - << "\\phantomsection\\label{parameters:"; - for (const auto &path : subsection_path) - out << mangle(path) << "/"; - out << p.first; - out << "}\n\n" << std::endl; - - out << "\\index[prmindex]{" << escape(demangle(p.first)) - << "}\n"; - out << "\\index[prmindexfull]{"; - for (const auto &path : subsection_path) - out << escape(path) << "!"; - out << escape(demangle(p.first)) << "}\n"; - - // finally print value and default - out << "{\\it Value:} " << escape(value) << "\n\n" - << std::endl - << "{\\it Default:} " - << escape(p.second.get("default_value")) - << "\n\n" - << std::endl; - - // if there is a documenting string, print it as well - if (!p.second.get("documentation").empty()) - out << "{\\it Description:} " - << p.second.get("documentation") - << "\n\n" - << std::endl; - - // also output possible values - const unsigned int pattern_index = - p.second.get("pattern"); - const std::string desc_str = - patterns[pattern_index]->description( - Patterns::PatternBase::LaTeX); - out << "{\\it Possible values:} " << desc_str << std::endl; - } - else if (is_alias_node(p.second) == true) - { - const std::string alias = - p.second.get("alias"); - - // print name - out << "\\item {\\it Parameter name:} {\\tt " - << escape(demangle(p.first)) << "}\n" - << "\\phantomsection\\label{parameters:"; - for (const auto &path : subsection_path) - out << mangle(path) << "/"; - out << p.first; - out << "}\n\n" << std::endl; - - out << "\\index[prmindex]{" << escape(demangle(p.first)) - << "}\n"; - out << "\\index[prmindexfull]{"; - for (const auto &path : subsection_path) - out << escape(path) << "!"; - out << escape(demangle(p.first)) << "}\n"; - - // finally print alias and indicate if it is deprecated - out - << "This parameter is an alias for the parameter ``\\texttt{" - << escape(alias) << "}''." - << (p.second.get("deprecation_status") == - "true" ? - " Its use is deprecated." : - "") - << "\n\n" - << std::endl; - } - out << "\\end{itemize}" << std::endl; - } - - break; - } - - case Description: - { - // if there are top level elements to print, do it - if (include_top_level_elements && (subsection_path.size() > 0)) - for (const auto &path : subsection_path) - { - out << std::setw(overall_indent_level * 2) << "" - << "subsection " << demangle(path) << std::endl; - overall_indent_level += 1; - }; - - // first find out the longest entry name to be able to align the - // equal signs - std::size_t longest_name = 0; - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - longest_name = std::max(longest_name, demangle(p.first).length()); - - // print entries one by one - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - { - // print name and value - out << std::setw(overall_indent_level * 2) << "" - << "set " << demangle(p.first) - << std::setw(longest_name - demangle(p.first).length() + 1) - << " " - << " = "; - - // print possible values: - const unsigned int pattern_index = - p.second.get("pattern"); - const std::string full_desc_str = - patterns[pattern_index]->description( - Patterns::PatternBase::Text); - const std::vector description_str = - Utilities::break_text_into_lines( - full_desc_str, 78 - overall_indent_level * 2 - 2, '|'); - if (description_str.size() > 1) - { - out << std::endl; - for (const auto &description : description_str) - out << std::setw(overall_indent_level * 2 + 6) << "" - << description << std::endl; - } - else if (description_str.empty() == false) - out << " " << description_str[0] << std::endl; - else - out << std::endl; - - // if there is a documenting string, print it as well - if (p.second.get("documentation").length() != 0) - out << std::setw(overall_indent_level * 2 + longest_name + 10) - << "" - << "(" << p.second.get("documentation") - << ")" << std::endl; - } - - break; - } - - default: - Assert(false, ExcNotImplemented()); - } - - - // if there was text before and there are sections to come, put two - // newlines between the last entry and the first subsection - if (style != XML) - { - unsigned int n_parameters = 0; - unsigned int n_sections = 0; - for (const auto &p : current_section) - if (is_parameter_node(p.second) == true) - ++n_parameters; - else if (is_alias_node(p.second) == false) - ++n_sections; - - if ((style != Description) && (!(style & 128)) && (n_parameters != 0) && - (n_sections != 0)) - out << std::endl << std::endl; - - // now transverse subsections tree - for (const auto &p : current_section) - if ((is_parameter_node(p.second) == false) && - (is_alias_node(p.second) == false)) - { - // first print the subsection header - switch (style) - { - case Text: - case Description: - case ShortText: - out << std::setw(overall_indent_level * 2) << "" - << "subsection " << demangle(p.first) << std::endl; - break; - case LaTeX: - { - auto escape = [](const std::string &input) { - return Patterns::internal::escape( - input, Patterns::PatternBase::LaTeX); - }; - - out << std::endl - << "\\subsection{Parameters in section \\tt "; - - // find the path to the current section so that we can - // print it in the \subsection{...} heading - for (const auto &path : subsection_path) - out << escape(path) << "/"; - out << escape(demangle(p.first)); - - out << "}" << std::endl; - out << "\\label{parameters:"; - for (const auto &path : subsection_path) - out << mangle(path) << "/"; - out << p.first << "}"; - out << std::endl; - - out << std::endl; - break; - } - - default: - Assert(false, ExcNotImplemented()); - } - - // then the contents of the subsection - enter_subsection(demangle(p.first)); - print_parameters_section(out, style, overall_indent_level + 1); - leave_subsection(); - switch (style) - { - case Text: - // write end of subsection. one blank line after each - // subsection - out << std::setw(overall_indent_level * 2) << "" - << "end" << std::endl - << std::endl; - - // if this is a toplevel subsection, then have two - // newlines - if (overall_indent_level == 0) - out << std::endl; - - break; - case Description: - break; - case ShortText: - // write end of subsection. - out << std::setw(overall_indent_level * 2) << "" - << "end" << std::endl; - break; - case LaTeX: - break; - default: - Assert(false, ExcNotImplemented()); - } - } - } - - // close top level elements, if there are any - switch (style) - { - case XML: - case LaTeX: - case Description: - break; - case Text: - case ShortText: - { - if (include_top_level_elements && (subsection_path.size() > 0)) - for (unsigned int i = 0; i < subsection_path.size(); ++i) - { - overall_indent_level -= 1; - out << std::setw(overall_indent_level * 2) << "" - << "end" << std::endl; - } - - break; - } - - default: - Assert(false, ExcNotImplemented()); - } -} - void diff --git a/tests/parameter_handler/parameter_handler_write_section_1.cc b/tests/parameter_handler/parameter_handler_write_section_1.cc deleted file mode 100644 index 8fdff42801..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2002 - 2018 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - - -// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a -// few names that contain all sorts of weird (for XML) characters - -#include - -#include "../tests.h" - - -int -main() -{ - initlog(); - - ParameterHandler prm; - prm.declare_entry("int1", "1", Patterns::Integer(), "doc 1"); - prm.enter_subsection("ss1"); - { - prm.declare_entry("double 1", "1.234", Patterns::Double(), "doc 3"); - - // things with strange characters - prm.enter_subsection("Testing%testing"); - { - prm.declare_entry("double 2", "4.321", Patterns::Double(), "doc 4"); - prm.declare_entry("string&list", - "< & > ; /", - Patterns::Anything(), - "docs 1"); - prm.declare_entry("int*int", "2", Patterns::Integer()); - prm.declare_entry("double+double", - "6.1415926", - Patterns::Double(), - "docs 3"); - } - prm.leave_subsection(); - } - prm.leave_subsection(); - - prm.enter_subsection("ss1"); - prm.enter_subsection("Testing%testing"); - prm.print_parameters_section(deallog.get_file_stream(), - ParameterHandler::Text, - 0); - prm.leave_subsection(); - prm.leave_subsection(); - - deallog.get_file_stream() << std::endl; - - return 0; -} diff --git a/tests/parameter_handler/parameter_handler_write_section_1.output b/tests/parameter_handler/parameter_handler_write_section_1.output deleted file mode 100644 index ddcb05bbb2..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_1.output +++ /dev/null @@ -1,11 +0,0 @@ - -# doc 4 -set double 2 = 4.321 - -# docs 3 -set double+double = 6.1415926 -set int*int = 2 - -# docs 1 -set string&list = < & > ; / - diff --git a/tests/parameter_handler/parameter_handler_write_section_2.cc b/tests/parameter_handler/parameter_handler_write_section_2.cc deleted file mode 100644 index 6fb0d9284d..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_2.cc +++ /dev/null @@ -1,67 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2002 - 2018 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - - -// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a -// few names that contain all sorts of weird (for XML) characters - -#include - -#include "../tests.h" - - -int -main() -{ - initlog(); - - ParameterHandler prm; - prm.declare_entry("int1", "1", Patterns::Integer(), "doc 1"); - prm.enter_subsection("ss1"); - { - prm.declare_entry("double 1", "1.234", Patterns::Double(), "doc 3"); - - // things with strange characters - prm.enter_subsection("Testing%testing"); - { - prm.declare_entry("double 2", "4.321", Patterns::Double(), "doc 4"); - prm.declare_entry("string&list", - "< & > ; /", - Patterns::Anything(), - "docs 1"); - prm.declare_entry("int*int", "2", Patterns::Integer()); - prm.declare_entry("double+double", - "6.1415926", - Patterns::Double(), - "docs 3"); - } - prm.leave_subsection(); - } - prm.leave_subsection(); - - prm.enter_subsection("ss1"); - prm.enter_subsection("Testing%testing"); - prm.print_parameters_section(deallog.get_file_stream(), - ParameterHandler::Text, - 0, - true); - prm.leave_subsection(); - prm.leave_subsection(); - - deallog.get_file_stream() << std::endl; - - return 0; -} diff --git a/tests/parameter_handler/parameter_handler_write_section_2.output b/tests/parameter_handler/parameter_handler_write_section_2.output deleted file mode 100644 index 2312214379..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_2.output +++ /dev/null @@ -1,15 +0,0 @@ - -subsection ss1 - subsection Testing%testing - # doc 4 - set double 2 = 4.321 - - # docs 3 - set double+double = 6.1415926 - set int*int = 2 - - # docs 1 - set string&list = < & > ; / - end -end - diff --git a/tests/parameter_handler/parameter_handler_write_section_xml.cc b/tests/parameter_handler/parameter_handler_write_section_xml.cc deleted file mode 100644 index d9d492c811..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_xml.cc +++ /dev/null @@ -1,67 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2002 - 2018 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - - -// check ParameterHandler::print_parameters_section (..., XML, 0, true). have a -// few names that contain all sorts of weird (for XML) characters - -#include - -#include "../tests.h" - - -int -main() -{ - initlog(); - - ParameterHandler prm; - prm.declare_entry("int1", "1", Patterns::Integer(), "doc 1"); - prm.enter_subsection("ss1"); - { - prm.declare_entry("double 1", "1.234", Patterns::Double(), "doc 3"); - - // things with strange characters - prm.enter_subsection("Testing%testing"); - { - prm.declare_entry("double 2", "4.321", Patterns::Double(), "doc 4"); - prm.declare_entry("string&list", - "< & > ; /", - Patterns::Anything(), - "docs 1"); - prm.declare_entry("int*int", "2", Patterns::Integer()); - prm.declare_entry("double+double", - "6.1415926", - Patterns::Double(), - "docs 3"); - } - prm.leave_subsection(); - } - prm.leave_subsection(); - - prm.enter_subsection("ss1"); - prm.enter_subsection("Testing%testing"); - prm.print_parameters_section(deallog.get_file_stream(), - ParameterHandler::XML, - 0, - true); - prm.leave_subsection(); - prm.leave_subsection(); - - deallog.get_file_stream() << std::endl; - - return 0; -} diff --git a/tests/parameter_handler/parameter_handler_write_section_xml.output b/tests/parameter_handler/parameter_handler_write_section_xml.output deleted file mode 100644 index 9c7514142e..0000000000 --- a/tests/parameter_handler/parameter_handler_write_section_xml.output +++ /dev/null @@ -1,3 +0,0 @@ - - -4.3214.321doc 42[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]6.14159266.1415926docs 35[Double -MAX_DOUBLE...MAX_DOUBLE (inclusive)]224[Integer range -2147483648...2147483647 (inclusive)]< & > ; /< & > ; /docs 13[Anything]