mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 18:10:26 +00:00
feat(Core/Common): add new helpers for time utility (#10207)
This commit is contained in:
@@ -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()*/);
|
||||
|
||||
Reference in New Issue
Block a user