本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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
}
示例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, '\\');
}
}
}
示例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( ":/" ) );
}
示例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;
}
示例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();
}
示例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;
//.........这里部分代码省略.........