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


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

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


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

示例1: SHTokenizeW

void SHTokenizeW( 
	const wstring& target, 
	vector<wstring>& tokens, 
	const wstring &delim 
	)
{
	wstring::size_type lastPos = target.find_first_not_of( delim );
	wstring::size_type pos = target.find_first_of( delim, lastPos );

	while( wstring::npos != pos || wstring::npos != lastPos )
	{
		tokens.push_back( target.substr(lastPos, pos - lastPos) );
		lastPos = target.find_first_not_of( delim, pos );
		pos = target.find_first_of( delim, lastPos );
	}
}
开发者ID:poorboy,项目名称:ProcessFileSystem,代码行数:16,代码来源:StringHelper.cpp

示例2: SetDetailedVersion

    /**
    Gather the Major and Minor version from Product version

    Parameters:  version - Product version, its format like 11.23.32, REV- or 0.4b41

    */
    void InstalledSoftwareInstance::SetDetailedVersion(const wstring& version)
    {
        size_t pos = version.find_first_of('.');
        if( pos != wstring::npos )
        {
            wstring left = version.substr(0, pos);
            wstring right = version.substr(pos+1);
            try
            {
                m_versionMajor = StrToUInt(left);
                // Exclude characters
                for(pos = 0; pos< right.size(); pos++)
                {
                    if( right[pos] < '0' || right[pos] > '9' ) {
                        break;
                    }
                }
                if(pos > 0) {
                    left = right.substr(0, pos);
                    m_versionMinor = StrToUInt(left);
                }
            }
            catch (const SCXException& e)
            {
                SCX_LOGWARNING(m_log, StrAppend(L"parse InstalledSoftwareInstance version fails:", version).append(L" - ").append(e.What()));
            }
        }
    }
开发者ID:Microsoft,项目名称:SCVMMLinuxGuestAgent,代码行数:34,代码来源:installedsoftwareinstance.cpp

示例3: GetTimecode

int CRealTextParser::GetTimecode(const wstring& p_crszTimecode)
{
	int iTimecode(0);
	int iMultiplier(1);

	// Exception: if the timecode doesn't contain any separators, assume the time code is in seconds (and change multiplier to reflect that)
	if (p_crszTimecode.find_first_of('.') == wstring::npos && p_crszTimecode.find_first_of(':') == wstring::npos)
		iMultiplier = 1000;

	wstring szCurrentPart;

	for (int i = p_crszTimecode.length() - 1; i >= 0; --i)
	{
		if (p_crszTimecode.at(i) == '.' || p_crszTimecode.at(i) == ':')
		{
			if (iMultiplier == 1)
			{
				while (szCurrentPart.length() < 3)
					szCurrentPart += L"0";
			}

			iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());

			if (iMultiplier == 1)
			{
				iMultiplier = 1000;
			}
			else
			{
				iMultiplier *= 60;
			}

			szCurrentPart = L"";
		}
		else
		{
			szCurrentPart = p_crszTimecode.substr(i, 1) + szCurrentPart;
		}
	}

	iTimecode += iMultiplier * ::_wtoi(szCurrentPart.c_str());

	return iTimecode;
}
开发者ID:Fluffiest,项目名称:mpc-hc,代码行数:44,代码来源:RealTextParser.cpp

示例4: GetNextValue

HRESULT CDataTuple::GetNextValue(int &iVal, wstring &line, size_t &start)
{
	HRESULT hRet = E_FAIL;
	size_t	 end;
	wstring	sep(TEXT(" \t"), 1);

	if (start >= line.length())
	{
		return hRet;
	}

	end = line.find_first_of (sep, start+1);

	wstring substr;

	if (string::npos != end && end > start)
	{
		substr = line.substr(start, end -start);
	}
	else
	{
		substr = line.substr(start, line.length() -start);
	}

	if (substr.length() > 0)
	{
		float val;
		if (1 == _stscanf_s(substr.c_str(), TEXT("%f"), &val))
		{
			iVal = (int)val;
			hRet = S_OK;
		}
	}
	else
	{
		start = string::npos;
	}

	if (SUCCEEDED(hRet) && end != string::npos)
	{
		start = line.find(sep, end);

		while (start < line.length() && line[start +1] == ' ')
		{
			++start;
		}

	}
	else
	{
		start = string::npos;
	}

	return hRet;
}
开发者ID:mrevow,项目名称:nnTcl,代码行数:55,代码来源:DataTuple.cpp

示例5: EraseChars

void EraseChars(wstring& str, const wchar_t chars[]) {
  size_t pos = 0;

  do {
    pos = str.find_first_of(chars, pos);

    if (pos != wstring::npos)
      str.erase(pos, 1);

  } while (pos != wstring::npos);
}
开发者ID:vjcagay,项目名称:taiga,代码行数:11,代码来源:string.cpp

示例6: ReplaceChar

void ReplaceChar(wstring& str, const wchar_t c, const wchar_t replace_with) {
  if (c == replace_with)
    return;

  size_t pos = 0;

  do {
    pos = str.find_first_of(c, pos);
    if (pos != wstring::npos)
      str.at(pos) = replace_with;
  } while (pos != wstring::npos);
}
开发者ID:vjcagay,项目名称:taiga,代码行数:12,代码来源:string.cpp

示例7: ReplaceChars

void ReplaceChars(wstring& str, const wchar_t chars[],
                  const wstring replace_with) {
  if (chars == replace_with)
    return;

  size_t pos = 0;

  do {
    pos = str.find_first_of(chars, pos);
    if (pos != wstring::npos)
      str.replace(pos, 1, replace_with);
  } while (pos != wstring::npos);
}
开发者ID:vjcagay,项目名称:taiga,代码行数:13,代码来源:string.cpp

示例8: parse_line

//The data has the following form in each line.
//"dialog title"    "button text"
//
void parse_line(const wstring& line, wstring& dlg_title, wstring& ctrl_text)
{
    //Retrieve the title
    size_t first_quote = line.find_first_of(QUOTE, 0);
    if(first_quote == wstring::npos)
        return;
    first_quote = first_quote + 1;
    size_t second_quote = line.find_first_of(QUOTE, first_quote);
    if(second_quote == wstring::npos)
        return;
    dlg_title = line.substr(first_quote, second_quote - first_quote);

    //Retrieve the control text.
    first_quote = line.find_first_of(QUOTE, second_quote + 1);
    if(first_quote == wstring::npos)
        return;
    first_quote = first_quote + 1;
    second_quote = line.find_first_of(QUOTE, first_quote);
    if(second_quote == wstring::npos)
        return;
    ctrl_text = line.substr(first_quote, second_quote - first_quote);
}
开发者ID:kasim-du,项目名称:learning,代码行数:25,代码来源:dismissal.cpp

示例9: StrTokenize

    /**
        Extract a vector of the substrings that are separated by one of the delimter characters

        \param    str          String to tokenize
        \param    tokens       Return a vector of tokens
        \param    delimiters   String containing the delimeter charachters
        \param    trim         true if all tokens should be trimmed (default), otherwise false
        \param    emptyTokens  false if empty tokens should be removed from the result (default), otherwise true.
        \param    keepDelimiters true if delimiters found should be added to the token vector, otherwise (default)
                                 delimiters are removed.

    */
    void StrTokenize(const wstring& str, vector<std::wstring>& tokens,
                     const wstring& delimiters, bool trim, bool emptyTokens, bool keepDelimiters)
    {
        tokens.clear();

        wstring::size_type lastPos = 0;
        wstring::size_type pos = delimiters.empty()?wstring::npos:str.find_first_of(delimiters);

        while (wstring::npos != pos)
        {
            wstring tmp = str.substr(lastPos, pos - lastPos);
            if ( ! tmp.empty() && trim)
            {
                tmp = StrTrim(tmp);
            }
            if ( ! tmp.empty() || emptyTokens)
            {
                tokens.push_back(tmp);
            }
            if ( keepDelimiters )
            {
                tokens.push_back(str.substr(pos, 1));
            }
            lastPos = pos + 1;
            // Find next "non-delimiter"
            pos = str.find_first_of(delimiters, lastPos);
        }

        wstring tmp = str.substr(lastPos, wstring::npos);
        if ( ! tmp.empty() && trim)
        {
            tmp = StrTrim(tmp);
        }
        if ( ! tmp.empty() || emptyTokens)
        {
            tokens.push_back(tmp);
        }
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:50,代码来源:stringaid.cpp

示例10: EscapeCommand

// vds: >>
wstring EscapeCommand(wstring cmd) {
	wstring ret;
	size_t cursor = 0;
	while (true) {
		size_t pos = cmd.find_first_of(L"\"", cursor);
		if (pos == wstring::npos) {
			ret += cmd.substr(cursor);
			break;
		}
		ret += cmd.substr(cursor, pos - cursor);
		ret += wstring(L"\\\"");
		cursor = pos + 1;
	}

	return ret;
}
开发者ID:mirror,项目名称:console-devel,代码行数:17,代码来源:Console.cpp

示例11: Tokenize

size_t Tokenize(const wstring& str, const wstring& delimiters,
                vector<wstring>& tokens) {
  tokens.clear();

  size_t index_begin = str.find_first_not_of(delimiters);

  while (index_begin != wstring::npos) {
    size_t index_end = str.find_first_of(delimiters, index_begin + 1);
    if (index_end == wstring::npos) {
      tokens.push_back(str.substr(index_begin));
      break;
    } else {
      tokens.push_back(str.substr(index_begin, index_end - index_begin));
      index_begin = str.find_first_not_of(delimiters, index_end + 1);
    }
  }

  return tokens.size();
}
开发者ID:vjcagay,项目名称:taiga,代码行数:19,代码来源:string.cpp

示例12: while

vector <int> ApplicationVersion::GetComponents(wstring version)
{
	vector <int> components;
	int start = 0, end = 0, pos, num;
	wstring number;

	// Do not use it with strings
	for (unsigned int i = 0; i < version.size(); i++)
		assert(iswdigit(version[i]) || version[i] == L'.');

	do
	{
		pos = version.find_first_of(SEPARATOR, end);
		start = end;
		end = pos;
		number = version.substr(start, end - start);
		num = _wtoi(number.c_str());
		components.push_back(num);
		end = end + SEPARATOR_LEN;
		
	} while (pos != string::npos);

	return components;
}
开发者ID:xmps,项目名称:Catalanitzador,代码行数:24,代码来源:ApplicationVersion.cpp

示例13: if

extern vector<wstring> TokenizeWString(const wstring& src, wstring tok, bool trim, wstring null_subst)
{   
	if( src.empty() || tok.empty() ) 
	{
		throw "TokenizeString: empty string\0";   
	}
	
	vector<wstring> v;   
	S_T pre_index = 0, index = 0, len = 0;  
	
	while( (index = src.find_first_of(tok, pre_index)) != npos )   
	{   
		if( (len = index-pre_index)!=0 )   
		{
			v.push_back(src.substr(pre_index, len));   
		}
		else if(trim==false)   
		{
			v.push_back(null_subst);   
		}
		
		pre_index = index+1;   
	}   
	
	wstring endstr = src.substr(pre_index);   
	if( trim==false )
	{
		v.push_back( endstr.empty()?null_subst:endstr );   
	}
	else if( !endstr.empty() )
	{
		v.push_back(endstr);   
	}
	
	return v;   
}   
开发者ID:philipchang,项目名称:Gis,代码行数:36,代码来源:Common.cpp

示例14: InStrChars

int InStrChars(const wstring& str1, const wstring& str2, int pos) {
  size_t i = str1.find_first_of(str2, pos);
  return (i != wstring::npos) ? i : -1;
}
开发者ID:vjcagay,项目名称:taiga,代码行数:4,代码来源:string.cpp

示例15: GetAttributes

bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes)
{
    if (!SkipSpaces(p_rszLine, p_riPos)) {
        return false;
    }

    while (p_riPos > p_rszLine.length() && p_rszLine.at(p_riPos) != '/' && p_rszLine.at(p_riPos) != '>') {
        wstring szName;
        if (!GetString(p_rszLine, p_riPos, szName, L"\r\n\t =")) {
            return false;
        }

        if (!SkipSpaces(p_rszLine, p_riPos)) {
            return false;
        }

        if (p_rszLine.at(p_riPos) != '=') {
            if (m_bTryToIgnoreErrors) {
                p_riPos = (unsigned int)p_rszLine.find_first_of('=', p_riPos);
                if (p_riPos == wstring::npos) {
                    return false;
                }
            } else {
                return false;
            }
        }

        ++p_riPos;

        if (!SkipSpaces(p_rszLine, p_riPos)) {
            return false;
        }

        bool bUsesQuotes(false);
        if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
            ++p_riPos;
            bUsesQuotes = true;
        }

        if (!SkipSpaces(p_rszLine, p_riPos)) {
            return false;
        }

        wstring szValue;
        if (bUsesQuotes) {
            if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>")) {
                return false;
            }
        } else {
            if (!GetString(p_rszLine, p_riPos, szValue, L" \t/>")) {
                return false;
            }
        }

        p_rmapAttributes[StringToLower(szName)] = szValue;

        if (!SkipSpaces(p_rszLine, p_riPos)) {
            return false;
        }

        if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
            ++p_riPos;
        }

        if (!SkipSpaces(p_rszLine, p_riPos)) {
            return false;
        }
    }

    return p_rszLine.length() > p_riPos;
}
开发者ID:AeonAxan,项目名称:mpc-hc,代码行数:71,代码来源:RealTextParser.cpp


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