diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index 54e2b18f2..fd70dfaa7 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -1,6 +1,7 @@ #include "utils/StringUtil.h" #include +#include namespace Utils { @@ -134,6 +135,17 @@ namespace Utils } // moveCursor + std::string toLower(const std::string& _string) + { + std::string string; + + for(size_t i = 0; i < _string.length(); ++i) + string += (char)tolower(_string[i]); + + return string; + + } // toLower + std::string toUpper(const std::string& _string) { std::string string; @@ -243,6 +255,31 @@ namespace Utils } // vectorToCommaString + std::string format(const char* _format, ...) + { + va_list args; + va_list copy; + + va_start(args, _format); + + va_copy(copy, args); + const int length = vsnprintf(nullptr, 0, _format, copy); + va_end(copy); + + char* buffer = new char[length + 1]; + va_copy(copy, args); + vsnprintf(buffer, length + 1, _format, copy); + va_end(copy); + + va_end(args); + + std::string out(buffer); + delete buffer; + + return out; + + } // format + } // String:: } // Utils:: diff --git a/es-core/src/utils/StringUtil.h b/es-core/src/utils/StringUtil.h index 47fb7d1fe..47bba35ac 100644 --- a/es-core/src/utils/StringUtil.h +++ b/es-core/src/utils/StringUtil.h @@ -16,6 +16,7 @@ namespace Utils size_t nextCursor (const std::string& _string, const size_t _cursor); size_t prevCursor (const std::string& _string, const size_t _cursor); size_t moveCursor (const std::string& _string, const size_t _cursor, const int _amount); + std::string toLower (const std::string& _string); std::string toUpper (const std::string& _string); std::string trim (const std::string& _string); std::string replace (const std::string& _string, const std::string& _replace, const std::string& _with); @@ -24,6 +25,7 @@ namespace Utils std::string removeParenthesis (const std::string& _string); stringVector commaStringToVector(const std::string& _string); std::string vectorToCommaString(stringVector _vector); + std::string format (const char* _string, ...); } // String::