本文整理汇总了C++中StringT::find_first_of方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::find_first_of方法的具体用法?C++ StringT::find_first_of怎么用?C++ StringT::find_first_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringT
的用法示例。
在下文中一共展示了StringT::find_first_of方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
inline StringT
unescape_lit(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("\\", 0);
if (StringT::npos != pos1) {
do {
if ('\\' == value[pos1+1] || '\"' == value[pos1+1] ||
'?' == value[pos1+1])
{
result = result + value.substr(pos, pos1-pos);
pos1 = value.find_first_of ("\\", (pos = pos1+1)+1);
}
else {
result = result + value.substr(pos, pos1-pos+1);
pos1 = value.find_first_of ("\\", pos = pos1+1);
}
} while (pos1 != StringT::npos);
result = result + value.substr(pos);
}
else {
// the string doesn't contain any escaped character sequences
result = value;
}
return result;
}
示例2: trigraph
inline StringT
convert_trigraphs(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("?", 0);
if (StringT::npos != pos1) {
do {
result += value.substr(pos, pos1-pos);
StringT trigraph (value.substr(pos1));
if (is_trigraph(trigraph)) {
result += convert_trigraph(trigraph);
pos1 = value.find_first_of ("?", pos = pos1+3);
}
else {
result += value[pos1];
pos1 = value.find_first_of ("?", pos = pos1+1);
}
} while (StringT::npos != pos1);
result += value.substr(pos);
}
else {
result = value;
}
return result;
}
示例3: while
inline bool
is_escaped_lit(StringT const &value)
{
typename StringT::size_type pos = value.find_first_of ("\\", 0);
if (StringT::npos != pos) {
do {
if ('\\' == value[pos+1] ||
'\"' == value[pos+1] ||
'?' == value[pos+1])
{
return true;
}
else {
pos = value.find_first_of ("\\", pos+1);
}
} while (pos != StringT::npos);
}
return false;
}
示例4: StringT
inline StringT
escape_lit(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("\"\\?", 0);
if (StringT::npos != pos1) {
do {
result += value.substr(pos, pos1-pos)
+ StringT("\\")
+ StringT(1, value[pos1]);
pos1 = value.find_first_of ("\"\\?", pos = pos1+1);
} while (StringT::npos != pos1);
result += value.substr(pos);
}
else {
result = value;
}
return result;
}
示例5: uchar_val
inline void
validate_identifier_name (StringT const &name, std::size_t line,
std::size_t column, StringT const &file_name)
{
using namespace std; // some systems have strtoul in namespace std::
typename StringT::size_type pos = name.find_first_of('\\');
while (StringT::npos != pos) {
// the identifier name contains a backslash (must be universal char)
BOOST_ASSERT('u' == name[pos+1] || 'U' == name[pos+1]);
StringT uchar_val(name.substr(pos+2, ('u' == name[pos+1]) ? 4 : 8));
universal_char_type type =
classify_universal_char(strtoul(uchar_val.c_str(), 0, 16));
if (universal_char_type_valid != type) {
// an invalid char was found, so throw an exception
StringT error_uchar(name.substr(pos, ('u' == name[pos+1]) ? 6 : 10));
if (universal_char_type_invalid == type) {
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_invalid,
error_uchar, line, column, file_name.c_str());
}
else if (universal_char_type_base_charset == type) {
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_base_charset,
error_uchar, line, column, file_name.c_str());
}
else {
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_not_allowed,
error_uchar, line, column, file_name.c_str());
}
}
// find next universal char (if appropriate)
pos = name.find_first_of('\\', pos+2);
}
}
示例6: switch
inline StringT
unescape_lit(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("\\", 0);
if (StringT::npos != pos1) {
do {
switch (value[pos1+1]) {
case '\\':
case '\"':
case '?':
result = result + value.substr(pos, pos1-pos);
pos1 = value.find_first_of ("\\", (pos = pos1+1)+1);
break;
case 'n':
result = result + value.substr(pos, pos1-pos) + "\n";
pos1 = value.find_first_of ("\\", pos = pos1+1);
++pos;
break;
default:
result = result + value.substr(pos, pos1-pos+1);
pos1 = value.find_first_of ("\\", pos = pos1+1);
}
} while (pos1 != StringT::npos);
result = result + value.substr(pos);
}
else {
// the string doesn't contain any escaped character sequences
result = value;
}
return result;
}
示例7: CheckFind
void CheckFind()
{
StringT E = "";
StringT X = "x";
StringT Y = "y";
StringT S = "xxx";
EXPECT_EQ(E.find(E), 0u);
EXPECT_EQ(S.find(E), 0u);
EXPECT_EQ(E.find(E, 2), StringT::npos);
EXPECT_EQ(S.find(E, 2), 2u);
EXPECT_EQ(E.find(E, 8), StringT::npos);
EXPECT_EQ(S.find(E, 8), StringT::npos);
EXPECT_EQ(E.find(E, StringT::npos), StringT::npos);
EXPECT_EQ(S.find(E, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_of(E), StringT::npos);
EXPECT_EQ(S.find_first_of(E), StringT::npos);
EXPECT_EQ(E.find_first_of(E, 2), StringT::npos);
EXPECT_EQ(S.find_first_of(E, 2), StringT::npos);
EXPECT_EQ(E.find_first_of(E, 8), StringT::npos);
EXPECT_EQ(S.find_first_of(E, 8), StringT::npos);
EXPECT_EQ(E.find_first_of(E, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_of(E, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_of(X), StringT::npos);
EXPECT_EQ(S.find_first_of(X), 0u);
EXPECT_EQ(E.find_first_of(X, 2), StringT::npos);
EXPECT_EQ(S.find_first_of(X, 2), 2u);
EXPECT_EQ(E.find_first_of(X, 8), StringT::npos);
EXPECT_EQ(S.find_first_of(X, 8), StringT::npos);
EXPECT_EQ(E.find_first_of(X, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_of(X, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_of(Y, 2), StringT::npos);
EXPECT_EQ(S.find_first_of(Y, 2), StringT::npos);
EXPECT_EQ(E.find_first_of(Y, 8), StringT::npos);
EXPECT_EQ(S.find_first_of(Y, 8), StringT::npos);
EXPECT_EQ(E.find_first_of(Y, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_of(Y, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_not_of(E), StringT::npos);
EXPECT_EQ(S.find_first_not_of(E), 0u);
EXPECT_EQ(E.find_first_not_of(E, 2), StringT::npos);
EXPECT_EQ(S.find_first_not_of(E, 2), 2u);
EXPECT_EQ(E.find_first_not_of(E, 8), StringT::npos);
EXPECT_EQ(S.find_first_not_of(E, 8), StringT::npos);
EXPECT_EQ(E.find_first_not_of(E, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_not_of(E, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_not_of(X), StringT::npos);
EXPECT_EQ(S.find_first_not_of(X), StringT::npos);
EXPECT_EQ(E.find_first_not_of(X, 2), StringT::npos);
EXPECT_EQ(S.find_first_not_of(X, 2), StringT::npos);
EXPECT_EQ(E.find_first_not_of(X, 8), StringT::npos);
EXPECT_EQ(S.find_first_not_of(X, 8), StringT::npos);
EXPECT_EQ(E.find_first_not_of(X, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_not_of(X, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_first_not_of(Y, 2), StringT::npos);
EXPECT_EQ(S.find_first_not_of(Y, 2), 2u);
EXPECT_EQ(E.find_first_not_of(Y, 8), StringT::npos);
EXPECT_EQ(S.find_first_not_of(Y, 8), StringT::npos);
EXPECT_EQ(E.find_first_not_of(Y, StringT::npos), StringT::npos);
EXPECT_EQ(S.find_first_not_of(Y, StringT::npos), StringT::npos);
EXPECT_EQ(E.find_last_of(E), StringT::npos);
EXPECT_EQ(S.find_last_of(E), StringT::npos);
EXPECT_EQ(E.find_last_of(E, 2), StringT::npos);
EXPECT_EQ(S.find_last_of(E, 2), StringT::npos);
EXPECT_EQ(E.find_last_of(E, 8), StringT::npos);
EXPECT_EQ(S.find_last_of(E, 8), StringT::npos);
EXPECT_EQ(E.find_last_of(E, 0), StringT::npos);
EXPECT_EQ(S.find_last_of(E, 0), StringT::npos);
EXPECT_EQ(E.find_last_of(E), StringT::npos);
EXPECT_EQ(S.find_last_of(E), StringT::npos);
EXPECT_EQ(E.find_last_of(X, 2), StringT::npos);
EXPECT_EQ(S.find_last_of(X, 2), 2u);
EXPECT_EQ(E.find_last_of(X, 8), StringT::npos);
EXPECT_EQ(S.find_last_of(X, 8), 2u);
EXPECT_EQ(E.find_last_of(X, 0), StringT::npos);
EXPECT_EQ(S.find_last_of(X, 0), 0u);
EXPECT_EQ(E.find_last_of(Y, 2), StringT::npos);
EXPECT_EQ(S.find_last_of(Y, 2), StringT::npos);
EXPECT_EQ(E.find_last_of(Y, 8), StringT::npos);
EXPECT_EQ(S.find_last_of(Y, 8), StringT::npos);
EXPECT_EQ(E.find_last_of(Y, 0), StringT::npos);
EXPECT_EQ(S.find_last_of(Y, 0), StringT::npos);
EXPECT_EQ(E.find_last_not_of(E), StringT::npos);
EXPECT_EQ(S.find_last_not_of(E), 2u);
EXPECT_EQ(E.find_last_not_of(E, 2), StringT::npos);
EXPECT_EQ(S.find_last_not_of(E, 2), 2u);
EXPECT_EQ(E.find_last_not_of(E, 8), StringT::npos);
EXPECT_EQ(S.find_last_not_of(E, 8), 2u);
EXPECT_EQ(E.find_last_not_of(E, 0), StringT::npos);
EXPECT_EQ(S.find_last_not_of(E, 0), 0u);
EXPECT_EQ(E.find_last_not_of(E), StringT::npos);
EXPECT_EQ(S.find_last_not_of(E), 2u);
EXPECT_EQ(E.find_last_not_of(X, 2), StringT::npos);
EXPECT_EQ(S.find_last_not_of(X, 2), StringT::npos);
EXPECT_EQ(E.find_last_not_of(X, 8), StringT::npos);
EXPECT_EQ(S.find_last_not_of(X, 8), StringT::npos);
EXPECT_EQ(E.find_last_not_of(X, 0), StringT::npos);
//.........这里部分代码省略.........