本文整理汇总了C++中TString::ToCString方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::ToCString方法的具体用法?C++ TString::ToCString怎么用?C++ TString::ToCString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::ToCString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IndexOfAny
inline
int IndexOfAny( const TString& needles, enums::Inclusion inclusion, int startIdx= 0 )
const
{
if (TCheck)
{
if ( startIdx < 0 ) startIdx= 0;
if ( startIdx >= length ) return -1;
}
else
{
#if defined(ALIB_DEBUG)
if ( startIdx < 0
|| startIdx >= length
|| needles.Length() == 0 )
dbgAStringAlibError( "Non checking and illegal parameters" );
#endif
}
if ( inclusion == enums::Inclusion::Include )
{
const char* res= std::strpbrk( ToCString() + startIdx, needles.ToCString() );
return res == nullptr ? -1 : (int) (res - buffer);
}
else
{
const char* haystack= ToCString() + startIdx;
int idx= (int) std::strspn ( haystack, needles.ToCString() );
return *( haystack + idx ) == '\0' ? -1 : startIdx + idx;
}
}
示例2: IndexOf
inline
int IndexOf( const TString& needle,
int startIdx= 0,
enums::Case sensitivity= enums::Case::Sensitive )
const
{
if (TCheck)
{
if ( startIdx < 0 ) startIdx= 0;
if ( startIdx + needle.Length() > length ) return -1;
if ( needle.Length() == 0 ) return startIdx;
}
else
{
#if defined(ALIB_DEBUG)
if ( startIdx < 0
|| startIdx >= length
|| needle.Length() == 0 )
dbgAStringAlibError( "Non checking and illegal parameters" );
#endif
}
#if defined (__GLIBCXX__)
const char* foundAt= sensitivity == enums::Case::Sensitive
? strstr ( ToCString() + startIdx, needle.ToCString() )
: strcasestr( ToCString() + startIdx, needle.ToCString() );
return foundAt != nullptr ? foundAt - buffer : -1;
#else
if ( sensitivity == enums::Case::Sensitive )
{
const char* foundAt= strstr( ToCString() + startIdx, needle.ToCString() );
return foundAt != nullptr ? (int) (foundAt - buffer) : -1;
}
else
// there is no strcasestr in windows, we use the slower String version, non-checking
return IndexOfSubstring<false>( needle, startIdx , enums::Case::Ignore );
#endif
}