Index: trunk/src/lib/util/substring.cc
===================================================================
--- trunk/src/lib/util/substring.cc	(revision 7300)
+++ trunk/src/lib/util/substring.cc	(revision 7319)
@@ -26,10 +26,4 @@
 */
 
-
-/**
- *  breaks a string into parts that were initially seperated by comma
- * @param string the string to break into substrings
-*/
-
 #include "substring.h"
 
@@ -37,4 +31,9 @@
 #include <cassert>
 
+/**
+ * @brief create a SubString from
+ * @param string the String to Spilit
+ * @param splitter the Character at which to split string (delimiter)
+ */
 SubString::SubString(const std::string& string, char splitter)
 {
@@ -47,27 +46,116 @@
 
 /**
- * Splits a String into a Substring removing all whiteSpaces
+ * @brief Splits a String into a SubString removing all whiteSpaces
  * @param string the String to Split
- * @param whiteSpaces MUST BE __TRUE__
- *
+ * @param whiteSpaces MUST BE __TRUE__ or __FALSE__ (will be ignored)
  */
 SubString::SubString(const std::string& string, bool whiteSpaces)
 {
   SubString::splitLine(this->strings, this->offsets,
-                      string);
-}
+                       string);
+}
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param splitters multiple set of characters at what to split. (delimiters)
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
 SubString::SubString(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
 {
   SubString::splitLine(this->strings, this->offsets,
-                       string, splitters, escapeChar, safemode_char);
-}
-
-/**
- * An empty String
+                       string, splitters, escapeChar, safemode_char, comment_char);
+}
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a set from.
+ * @param subSetBegin the beginning to the end
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+{
+  for (unsigned int i = subSetBegin; i < subString.size(); i++)
+    this->strings.push_back(subString[i]);
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a Set from
+ * @param subSetBegin the beginning to the end
+ * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly)
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd)
+{
+  for (unsigned int i = subSetBegin; i < subString.size() || i < subSetEnd; i++)
+    this->strings.push_back(subString[i]);
+}
+
+
+/**
+ * @brief removes the object from memory
+ */
+SubString::~SubString()
+{ }
+
+/**
+ * @brief An empty String
  */
 const std::string SubString::emptyString = "";
 
-
-
+/**
+ * @brief stores the Value of subString in this SubString
+ * @param subString will be copied into this String.
+ * @returns this SubString.
+ */
+SubString& SubString::operator=(const SubString& subString)
+{
+  this->offsets = subString.offsets;
+  this->strings = subString.strings;
+  return *this;
+}
+
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @returns true if the Stored Strings match
+ */
+bool SubString::operator==(const SubString& subString)
+{
+  return (this->strings == subString.strings);
+}
+
+
+/**
+ * @brief append operator
+ * @param subString the String to append.
+ * @returns a SubString where this and subString are appended.
+ */
+SubString SubString::operator+(const SubString& subString) const
+{
+  return SubString(subString) += subString;
+}
+
+
+/**
+ * @brief append operator.
+ * @param subString append subString to this SubString.
+ * @returns this substring appended with subString
+ */
+SubString& SubString::operator+=(const SubString& subString)
+{
+  for (unsigned int i = 0; i < subString.size(); i++)
+    this->strings.push_back(subString[i]);
+}
+
+
+/**
+ * @brief Split the String at
+ * @param string where to split
+ * @param splitter delimiter.
+ */
 unsigned int SubString::split(const std::string& string, char splitter)
 {
@@ -83,5 +171,5 @@
 
 /**
- * Splits a String into a Substring removing all whiteSpaces
+ * @brief Splits a String into a Substring removing all whiteSpaces
  * @param string the String to Split
  * @param whiteSpaces MUST BE __TRUE__
@@ -96,4 +184,13 @@
 }
 
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param splitters multiple set of characters at what to split. (delimiters)
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
 unsigned int SubString::split(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
 {
@@ -103,4 +200,66 @@
                        string, splitters, escapeChar, safemode_char);
   return strings.size();
+}
+
+
+/**
+ * @brief joins together all Strings of this Substring.
+ * @param delimiter the String between the subStrings.
+ * @returns the joined String.
+ */
+std::string SubString::join(const std::string& delimiter) const
+{
+  if (!this->strings.empty())
+  {
+    std::string retVal = this->strings[0];
+    for (unsigned int i = 0; i < this->strings.size(); i++)
+      retVal += delimiter + this->strings[i];
+    return retVal;
+  }
+  else
+    return SubString::emptyString;
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to the end
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::getSubSet(unsigned int subSetBegin) const
+{
+  return SubString(*this, subSetBegin);
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to
+ * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.)
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const
+{
+  return SubString(*this, subSetBegin, subSetEnd);
+}
+
+
+/**
+ * @brief get a particular substring's offset
+ * @param i the ID of the substring to get the offset from
+ * @returns the offset or NULL if an invalid ID was given
+ */
+unsigned int SubString::getOffset(unsigned int i) const
+{
+  if( i < this->offsets.size() && i >= 0)
+    return this->offsets[i];
+  else
+    return 0;
 }
 
@@ -119,4 +278,5 @@
  * @returns SPLIT_LINE_STATE the parser was in when returning
  *
+ * This is the Actual Splitting Algorithm from Clemens Wacha
  * Supports delimiters, escape characters,
  * ignores special  characters between safemode_char and between comment_char and linend '\n'.
@@ -142,99 +302,99 @@
     switch(state)
     {
-    case SL_NORMAL:
-      if(line[i] == escape_char)
-      {
-        state = SL_ESCAPE;
-      }
-      else if(line[i] == safemode_char)
-      {
+      case SL_NORMAL:
+        if(line[i] == escape_char)
+        {
+          state = SL_ESCAPE;
+        }
+        else if(line[i] == safemode_char)
+        {
+          state = SL_SAFEMODE;
+        }
+        else if(line[i] == comment_char)
+        {
+          /// FINISH
+          if(token.size() > 0)
+          {
+            ret.push_back(token);
+            offsets.push_back(i);
+            token.clear();
+          }
+          token += line[i];       // EAT
+          state = SL_COMMENT;
+        }
+        else if(delimiters.find(line[i]) != std::string::npos)
+        {
+          // line[i] is a delimiter
+          /// FINISH
+          if(token.size() > 0)
+          {
+            ret.push_back(token);
+            offsets.push_back(i);
+            token.clear();
+          }
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+      case SL_ESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
+        state = SL_NORMAL;
+        break;
+      case SL_SAFEMODE:
+        if(line[i] == safemode_char)
+        {
+          state = SL_NORMAL;
+        }
+        else if(line[i] == escape_char)
+        {
+          state = SL_SAFEESCAPE;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+      case SL_SAFEESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
         state = SL_SAFEMODE;
-      }
-      else if(line[i] == comment_char)
-      {
-        /// FINISH
-        if(token.size() > 0)
-        {
-          ret.push_back(token);
-          offsets.push_back(i);
-          token.clear();
-        }
-        token += line[i];       // EAT
-        state = SL_COMMENT;
-      }
-      else if(delimiters.find(line[i]) != std::string::npos)
-      {
-        // line[i] is a delimiter
-        /// FINISH
-        if(token.size() > 0)
-        {
-          ret.push_back(token);
-          offsets.push_back(i);
-          token.clear();
-        }
-      }
-      else
-      {
-        token += line[i];       // EAT
-      }
-      break;
-    case SL_ESCAPE:
-      if(line[i] == 'n') token += '\n';
-      else if(line[i] == 't') token += '\t';
-      else if(line[i] == 'v') token += '\v';
-      else if(line[i] == 'b') token += '\b';
-      else if(line[i] == 'r') token += '\r';
-      else if(line[i] == 'f') token += '\f';
-      else if(line[i] == 'a') token += '\a';
-      else if(line[i] == '?') token += '\?';
-      else token += line[i];  // EAT
-      state = SL_NORMAL;
-      break;
-    case SL_SAFEMODE:
-      if(line[i] == safemode_char)
-      {
-        state = SL_NORMAL;
-      }
-      else if(line[i] == escape_char)
-      {
-        state = SL_SAFEESCAPE;
-      }
-      else
-      {
-        token += line[i];       // EAT
-      }
-      break;
-    case SL_SAFEESCAPE:
-      if(line[i] == 'n') token += '\n';
-      else if(line[i] == 't') token += '\t';
-      else if(line[i] == 'v') token += '\v';
-      else if(line[i] == 'b') token += '\b';
-      else if(line[i] == 'r') token += '\r';
-      else if(line[i] == 'f') token += '\f';
-      else if(line[i] == 'a') token += '\a';
-      else if(line[i] == '?') token += '\?';
-      else token += line[i];  // EAT
-      state = SL_SAFEMODE;
-      break;
-    case SL_COMMENT:
-      if(line[i] == '\n')
-      {
-        /// FINISH
-        if(token.size() > 0)
-        {
-          ret.push_back(token);
-          offsets.push_back(i);
-          token.clear();
-        }
-        state = SL_NORMAL;
-      }
-      else
-      {
-        token += line[i];       // EAT
-      }
-      break;
-    default:
-      // nothing
-      break;
+        break;
+      case SL_COMMENT:
+        if(line[i] == '\n')
+        {
+          /// FINISH
+          if(token.size() > 0)
+          {
+            ret.push_back(token);
+            offsets.push_back(i);
+            token.clear();
+          }
+          state = SL_NORMAL;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+      default:
+        // nothing
+        break;
     }
     i++;
@@ -251,25 +411,7 @@
 }
 
-/**
- *  removes the object from memory
-*/
-SubString::~SubString()
-{ }
-
-/**
- * get a particular substring's offset
- * @param i the ID of the substring to get the offset from
- * @returns the offset or NULL if an invalid ID was given
- */
-unsigned int SubString::getOffset(unsigned int i)
-{
-  if( i < this->offsets.size() && i >= 0)
-    return this->offsets[i];
-  else
-    return 0;
-}
-
-/**
- * Some nice debug information about this SubString
+
+/**
+ * @brief Some nice debug information about this SubString
  */
 void SubString::debug() const
Index: trunk/src/lib/util/substring.h
===================================================================
--- trunk/src/lib/util/substring.h	(revision 7300)
+++ trunk/src/lib/util/substring.h	(revision 7319)
@@ -10,42 +10,69 @@
 #include <string>
 
-  typedef enum {
-    SL_NORMAL,
-    SL_ESCAPE,
-    SL_SAFEMODE,
-    SL_SAFEESCAPE,
-    SL_COMMENT,
-  } SPLIT_LINE_STATE;
+typedef enum {
+  SL_NORMAL,
+  SL_ESCAPE,
+  SL_SAFEMODE,
+  SL_SAFEESCAPE,
+  SL_COMMENT,
+} SPLIT_LINE_STATE;
 
 //! A class that can load one string and split it in multipe ones
+/**
+ * SubString is a very Powerfull way to create a SubSet from a String
+ * It can be used, to Split strings append them and join them again.
+ */
 class SubString
 {
- public:
+public:
   SubString(const std::string& string = "", char splitter = ',');
   SubString(const std::string& string, bool whiteSpaces);
   SubString(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
+  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
+  SubString(const SubString& subString) { *this = subString; };
+  SubString(const SubString& subString, unsigned int subSetBegin);
+  SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd);
   ~SubString();
 
+  // operate on the SubString
+  SubString& operator=(const SubString& subString);
+  bool operator==(const SubString& subString);
+  SubString operator+(const SubString& subString) const;
+  SubString& operator+=(const SubString& subString);
+  /** @param subString the String to append @returns appended String. @brief added for convenience */
+  SubString& append(const SubString subString) { return (*this += subString); };
+
+  /////////////////////////////////////////
+  // Split and Join the any String. ///////
   unsigned int split(const std::string& string = "", char splitter = ',');
   unsigned int split(const std::string& string, bool whiteSpaces);
   unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
+  std::string join(const std::string& delimiter) const;
+  ////////////////////////////////////////
 
-  inline unsigned int getCount() { return this->strings.size(); };
-  const std::string& getString(unsigned int i) { return (i < this->strings.size()) ? this->strings[i] : emptyString; }; // safety-precaution
-  const std::string& operator[](unsigned int i) { return this->getString(i); };
-  unsigned int getOffset(unsigned int i);
+  // retrieve a SubSet from the String
+  SubString getSubSet(unsigned int subSetBegin) const;
+  SubString getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
 
+  // retrieve Information from within
+  inline unsigned int size() const { return this->strings.size(); };
+const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; }
+  ; // safety-precaution
+  const std::string& operator[](unsigned int i) const { return this->getString(i); };
+  unsigned int getOffset(unsigned int i) const;
+
+  // the almighty algorithm.
   static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,std::vector<unsigned int>& offsets,
                                     const std::string& line, const std::string& delimiters = " \t\r\n",
                                     char escape_char = '\\', char safemode_char = '"', char comment_char = '\0',
                                     SPLIT_LINE_STATE start_state = SL_NORMAL);
-
+  // debugging.
   void debug() const;
 
- private:
-   std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
-   std::vector<unsigned int> offsets;                      //!< offsets of the beginning of the input-string to the beginning of each substring.
+private:
+  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
+  std::vector<unsigned int> offsets;                      //!< offsets of the beginning of the input-string to the beginning of each substring.
 
-   static const std::string emptyString;
+  static const std::string emptyString;
 };
 
