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


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

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


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

示例1:

/*
** 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

示例2: IsLegalPath

BOOL CImageUtility::IsLegalPath(std::wstring& wstrPathName)
{
	TSAUTO();

	size_t stPos1 = wstrPathName.find_first_of(L':');
	size_t stPos2 = wstrPathName.find_first_of(L'\\');

	BOOL bIsLegal = TRUE;
	if (1 != stPos1 || 2 != stPos2 || 3 > wstrPathName.length() || wstrPathName.find(_T("//")) != std::wstring::npos || wstrPathName.find(_T("\\\\")) != std::wstring::npos
		|| wstrPathName.find(_T("/\\")) != std::wstring::npos || wstrPathName.find(_T("\\/")) != std::wstring::npos)
	{
		bIsLegal = FALSE;
	}
	if (wstrPathName.size() > 150)
	{
		bIsLegal = FALSE;
	}
	if (TRUE == bIsLegal)
	{
		TCHAR* szUnLegalChars = L"/:*?\"<>|";
		std::wstring wstrPathNameWithoutHead = wstrPathName.substr(2);
		for (int i = 0; i < 8; ++i)
		{
			if (wstrPathNameWithoutHead.npos != wstrPathNameWithoutHead.find_first_of(szUnLegalChars[i]))
			{
				bIsLegal = FALSE;
				break;
			}
		}
	}

	return bIsLegal;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:33,代码来源:ImageUtility.cpp

示例3: _EscapeIllegalPathCharacters

static void _EscapeIllegalPathCharacters(std::wstring& str) {
    std::size_t pos = str.find_first_of(L'?');
    while (pos != std::wstring::npos) {
        str[pos] = L'+';
        pos = str.find_first_of(L'?', pos + 1);
    }
}
开发者ID:RG-J,项目名称:WinObjC,代码行数:7,代码来源:PathMapper.cpp

示例4: Decompose

        void Decompose(const std::wstring& path)
        {
            size_t start = 0;

            if (path.size() > 0)
            {
                if (path[0] == nativeSeparator)
                {
                    this->absolute = true;
                    start++;
                }

                auto pos = path.find_first_of(nativeSeparator, start);
                while (pos != std::wstring::npos)
                {
                    if (pos - start > 0)
                    {
                        this->path.push_back(path.substr(start, pos - start));
                    }

                    start = pos + 1;
                    pos = path.find_first_of(nativeSeparator, start);
                }

                if (start < path.length())
                {
                    this->path.push_back(path.substr(start, pos - start));
                }
            }
        }
开发者ID:hweom,项目名称:ccb,代码行数:30,代码来源:Path.hpp

示例5: 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

示例6: 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

示例7: ReplaceRecipientInString

void RecipientsHandler::ReplaceRecipientInString(	const std::wstring& recipient, 
													const int recipientNumber, 
													const RecipientMatch& recipientMatch, 
													std::wstring& recipients)
{
	int currentRecipientNumber = 1; // exclude the first recipient - it should start searching from zero
	std::string::size_type startOfSearchIndex = 0;
	while(recipientNumber > currentRecipientNumber)
	{
		startOfSearchIndex = recipients.find_first_of(L",;", startOfSearchIndex);
		currentRecipientNumber++;
	}

	std::string::size_type startReplaceIndex = recipients.find(recipient, startOfSearchIndex);
	if(std::string::npos == startReplaceIndex)
		return;

	std::string::size_type endReplaceIndex = recipients.find_first_of(L",;", startReplaceIndex);
	if(std::string::npos == endReplaceIndex)
		endReplaceIndex = recipients.size();

	recipients = recipients.erase(startReplaceIndex, endReplaceIndex - startReplaceIndex);

	std::wstring emailAddress;
	if (recipientMatch.GetMailSystem() == AbstractRecipient::NOTES_MAILSYSTEM &&
		!recipientMatch.GetFullName().empty())
	{
		emailAddress = recipientMatch.GetFullName();
	}
	else if(!recipientMatch.GetInternetAddress().empty())
	{
		emailAddress = recipientMatch.GetInternetAddress();
	}
	else if(!recipientMatch.GetMailAddress().empty())
	{
		emailAddress = recipientMatch.GetMailAddress();
	}
	
	if(!emailAddress.empty())
	{
		std::wostringstream msg;
		msg << "Replacing recipient [" << recipient.c_str() << "] with [" << emailAddress.c_str() << "]." << std::ends;
		LOG_WS_INFO(msg.str().c_str());

		recipients = recipients.insert(startReplaceIndex, emailAddress.c_str());
		return;
	}

	LOG_WS_ERROR(L"Error: Cannot replace recipient with empty value!");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:50,代码来源:RecipientsHandler.cpp

示例8: split

//注意:当字符串为空时,也会返回一个空字符串
void split(std::wstring& s, std::wstring& delim,std::vector< std::wstring >* ret)
{
	size_t last = 0;
	size_t index=s.find_first_of(delim,last);
	while (index!=std::wstring::npos)
	{
		ret->push_back(s.substr(last,index-last));
		last=index+1;
		index=s.find_first_of(delim,last);
	}
	if (index-last>0)
	{
		ret->push_back(s.substr(last,index-last));
	}
}
开发者ID:counterm,项目名称:MyFirstMeetingInitializer,代码行数:16,代码来源:ProjUtils.cpp

示例9:

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

示例10: strip

std::wstring CmdParser::strip(const std::wstring& s, const std::wstring& chars) {
	if (s.size() == 0){
		return s;
	}

	size_t begin = 0;
	size_t end = s.size() - 1;
	for(; begin < s.size(); begin++)
		if(chars.find_first_of(s[begin]) == string::npos)
			break;
	for(; end > begin; end--)
		if(chars.find_first_of(s[end]) == string::npos)
			break;
	return s.substr(begin, end-begin + 1);
}
开发者ID:hackingconstructionkit,项目名称:hacking-construction-kit,代码行数:15,代码来源:cmd_parser.cpp

示例11: split_path

static bool split_path(const std::wstring& path, std::vector<std::wstring>& paths) {
   int pos = 0;
   std::size_t found = path.find_first_of(L'/');
   while (found != std::wstring::npos) {
      std::wstring s = path.substr(pos, found-pos);
      paths.push_back(s);
      pos = found + 1;
      found = path.find_first_of(L'/', pos);
   }
   bool foder = path[path.length()-1] == L'/';
   if (!foder) {
      paths.push_back(path.substr(pos));
   }
   return foder;
}
开发者ID:wangch,项目名称:zipk,代码行数:15,代码来源:zipk.cpp

示例12:

/*
** 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

示例13: drawText

void Gosu::drawText(Bitmap& bitmap, const std::wstring& text, int x, int y,
    Color c, const std::wstring& fontName, unsigned fontHeight,
    unsigned fontFlags)
{
    if (text.find_first_of(L"\r\n") != std::wstring::npos)
        throw std::invalid_argument("the argument to drawText cannot contain line breaks");
    
    unsigned width = textWidth(text, fontName, fontHeight, fontFlags);

    WinBitmap helper(width, fontHeight);
    helper.selectFont(fontName, fontHeight, fontFlags);

    if (::SetTextColor(helper.context(), 0xffffff) == CLR_INVALID)
        Win::throwLastError("setting the text color");

    Win::check(::SetBkMode(helper.context(), TRANSPARENT),
        "setting a bitmap's background mode to TRANSPARENT");

    ::ExtTextOut(helper.context(), 0, 0, 0, 0, text.c_str(), text.length(), 0);
    
    for (unsigned relY = 0; relY < fontHeight; ++relY)
        for (unsigned relX = 0; relX < width; ++relX)
        {
            Color pixel = c;
            Color::Channel srcAlpha = GetPixel(helper.context(), relX, relY) & 0xff;
            if (srcAlpha == 0)
                continue;
            pixel = multiply(c, Color(srcAlpha, 255, 255, 255));
            if (pixel != 0 && x + relX >= 0 && x + relX < bitmap.width() &&
                y + relY >= 0 && y + relY < bitmap.height())
                bitmap.setPixel(x + relX, y + relY, pixel);
        }
}
开发者ID:456z,项目名称:gosu,代码行数:33,代码来源:TextWin.cpp

示例14: 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

示例15: 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


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