本文整理汇总了C++中std::wstring::find_last_not_of方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::find_last_not_of方法的具体用法?C++ wstring::find_last_not_of怎么用?C++ wstring::find_last_not_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::find_last_not_of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ltrim
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);
}
示例2:
std::wstring
stringHelper::rtrim( const std::wstring& wstr )
{
if ( wstr.empty() ) return wstr ;
return wstr.substr( 0, wstr.find_last_not_of( __delimiters ) + 1 ) ;
}
示例3: wbasename
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);
}
示例4: STLTrimRight
/*
* 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 );
}
示例5: trimTrailingSpaces
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;
}
示例6: rtrim
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();
}
}
示例7: wtrim
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());
}
示例8: trims
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;
}
示例9: VerifyGroup
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;
}
示例10: CreateGroup
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;
}
示例11: trim
// 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);
}
}
示例12: Init
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;
}
示例13: StrToFieldtype
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;
}
示例14: TrimRight
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);
}
示例15: Trim
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));
}