void StringUtil::ltrim(std::wstring& str) { if (str.empty()) return; std::wstring::size_type pos = str.find_last_not_of(L" "); if (pos != std::wstring::npos) str.erase(pos+1); pos = str.find_last_not_of(L"\t"); if (pos != std::wstring::npos) str.erase(pos+1); }
std::wstring stringHelper::rtrim( const std::wstring& wstr ) { if ( wstr.empty() ) return wstr ; return wstr.substr( 0, wstr.find_last_not_of( __delimiters ) + 1 ) ; }
static std::wstring wbasename(const std::wstring &s) { const auto i = s.find_last_not_of(L"/"); if (i == std::wstring::npos) { return s.empty() ? L"." : L"/"; } const auto from = 1 + s.find_last_of(L"/", i); /* 1 + std::wstring::npos == 0 */ return s.substr(from, i - from + 1); }
/* * Trim chTarget from the right of string s. */ void StringUtils::STLTrimRight(std::wstring& s, wchar_t chTarget) { std::wstring::size_type n = s.find_last_not_of( chTarget ); if( n == std::wstring::npos ) s.clear(); else s = s.substr( 0, n+1 ); }
std::wstring UeiArgsParser::trimTrailingSpaces(std::wstring& aString, const std::wstring& aWhitespaces) { size_t trailingSpace = aString.find_last_not_of(aWhitespaces); if (trailingSpace != std::wstring::npos) { aString.erase(trailingSpace + 1); } return aString; }
void rtrim( std::wstring &s ) { std::wstring::size_type pos( s.find_last_not_of( L" \t" ) ); if( pos != std::wstring::npos ) { s.resize( pos+1 ); } else { s.clear(); } }
void TestUtils::wtrim(std::wstring& str, const wchar_t* szTrim) { std::string::size_type pos = str.find_last_not_of(szTrim); if(pos != std::string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(szTrim); if(pos != std::string::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); }
bool trims(const std::wstring& str, std::vector <std::wstring>& vcResult, char c) { size_t fst = str.find_first_not_of( c ); size_t lst = str.find_last_not_of( c ); if( fst != std::wstring::npos ) vcResult.push_back(str.substr(fst, lst - fst + 1)); return true; }
std::wstring Group::VerifyGroup(const std::wstring& str) const { std::wstring strTmp; std::wstring::size_type pos = str.find_first_not_of(L" \t\r\n"); if (pos != std::wstring::npos) { // Trim white-space strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1); CreateGroup(strTmp); } return strTmp; }
std::wstring CGroup::CreateGroup(const std::wstring& str) { std::wstring strTmp; std::wstring::size_type pos = str.find_first_not_of(L" \t\r\n"); if (pos != std::wstring::npos) { // Trim white-space strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1); _wcsupr(&strTmp[0]); } return strTmp; }
// trim whitespace in front and back of string void trim(std::wstring& value) { const wchar_t* whitespace = L"\n\r\t"; size_t startpos = value.find_first_not_of(whitespace); if (std::wstring::npos != startpos) { value = value.substr(startpos); } size_t endpos = value.find_last_not_of(whitespace); if (std::wstring::npos != endpos) { value = value.substr(0, endpos + 1); } }
DWORD Init() { Registry reg; auto result = reg.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", Registry::Mode::Read); if (result != ERROR_SUCCESS) { return result; } reg.TryReadString(L"CurrentBuildNumber", CurrentBuildNumber); reg.TryReadDword(L"CurrentMajorVersionNumber", CurrentMajorVersionNumber); reg.TryReadDword(L"CurrentMinorVersionNumber", CurrentMinorVersionNumber); reg.TryReadString(L"CSDbuildNumber", CSDBuildNumber); reg.TryReadString(L"CSDVersion", ServicePack); auto pos = ServicePack.find_last_not_of(L"Service Pack "); if (pos != std::wstring::npos) { ServicePack = L"SP" + ServicePack.substr(pos); } if (reg.TryReadString(L"BuildLabEx", BuildLabEx) != NO_ERROR) { reg.TryReadString(L"BuildLab", BuildLabEx); } reg.TryReadString(L"CurrentVersion", CurrentVersion); reg.TryReadString(L"EditionId", EditionId); reg.TryReadString(L"ProductName", ProductName); if (CurrentMajorVersionNumber > 0) { CurrentVersion = std::to_wstring(CurrentMajorVersionNumber) + L"." + std::to_wstring(CurrentMinorVersionNumber); } else { reg.TryReadString(L"CurrentVersion", CurrentVersion); } Architecture = IsX64() ? std::wstring(L"x64") : std::wstring(L"x86"); Language = GetDefaultLocaleName(); return ERROR_SUCCESS; }
FIELDTYPE StrToFieldtype(std::wstring string) { string.erase(string.find_last_not_of(L" \n\r\t")+1); if(string == L"b") { return FT_BYTE; } else if(string == L"s") { return FT_WORD; } else if(string == L"w") { return FT_WORD; } else if(string == L"dw") { return FT_DWORD; } else if(string == L"f") { return FT_FLOAT; } else if(string == L"df") { return FT_DFLOAT; } return FT_BYTE; }
std::wstring StringUtilities::TrimRight(const std::wstring& input) { size_t endpos = input.find_last_not_of(WIDE_WHITESPACE); return (endpos == std::wstring::npos) ? L"" : input.substr(0, endpos + 1); }
static void Trim( std::wstring& str , const std::wstring& chars = L" \t" ) { str.erase(str.find_last_not_of(chars)+1); str.erase(0, str.find_first_not_of(chars)); }
inline std::wstring trim_right(std::wstring& source) { source.erase(source.find_last_not_of(L' ')+1); return source; }
void TrimQuotes(std::wstring &fileName) { fileName.erase(fileName.find_last_not_of(L'\"') + 1); fileName.erase(0, fileName.find_first_not_of(L'\"')); }
void TrimStringRight(std::wstring &str, const std::wstring &strWhitespace) { size_t pos = str.find_last_not_of(strWhitespace); str.erase(pos + 1); }