diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-02-14 11:22:58 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-14 11:22:58 +0000 |
commit | 40919b309b9918ae8006ae01b74d50b990a37cab (patch) | |
tree | 67c0b3f71c99b987d420aa4f80ab5411298ecf83 /comphelper/inc | |
parent | f7992005e08b9814926322beccc891441f0d6590 (diff) |
move this (cool) natural sort into comphelper
Diffstat (limited to 'comphelper/inc')
-rw-r--r-- | comphelper/inc/comphelper/string.hxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx index 85b1a2e4efe1..9ef4ec657bbb 100644 --- a/comphelper/inc/comphelper/string.hxx +++ b/comphelper/inc/comphelper/string.hxx @@ -131,6 +131,44 @@ COMPHELPER_DLLPUBLIC ::rtl::OUString convertCommaSeparated( COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::rtl::OUString > convertCommaSeparated( ::rtl::OUString const & i_rString ); +/** + Compares two strings using natural order. + + For non digit characters, the comparison use the same algorithm as + rtl_str_compare. When a number is encountered during the comparison, + natural order is used. Thus, Heading 10 will be considered as greater + than Heading 2. Numerical comparison is done using decimal representation. + + Beware that "MyString 001" and "MyString 1" will be considered as equal + since leading 0 are meaningless. + + @param str the object to be compared. + @return 0 - if both strings are equal + < 0 - if this string is less than the string argument + > 0 - if this string is greater than the string argument +*/ +COMPHELPER_DLLPUBLIC sal_Int32 compareNatural( const ::rtl::OUString &rLHS, const ::rtl::OUString &rRHS ) + SAL_THROW(()); + +/** + Compares two strings using natural order. + + For non digit characters, the comparison use the same algorithm as + rtl_str_compare. When a number is encountered during the comparison, + natural order is used. Thus, Heading 10 will be considered as greater + than Heading 2. Numerical comparison is done using decimal representation. + + Beware that "MyString 001" and "MyString 1" will be considered as equal + since leading 0 are meaningless. + + @param str the object to be compared. + @return 0 - if both strings are equal + < 0 - if this string is less than the string argument + > 0 - if this string is greater than the string argument + */ +COMPHELPER_DLLPUBLIC sal_Int32 compareNatural( const ::rtl::OString &rLHS, const ::rtl::OString &rRHS ) + SAL_THROW(()); + } } #endif |