]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make mangle an internal function of ParameterHandler.
authorMFraters <menno.fraters@hotmail.com>
Sun, 4 Mar 2018 02:26:55 +0000 (03:26 +0100)
committerMFraters <menno.fraters@hotmail.com>
Sun, 4 Mar 2018 14:16:34 +0000 (15:16 +0100)
include/deal.II/base/parameter_handler.h
source/base/parameter_handler.cc

index e5bc57cb978a8845a96285ff5f994e64865f9047..95668d351dab3297e39ba05a78494b8e51c68e46 100644 (file)
@@ -1478,17 +1478,6 @@ private:
    */
   std::vector<std::function<void (const std::string &)> > actions;
 
-  /**
-   * Mangle a string so that it doesn't contain any special characters or
-   * spaces.
-   */
-  static std::string mangle (const std::string &s);
-
-  /**
-   * Unmangle a string into its original form.
-   */
-  static std::string demangle (const std::string &s);
-
   /**
    * Given a list of directories and subdirectories that identify
    * a particular place in the tree, return the string that identifies
index 506bffeae11ee8a91713dba6d429aaf28ad34ed0..604e1d0f3fbde194e45937a15c252baba679b1e1 100644 (file)
@@ -46,181 +46,178 @@ ParameterHandler::ParameterHandler ()
 {}
 
 
-
-std::string
-ParameterHandler::mangle (const std::string &s)
+namespace
 {
-  std::string u;
-
-  // reserve the minimum number of characters we will need. it may
-  // be more but this is the least we can do
-  u.reserve (s.size());
+  std::string
+  mangle (const std::string &s)
+  {
+    std::string u;
 
-  // see if the name is special and if so mangle the whole thing
-  const bool mangle_whole_string = (s == "value");
+    // reserve the minimum number of characters we will need. it may
+    // be more but this is the least we can do
+    u.reserve (s.size());
 
-  // for all parts of the string, see
-  // if it is an allowed character or
-  // not
-  for (unsigned int i=0; i<s.size(); ++i)
-    {
-      static const std::string allowed_characters
-      ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+    // see if the name is special and if so mangle the whole thing
+    const bool mangle_whole_string = (s == "value");
 
-      if ((! mangle_whole_string)
-          &&
-          (allowed_characters.find (s[i]) != std::string::npos))
-        u.push_back (s[i]);
-      else
-        {
-          u.push_back ('_');
-          static const char hex[16]
-            = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
-          u.push_back (hex[static_cast<unsigned char>(s[i])/16]);
-          u.push_back (hex[static_cast<unsigned char>(s[i])%16]);
-        }
-    }
-
-  return u;
-}
+    // for all parts of the string, see
+    // if it is an allowed character or
+    // not
+    for (unsigned int i=0; i<s.size(); ++i)
+      {
+        static const std::string allowed_characters
+        ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
 
+        if ((! mangle_whole_string)
+            &&
+            (allowed_characters.find (s[i]) != std::string::npos))
+          u.push_back (s[i]);
+        else
+          {
+            u.push_back ('_');
+            static const char hex[16]
+              = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+            u.push_back (hex[static_cast<unsigned char>(s[i])/16]);
+            u.push_back (hex[static_cast<unsigned char>(s[i])%16]);
+          }
+      }
 
+    return u;
+  }
 
-std::string
-ParameterHandler::demangle (const std::string &s)
-{
-  std::string u;
-  u.reserve (s.size());
 
-  for (unsigned int i=0; i<s.size(); ++i)
-    if (s[i] != '_')
-      u.push_back (s[i]);
-    else
-      {
-        Assert (i+2 < s.size(),
-                ExcMessage ("Trying to demangle an invalid string."));
 
-        unsigned char c = 0;
-        switch (s[i+1])
-          {
-          case '0':
-            c = 0 * 16;
-            break;
-          case '1':
-            c = 1 * 16;
-            break;
-          case '2':
-            c = 2 * 16;
-            break;
-          case '3':
-            c = 3 * 16;
-            break;
-          case '4':
-            c = 4 * 16;
-            break;
-          case '5':
-            c = 5 * 16;
-            break;
-          case '6':
-            c = 6 * 16;
-            break;
-          case '7':
-            c = 7 * 16;
-            break;
-          case '8':
-            c = 8 * 16;
-            break;
-          case '9':
-            c = 9 * 16;
-            break;
-          case 'a':
-            c = 10 * 16;
-            break;
-          case 'b':
-            c = 11 * 16;
-            break;
-          case 'c':
-            c = 12 * 16;
-            break;
-          case 'd':
-            c = 13 * 16;
-            break;
-          case 'e':
-            c = 14 * 16;
-            break;
-          case 'f':
-            c = 15 * 16;
-            break;
-          default:
-            Assert (false, ExcInternalError());
-          }
-        switch (s[i+2])
-          {
-          case '0':
-            c += 0;
-            break;
-          case '1':
-            c += 1;
-            break;
-          case '2':
-            c += 2;
-            break;
-          case '3':
-            c += 3;
-            break;
-          case '4':
-            c += 4;
-            break;
-          case '5':
-            c += 5;
-            break;
-          case '6':
-            c += 6;
-            break;
-          case '7':
-            c += 7;
-            break;
-          case '8':
-            c += 8;
-            break;
-          case '9':
-            c += 9;
-            break;
-          case 'a':
-            c += 10;
-            break;
-          case 'b':
-            c += 11;
-            break;
-          case 'c':
-            c += 12;
-            break;
-          case 'd':
-            c += 13;
-            break;
-          case 'e':
-            c += 14;
-            break;
-          case 'f':
-            c += 15;
-            break;
-          default:
-            Assert (false, ExcInternalError());
-          }
+  std::string
+  demangle (const std::string &s)
+  {
+    std::string u;
+    u.reserve (s.size());
 
-        u.push_back (static_cast<char>(c));
+    for (unsigned int i=0; i<s.size(); ++i)
+      if (s[i] != '_')
+        u.push_back (s[i]);
+      else
+        {
+          Assert (i+2 < s.size(),
+                  ExcMessage ("Trying to demangle an invalid string."));
 
-        // skip the two characters
-        i += 2;
-      }
+          unsigned char c = 0;
+          switch (s[i+1])
+            {
+            case '0':
+              c = 0 * 16;
+              break;
+            case '1':
+              c = 1 * 16;
+              break;
+            case '2':
+              c = 2 * 16;
+              break;
+            case '3':
+              c = 3 * 16;
+              break;
+            case '4':
+              c = 4 * 16;
+              break;
+            case '5':
+              c = 5 * 16;
+              break;
+            case '6':
+              c = 6 * 16;
+              break;
+            case '7':
+              c = 7 * 16;
+              break;
+            case '8':
+              c = 8 * 16;
+              break;
+            case '9':
+              c = 9 * 16;
+              break;
+            case 'a':
+              c = 10 * 16;
+              break;
+            case 'b':
+              c = 11 * 16;
+              break;
+            case 'c':
+              c = 12 * 16;
+              break;
+            case 'd':
+              c = 13 * 16;
+              break;
+            case 'e':
+              c = 14 * 16;
+              break;
+            case 'f':
+              c = 15 * 16;
+              break;
+            default:
+              Assert (false, ExcInternalError());
+            }
+          switch (s[i+2])
+            {
+            case '0':
+              c += 0;
+              break;
+            case '1':
+              c += 1;
+              break;
+            case '2':
+              c += 2;
+              break;
+            case '3':
+              c += 3;
+              break;
+            case '4':
+              c += 4;
+              break;
+            case '5':
+              c += 5;
+              break;
+            case '6':
+              c += 6;
+              break;
+            case '7':
+              c += 7;
+              break;
+            case '8':
+              c += 8;
+              break;
+            case '9':
+              c += 9;
+              break;
+            case 'a':
+              c += 10;
+              break;
+            case 'b':
+              c += 11;
+              break;
+            case 'c':
+              c += 12;
+              break;
+            case 'd':
+              c += 13;
+              break;
+            case 'e':
+              c += 14;
+              break;
+            case 'f':
+              c += 15;
+              break;
+            default:
+              Assert (false, ExcInternalError());
+            }
 
-  return u;
-}
+          u.push_back (static_cast<char>(c));
 
+          // skip the two characters
+          i += 2;
+        }
 
+    return u;
+  }
 
-namespace
-{
   /**
    * Return whether a given node is a parameter node (as opposed
    * to being a subsection or alias node)

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.