Index: code/trunk/src/libraries/util/StringUtils.cc
===================================================================
--- code/trunk/src/libraries/util/StringUtils.cc	(revision 11109)
+++ code/trunk/src/libraries/util/StringUtils.cc	(revision 11111)
@@ -34,4 +34,5 @@
 #include "StringUtils.h"
 
+#include <algorithm>
 #include <cctype>
 #include <ctime>
@@ -54,11 +55,5 @@
     void strip(std::string* str)
     {
-        size_t pos;
-        while ((pos = str->find(' ')) < str->length())
-            str->erase(pos, 1);
-        while ((pos = str->find('\t')) < str->length())
-            str->erase(pos, 1);
-        while ((pos = str->find('\n')) < str->length())
-            str->erase(pos, 1);
+        str->erase(std::remove_if(str->begin(), str->end(), [](char val) { return std::isspace(val) != 0; }), str->end());
     }
 
@@ -74,9 +69,12 @@
     std::string removeTrailingWhitespaces(const std::string& str)
     {
-        size_t pos1 = 0;
-        int pos2 = static_cast<int>(str.size() - 1);
-        for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
-        for (; pos2 > 0         && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
-        return str.substr(pos1, pos2 - pos1 + 1);
+        auto pos1 = std::find_if(str.begin(), str.end(), [](char val) { return std::isspace(val) == 0; });
+        auto pos2 = std::find_if(str.rbegin(), str.rend(), [](char val) { return std::isspace(val) == 0; });
+        if (pos1 == str.end() && pos2 == str.rend())
+        {
+            // String doesn't have non-whitespace characters
+            return "";
+        }
+        return std::string(pos1, pos2.base());
     }
 
@@ -162,37 +160,29 @@
     /**
         @brief Removes enclosing quotation marks if available (including whitespaces at the outside of the quotation marks).
-        @return The striped string without quotation marks
+        @return The stripped string without quotation marks
     */
     std::string stripEnclosingQuotes(const std::string& str)
     {
-        size_t start = std::string::npos;
-        size_t end = 0;
-
-        for (size_t pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
-        {
-            if (str[pos] == '"')
-            {
-                start = pos;
-                break;
-            }
-
-            if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+        auto start = str.begin();
+        auto end = str.rbegin();
+
+        for (; start != str.end() && *start != '"'; ++start)
+        {
+            if (std::isspace(*start) == 0)
                 return str;
         }
 
-        for (size_t pos = str.size() - 1; pos < std::string::npos; pos--)
-        {
-            if (str[pos] == '"')
-            {
-                end = pos;
-                break;
-            }
-
-            if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+        for (; end != str.rend() && *end != '"'; ++end)
+        {
+            if (std::isspace(*end) == 0)
                 return str;
         }
 
-        if ((start != std::string::npos) && (end != 0))
-            return str.substr(start + 1, end - start - 1);
+        if (start != str.end() && end != str.rend())
+        {
+            ++start; // Skip "
+            ++end; // Skip "
+            return std::string(start, end.base());
+        }
         else
             return str;
@@ -201,14 +191,23 @@
     /**
         @brief Removes enclosing braces '{' and '}' (the braces must be exactly on the beginning and the end of the string).
-        @return The striped string without braces
+        @return The stripped string without braces
     */
     std::string stripEnclosingBraces(const std::string& str)
     {
-        std::string output = str;
-
-        while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
-            output = output.substr(1, output.size() - 2);
-
-        return output;
+        if (str.empty())
+        {
+            return "";
+        }
+
+        auto start = str.begin();
+        auto end = str.rbegin();
+
+        while (*start == '{' && *end == '}')
+        {
+            ++start;
+            ++end;
+        }
+
+        return std::string(start, end.base());
     }
 
@@ -245,5 +244,5 @@
     bool isEmpty(const std::string& str)
     {
-        return getStripped(str).empty();
+        return std::all_of(str.begin(), str.end(), [](char val) { return std::isspace(val) != 0; });
     }
 
@@ -337,8 +336,5 @@
     void lowercase(std::string* str)
     {
-        for (char& character : *str)
-        {
-            character = static_cast<char>(tolower(character));
-        }
+        std::transform(str->begin(), str->end(), str->begin(), [](char val) { return std::tolower(val); });
     }
 
@@ -354,8 +350,5 @@
     void uppercase(std::string* str)
     {
-        for (char& character : *str)
-        {
-            character = static_cast<char>(toupper(character));
-        }
+        std::transform(str->begin(), str->end(), str->begin(), [](char val) { return std::toupper(val); });
     }
 
@@ -370,26 +363,22 @@
     /**
         @brief Compares two strings ignoring different casing.
-        @return s1 == s1 -> returns 0 / s1 < s2 -> returns -1 / s1 >= s2 -> returns 1
+        @return s1 == s2 -> returns 0 / s1 < s2 -> returns -1 / s1 >= s2 -> returns 1
     */
     int nocaseCmp(const std::string& s1, const std::string& s2)
     {
-        std::string::const_iterator it1=s1.begin();
-        std::string::const_iterator it2=s2.begin();
-
-        //stop when either string's end has been reached
-        while ( (it1!=s1.end()) && (it2!=s2.end()) )
-        {
-            if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
-                // return -1 to indicate smaller than, 1 otherwise
-                return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
-            //proceed to the next character in each string
-            ++it1;
-            ++it2;
-        }
-        size_t size1=s1.size(), size2=s2.size();// cache lengths
+        size_t size1 = s1.size(), size2 = s2.size(); // cache lengths
+
+        int res = nocaseCmp(s1, s2, std::min(size1, size2));
+
+        if (res != 0)
+        {
+            return res;
+        }
+
         //return -1,0 or 1 according to strings' lengths
-        if (size1==size2)
+        if (size1 == size2)
             return 0;
-        return (size1<size2) ? -1 : 1;
+        return (size1 < size2) ? -1 : 1;
+
     }
 
@@ -405,13 +394,13 @@
         if (len == 0)
             return 0;
-        std::string::const_iterator it1=s1.begin();
-        std::string::const_iterator it2=s2.begin();
+        std::string::const_iterator it1 = s1.begin();
+        std::string::const_iterator it2 = s2.begin();
 
         //stop when either string's end has been reached
-        while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
-        {
-            if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+        while ( (it1 != s1.end()) && (it2 != s2.end()) && len-- > 0)
+        {
+            if(std::toupper(*it1) != std::toupper(*it2)) //letters differ?
                 // return -1 to indicate smaller than, 1 otherwise
-                return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
+                return (std::toupper(*it1)  < std::toupper(*it2)) ? -1 : 1;
             //proceed to the next character in each string
             ++it1;
@@ -508,5 +497,5 @@
     /**
     @brief
-        Get a timestamp for the curent time instant.
+        Get a timestamp for the current time instant.
     @return
         Returns a string with the timestamp.
@@ -514,14 +503,8 @@
     std::string getTimestamp(void)
     {
-        struct tm *pTime;
         time_t ctTime; std::time(&ctTime);
-        pTime = std::localtime( &ctTime );
+        tm* pTime = std::localtime(&ctTime);
         std::ostringstream oss;
-        oss << std::setw(2) << std::setfill('0') << (pTime->tm_mon + 1)
-            << std::setw(2) << std::setfill('0') << pTime->tm_mday
-            << std::setw(2) << std::setfill('0') << (pTime->tm_year + 1900)
-            << "_" << std::setw(2) << std::setfill('0') << pTime->tm_hour
-            << std::setw(2) << std::setfill('0') << pTime->tm_min
-            << std::setw(2) << std::setfill('0') << pTime->tm_sec;
+        oss << std::put_time(pTime, "%m%d%Y_%H%M%S");
         return oss.str();
     }
