Index: trunk/FACT++/src/tools.cc
===================================================================
--- trunk/FACT++/src/tools.cc	(revision 13167)
+++ trunk/FACT++/src/tools.cc	(revision 13168)
@@ -73,2 +73,43 @@
     return str.substr(start, end-start+1);
 }
+
+// --------------------------------------------------------------------------
+//
+//! This is a static helper to remove leading and trailing whitespaces.
+//!
+//! Usage example:
+//!
+//! \code
+//!    string str = "     Dies ist ein test fuer einen ganz     langen Satz "
+//!        "und ob er korrekt umgebrochen und formatiert wird. Alles "
+//!        "nur ein simpler test aber trotzdem ganz wichtig.";
+//!
+//!    cout << setfill('-') << setw(40) << "+" << endl;
+//!    while (1)
+//!    {
+//!        const string rc = Tools::Wrap(str, 40);
+//!        if (rc.empty())
+//!            break;
+//!        cout << rc << endl;
+//!    }
+//! \endcode
+//!
+string Tools::Wrap(string &str, size_t width)
+{
+    const size_t pos = str.length()<width ? string::npos : str.find_last_of(' ', width);
+    if (pos==string::npos)
+    {
+        const string rc = str;
+        str = "";
+        return rc;
+    }
+
+    const size_t indent = str.find_first_not_of(' ');
+
+    const string rc = str.substr(0, pos);
+    const size_t p2 = str.find_first_not_of(' ', pos+1);
+
+    str = str.substr(0, indent) + str.substr(p2==string::npos ? pos+1 : p2);
+
+    return rc;
+}
Index: trunk/FACT++/src/tools.h
===================================================================
--- trunk/FACT++/src/tools.h	(revision 13167)
+++ trunk/FACT++/src/tools.h	(revision 13168)
@@ -1,2 +1,5 @@
+#ifndef FACT_Tools
+#define FACT_Tools
+
 #include <string>
 
@@ -6,3 +9,6 @@
     std::string Form(const char *fmt, ...);
     std::string Trim(const std::string &str);
+    std::string Wrap(std::string &str, size_t width=78);
 }
+
+#endif
