aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llstring.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llcommon/llstring.h54
1 files changed, 50 insertions, 4 deletions
diff --git a/linden/indra/llcommon/llstring.h b/linden/indra/llcommon/llstring.h
index cd58d11..82ebdc9 100644
--- a/linden/indra/llcommon/llstring.h
+++ b/linden/indra/llcommon/llstring.h
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -299,6 +299,10 @@ public:
299 // a.k.a. strdictcmp() 299 // a.k.a. strdictcmp()
300 static S32 compareDict(const std::basic_string<T>& a, const std::basic_string<T>& b); 300 static S32 compareDict(const std::basic_string<T>& a, const std::basic_string<T>& b);
301 301
302 // Case *in*sensitive comparison with good handling of numbers. Does not use current locale.
303 // a.k.a. strdictcmp()
304 static S32 compareDictInsensitive(const std::basic_string<T>& a, const std::basic_string<T>& b);
305
302 // Puts compareDict() in a form appropriate for LL container classes to use for sorting. 306 // Puts compareDict() in a form appropriate for LL container classes to use for sorting.
303 static BOOL precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ); 307 static BOOL precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b );
304 308
@@ -310,7 +314,7 @@ public:
310 // Copies src into dst at a given offset. 314 // Copies src into dst at a given offset.
311 static void copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset); 315 static void copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset);
312 316
313#ifdef _DEBUG 317#ifdef _DEBUG
314 static void testHarness(); 318 static void testHarness();
315#endif 319#endif
316 320
@@ -433,6 +437,15 @@ S32 wchar_utf8_length(const llwchar wc);
433 437
434std::string utf8str_tolower(const std::string& utf8str); 438std::string utf8str_tolower(const std::string& utf8str);
435 439
440// Length in llwchar (UTF-32) of the first len units (16 bits) of the given UTF-16 string.
441S32 utf16str_wstring_length(const llutf16string &utf16str, S32 len);
442
443// Length in utf16string (UTF-16) of wlen wchars beginning at woffset.
444S32 wstring_utf16_length(const LLWString & wstr, S32 woffset, S32 wlen);
445
446// Length in wstring (i.e., llwchar count) of a part of a wstring specified by utf16 length (i.e., utf16 units.)
447S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, S32 woffset, S32 utf16_length, BOOL *unaligned = NULL);
448
436/** 449/**
437 * @brief Properly truncate a utf8 string to a maximum byte count. 450 * @brief Properly truncate a utf8 string to a maximum byte count.
438 * 451 *
@@ -440,7 +453,7 @@ std::string utf8str_tolower(const std::string& utf8str);
440 * happens in the middle of a glyph. If max_len is longer than the 453 * happens in the middle of a glyph. If max_len is longer than the
441 * string passed in, the return value == utf8str. 454 * string passed in, the return value == utf8str.
442 * @param utf8str A valid utf8 string to truncate. 455 * @param utf8str A valid utf8 string to truncate.
443 * @param max_len The maximum number of bytes in the returne 456 * @param max_len The maximum number of bytes in the return value.
444 * @return Returns a valid utf8 string with byte count <= max_len. 457 * @return Returns a valid utf8 string with byte count <= max_len.
445 */ 458 */
446std::string utf8str_truncate(const std::string& utf8str, const S32 max_len); 459std::string utf8str_truncate(const std::string& utf8str, const S32 max_len);
@@ -699,6 +712,39 @@ S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::ba
699 return ca-cb; 712 return ca-cb;
700} 713}
701 714
715template<class T>
716S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr)
717{
718 const T* a = astr.c_str();
719 const T* b = bstr.c_str();
720 T ca, cb;
721 S32 ai, bi, cnt = 0;
722
723 ca = *(a++);
724 cb = *(b++);
725 while( ca && cb ){
726 if( LLStringOps::isUpper(ca) ){ ca = LLStringOps::toLower(ca); }
727 if( LLStringOps::isUpper(cb) ){ cb = LLStringOps::toLower(cb); }
728 if( LLStringOps::isDigit(ca) ){
729 if( cnt-->0 ){
730 if( cb!=ca ) break;
731 }else{
732 if( !LLStringOps::isDigit(cb) ) break;
733 for(ai=0; LLStringOps::isDigit(a[ai]); ai++);
734 for(bi=0; LLStringOps::isDigit(b[bi]); bi++);
735 if( ai<bi ){ ca=0; break; }
736 if( bi<ai ){ cb=0; break; }
737 if( ca!=cb ) break;
738 cnt = ai;
739 }
740 }else if( ca!=cb ){ break;
741 }
742 ca = *(a++);
743 cb = *(b++);
744 }
745 return ca-cb;
746}
747
702// Puts compareDict() in a form appropriate for LL container classes to use for sorting. 748// Puts compareDict() in a form appropriate for LL container classes to use for sorting.
703// static 749// static
704template<class T> 750template<class T>