Index: code/branches/core2/src/util/String.cc
===================================================================
--- code/branches/core2/src/util/String.cc	(revision 1020)
+++ code/branches/core2/src/util/String.cc	(revision 1049)
@@ -27,5 +27,5 @@
 
 #include <cctype>
-
+#include <iostream>
 #include "String.h"
 
@@ -92,4 +92,28 @@
 
     return quote;
+}
+
+/**
+    @brief Returns true if pos is between two quotes.
+    @param str The string
+    @param pos The position to check
+    @return True if pos is between two quotes
+*/
+bool isBetweenQuotes(const std::string& str, unsigned int pos)
+{
+    if (pos == std::string::npos)
+        return false;
+
+    unsigned int quotecount = 0;
+    unsigned int quote = 0;
+    while ((quote = getNextQuote(str, quote)) < pos)
+    {
+        quotecount++;
+    }
+
+    if (quote == std::string::npos)
+        return false;
+
+    return ((quotecount % 2) == 1);
 }
 
@@ -124,13 +148,14 @@
     @brief Removes enclosing quotes if available.
     @brief str The string to strip
-*/
-void stripEnclosingQuotes(std::string* str)
+    @return The string with removed quotes
+*/
+std::string stripEnclosingQuotes(const std::string& str)
 {
     unsigned int start = std::string::npos;
     unsigned int end = 0;
 
-    for (unsigned int pos = 0; (pos < (*str).size()) && (pos < std::string::npos); pos++)
-    {
-        if ((*str)[pos] == '"')
+    for (unsigned int pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
+    {
+        if (str[pos] == '"')
         {
             start = pos;
@@ -138,11 +163,11 @@
         }
 
-        if (((*str)[pos] != ' ') && ((*str)[pos] != '\t') && ((*str)[pos] != '\n'))
-            return;
-    }
-
-    for (unsigned int pos = (*str).size() - 1; pos < std::string::npos; pos--)
-    {
-        if ((*str)[pos] == '"')
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
+    }
+
+    for (unsigned int pos = str.size() - 1; pos < std::string::npos; pos--)
+    {
+        if (str[pos] == '"')
         {
             end = pos;
@@ -150,22 +175,12 @@
         }
 
-        if (((*str)[pos] != ' ') && ((*str)[pos] != '\t') && ((*str)[pos] != '\n'))
-            return;
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
     }
 
     if ((start != std::string::npos) && (end != 0))
-        (*str) = (*str).substr(start + 1, end - start - 1);
-}
-
-/**
-    @brief Returns a copy of the string with removed enclosing quotes (if available).
-    @brief str The string to strip
-    @return The striped copy of the string
-*/
-std::string getStrippedEnclosingQuotes(const std::string& str)
-{
-    std::string output = std::string(str);
-    stripEnclosingQuotes(&output);
-    return output;
+        return str.substr(start + 1, end - start - 1);
+    else
+        return str;
 }
 
@@ -235,4 +250,51 @@
 }
 
+std::string addSlashes(const std::string& str)
+{
+    std::string output = str;
+
+    for (unsigned int pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\\\"); }
+    for (unsigned int pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\n"); }
+    for (unsigned int pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\t"); }
+    for (unsigned int pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\v"); }
+    for (unsigned int pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\b"); }
+    for (unsigned int pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\r"); }
+    for (unsigned int pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\f"); }
+    for (unsigned int pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\a"); }
+    for (unsigned int pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\\""); }
+    for (unsigned int pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 2, "\\0"); }
+
+    return output;
+}
+
+std::string removeSlashes(const std::string& str)
+{
+    if (str.size() == 0)
+        return str;
+
+    std::string output = "";
+    for (unsigned int pos = 0; pos < str.size() - 1; )
+    {
+        if (str[pos] == '\\')
+        {
+            if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; }
+            else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; }
+            else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; }
+            else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; }
+            else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; }
+            else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; }
+            else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; }
+            else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; }
+            else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; }
+            else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; }
+        }
+        output += str[pos];
+        pos++;
+    }
+    output += str[str.size() - 1];
+
+    return output;
+}
+
 /**
     @brief Replaces each char between A and Z with its lowercase equivalent.
@@ -364,5 +426,16 @@
 unsigned int getCommentPosition(const std::string& str)
 {
-    for (unsigned int i = 0; i < str.size(); i++)
+    return getNextCommentPosition(str, 0);
+}
+
+/**
+    @brief Returns the position of the next comment-symbol, starting with start.
+    @param str The string
+    @param start The startposition
+    @return The position
+*/
+unsigned int getNextCommentPosition(const std::string& str, unsigned int start)
+{
+    for (unsigned int i = start; i < str.size(); i++)
         if (isComment(str.substr(i)))
             return i;
Index: code/branches/core2/src/util/String.h
===================================================================
--- code/branches/core2/src/util/String.h	(revision 1020)
+++ code/branches/core2/src/util/String.h	(revision 1049)
@@ -40,14 +40,17 @@
 
 _UtilExport unsigned int getNextQuote(const std::string& str, unsigned int start);
+_UtilExport bool         isBetweenQuotes(const std::string& str, unsigned int pos);
 
 _UtilExport bool         hasStringBetweenQuotes(const std::string& str);
 _UtilExport std::string  getStringBetweenQuotes(const std::string& str);
 
-_UtilExport void         stripEnclosingQuotes(std::string* str);
-_UtilExport std::string  getStrippedEnclosingQuotes(const std::string& str);
+_UtilExport std::string  stripEnclosingQuotes(const std::string& str);
 
 _UtilExport bool         isEmpty(const std::string& str);
 _UtilExport bool         isComment(const std::string& str);
 _UtilExport bool         isNumeric(const std::string& str);
+
+_UtilExport std::string  addSlashes(const std::string& str);
+_UtilExport std::string  removeSlashes(const std::string& str);
 
 _UtilExport void         lowercase(std::string* str);
@@ -63,4 +66,5 @@
 _UtilExport std::string  getComment(const std::string& str);
 _UtilExport unsigned int getCommentPosition(const std::string& str);
+_UtilExport unsigned int getNextCommentPosition(const std::string& str, unsigned int start = 0);
 
 //! The Convert class has some static member functions to convert strings to values and values to strings.
