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


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

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


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

示例1: GetParenthesisedList

// Break up a string composed of multiple sections in parentheses into a collection
// of sub-strings. Sample input string: (Hello)(World1,World2)
MgStringCollection* WfsGetFeatureParams::GetParenthesisedList(CREFSTRING sourceString)
{
    MgStringCollection* stringList = new MgStringCollection();
    if(sourceString.length() > 0)
    {
        // Create a collection of strings
        STRING remaining = MgUtil::Trim(sourceString);
        while(remaining.length() > 0)
        {
            STRING::size_type openParenthesis = remaining.find_first_of(L"(");
            if(openParenthesis != string::npos)
            {
                STRING::size_type closeParenthesis = remaining.find_first_of(L")");
                if(closeParenthesis != string::npos)
                {
                    STRING thisString = remaining.substr(openParenthesis + 1, closeParenthesis - openParenthesis - 1);
                    stringList->Add(thisString);
                    remaining = remaining.substr(closeParenthesis + 1);
                }
            }
            else
            {
                stringList->Add(remaining);
                break;
            }
        }
    }
    return stringList;
}
开发者ID:kanbang,项目名称:Colt,代码行数:31,代码来源:WfsGetFeatureParams.cpp

示例2: EscapeQuotes

 /*!
  * Add escaping to each quote character (") by preceding it with a backslash (\).
  */
 void EscapeQuotes()
 {
     size_t quote = _quoted.find_first_of('"');
     while (quote != STRING::npos)
     {
         _quoted.insert(quote, 1, '\\');
         quote = _quoted.find_first_of('"', quote + 2);
     }
 }
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:12,代码来源:quote-argument-ms.hpp

示例3: EscapeBackSlashes

 /*!
  * @param[in] arg           The string that needs to be quoted.
  * @param[in] whitespace    The set of characters that are considered whitespace.
  */
 QUOTE_ARGUMENT_MS_BASE(const STRING &arg, const T *whitespace)
 {
     // Quoting is only necessary if the argument contains whitespace or a quote (").
     //
     _quoted = arg;
     if (_quoted.find_first_of(whitespace) != STRING::npos ||
         _quoted.find_first_of('"') != STRING::npos)
     {
         EscapeBackSlashes();
         EscapeQuotes();
         AddQuotes(whitespace);
     }
 }
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:17,代码来源:quote-argument-ms.hpp

示例4: SetPartName

int LPID::SetPartName( const STRING& aPartName )
{
    STRING  category;
    STRING  base;
    int     offset;
    int     separation = int( aPartName.find_first_of( "/" ) );

    if( separation != -1 )
    {
        category = aPartName.substr( 0, separation );
        base     = aPartName.substr( separation+1 );
    }
    else
    {
        // leave category empty
        base = aPartName;
    }

    if( (offset = SetCategory( category )) != -1 )
        return offset;

    if( (offset = SetBaseName( base )) != -1 )
    {
        return offset + separation + 1;
    }

    return -1;
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:28,代码来源:sch_lpid.cpp

示例5: okBase

static inline int okBase( const STRING& aField )
{
    int offset = int( aField.find_first_of( ":/" ) );
    if( offset != -1 )
        return offset;

    // cannot be empty
    if( !aField.size() )
        return 0;

    return offset;  // ie. -1
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:12,代码来源:sch_lpid.cpp

示例6: AddQuotes

    /*!
     * Add quotes around the string if it contains any whitespace.
     */
    void AddQuotes(const T *whitespace)
    {
        if (_quoted.find_first_of(whitespace) != STRING::npos)
        {
            _quoted.insert(0, 1, '"');
            _quoted.append(1, '"');

            // If the last character (prior to adding the quotes) was a backslash,
            // it needs to be escaped now because it precedes a quote.
            //
            size_t quote = _quoted.size() - 1;
            if (_quoted[quote-1] == '\\')
            {
                size_t notSlash = _quoted.find_last_not_of('\\', quote-2);
                size_t numSlashes = quote - notSlash - 1;
                _quoted.insert(quote, numSlashes, '\\');
            }
        }
    }
开发者ID:EmilyBragg,项目名称:profiling-tool,代码行数:22,代码来源:quote-argument-ms.hpp

示例7: int

static inline int okLogical( const STRING& aField )
{
    // std::string::npos is largest positive number, casting to int makes it -1.
    // Returning that means success.
    return int( aField.find_first_of( ":/" ) );
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:6,代码来源:sch_lpid.cpp

示例8: Format

STRING LPID::Format( const STRING& aLogicalLib, const STRING& aPartName, const STRING& aRevision )
    throw( PARSE_ERROR )
{
    STRING  ret;
    int     offset;

    if( aLogicalLib.size() )
    {
        offset = okLogical( aLogicalLib );
        if( offset != -1 )
        {
            THROW_PARSE_ERROR(
                    _( "Illegal character found in logical lib name" ),
                    wxString::FromUTF8( aLogicalLib.c_str() ),
                    aLogicalLib.c_str(),
                    0,
                    offset
                    );
        }
        ret += aLogicalLib;
        ret += ':';
    }

    {
        STRING  category;
        STRING  base;

        int separation = int( aPartName.find_first_of( "/" ) );

        if( separation != -1 )
        {
            category = aPartName.substr( 0, separation );
            base     = aPartName.substr( separation+1 );
        }
        else
        {
            // leave category empty
            base = aPartName;
        }

        if( (offset = okCategory( category )) != -1 )
        {
            THROW_PARSE_ERROR(
                    _( "Illegal character found in category" ),
                    wxString::FromUTF8( aRevision.c_str() ),
                    aRevision.c_str(),
                    0,
                    offset
                    );
        }

        if( (offset = okBase( base )) != -1 )
        {
            THROW_PARSE_ERROR(
                    _( "Illegal character found in base name" ),
                    wxString::FromUTF8( aRevision.c_str() ),
                    aRevision.c_str(),
                    0,
                    offset + separation + 1
                    );
        }

        if( category.size() )
        {
            ret += category;
            ret += '/';
        }

        ret += base;
    }

    if( aRevision.size() )
    {
        offset = okRevision( aRevision );
        if( offset != -1 )
        {
            THROW_PARSE_ERROR(
                    _( "Illegal character found in revision" ),
                    wxString::FromUTF8( aRevision.c_str() ),
                    aRevision.c_str(),
                    0,
                    offset
                    );
        }

        ret += '/';
        ret += aRevision;
    }

    return ret;
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:91,代码来源:sch_lpid.cpp

示例9:

// 字符串相关
INT	KLU_ConvertStringToVector(LPCTSTR strStrintgSource, std::vector< STRING >& vRet, LPCTSTR szKey, BOOL bOneOfKey, BOOL bIgnoreEmpty)
{
	vRet.clear();

	//------------------------------------------------------------
	//合法性
	if(!strStrintgSource || strStrintgSource[0] == '\0') return 0;
	
	STRING strSrc = strStrintgSource;

	//------------------------------------------------------------
	//查找第一个分割点
	STRING::size_type nLeft = 0;
	STRING::size_type nRight;
	if(bOneOfKey)
	{
		nRight = strSrc.find_first_of(szKey);
	}
	else
	{
		nRight = strSrc.find(szKey);
	}

	if(nRight == std::string::npos)
	{
		nRight = strSrc.length();
	}
	while(TRUE)
	{
		STRING strItem = strSrc.substr(nLeft, nRight-nLeft);
		if(strItem.length() > 0 || !bIgnoreEmpty)
		{
			vRet.push_back(strItem);
		}

		if(nRight == strSrc.length())
		{
			break;
		}

		nLeft = nRight + (bOneOfKey ? 1 : _tcslen(szKey));
		
		if(bOneOfKey)
		{
			STRING strTemp = strSrc.substr(nLeft);
			nRight = strTemp.find_first_of(szKey);
			if(nRight != STRING::npos) nRight += nLeft;
		}
		else
		{
			nRight = strSrc.find(szKey, nLeft);
		}

		if(nRight == std::string::npos)
		{
			nRight = strSrc.length();
		}
	}

	return (INT)vRet.size();
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:62,代码来源:GIUtil.cpp

示例10: ReplaceToSign

VOID CStringFilter::ReplaceToSign(const STRING& strIn, STRING& strOut)
{
	const CHAR		KeyStart		= '#';
	const CHAR		ContentsEnd		= '}';

	std::vector<PICE>	vSrcPice;	//来源字串分割成多段
	
	STRING strSrc = strIn;

	PICE			  pc;
	STRING::size_type sB = 0;
	STRING::size_type sC = 0;
	STRING::size_type sE = strSrc.find_first_of(KeyStart);
	STRING::size_type sLen = strSrc.size();

#if	0
	::OutputDebugString("ReplaceToSign Begin=======================\n");
	char dbgmsg[256];
	_snprintf(dbgmsg, 255, "strSrc:%s", strSrc.c_str());
	::OutputDebugString(dbgmsg);
	::OutputDebugString("\n------------------------------------------");
#endif

	do
	{	
		if(sE == STRING::npos)
		{
			//push last replace str
			pc.bReplace = TRUE;
			pc.pice = strSrc.substr(sC);
			vSrcPice.push_back(pc);
			break;
		}

		//get op
		STRING strOp = strSrc.substr(sE+1, 1);

		if(strOp == "{")	//ok, check magic #{} string.
		{
			//item element is valid. ex: #{_INFOID123}
			STRING strItemElement = strSrc.substr(sE+2, 7);
			//info message is valid. ex: #{_INFOMSGxxxxxx}
			STRING strInfoMsg = strSrc.substr(sE+2, 8);

			if(strItemElement == "_INFOID")
			{
				//get itemId
				//todo_yangjun	需要仔细检查剩下的字符是否还是一个完整的INFOID信息
				STRING::size_type sIDEnd = strSrc.find(ContentsEnd, sE+2+7);
				if(sE+2+7 >= sLen)	// fix dead loop if str is "xxx#{_INFOID" [9/25/2006]
				{
					//skip invalid #{
					sE += 2;
					goto LengthOver2;
				}
				STRING strId = strSrc.substr(sE+2+7, sIDEnd-sE-2-7);
				INT itemId = atoi(strId.c_str());

				if(g_pTransferItemSystem->IsElementExist(itemId))
				{//ok, valid item element found.

					//0. push normal replace str
					pc.bReplace = TRUE;
					pc.pice = strSrc.substr(sC, sE-sC);
					vSrcPice.push_back(pc);
					//1. push no replace str
					pc.bReplace = FALSE;
					pc.pice = strSrc.substr(sE, sIDEnd-sE+1);
					vSrcPice.push_back(pc);
				}

				//step to new point.
				sE = sIDEnd + 1;
				sC = sE;
			}
			else if(strInfoMsg == "_INFOMSG")
			{
				//get info message
				INT nContentsLen = atoi(strSrc.substr(sE+2+8,3).c_str());
				STRING::size_type sIDEnd = sE+2+8+3+nContentsLen;
				if(sE+2+8 >= sLen)
				{
					//skip invalid #{
					sE += 2;
					goto LengthOver2;
				}
				
				//ok, valid info message found.
				//0. push normal replace str
				pc.bReplace = TRUE;
				pc.pice = strSrc.substr(sC, sE-sC);
				vSrcPice.push_back(pc);
				//1. push no replace str
				pc.bReplace = FALSE;
				pc.pice = strSrc.substr(sE, sIDEnd-sE+1);
				vSrcPice.push_back(pc);

				//step to new point.
				sE = sIDEnd + 1;
				sC = sE;
//.........这里部分代码省略.........
开发者ID:jjiezheng,项目名称:pap_full,代码行数:101,代码来源:UIString_Filter.cpp


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