From: Timo Heister Date: Fri, 10 Nov 2017 19:23:16 +0000 (-0500) Subject: move to namespace X-Git-Tag: v9.0.0-rc1~781^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc028831717d78584abb850531dffc8f4f08231b;p=dealii.git move to namespace --- diff --git a/include/deal.II/base/patterns.h b/include/deal.II/base/patterns.h index 8b01b979f5..886eca3a27 100644 --- a/include/deal.II/base/patterns.h +++ b/include/deal.II/base/patterns.h @@ -148,13 +148,16 @@ namespace Patterns */ std::unique_ptr pattern_factory (const std::string &description); - /** - * Escape the string @p input for the specified @p style so that characters - * will appear as intended. For example, characters like _ can not be - * written as is in LateX and have to be escaped as \_. - */ - std::string escape(const std::string &input, const PatternBase::OutputStyle style); + namespace internal + { + /** + * Escape the string @p input for the specified @p style so that characters + * will appear as intended. For example, characters like _ can not be + * written as is in LateX and have to be escaped as \_. + */ + std::string escape(const std::string &input, const PatternBase::OutputStyle style); + } /** * Test for the string being an integer. If bounds are given to the diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 16e28de4ea..003351a81f 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -1106,7 +1106,7 @@ ParameterHandler::recursively_print_parameters (const std::vector & { auto escape = [] (const std::string &input) { - return Patterns::escape(input, Patterns::PatternBase::LaTeX); + return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX); }; // if there are any parameters in this section then print them @@ -1347,7 +1347,7 @@ ParameterHandler::recursively_print_parameters (const std::vector & { auto escape = [] (const std::string &input) { - return Patterns::escape(input, Patterns::PatternBase::LaTeX); + return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX); }; out << '\n' @@ -1577,7 +1577,7 @@ ParameterHandler::print_parameters_section (std::ostream &out, { auto escape = [] (const std::string &input) { - return Patterns::escape(input, Patterns::PatternBase::LaTeX); + return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX); }; // if there are any parameters in this section then print them @@ -1796,7 +1796,7 @@ ParameterHandler::print_parameters_section (std::ostream &out, { auto escape = [] (const std::string &input) { - return Patterns::escape(input, Patterns::PatternBase::LaTeX); + return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX); }; out << std::endl diff --git a/source/base/patterns.cc b/source/base/patterns.cc index e146091d01..bb7d3e64d2 100644 --- a/source/base/patterns.cc +++ b/source/base/patterns.cc @@ -48,6 +48,66 @@ DEAL_II_NAMESPACE_OPEN namespace Patterns { + + namespace internal + { + + + std::string escape(const std::string &input, const PatternBase::OutputStyle style) + { + switch (style) + { + case PatternBase::Machine: + case PatternBase::Text: + return input; + case PatternBase::LaTeX: + { + std::string u; + u.reserve (input.size()); + for (auto c : input) + { + switch (c) + { + case '#': + case '$': + case '%': + case '&': + case '_': + case '{': + case '}': + // simple escaping: + u.push_back('\\'); + u.push_back(c); + break; + + case '\\': + u.append("\\textbackslash{}"); + break; + + case '^': + u.append("\\^{}"); + break; + + case '~': + u.append("\\~{}"); + break; + + default: + // all other chars are just copied: + u.push_back(c); + } + } + return u; + } + default: + Assert(false, ExcNotImplemented()); + } + return ""; + } + + } + + namespace { /** @@ -76,60 +136,6 @@ namespace Patterns - std::string escape(const std::string &input, const PatternBase::OutputStyle style) - { - switch (style) - { - case PatternBase::Machine: - case PatternBase::Text: - return input; - case PatternBase::LaTeX: - { - std::string u; - u.reserve (input.size()); - for (auto c : input) - { - switch (c) - { - case '#': - case '$': - case '%': - case '&': - case '_': - case '{': - case '}': - // simple escaping: - u.push_back('\\'); - u.push_back(c); - break; - - case '\\': - u.append("\\textbackslash{}"); - break; - - case '^': - u.append("\\^{}"); - break; - - case '~': - u.append("\\~{}"); - break; - - default: - // all other chars are just copied: - u.push_back(c); - } - } - return u; - } - default: - Assert(false, ExcNotImplemented()); - } - return ""; - } - - - std::unique_ptr pattern_factory(const std::string &description) { std::unique_ptr p; @@ -571,7 +577,7 @@ namespace Patterns std::ostringstream description; description << "Any one of " - << escape(Utilities::replace_in_string(sequence,"|",", "), style); + << internal::escape(Utilities::replace_in_string(sequence,"|",", "), style); return description.str(); } @@ -711,7 +717,7 @@ namespace Patterns << " elements "; if (separator != ",") description << "separated by <" - << escape(separator, style) + << internal::escape(separator, style) << "> "; description << "where each element is [" << pattern->description(style) @@ -884,12 +890,12 @@ namespace Patterns std::ostringstream description; description << "A key" - << escape(key_value_separator, style) + << internal::escape(key_value_separator, style) << "value map of " << min_elements << " to " << max_elements << " elements "; if (separator != ",") - description << " separated by <" << escape(separator, style) << "> "; + description << " separated by <" << internal::escape(separator, style) << "> "; description << " where each key is [" << key_pattern->description(style) << "]" @@ -1091,13 +1097,13 @@ namespace Patterns << patterns.size() << " elements "; if (separator != ":") - description << " separated by <" << escape(separator, style) << "> "; + description << " separated by <" << internal::escape(separator, style) << "> "; description << " where each element is [" << patterns[0]->description(style) << "]"; for (unsigned int i=1; idescription(style) << "]"; } @@ -1290,7 +1296,7 @@ namespace Patterns std::ostringstream description; description << "A comma-separated list of any of " - << escape(Utilities::replace_in_string(sequence,"|",", "), style); + << internal::escape(Utilities::replace_in_string(sequence,"|",", "), style); return description.str(); }