added to convert/text.h:
bool IsSubStringp(const StringType1 * short_str, const StringType2 * long_str); bool IsSubString(const StringType1 * short_str, const StringType2 * long_str); bool IsSubString(const StringType1 & short_str, const StringType2 & long_str); bool IsSubStringNoCasep(const StringType1 * short_str, const StringType2 * long_str); bool IsSubStringNoCase(const StringType1 * short_str, const StringType2 * long_str); bool IsSubStringNoCase(const StringType1 & short_str, const StringType2 & long_str); (moved from winix) git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1133 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
5fe920d591
commit
6984a34fcd
|
@ -198,6 +198,71 @@ bool EqualNoCase(const StringType1 * str1_begin, const StringType1 * str1_end, c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubStringp(const StringType1 * short_str, const StringType2 * long_str)
|
||||||
|
{
|
||||||
|
while( *short_str && *long_str && wchar_t(*short_str) == wchar_t(*long_str) )
|
||||||
|
{
|
||||||
|
++short_str;
|
||||||
|
++long_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *short_str == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubString(const StringType1 * short_str, const StringType2 * long_str)
|
||||||
|
{
|
||||||
|
return IsSubStringp(short_str, long_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubString(const StringType1 & short_str, const StringType2 & long_str)
|
||||||
|
{
|
||||||
|
return IsSubStringp(short_str.c_str(), long_str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubStringNoCasep(const StringType1 * short_str, const StringType2 * long_str)
|
||||||
|
{
|
||||||
|
while( *short_str && *long_str && ToLower(*short_str) == ToLower(*long_str) )
|
||||||
|
{
|
||||||
|
++short_str;
|
||||||
|
++long_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *short_str == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubStringNoCase(const StringType1 * short_str, const StringType2 * long_str)
|
||||||
|
{
|
||||||
|
return IsSubStringNoCasep(short_str, long_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType1, class StringType2>
|
||||||
|
bool IsSubStringNoCase(const StringType1 & short_str, const StringType2 & long_str)
|
||||||
|
{
|
||||||
|
return IsSubStringNoCasep(short_str.c_str(), long_str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue