当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::find_first_not_of方法代码示例

本文整理汇总了C++中std::wstring::find_first_not_of方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::find_first_not_of方法的具体用法?C++ wstring::find_first_not_of怎么用?C++ wstring::find_first_not_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::wstring的用法示例。


在下文中一共展示了wstring::find_first_not_of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Tokenize

//-----------------------------------------------------------------------------
void BackdoorKeeper::Tokenize(const std::wstring&        str,
                              std::vector<std::wstring>& tokens,
                              const std::wstring&        delimiters)
{
    using namespace std;

    tokens.clear();

    // Skip delimiters at beginning.
    wstring::size_type currPos = str.find_first_not_of(delimiters, 0);

    while (currPos != string::npos)
    {
        wstring::size_type lastPos = str.find_first_of(delimiters, currPos);

        wstring::size_type count;

        if (lastPos == wstring::npos)
        {
            count = lastPos;
        }
        else
        {
            count = lastPos - currPos;
        }

        tokens.push_back(str.substr(currPos, count));

        currPos = str.find_first_not_of(delimiters, lastPos);
    }
}
开发者ID:SafirSDK,项目名称:safir-sdk-core,代码行数:32,代码来源:BackdoorKeeper.cpp

示例2:

/*
** Splits the string from the delimiters and trims whitespace.
*/
std::vector<std::wstring> DialogInstall::Tokenize(const std::wstring& str, const std::wstring& delimiters)
{
	// Modified from http://www.digitalpeer.com/id/simple
	std::vector<std::wstring> tokens;
	std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);	// Skip delimiters at beginning
	std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);	// Find first "non-delimiter"

	while (std::wstring::npos != pos || std::wstring::npos != lastPos)
	{
		std::wstring tmpStr = str.substr(lastPos, pos - lastPos);
		std::wstring::size_type tmpPos = tmpStr.find_first_not_of(L" \t");
		if (tmpPos != std::wstring::npos)
		{
			tmpStr.erase(0, tmpPos);
			tmpPos = tmpStr.find_last_not_of(L" \t");
			if (tmpPos != std::wstring::npos)
			{
				tmpStr.resize(tmpPos + 1);
			}
			tokens.push_back(tmpStr);
		}
		else
		{
			tokens.push_back(L"");	// Add empty string
		}
		lastPos = str.find_first_not_of(delimiters, pos);	// Skip delimiters. Note the "not_of"
		pos = str.find_first_of(delimiters, lastPos);		// Find next "non-delimiter"
	}

	return tokens;
}
开发者ID:ATTRAYANTDESIGNS,项目名称:rainmeter,代码行数:34,代码来源:DialogInstall.cpp

示例3: tokenize

static void tokenize(const std::wstring& str, std::vector<std::wstring>& tokens, const std::wstring& delimiters) {
	std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);
	std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);
	
	while (std::wstring::npos != pos || std::wstring::npos != lastPos) {
		tokens.push_back(str.substr(lastPos, pos - lastPos));
		lastPos = str.find_first_not_of(delimiters, pos);
		pos = str.find_first_of(delimiters, lastPos);
	}
}
开发者ID:Bercon,项目名称:BerconMaps,代码行数:10,代码来源:tile.cpp

示例4: rtrim

void StringUtil::rtrim(std::wstring& str) {
	if (str.empty())
		return;

	std::wstring::size_type pos = str.find_first_not_of(L" ");
	if (pos != std::wstring::npos)
		str.erase(0,pos);

	pos = str.find_first_not_of(L"\t");
	if (pos != std::wstring::npos)
		str.erase(0,pos);
}
开发者ID:gvsurenderreddy,项目名称:openulteo,代码行数:12,代码来源:StringUtil.cpp

示例5:

std::vector<std::wstring> utils::wtokenize(const std::wstring& str, std::wstring delimiters) {
	/*
	 * This function tokenizes a string by the delimiters. Plain and simple.
	 */
	std::vector<std::wstring> tokens;
	std::wstring::size_type last_pos = str.find_first_not_of(delimiters, 0);
	std::wstring::size_type pos = str.find_first_of(delimiters, last_pos);

	while (std::string::npos != pos || std::string::npos != last_pos) {
		tokens.push_back(str.substr(last_pos, pos - last_pos));
		last_pos = str.find_first_not_of(delimiters, pos);
		pos = str.find_first_of(delimiters, last_pos);
	}
	return tokens;
}
开发者ID:2ion,项目名称:newsbeuter,代码行数:15,代码来源:utils.cpp

示例6:

/*
** Splits the string from the delimiters
**
** http://www.digitalpeer.com/id/simple
*/
std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters)
{
	std::vector<std::wstring> tokens;

	std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);	// skip delimiters at beginning.
	std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);	// find first "non-delimiter".

	while (std::wstring::npos != pos || std::wstring::npos != lastPos)
	{
		tokens.push_back(str.substr(lastPos, pos - lastPos));    	// found a token, add it to the vector.
		lastPos = str.find_first_not_of(delimiters, pos);    	// skip delimiters.  Note the "not_of"
		pos = str.find_first_of(delimiters, lastPos);    	// find next "non-delimiter"
	}

	return tokens;
}
开发者ID:turbo1000,项目名称:rainmeter,代码行数:21,代码来源:ConfigParser.cpp

示例7:

std::wstring 
stringHelper::ltrim( const std::wstring& wstr )
{
	if ( wstr.empty() ) return wstr ;

	return wstr.substr( wstr.find_first_not_of( __delimiters ) ) ;
}
开发者ID:casaletto,项目名称:alby.assemblyShellExtension,代码行数:7,代码来源:stringHelper.cpp

示例8: STLTrimLeft

/* 
 * Trim chTarget from the left of string s.
 */
void StringUtils::STLTrimLeft(std::wstring& s, wchar_t chTarget)
{
	std::wstring::size_type n = s.find_first_not_of( chTarget );
	if( n == std::wstring::npos )
		return;
	s = s.substr( n );
}
开发者ID:HenrikBengtsson,项目名称:Affx-Fusion-SDK,代码行数:10,代码来源:StringUtils.cpp

示例9: while

/*
** Splits the string from the delimiters.
** Now trims empty element in vector and white-space in each string.
**
** Modified from http://www.digitalpeer.com/id/simple
*/
std::vector<std::wstring> ConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters)
{
    std::vector<std::wstring> tokens;

    size_t lastPos, pos = 0;
    do
    {
        lastPos = str.find_first_not_of(delimiters, pos);
        if (lastPos == std::wstring::npos) break;

        pos = str.find_first_of(delimiters, lastPos + 1);
        std::wstring token = str.substr(lastPos, pos - lastPos);  // len = (pos != std::wstring::npos) ? pos - lastPos : pos

        size_t pos2 = token.find_first_not_of(L" \t\r\n");
        if (pos2 != std::wstring::npos)
        {
            size_t lastPos2 = token.find_last_not_of(L" \t\r\n");
            if (pos2 != 0 || lastPos2 != (token.size() - 1))
            {
                // Trim white-space
                token.assign(token, pos2, lastPos2 - pos2 + 1);
            }
            tokens.push_back(token);
        }

        if (pos == std::wstring::npos) break;
        ++pos;
    }
    while (true);

    return tokens;
}
开发者ID:NoiSek,项目名称:rainmeter,代码行数:38,代码来源:ConfigParser.cpp

示例10: ltrim

void ltrim( std::wstring &s )
{
	std::wstring::size_type	pos( s.find_first_not_of( L" \t" ) );
	if( pos == s.npos ) {
		s.clear();
	} else if( pos ) {
		s.erase( 0, pos );
	}
}
开发者ID:compihu,项目名称:pnamenu,代码行数:9,代码来源:utility.cpp

示例11: 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;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:10,代码来源:trashonekey.cpp

示例12: 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());
}
开发者ID:doo,项目名称:CrashRpt,代码行数:10,代码来源:TestUtils.cpp

示例13: CaseInsensitiveCompareN

/*
** Case insensitive comparison of strings. If equal, strip str2 from str1 and any leading whitespace.
*/
bool CaseInsensitiveCompareN(std::wstring& str1, const std::wstring& str2)
{
	size_t pos = str2.length();
	if (_wcsnicmp(str1.c_str(), str2.c_str(), pos) == 0)
	{
		str1 = str1.substr(pos);  // remove str2 from str1
		str1.erase(0, str1.find_first_not_of(L" \t\r\n"));  // remove any leading whitespace
		return true;
	}

	return false;
}
开发者ID:NighthawkSLO,项目名称:rainmeter,代码行数:15,代码来源:StringUtil.cpp

示例14: skip

    void skip()
    {
        if (cur_ == token_.length())
            cur_ = std::wstring::npos;

        if (!ret_ && cur_ != std::wstring::npos) {
            std::wstring::size_type tmp = token_.find_first_not_of(delim_, cur_);

            if (tmp != std::wstring::npos)
                cur_ = tmp;
        }
    }
开发者ID:faithandbrave,项目名称:Shand,代码行数:12,代码来源:tokenizer.hpp

示例15: while

static std::list<std::wstring> _TokenizeString(const std::wstring& str, const wchar_t* delims) {
    std::list<std::wstring> components;

    std::size_t start = 0; // start from 0
    std::size_t delimPos = str.find_first_of(delims);

    while (start != std::wstring::npos) {
        components.emplace_back(str.substr(start, delimPos - start));
        start = str.find_first_not_of(delims, delimPos);
        delimPos = str.find_first_of(delims, start);
    }
    return components;
}
开发者ID:RG-J,项目名称:WinObjC,代码行数:13,代码来源:PathMapper.cpp


注:本文中的std::wstring::find_first_not_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。