]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Made whitespace character a default delimiter for utility function break_text_into_li...
authorprill <prill@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Oct 2006 15:51:16 +0000 (15:51 +0000)
committerprill <prill@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Oct 2006 15:51:16 +0000 (15:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@13994 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/utilities.h
deal.II/base/source/utilities.cc

index 791ab2f51bc60940fb6994758722fef68853b046..f32f9cb710b9b0fec254b0c3752e4315dfab4db1 100644 (file)
@@ -89,14 +89,16 @@ namespace Utilities
                                     * something, and try to break it into
                                     * individual lines of text at most @p
                                     * width characters wide, by breaking at
-                                    * spaces in the text. If this is not
-                                    * possible, return the shortest lines than
-                                    * are longer than @p width.
+                                    * positions marked by @p delimiter in the text.
+                                    * If this is not possible, return the shortest
+                                    * lines than are longer than @p width.
+                                    * The default value of the delimiter is a
+                                    * space character.
                                     */
   std::vector<std::string>
   break_text_into_lines (const std::string &original_text,
-                         const unsigned int width);
-
+                         const unsigned int width,
+                         const char delimiter = ' ');
 
                                   /**
                                    * Teturn true if the given pattern
index c59741c668dd9411ada17888fab5e519a49e173c..6f467c250c4c7a985a9993fa42f81d957df07525 100644 (file)
@@ -180,13 +180,14 @@ namespace Utilities
 
   std::vector<std::string>
   break_text_into_lines (const std::string &original_text,
-                         const unsigned int width)
+                         const unsigned int width,
+                         const char delimiter)
   {
     std::string              text = original_text;
     std::vector<std::string> lines;
 
                                      // remove trailing spaces
-    while ((text.length() != 0) && (text[text.length()-1] == ' '))
+    while ((text.length() != 0) && (text[text.length()-1] == delimiter))
       text.erase(text.length()-1,1);
   
                                      // then split the text into lines
@@ -194,7 +195,7 @@ namespace Utilities
       {
                                          // in each iteration, first remove
                                          // leading spaces
-        while ((text.length() != 0) && (text[0] == ' '))
+        while ((text.length() != 0) && (text[0] == delimiter))
           text.erase(0, 1);
 
                                          // if we can fit everything into one
@@ -212,7 +213,7 @@ namespace Utilities
                                              // that we can break around there
             int location = std::min<int>(width,text.length()-1);
             for (; location>=0; --location)
-              if (text[location] == ' ')
+              if (text[location] == delimiter)
                 break;
           
                                              // if there are no spaces, then try if
@@ -221,7 +222,7 @@ namespace Utilities
               for (location = std::min<int>(width,text.length()-1);
                    location<static_cast<int>(text.length());
                    ++location)
-                if (text[location] == ' ')
+                if (text[location] == delimiter)
                   break;
           
                                              // now take the text up to the found

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.