本文整理汇总了C++中strArray类的典型用法代码示例。如果您正苦于以下问题:C++ strArray类的具体用法?C++ strArray怎么用?C++ strArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了strArray类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mult
void mult(strArray &a, strArray &b)
{
strArray c(a); a.clear();
for (int i = 0; i < c.size(); i ++)
for (int j = 0; j < b.size(); j ++)
a.push_back(c[i] + b[j]);
};
开发者ID:kyokey,项目名称:MIPT,代码行数:7,代码来源:P030.cpp
示例2: split
// string toolkit
static inline void split(std::string src, const char* token, strArray& vect)
{
int nend=0;
int nbegin=0;
while(nend != -1)
{
nend = src.find(token, nbegin);
if(nend == -1)
vect.push_back(src.substr(nbegin, src.length()-nbegin));
else
vect.push_back(src.substr(nbegin, nend-nbegin));
nbegin = nend + strlen(token);
}
}
开发者ID:136446529,项目名称:Tiny-Wings-Remake-on-Android,代码行数:15,代码来源:CCNS.cpp
示例3: split
// string toolkit
static inline void split(const std::string& src, const std::string& token, strArray& vect)
{
size_t nend = 0;
size_t nbegin = 0;
size_t tokenSize = token.size();
while(nend != std::string::npos)
{
nend = src.find(token, nbegin);
if(nend == std::string::npos)
vect.push_back(src.substr(nbegin, src.length()-nbegin));
else
vect.push_back(src.substr(nbegin, nend-nbegin));
nbegin = nend + tokenSize;
}
}
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:16,代码来源:CCNS.cpp
示例4: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
// 首先,判断表格的字符串是否为{x,y}
// 是,则使用分裂字符串到参数strs
// 否则参数strs为空;
// 表格是对的,则返回true
static bool splitWithForm(const char* pStr, strArray& strs)
{
bool bRet = false;
do
{
CC_BREAK_IF(!pStr);
// string is empty
// 字符串为空
std::string content = pStr;
CC_BREAK_IF(content.length() == 0);
int nPosLeft = content.find('{');
int nPosRight = content.find('}');
// don't have '{' and '}'
// 不含有{}
CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
// '}' is before '{'
// }在{前
CC_BREAK_IF(nPosLeft > nPosRight);
std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
// nothing between '{' and '}'
// 在{}之前没有任何参数
CC_BREAK_IF(pointStr.length() == 0);
int nPos1 = pointStr.find('{');
int nPos2 = pointStr.find('}');
// contain '{' or '}'
// 包含{}
CC_BREAK_IF(nPos1 != (int)std::string::npos || nPos2 != (int)std::string::npos);
split(pointStr, ",", strs);
if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0)
{
strs.clear();
break;
}
bRet = true;
} while (0);
return bRet;
}
开发者ID:LaughingYan,项目名称:cocos2d-x,代码行数:54,代码来源:CCNS.cpp
示例5: trans
bool trans(int l, int r, strArray &a)
{
int i = l, ope = 1, j;
strArray b, c, d;
string s;
a.clear();
if (l > r) {
a.push_back("");
return 1;
};
while (i <= r)
{
if (st[i] == '+')
{
if (ope) return 0;
ope = 1; ++i;
}
else {
if (!ope || (st[i] < 'a' || st[i] > 'z') && st[i] != '(') return 0;
b.clear(); b.push_back("");
while (i <= r && (st[i] >= 'a' && st[i] <= 'z' || st[i] == '('))
{
if (st[i] == '(')
{
if (!findEnd(i, j, r)) return 0;
if (!trans(i + 1, j - 1, c)) return 0;
i = j + 1;
}
else {
s = "";
while (i <= r && st[i] >= 'a' && st[i] <= 'z') s += st[i ++];
c.clear(); c.push_back(s);
};
if (c.empty()) return 0;
mult(b, c);
};
if (b.size() == 1 && b[0] == "") continue;
add(a, b); ope = 0;
};
};
if (ope && !a.empty()) return 0;
return 1;
};
开发者ID:kyokey,项目名称:MIPT,代码行数:43,代码来源:P030.cpp
示例6: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
static KDbool splitWithForm ( const KDchar* szString, strArray& vStrings )
{
KDbool bRet = KD_FALSE;
do
{
CC_BREAK_IF ( !szString );
// string is empty
std::string sContent = szString;
CC_BREAK_IF ( sContent.length ( ) == 0 );
KDuint nPosLeft = sContent.find ( '{' );
KDuint nPosRight = sContent.find ( '}' );
// don't have '{' and '}'
CC_BREAK_IF ( nPosLeft == std::string::npos || nPosRight == std::string::npos );
// '}' is before '{'
CC_BREAK_IF ( nPosLeft > nPosRight );
std::string sPointStr = sContent.substr ( nPosLeft + 1, nPosRight - nPosLeft - 1 );
// nothing between '{' and '}'
CC_BREAK_IF ( sPointStr.length ( ) == 0 );
KDuint nPos1 = sPointStr.find ( '{' );
KDuint nPos2 = sPointStr.find ( '}' );
// contain '{' or '}'
CC_BREAK_IF ( nPos1 != std::string::npos || nPos2 != std::string::npos );
split ( sPointStr, ",", vStrings );
if ( vStrings.size ( ) != 2 || vStrings [ 0 ].length ( ) == 0 || vStrings [ 1 ].length ( ) == 0 )
{
vStrings.clear ( );
break;
}
bRet = KD_TRUE;
} while ( 0 );
return bRet;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:46,代码来源:CCNS.cpp
示例7: split
// string toolkit
static KDvoid split ( std::string sString, const KDchar* szToken, strArray& vStrings )
{
KDint nEnd = 0;
KDint nBegin = 0;
while ( nEnd != -1 )
{
nEnd = sString.find ( szToken, nBegin );
if ( nEnd == -1 )
{
vStrings.push_back ( sString.substr ( nBegin, sString.length ( ) - nBegin ) );
}
else
{
vStrings.push_back ( sString.substr ( nBegin, nEnd - nBegin ) );
}
nBegin = nEnd + kdStrlen ( szToken );
}
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:22,代码来源:CCNS.cpp
示例8: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
static bool splitWithForm(const std::string& content, strArray& strs)
{
bool bRet = false;
do
{
CC_BREAK_IF(content.empty());
size_t nPosLeft = content.find('{');
size_t nPosRight = content.find('}');
// don't have '{' and '}'
CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos);
// '}' is before '{'
CC_BREAK_IF(nPosLeft > nPosRight);
const std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
// nothing between '{' and '}'
CC_BREAK_IF(pointStr.length() == 0);
size_t nPos1 = pointStr.find('{');
size_t nPos2 = pointStr.find('}');
// contain '{' or '}'
CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos);
split(pointStr, ",", strs);
if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0)
{
strs.clear();
break;
}
bRet = true;
} while (0);
return bRet;
}
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:41,代码来源:CCNS.cpp
示例9: add
void add(strArray &a, const strArray &b)
{
for (int i = 0; i < b.size(); i ++)
a.push_back(b[i]);
};
开发者ID:kyokey,项目名称:MIPT,代码行数:5,代码来源:P030.cpp
示例10: print
void print(strArray &answer)
{
if (answer.size()) printf("%s", answer[0].c_str());
for (int i = 1; i < answer.size(); i++) printf("+%s", answer[i].c_str());
printf("\n");
};
开发者ID:kyokey,项目名称:MIPT,代码行数:6,代码来源:P030.cpp
注:本文中的strArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论