本文整理汇总了C++中StringT::find方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::find方法的具体用法?C++ StringT::find怎么用?C++ StringT::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringT
的用法示例。
在下文中一共展示了StringT::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dims
void
WriteStringT( hid_t iParent,
const std::string &iAttrName,
const StringT &iString )
{
// Verify that no NULL characters have been hidden in the string.
CharT NullChar = ( CharT )0;
ABCA_ASSERT( iString.find( NullChar ) == StringT::npos,
"Illegal NULL character found in string in WriteStringT" );
// Create the dataspace.
size_t len = iString.length();
Dimensions dims( len + 1 );
HDimensions hdims( dims );
size_t npoints = hdims.numPoints();
ABCA_ASSERT( npoints > 0,
"Cannot create degenerate dataspace" );
hid_t dspaceId = H5Screate_simple( hdims.rank(), hdims.rootPtr(), NULL );
DspaceCloser dspaceCloser( dspaceId );
// Get the data.
const CharT *data;
if ( len == 0 )
{
data = &NullChar;
}
else
{
data = iString.c_str();
}
// Write into it.
WriteDataToAttr( iParent, dspaceId, iAttrName,
GetFileDtype<CharT>(), GetNativeDtype<CharT>(),
( const void * )data );
}
示例2: 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);
//.........这里部分代码省略.........