summaryrefslogtreecommitdiff
path: root/src/common/Utilities/StringFormat.cpp
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.com>2022-01-19 12:01:59 +0700
committerGitHub <noreply@github.com>2022-01-19 12:01:59 +0700
commit259b9133f68ef0d740fc871d59fab3d2791f33b4 (patch)
tree89da4d2a14ee203de3baff62e6c2d5b4b025bbfa /src/common/Utilities/StringFormat.cpp
parentb5ab409614bf0d45e7a4f03c57b15edf113fe5f0 (diff)
feat(Core/Common): add new helpers for time utility (#10207)
Diffstat (limited to 'src/common/Utilities/StringFormat.cpp')
-rw-r--r--src/common/Utilities/StringFormat.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/common/Utilities/StringFormat.cpp b/src/common/Utilities/StringFormat.cpp
index 0d8ca27491..83e2d2a468 100644
--- a/src/common/Utilities/StringFormat.cpp
+++ b/src/common/Utilities/StringFormat.cpp
@@ -16,10 +16,11 @@
*/
#include "StringFormat.h"
+#include "Define.h"
#include <locale>
template<class Str>
-Str Acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/)
+AC_COMMON_API Str Acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/)
{
typename Str::const_iterator first = s.begin();
typename Str::const_iterator end = s.end();
@@ -49,5 +50,19 @@ Str Acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/
return s;
}
+std::string Acore::String::TrimRightInPlace(std::string& str)
+{
+ int pos = int(str.size()) - 1;
+
+ while (pos >= 0 && std::isspace(str[pos]))
+ {
+ --pos;
+ }
+
+ str.resize(static_cast<std::basic_string<char, std::char_traits<char>, std::allocator<char>>::size_type>(pos) + 1);
+
+ return str;
+}
+
// Template Trim
-template std::string Acore::String::Trim<std::string>(const std::string& s, const std::locale& loc /*= std::locale()*/);
+template AC_COMMON_API std::string Acore::String::Trim<std::string>(const std::string& s, const std::locale& loc /*= std::locale()*/);