]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use the has_documentation flag.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Sep 2005 23:56:34 +0000 (23:56 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Sep 2005 23:56:34 +0000 (23:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@11375 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/utilities.cc

index 1f3a98b25a84d08d7881048ce3771bbe00695028..feafbb211e06f69dd11d5a2000a96539ff6c64a8 100644 (file)
@@ -176,6 +176,65 @@ namespace Utilities
 
     return split_list;
   }
+
+
+
+  std::vector<std::string>
+  break_text_into_lines (const std::string &original_text,
+                         const unsigned int width)
+  {
+    std::string              text = original_text;
+    std::vector<std::string> lines;
+
+                                     // remove trailing spaces
+    while ((text.length() != 0) && (text[text.length()-1] == ' '))
+      text.erase(text.length()-1,1);
+  
+                                     // then split the text into lines
+    while (text.length() != 0)
+      {
+                                         // in each iteration, first remove
+                                         // leading spaces
+        while ((text.length() != 0) && (text[0] == ' '))
+          text.erase(0, 1);
+
+                                         // if we can fit everything into one
+                                         // line, then do so. otherwise, we have
+                                         // to keep breaking
+        if (text.length() < width)
+          {
+            lines.push_back (text);
+            text = "";
+          }
+        else
+          {
+                                             // starting at position width, find the
+                                             // location of the previous space, so
+                                             // that we can break around there
+            int location = std::min(width,text.length()-1);
+            for (; location>=0; --location)
+              if (text[location] == ' ')
+                break;
+          
+                                             // if there are no spaces, then try if
+                                             // there are spaces coming up
+            if (location == 0)
+              for (location = std::min(width,text.length()-1);
+                   location<static_cast<int>(text.length());
+                   ++location)
+                if (text[location] == ' ')
+                  break;
+          
+                                             // now take the text up to the found
+                                             // location and put it into a single
+                                             // line, and remove it from 'text'
+            lines.push_back (std::string (text, 0, location));
+            text.erase (0, location);
+          }
+      }
+  
+    return lines;
+  }
   
   
 

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.