]> https://gitweb.dealii.org/ - dealii.git/commitdiff
move to namespace 5385/head
authorTimo Heister <timo.heister@gmail.com>
Fri, 10 Nov 2017 19:23:16 +0000 (14:23 -0500)
committerTimo Heister <timo.heister@gmail.com>
Fri, 10 Nov 2017 19:23:16 +0000 (14:23 -0500)
include/deal.II/base/patterns.h
source/base/parameter_handler.cc
source/base/patterns.cc

index 8b01b979f56faf1a4ef9b329e61c8ec567705eb7..886eca3a27582235e3d1bebfcec3522ac998e8f9 100644 (file)
@@ -148,13 +148,16 @@ namespace Patterns
    */
   std::unique_ptr<PatternBase> 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
index 16e28de4ea8dca9bd88a5ff41720cf6fe0fc3903..003351a81f6edbca837f5ccaaacd868dab691421 100644 (file)
@@ -1106,7 +1106,7 @@ ParameterHandler::recursively_print_parameters (const std::vector<std::string> &
     {
       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<std::string> &
           {
             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
index e146091d019f6e1127e23928c5a5c3de3da03c4f..bb7d3e64d2fea261d91e18e6566bcf883acbd10f 100644 (file)
@@ -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<PatternBase> pattern_factory(const std::string &description)
   {
     std::unique_ptr<PatternBase> 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; i<patterns.size(); ++i)
           {
-            description << escape(separator, style)
+            description << internal::escape(separator, style)
                         << "[" << patterns[i]->description(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();
       }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.