Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

4.4 Lexicographic Comparisons

If you are putting together a dictionary, you will find the lexicographics comparison operators of RWCString particularly useful. They are:

These operators are case sensitive. If you wish to make case insensitive comparisons, you can use the member function:

Here the function returns an integer less than zero, equal to zero, or greater than zero, depending on whether str is lexicographically less than, equal to, or greater than self. The type caseCompare is an enum with values:

exact

Case sensitive

ignoreCase

Case insensitive

Its default setting is exact, which gives the same result as the logical operators ==, !=, etc.

For locale-specific string collations, you would use the member function:

which is an encapsulation of the Standard C library function strcoll(). This function returns results computed according to the locale-specific collating conventions set by category LC_COLLATE of the Standard C library function setlocale(). Because this is a relatively expensive calculation, you may want to pretransform one or more strings using the global function:

then use compareTo() or one of the logical operators, ==, !=, etc., on the results. See the SourcePro C++ API Reference Guide entry for RWCString: the function strXForm() appears under related functions.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.