本文整理汇总了C++中VectorString::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorString::clear方法的具体用法?C++ VectorString::clear怎么用?C++ VectorString::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorString
的用法示例。
在下文中一共展示了VectorString::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: split
bool DAOProxy::split(const string& str, VectorString& array)
{
//ACS_TRACE("cdb::DAOProxy::split");
// The string that will be added to the list next.
string strCur;
// Tells us what kind of quote we are in.
bool bQuote = 0;
unsigned int iter = 0;
unsigned int len = str.length();
array.clear();
while(iter < len)
{
// We got to a whitespace and we are not in a quote: push the currently
// build substring at the end of the array.
if(!bQuote && str[iter] == ',')
{
if(strCur.length()!=0)
{
array.push_back(strCur);
strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks
}
}
// Escape sequence.
else if(str[iter] == '\\')
{
++iter;
// Whoops, escape ended before the new line.
if(iter == len)
{
return false;
}
switch(str[iter])
{
case 'n':
strCur += '\n';
break;
case 'r':
strCur += '\r';
break;
case ',':
case '\\':
case '\'':
case '"':
// Treat next character verbatim, regardless what it may be.
strCur += str[iter];
break;
default:
// An unrecognized escape!
return false;
}
}
// The quote ended.
else if(bQuote && str[iter] == '"')
{
// Indicate that we are in the quote no longer.
bQuote = 0;
array.push_back(strCur);
strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks
}
// The quote begun.
else if(str[iter] == '"')
{
if(strCur.length()!=0)
{
array.push_back(strCur);
strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks
}
bQuote = 1;
}
else
{
// A regular character.
strCur += str[iter];
}
++iter;
}
// Push the last string to the end of the array.
if(strCur.length()!=0)
{
array.push_back(strCur);
}
return true;
}