本文整理汇总了C++中CStdString::Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::Tokenize方法的具体用法?C++ CStdString::Tokenize怎么用?C++ CStdString::Tokenize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::Tokenize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseOutputString
bool GameJoltAPI::ParseOutputString( CStdString inputString, vector<map<CStdString, CStdString>> &returnData )
{
map<CStdString, CStdString> resourceData;
vector<CStdString> parsedLines;
vector<CStdString>::iterator it;
CStdString curPiece;
CStdString curKey;
CStdString curValue;
int curPos = 0;
curPiece = inputString.Tokenize( _T("\n"), curPos );
while ( curPiece != _T("") )
{
parsedLines.push_back( curPiece );
curPiece = inputString.Tokenize( _T("\n"), curPos );
}
if ( parsedLines.size() == 0 )
{
m_ErrorMessage += _T("(Could not parse the response.)");
return false;
}
for ( it = parsedLines.begin(); it < parsedLines.end(); it++ )
{
curPos = (*it).FindOneOf( _T(":") );
curKey = (*it).Mid( 0, curPos );
curValue = (*it).Mid( curPos + 2, (*it).GetLength() - curPos - 4 );
// If this key is set, then we have looped and have a new resource.
// Push the data and clear.
if ( resourceData[curKey] != _T("") )
{
returnData.push_back( resourceData );
resourceData.clear();
}
resourceData[curKey] = curValue;
}
// We do one final push.
returnData.push_back( resourceData );
if ( returnData.front()["success"] != _T("true") )
m_ErrorMessage += _T("(") + returnData.front()["message"] + _T(")");
// Return it.
return true;
}