Compare strings

Web Site  Methods

 
Str::Compare
 
int Compare (const STRCHAR* match) const

 
Str::CompareNoCase
 
int CompareNoCase (const STRCHAR* match) const

Compare will compare the content of the string object to the passed string and return one of the following values:

CompareNoCase works the same way, but performs a case-insensitive compare, and is a bit slower.

 

Windows Note

Comparisions are performed with the C RTL functions strcmp / stricmp; however, when compiling with the STR_NO_RTLIBRARY option, comparisions are done using the Windows API function lstrcmp, which yields slightly different results in some cases. For more information, lookup strcmp and lstrcmp in the online help.

This affects only the case where one string is greater than the other; equality / inequality always works in the same way when using case-insensitive compare.

 

 
Str::operator ==
Str::operator !=
 

BOOL operator ==(const Str& s1, const Str& s2)
BOOL operator == (const Str& s1, const STRCHAR* s2)
BOOL operator ==(const STRCHAR* s1, const Str& s2)
BOOL operator !=(const Str& s1, const Str& s2)
BOOL operator != (const Str& s1, const STRCHAR* s2)
BOOL operator !=(const STRCHAR* s1, const Str& s2)

The == and != operators are overloaded to compare the two strings and return TRUE if they are equal (or not equal). The comparision when using the operators is case-sensitive.

 

 
Str::operator >
Str::operator >=
Str::operator <
Str::operator <=
 

BOOL operator <(const Str& s1, const Str& s2)
BOOL operator < (const Str& s1, const STRCHAR* s2)
BOOL operator <(const STRCHAR* s1, const Str& s2)
BOOL operator <=(const Str& s1, const Str& s2)
BOOL operator <= (const Str& s1, const STRCHAR* s2)
BOOL operator <=(const STRCHAR* s1, const Str& s2)
BOOL operator >(const Str& s1, const Str& s2)
BOOL operator > (const Str& s1, const STRCHAR* s2)
BOOL operator >(const STRCHAR* s1, const Str& s2)
BOOL operator >=(const Str& s1, const Str& s2)
BOOL operator >= (const Str& s1, const STRCHAR* s2)
BOOL operator >=(const STRCHAR* s1, const Str& s2)

The comparision operators are overloaded so you can compare two strings with a simple syntax.  The return values are the same as those from the Compare method.  Notice that the operators always perform a case-sensitive comparision.

 

See also: Find, Replace, Compare