LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/rtl - ustring.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 330 361 91.4 %
Date: 2012-12-27 Functions: 466 769 60.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _RTL_USTRING_HXX_
      21             : #define _RTL_USTRING_HXX_
      22             : 
      23             : #include "sal/config.h"
      24             : 
      25             : #include <cassert>
      26             : #include <ostream>
      27             : #include <string.h>
      28             : 
      29             : #include "osl/diagnose.h"
      30             : #include <rtl/ustring.h>
      31             : #include <rtl/string.hxx>
      32             : #include <rtl/stringutils.hxx>
      33             : #include <rtl/textenc.h>
      34             : #include "sal/log.hxx"
      35             : 
      36             : #ifdef RTL_FAST_STRING
      37             : #include <rtl/stringconcat.hxx>
      38             : #endif
      39             : 
      40             : #if defined EXCEPTIONS_OFF
      41             : #include <stdlib.h>
      42             : #else
      43             : #include <new>
      44             : #endif
      45             : 
      46             : // The unittest uses slightly different code to help check that the proper
      47             : // calls are made. The class is put into a different namespace to make
      48             : // sure the compiler generates a different (if generating also non-inline)
      49             : // copy of the function and does not merge them together. The class
      50             : // is "brought" into the proper rtl namespace by a typedef below.
      51             : #ifdef RTL_STRING_UNITTEST
      52             : #define rtl rtlunittest
      53             : #endif
      54             : 
      55             : namespace rtl
      56             : {
      57             : 
      58             : #ifdef RTL_STRING_UNITTEST
      59             : #undef rtl
      60             : #endif
      61             : 
      62             : /* ======================================================================= */
      63             : 
      64             : /**
      65             :   This String class provides base functionality for C++ like Unicode
      66             :   character array handling. The advantage of this class is that it
      67             :   handles all the memory management for you - and it does it
      68             :   more efficiently. If you assign a string to another string, the
      69             :   data of both strings are shared (without any copy operation or
      70             :   memory allocation) as long as you do not change the string. This class
      71             :   also stores the length of the string, so that many operations are
      72             :   faster than the C-str-functions.
      73             : 
      74             :   This class provides only readonly string handling. So you could create
      75             :   a string and you could only query the content from this string.
      76             :   It provides also functionality to change the string, but this results
      77             :   in every case in a new string instance (in the most cases with a
      78             :   memory allocation). You don't have functionality to change the
      79             :   content of the string. If you want to change the string content, then
      80             :   you should use the OStringBuffer class, which provides these
      81             :   functionalities and avoids too much memory allocation.
      82             : 
      83             :   The design of this class is similar to the string classes in Java so
      84             :   less people should have understanding problems when they use this class.
      85             : */
      86             : 
      87             : class SAL_WARN_UNUSED OUString
      88             : {
      89             : public:
      90             :     /// @cond INTERNAL
      91             :     rtl_uString * pData;
      92             :     /// @endcond
      93             : 
      94             : private:
      95             :     class DO_NOT_ACQUIRE{};
      96             : 
      97     3195623 :     OUString( rtl_uString * value, SAL_UNUSED_PARAMETER DO_NOT_ACQUIRE * )
      98             :     {
      99     3195623 :         pData = value;
     100     3195623 :     }
     101             : 
     102             : public:
     103             :     /**
     104             :       New string containing no characters.
     105             :     */
     106    14218585 :     OUString() SAL_THROW(())
     107             :     {
     108    14218585 :         pData = 0;
     109    14218585 :         rtl_uString_new( &pData );
     110    14218585 :     }
     111             : 
     112             :     /**
     113             :       New string from OUString.
     114             : 
     115             :       @param    str         a OUString.
     116             :     */
     117    18996054 :     OUString( const OUString & str ) SAL_THROW(())
     118             :     {
     119    18996054 :         pData = str.pData;
     120    18996054 :         rtl_uString_acquire( pData );
     121    18996054 :     }
     122             : 
     123             :     /**
     124             :       New string from OUString data.
     125             : 
     126             :       @param    str         a OUString data.
     127             :     */
     128     2289725 :     OUString( rtl_uString * str )  SAL_THROW(())
     129             :     {
     130     2289725 :         pData = str;
     131     2289725 :         rtl_uString_acquire( pData );
     132     2289725 :     }
     133             : 
     134             :     /** New OUString from OUString data without acquiring it.  Takeover of ownership.
     135             : 
     136             :         The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this
     137             :         from other constructors.
     138             : 
     139             :         @param str
     140             :                OUString data
     141             :     */
     142     5055411 :     inline OUString( rtl_uString * str, __sal_NoAcquire ) SAL_THROW(())
     143     5055411 :         { pData = str; }
     144             : 
     145             :     /**
     146             :       New string from a single Unicode character.
     147             : 
     148             :       @param    value       a Unicode character.
     149             :     */
     150      422348 :     explicit OUString( sal_Unicode value ) SAL_THROW(())
     151      422348 :         : pData (0)
     152             :     {
     153      422348 :         rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
     154      422348 :     }
     155             : 
     156             :     /**
     157             :       New string from a Unicode character buffer array.
     158             : 
     159             :       @param    value       a NULL-terminated Unicode character array.
     160             :     */
     161     2135538 :     OUString( const sal_Unicode * value ) SAL_THROW(())
     162             :     {
     163     2135538 :         pData = 0;
     164     2135538 :         rtl_uString_newFromStr( &pData, value );
     165     2135538 :     }
     166             : 
     167             :     /**
     168             :       New string from a Unicode character buffer array.
     169             : 
     170             :       @param    value       a Unicode character array.
     171             :       @param    length      the number of character which should be copied.
     172             :                             The character array length must be greater than
     173             :                             or equal to this value.
     174             :     */
     175      335473 :     OUString( const sal_Unicode * value, sal_Int32 length ) SAL_THROW(())
     176             :     {
     177      335473 :         pData = 0;
     178      335473 :         rtl_uString_newFromStr_WithLength( &pData, value, length );
     179      335473 :     }
     180             : 
     181             :     /**
     182             :       New string from an 8-Bit string literal that is expected to contain only
     183             :       characters in the ASCII set (i.e. first 128 characters). This constructor
     184             :       allows an efficient and convenient way to create OUString
     185             :       instances from ASCII literals. When creating strings from data that
     186             :       is not pure ASCII, it needs to be converted to OUString by explicitly
     187             :       providing the encoding to use for the conversion.
     188             : 
     189             :       If there are any embedded \0's in the string literal, the result is undefined.
     190             :       Use the overload that explicitly accepts length.
     191             : 
     192             :       @param    literal         the 8-bit ASCII string literal
     193             : 
     194             :       @since LibreOffice 3.6
     195             :     */
     196             : #ifdef HAVE_SFINAE_ANONYMOUS_BROKEN
     197             :     // Old gcc can try to convert anonymous enums to OUString and give compile error.
     198             :     // So instead have a variant for const and non-const char[].
     199             :     template< int N >
     200             :     OUString( const char (&literal)[ N ] )
     201             :     {
     202             :         // Check that the string literal is in fact N - 1 long (no embedded \0's),
     203             :         // any decent compiler should optimize out calls to strlen with literals.
     204             :         assert( strlen( literal ) == N - 1 );
     205             :         pData = 0;
     206             :         rtl_uString_newFromLiteral( &pData, literal, N - 1, 0 );
     207             : #ifdef RTL_STRING_UNITTEST
     208             :         rtl_string_unittest_const_literal = true;
     209             : #endif
     210             :     }
     211             : 
     212             :     /**
     213             :      * It is an error to call this overload. Strings cannot directly use non-const char[].
     214             :      * @internal
     215             :      */
     216             :     template< int N >
     217             :     OUString( char (&value)[ N ] )
     218             : #ifndef RTL_STRING_UNITTEST
     219             :         ; // intentionally not implemented
     220             : #else
     221             :     {
     222             :         (void) value; // unused
     223             :         pData = 0;
     224             :         rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
     225             :         rtl_string_unittest_invalid_conversion = true;
     226             :     }
     227             : #endif
     228             : #else // HAVE_SFINAE_ANONYMOUS_BROKEN
     229             :     template< typename T >
     230     1240882 :     OUString( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() )
     231             :     {
     232             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     233     1240882 :         pData = 0;
     234     1240882 :         rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
     235             : #ifdef RTL_STRING_UNITTEST
     236          30 :         rtl_string_unittest_const_literal = true;
     237             : #endif
     238     1240882 :     }
     239             : 
     240             : #endif // HAVE_SFINAE_ANONYMOUS_BROKEN
     241             : 
     242             : 
     243             : #ifdef RTL_STRING_UNITTEST
     244             :     /**
     245             :      * Only used by unittests to detect incorrect conversions.
     246             :      * @internal
     247             :      */
     248             :     template< typename T >
     249          21 :     OUString( T&, typename internal::ExceptConstCharArrayDetector< T >::Type = internal::Dummy() )
     250             :     {
     251          21 :         pData = 0;
     252          21 :         rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
     253          21 :         rtl_string_unittest_invalid_conversion = true;
     254          21 :     }
     255             :     /**
     256             :      * Only used by unittests to detect incorrect conversions.
     257             :      * @internal
     258             :      */
     259             :     template< typename T >
     260           2 :     OUString( const T&, typename internal::ExceptCharArrayDetector< T >::Type = internal::Dummy() )
     261             :     {
     262           2 :         pData = 0;
     263           2 :         rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
     264           2 :         rtl_string_unittest_invalid_conversion = true;
     265           2 :     }
     266             : #endif
     267             : 
     268             :     /**
     269             :       New string from an 8-Bit character buffer array.
     270             : 
     271             :       @param    value           An 8-Bit character array.
     272             :       @param    length          The number of character which should be converted.
     273             :                                 The 8-Bit character array length must be
     274             :                                 greater than or equal to this value.
     275             :       @param    encoding        The text encoding from which the 8-Bit character
     276             :                                 sequence should be converted.
     277             :       @param    convertFlags    Flags which control the conversion.
     278             :                                 see RTL_TEXTTOUNICODE_FLAGS_...
     279             : 
     280             :       @exception std::bad_alloc is thrown if an out-of-memory condition occurs
     281             :     */
     282     3953495 :     OUString( const sal_Char * value, sal_Int32 length,
     283             :               rtl_TextEncoding encoding,
     284             :               sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
     285             :     {
     286     3953495 :         pData = 0;
     287     3953495 :         rtl_string2UString( &pData, value, length, encoding, convertFlags );
     288     3953495 :         if (pData == 0) {
     289             : #if defined EXCEPTIONS_OFF
     290             :             abort();
     291             : #else
     292           0 :             throw std::bad_alloc();
     293             : #endif
     294             :         }
     295     3953495 :     }
     296             : 
     297             :     /** Create a new string from an array of Unicode code points.
     298             : 
     299             :         @param codePoints
     300             :         an array of at least codePointCount code points, which each must be in
     301             :         the range from 0 to 0x10FFFF, inclusive.  May be null if codePointCount
     302             :         is zero.
     303             : 
     304             :         @param codePointCount
     305             :         the non-negative number of code points.
     306             : 
     307             :         @exception std::bad_alloc
     308             :         is thrown if either an out-of-memory condition occurs or the resulting
     309             :         number of UTF-16 code units would have been larger than SAL_MAX_INT32.
     310             : 
     311             :         @since UDK 3.2.7
     312             :     */
     313       11731 :     inline explicit OUString(
     314             :         sal_uInt32 const * codePoints, sal_Int32 codePointCount):
     315       11731 :         pData(NULL)
     316             :     {
     317       11731 :         rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
     318       11731 :         if (pData == NULL) {
     319             : #if defined EXCEPTIONS_OFF
     320             :             abort();
     321             : #else
     322           0 :             throw std::bad_alloc();
     323             : #endif
     324             :         }
     325       11731 :     }
     326             : 
     327             : #ifdef RTL_FAST_STRING
     328             :     /**
     329             :      @overload
     330             :      @internal
     331             :     */
     332             :     template< typename T1, typename T2 >
     333      517760 :     OUString( const OUStringConcat< T1, T2 >& c )
     334             :     {
     335      517760 :         const sal_Int32 l = c.length();
     336      517760 :         pData = rtl_uString_alloc( l );
     337      517760 :         if (l != 0)
     338             :         {
     339      517758 :             sal_Unicode* end = c.addData( pData->buffer );
     340      517758 :             pData->length = end - pData->buffer;
     341      517758 :             *end = '\0';
     342             :             // TODO realloc in case pData->length is noticeably smaller than l?
     343             :         }
     344      517760 :     }
     345             : #endif
     346             : 
     347             :     /**
     348             :       Release the string data.
     349             :     */
     350    51012292 :     ~OUString() SAL_THROW(())
     351             :     {
     352    51012292 :         rtl_uString_release( pData );
     353    51012292 :     }
     354             : 
     355             :     /** Provides an OUString const & passing a storage pointer of an
     356             :         rtl_uString * handle.
     357             :         It is more convenient to use C++ OUString member functions when dealing
     358             :         with rtl_uString * handles.  Using this function avoids unnecessary
     359             :         acquire()/release() calls for a temporary OUString object.
     360             : 
     361             :         @param ppHandle
     362             :                pointer to storage
     363             :         @return
     364             :                OUString const & based on given storage
     365             :     */
     366       38005 :     static inline OUString const & unacquired( rtl_uString * const * ppHandle )
     367       38005 :         { return * reinterpret_cast< OUString const * >( ppHandle ); }
     368             : 
     369             :     /**
     370             :       Assign a new string.
     371             : 
     372             :       @param    str         a OUString.
     373             :     */
     374    12526694 :     OUString & operator=( const OUString & str ) SAL_THROW(())
     375             :     {
     376    12526694 :         rtl_uString_assign( &pData, str.pData );
     377    12526694 :         return *this;
     378             :     }
     379             : 
     380             :     /**
     381             :       Assign a new string from an 8-Bit string literal that is expected to contain only
     382             :       characters in the ASCII set (i.e. first 128 characters). This operator
     383             :       allows an efficient and convenient way to assign OUString
     384             :       instances from ASCII literals. When assigning strings from data that
     385             :       is not pure ASCII, it needs to be converted to OUString by explicitly
     386             :       providing the encoding to use for the conversion.
     387             : 
     388             :       @param    literal         the 8-bit ASCII string literal
     389             : 
     390             :       @since LibreOffice 3.6
     391             :     */
     392             :     template< typename T >
     393      584082 :     typename internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal )
     394             :     {
     395             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     396      584082 :         rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
     397      584082 :         return *this;
     398             :     }
     399             : 
     400             :     /**
     401             :       Append a string to this string.
     402             : 
     403             :       @param    str         a OUString.
     404             :     */
     405     1402225 :     OUString & operator+=( const OUString & str ) SAL_THROW(())
     406             :     {
     407     1402225 :         rtl_uString_newConcat( &pData, pData, str.pData );
     408     1402225 :         return *this;
     409             :     }
     410             : 
     411             : #ifdef RTL_FAST_STRING
     412             :     /**
     413             :      @overload
     414             :      @internal
     415             :     */
     416             :     template< typename T1, typename T2 >
     417         563 :     OUString& operator+=( const OUStringConcat< T1, T2 >& c )
     418             :     {
     419         563 :         const int l = c.length();
     420         563 :         if( l == 0 )
     421           0 :             return *this;
     422         563 :         rtl_uString_ensureCapacity( &pData, pData->length + l );
     423         563 :         sal_Unicode* end = c.addData( pData->buffer + pData->length );
     424         563 :         *end = '\0';
     425         563 :         pData->length = end - pData->buffer;
     426         563 :         return *this;
     427             :     }
     428             : #endif
     429             : 
     430             :     /**
     431             :       Returns the length of this string.
     432             : 
     433             :       The length is equal to the number of Unicode characters in this string.
     434             : 
     435             :       @return   the length of the sequence of characters represented by this
     436             :                 object.
     437             :     */
     438    16212905 :     sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
     439             : 
     440             :     /**
     441             :       Checks if a string is empty.
     442             : 
     443             :       @return   sal_True if the string is empty;
     444             :                 sal_False, otherwise.
     445             : 
     446             :       @since LibreOffice 3.4
     447             :     */
     448     3390576 :     bool isEmpty() const SAL_THROW(())
     449             :     {
     450     3390576 :         return pData->length == 0;
     451             :     }
     452             : 
     453             :     /**
     454             :       Returns a pointer to the Unicode character buffer for this string.
     455             : 
     456             :       It isn't necessarily NULL terminated.
     457             : 
     458             :       @return   a pointer to the Unicode characters buffer for this object.
     459             :     */
     460    12927953 :     const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
     461             : 
     462             :     /**
     463             :       Access to individual characters.
     464             : 
     465             :       @param index must be non-negative and less than length.
     466             : 
     467             :       @return the character at the given index.
     468             : 
     469             :       @since LibreOffice 3.5
     470             :     */
     471     7219772 :     sal_Unicode operator [](sal_Int32 index) const { return getStr()[index]; }
     472             : 
     473             :     /**
     474             :       Compares two strings.
     475             : 
     476             :       The comparison is based on the numeric value of each character in
     477             :       the strings and return a value indicating their relationship.
     478             :       This function can't be used for language specific sorting.
     479             : 
     480             :       @param    str         the object to be compared.
     481             :       @return   0 - if both strings are equal
     482             :                 < 0 - if this string is less than the string argument
     483             :                 > 0 - if this string is greater than the string argument
     484             :     */
     485    18580180 :     sal_Int32 compareTo( const OUString & str ) const SAL_THROW(())
     486             :     {
     487             :         return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
     488    18580180 :                                             str.pData->buffer, str.pData->length );
     489             :     }
     490             : 
     491             :     /**
     492             :       Compares two strings with a maximum count of characters.
     493             : 
     494             :       The comparison is based on the numeric value of each character in
     495             :       the strings and return a value indicating their relationship.
     496             :       This function can't be used for language specific sorting.
     497             : 
     498             :       @param    str         the object to be compared.
     499             :       @param    maxLength   the maximum count of characters to be compared.
     500             :       @return   0 - if both strings are equal
     501             :                 < 0 - if this string is less than the string argument
     502             :                 > 0 - if this string is greater than the string argument
     503             : 
     504             :       @since UDK 3.2.7
     505             :     */
     506       38069 :     sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const SAL_THROW(())
     507             :     {
     508             :         return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
     509       38069 :                                                      str.pData->buffer, str.pData->length, maxLength );
     510             :     }
     511             : 
     512             :     /**
     513             :       Compares two strings in reverse order.
     514             : 
     515             :       The comparison is based on the numeric value of each character in
     516             :       the strings and return a value indicating their relationship.
     517             :       This function can't be used for language specific sorting.
     518             : 
     519             :       @param    str         the object to be compared.
     520             :       @return   0 - if both strings are equal
     521             :                 < 0 - if this string is less than the string argument
     522             :                 > 0 - if this string is greater than the string argument
     523             :     */
     524           0 :     sal_Int32 reverseCompareTo( const OUString & str ) const SAL_THROW(())
     525             :     {
     526             :         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
     527           0 :                                                    str.pData->buffer, str.pData->length );
     528             :     }
     529             : 
     530             :     /**
     531             :      @overload
     532             :      This function accepts an ASCII string literal as its argument.
     533             :      @since LibreOffice 4.1
     534             :     */
     535             :     template< typename T >
     536           1 :     typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const SAL_THROW(())
     537             :     {
     538             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     539             :         return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
     540           1 :             literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
     541             :     }
     542             : 
     543             :     /**
     544             :       Perform a comparison of two strings.
     545             : 
     546             :       The result is true if and only if second string
     547             :       represents the same sequence of characters as the first string.
     548             :       This function can't be used for language specific comparison.
     549             : 
     550             :       @param    str         the object to be compared.
     551             :       @return   sal_True if the strings are equal;
     552             :                 sal_False, otherwise.
     553             :     */
     554    17278321 :     sal_Bool equals( const OUString & str ) const SAL_THROW(())
     555             :     {
     556    17278321 :         if ( pData->length != str.pData->length )
     557    12687711 :             return sal_False;
     558     4590610 :         if ( pData == str.pData )
     559     2682700 :             return sal_True;
     560             :         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
     561     1907910 :                                                    str.pData->buffer, str.pData->length ) == 0;
     562             :     }
     563             : 
     564             :     /**
     565             :       Perform a ASCII lowercase comparison of two strings.
     566             : 
     567             :       The result is true if and only if second string
     568             :       represents the same sequence of characters as the first string,
     569             :       ignoring the case.
     570             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     571             :       values between 97 and 122 (ASCII a-z).
     572             :       This function can't be used for language specific comparison.
     573             : 
     574             :       @param    str         the object to be compared.
     575             :       @return   sal_True if the strings are equal;
     576             :                 sal_False, otherwise.
     577             :     */
     578       14559 :     sal_Bool equalsIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
     579             :     {
     580       14559 :         if ( pData->length != str.pData->length )
     581        3687 :             return sal_False;
     582       10872 :         if ( pData == str.pData )
     583        3544 :             return sal_True;
     584             :         return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
     585        7328 :                                                            str.pData->buffer, str.pData->length ) == 0;
     586             :     }
     587             : 
     588             :     /**
     589             :       Perform a ASCII lowercase comparison of two strings.
     590             : 
     591             :       Compare the two strings with uppercase ASCII
     592             :       character values between 65 and 90 (ASCII A-Z) interpreted as
     593             :       values between 97 and 122 (ASCII a-z).
     594             :       This function can't be used for language specific comparison.
     595             : 
     596             :       @param    str         the object to be compared.
     597             :       @return   0 - if both strings are equal
     598             :                 < 0 - if this string is less than the string argument
     599             :                 > 0 - if this string is greater than the string argument
     600             : 
     601             :       @since LibreOffice 4.0
     602             :     */
     603           3 :     sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
     604             :     {
     605             :         return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
     606           3 :                                                            str.pData->buffer, str.pData->length );
     607             :     }
     608             : 
     609             : 
     610             :     /**
     611             :      @overload
     612             :      This function accepts an ASCII string literal as its argument.
     613             :      @since LibreOffice 3.6
     614             :     */
     615             :     template< typename T >
     616        9265 :     typename internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const SAL_THROW(())
     617             :     {
     618             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     619        9265 :         if ( pData->length != internal::ConstCharArrayDetector< T, void >::size - 1 )
     620        9123 :             return sal_False;
     621             : 
     622         142 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, literal ) == 0;
     623             :     }
     624             : 
     625             :    /**
     626             :       Match against a substring appearing in this string.
     627             : 
     628             :       The result is true if and only if the second string appears as a substring
     629             :       of this string, at the given position.
     630             :       This function can't be used for language specific comparison.
     631             : 
     632             :       @param    str         the object (substring) to be compared.
     633             :       @param    fromIndex   the index to start the comparion from.
     634             :                             The index must be greater than or equal to 0
     635             :                             and less or equal as the string length.
     636             :       @return   sal_True if str match with the characters in the string
     637             :                 at the given position;
     638             :                 sal_False, otherwise.
     639             :     */
     640     1029660 :     sal_Bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     641             :     {
     642     1029660 :         return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     643     2059320 :                                                      str.pData->buffer, str.pData->length, str.pData->length ) == 0;
     644             :     }
     645             : 
     646             :     /**
     647             :      @overload
     648             :      This function accepts an ASCII string literal as its argument.
     649             :      @since LibreOffice 3.6
     650             :     */
     651             :     template< typename T >
     652       15069 :     typename internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     653             :     {
     654             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     655             :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     656       15069 :             literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
     657             :     }
     658             : 
     659             :     /**
     660             :       Match against a substring appearing in this string, ignoring the case of
     661             :       ASCII letters.
     662             : 
     663             :       The result is true if and only if the second string appears as a substring
     664             :       of this string, at the given position.
     665             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     666             :       values between 97 and 122 (ASCII a-z).
     667             :       This function can't be used for language specific comparison.
     668             : 
     669             :       @param    str         the object (substring) to be compared.
     670             :       @param    fromIndex   the index to start the comparion from.
     671             :                             The index must be greater than or equal to 0
     672             :                             and less than or equal to the string length.
     673             :       @return   sal_True if str match with the characters in the string
     674             :                 at the given position;
     675             :                 sal_False, otherwise.
     676             :     */
     677        4892 :     sal_Bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     678             :     {
     679        4892 :         return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     680             :                                                                     str.pData->buffer, str.pData->length,
     681        9784 :                                                                     str.pData->length ) == 0;
     682             :     }
     683             : 
     684             :     /**
     685             :      @overload
     686             :      This function accepts an ASCII string literal as its argument.
     687             :      @since LibreOffice 3.6
     688             :     */
     689             :     template< typename T >
     690           2 :     typename internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     691             :     {
     692             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     693             :         return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     694           2 :             literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
     695             :     }
     696             : 
     697             :     /**
     698             :       Compares two strings.
     699             : 
     700             :       The comparison is based on the numeric value of each character in
     701             :       the strings and return a value indicating their relationship.
     702             :       Since this method is optimized for performance, the ASCII character
     703             :       values are not converted in any way. The caller has to make sure that
     704             :       all ASCII characters are in the allowed range between 0 and
     705             :       127. The ASCII string must be NULL-terminated.
     706             :       This function can't be used for language specific sorting.
     707             : 
     708             :       @param  asciiStr      the 8-Bit ASCII character string to be compared.
     709             :       @return   0 - if both strings are equal
     710             :                 < 0 - if this string is less than the string argument
     711             :                 > 0 - if this string is greater than the string argument
     712             :     */
     713      368013 :     sal_Int32 compareToAscii( const sal_Char* asciiStr ) const SAL_THROW(())
     714             :     {
     715      368013 :         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
     716             :     }
     717             : 
     718             :     /**
     719             :       Compares two strings with a maximum count of characters.
     720             : 
     721             :       The comparison is based on the numeric value of each character in
     722             :       the strings and return a value indicating their relationship.
     723             :       Since this method is optimized for performance, the ASCII character
     724             :       values are not converted in any way. The caller has to make sure that
     725             :       all ASCII characters are in the allowed range between 0 and
     726             :       127. The ASCII string must be NULL-terminated.
     727             :       This function can't be used for language specific sorting.
     728             : 
     729             :       @param  asciiStr          the 8-Bit ASCII character string to be compared.
     730             :       @param  maxLength         the maximum count of characters to be compared.
     731             :       @return   0 - if both strings are equal
     732             :                 < 0 - if this string is less than the string argument
     733             :                 > 0 - if this string is greater than the string argument
     734             :     */
     735       20573 :     sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const SAL_THROW(())
     736             :     {
     737             :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
     738       20573 :                                                            asciiStr, maxLength );
     739             :     }
     740             : 
     741             :     /**
     742             :       Compares two strings in reverse order.
     743             : 
     744             :       This could be useful, if normally both strings start with the same
     745             :       content. The comparison is based on the numeric value of each character
     746             :       in the strings and return a value indicating their relationship.
     747             :       Since this method is optimized for performance, the ASCII character
     748             :       values are not converted in any way. The caller has to make sure that
     749             :       all ASCII characters are in the allowed range between 0 and 127.
     750             :       The ASCII string must be NULL-terminated and must be greater than
     751             :       or equal to asciiStrLength.
     752             :       This function can't be used for language specific sorting.
     753             : 
     754             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     755             :       @param    asciiStrLength  the length of the ascii string
     756             :       @return   0 - if both strings are equal
     757             :                 < 0 - if this string is less than the string argument
     758             :                 > 0 - if this string is greater than the string argument
     759             :     */
     760       33485 :     sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
     761             :     {
     762             :         return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
     763       33485 :                                                           asciiStr, asciiStrLength );
     764             :     }
     765             : 
     766             :     /**
     767             :       Perform a comparison of two strings.
     768             : 
     769             :       The result is true if and only if second string
     770             :       represents the same sequence of characters as the first string.
     771             :       Since this method is optimized for performance, the ASCII character
     772             :       values are not converted in any way. The caller has to make sure that
     773             :       all ASCII characters are in the allowed range between 0 and
     774             :       127. The ASCII string must be NULL-terminated.
     775             :       This function can't be used for language specific comparison.
     776             : 
     777             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     778             :       @return   sal_True if the strings are equal;
     779             :                 sal_False, otherwise.
     780             :     */
     781     2011863 :     sal_Bool equalsAscii( const sal_Char* asciiStr ) const SAL_THROW(())
     782             :     {
     783             :         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
     784     2011863 :                                                   asciiStr ) == 0;
     785             :     }
     786             : 
     787             :     /**
     788             :       Perform a comparison of two strings.
     789             : 
     790             :       The result is true if and only if second string
     791             :       represents the same sequence of characters as the first string.
     792             :       Since this method is optimized for performance, the ASCII character
     793             :       values are not converted in any way. The caller has to make sure that
     794             :       all ASCII characters are in the allowed range between 0 and
     795             :       127. The ASCII string must be NULL-terminated and must be greater than
     796             :       or equal to asciiStrLength.
     797             :       This function can't be used for language specific comparison.
     798             : 
     799             :       @param    asciiStr         the 8-Bit ASCII character string to be compared.
     800             :       @param    asciiStrLength   the length of the ascii string
     801             :       @return   sal_True if the strings are equal;
     802             :                 sal_False, otherwise.
     803             :     */
     804     5305722 :     sal_Bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
     805             :     {
     806     5305722 :         if ( pData->length != asciiStrLength )
     807     3956628 :             return sal_False;
     808             : 
     809             :         return rtl_ustr_asciil_reverseEquals_WithLength(
     810     1349094 :                     pData->buffer, asciiStr, asciiStrLength );
     811             :     }
     812             : 
     813             :     /**
     814             :       Perform a ASCII lowercase comparison of two strings.
     815             : 
     816             :       The result is true if and only if second string
     817             :       represents the same sequence of characters as the first string,
     818             :       ignoring the case.
     819             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     820             :       values between 97 and 122 (ASCII a-z).
     821             :       Since this method is optimized for performance, the ASCII character
     822             :       values are not converted in any way. The caller has to make sure that
     823             :       all ASCII characters are in the allowed range between 0 and
     824             :       127. The ASCII string must be NULL-terminated.
     825             :       This function can't be used for language specific comparison.
     826             : 
     827             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     828             :       @return   sal_True if the strings are equal;
     829             :                 sal_False, otherwise.
     830             :     */
     831      111264 :     sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
     832             :     {
     833      111264 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
     834             :     }
     835             : 
     836             :     /**
     837             :       Compares two ASCII strings ignoring case
     838             : 
     839             :       The comparison is based on the numeric value of each character in
     840             :       the strings and return a value indicating their relationship.
     841             :       Since this method is optimized for performance, the ASCII character
     842             :       values are not converted in any way. The caller has to make sure that
     843             :       all ASCII characters are in the allowed range between 0 and
     844             :       127. The ASCII string must be NULL-terminated.
     845             :       This function can't be used for language specific sorting.
     846             : 
     847             :       @param  asciiStr      the 8-Bit ASCII character string to be compared.
     848             :       @return   0 - if both strings are equal
     849             :                 < 0 - if this string is less than the string argument
     850             :                 > 0 - if this string is greater than the string argument
     851             : 
     852             :       @since LibreOffice 3.5
     853             :     */
     854       13667 :     sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
     855             :     {
     856       13667 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
     857             :     }
     858             : 
     859             :     /**
     860             :       Perform an ASCII lowercase comparison of two strings.
     861             : 
     862             :       The result is true if and only if second string
     863             :       represents the same sequence of characters as the first string,
     864             :       ignoring the case.
     865             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     866             :       values between 97 and 122 (ASCII a-z).
     867             :       Since this method is optimized for performance, the ASCII character
     868             :       values are not converted in any way. The caller has to make sure that
     869             :       all ASCII characters are in the allowed range between 0 and 127.
     870             :       The ASCII string must be NULL-terminated and must be greater than
     871             :       or equal to asciiStrLength.
     872             :       This function can't be used for language specific comparison.
     873             : 
     874             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     875             :       @param    asciiStrLength  the length of the ascii string
     876             :       @return   sal_True if the strings are equal;
     877             :                 sal_False, otherwise.
     878             :     */
     879       91985 :     sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
     880             :     {
     881       91985 :         if ( pData->length != asciiStrLength )
     882       46138 :             return sal_False;
     883             : 
     884       45847 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
     885             :     }
     886             : 
     887             :     /**
     888             :       Match against a substring appearing in this string.
     889             : 
     890             :       The result is true if and only if the second string appears as a substring
     891             :       of this string, at the given position.
     892             :       Since this method is optimized for performance, the ASCII character
     893             :       values are not converted in any way. The caller has to make sure that
     894             :       all ASCII characters are in the allowed range between 0 and
     895             :       127. The ASCII string must be NULL-terminated and must be greater than or
     896             :       equal to asciiStrLength.
     897             :       This function can't be used for language specific comparison.
     898             : 
     899             :       @param    asciiStr    the object (substring) to be compared.
     900             :       @param    asciiStrLength the length of asciiStr.
     901             :       @param    fromIndex   the index to start the comparion from.
     902             :                             The index must be greater than or equal to 0
     903             :                             and less than or equal to the string length.
     904             :       @return   sal_True if str match with the characters in the string
     905             :                 at the given position;
     906             :                 sal_False, otherwise.
     907             :     */
     908       37144 :     sal_Bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     909             :     {
     910       37144 :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     911       74288 :                                                            asciiStr, asciiStrLength ) == 0;
     912             :     }
     913             : 
     914             :     // This overload is left undefined, to detect calls of matchAsciiL that
     915             :     // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
     916             :     // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
     917             :     // platforms):
     918             : #if SAL_TYPES_SIZEOFLONG == 8
     919             :     void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
     920             : #endif
     921             : 
     922             :     /**
     923             :       Match against a substring appearing in this string, ignoring the case of
     924             :       ASCII letters.
     925             : 
     926             :       The result is true if and only if the second string appears as a substring
     927             :       of this string, at the given position.
     928             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     929             :       values between 97 and 122 (ASCII a-z).
     930             :       Since this method is optimized for performance, the ASCII character
     931             :       values are not converted in any way. The caller has to make sure that
     932             :       all ASCII characters are in the allowed range between 0 and
     933             :       127. The ASCII string must be NULL-terminated and must be greater than or
     934             :       equal to asciiStrLength.
     935             :       This function can't be used for language specific comparison.
     936             : 
     937             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     938             :       @param    asciiStrLength  the length of the ascii string
     939             :       @param    fromIndex       the index to start the comparion from.
     940             :                                 The index must be greater than or equal to 0
     941             :                                 and less than or equal to the string length.
     942             :       @return   sal_True if str match with the characters in the string
     943             :                 at the given position;
     944             :                 sal_False, otherwise.
     945             :     */
     946         109 :     sal_Bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
     947             :     {
     948         109 :         return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     949         218 :                                                                           asciiStr, asciiStrLength ) == 0;
     950             :     }
     951             : 
     952             :     // This overload is left undefined, to detect calls of
     953             :     // matchIgnoreAsciiCaseAsciiL that erroneously use
     954             :     // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
     955             :     // would lead to ambiguities on 32 bit platforms):
     956             : #if SAL_TYPES_SIZEOFLONG == 8
     957             :     void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
     958             :         const;
     959             : #endif
     960             : 
     961             :     /**
     962             :       Check whether this string starts with a given substring.
     963             : 
     964             :       @param str  the substring to be compared
     965             : 
     966             :       @return true if and only if the given str appears as a substring at the
     967             :       start of this string
     968             : 
     969             :       @since LibreOffice 4.0
     970             :     */
     971     1002653 :     bool startsWith(OUString const & str) const {
     972     1002653 :         return match(str, 0);
     973             :     }
     974             : 
     975             :     /**
     976             :      @overload
     977             :      This function accepts an ASCII string literal as its argument.
     978             :      @since LibreOffice 4.0
     979             :     */
     980             :     template< typename T >
     981       66288 :     typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
     982             :     {
     983             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
     984             :         return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
     985             :             && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
     986       66288 :                 internal::ConstCharArrayDetector< T, void >::size - 1);
     987             :     }
     988             : 
     989             :     /**
     990             :       Check whether this string starts with a given string, ignoring the case of
     991             :       ASCII letters.
     992             : 
     993             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     994             :       values between 97 and 122 (ASCII a-z).
     995             :       This function can't be used for language specific comparison.
     996             : 
     997             :       @param    str         the object (substring) to be compared.
     998             :       @return true if this string starts with str, ignoring the case of ASCII
     999             :       letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
    1000             :       @since LibreOffice 4.0
    1001             :     */
    1002             :     sal_Bool startsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
    1003             :     {
    1004             :         return matchIgnoreAsciiCase(str, 0);
    1005             :     }
    1006             : 
    1007             :     /**
    1008             :      @overload
    1009             :      This function accepts an ASCII string literal as its argument.
    1010             :      @since LibreOffice 4.0
    1011             :     */
    1012             :     template< typename T >
    1013           1 :     typename internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
    1014             :     {
    1015             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1016             :         return (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1017             :                     pData->buffer,
    1018             :                     internal::ConstCharArrayDetector< T, void >::size - 1, literal,
    1019             :                     internal::ConstCharArrayDetector< T, void >::size - 1)
    1020           1 :                 == 0);
    1021             :     }
    1022             : 
    1023             :     /**
    1024             :       Check whether this string ends with a given substring.
    1025             : 
    1026             :       @param str  the substring to be compared
    1027             : 
    1028             :       @return true if and only if the given str appears as a substring at the
    1029             :       end of this string
    1030             : 
    1031             :       @since LibreOffice 3.6
    1032             :     */
    1033           5 :     bool endsWith(OUString const & str) const {
    1034           5 :         return str.getLength() <= getLength()
    1035           5 :             && match(str, getLength() - str.getLength());
    1036             :     }
    1037             : 
    1038             :     /**
    1039             :      @overload
    1040             :      This function accepts an ASCII string literal as its argument.
    1041             :      @since LibreOffice 3.6
    1042             :     */
    1043             :     template< typename T >
    1044          21 :     typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
    1045             :     {
    1046             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1047             :         return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
    1048             :             && rtl_ustr_asciil_reverseEquals_WithLength(
    1049             :                 pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
    1050          21 :                 internal::ConstCharArrayDetector< T, void >::size - 1);
    1051             :     }
    1052             : 
    1053             :     /**
    1054             :       Check whether this string ends with a given ASCII string.
    1055             : 
    1056             :       @param asciiStr a sequence of at least asciiStrLength ASCII characters
    1057             :           (bytes in the range 0x00--0x7F)
    1058             :       @param asciiStrLength the length of asciiStr; must be non-negative
    1059             :       @return true if this string ends with asciiStr; otherwise, false is
    1060             :       returned
    1061             : 
    1062             :       @since UDK 3.2.7
    1063             :      */
    1064         876 :     inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
    1065             :         const
    1066             :     {
    1067             :         return asciiStrLength <= pData->length
    1068             :             && rtl_ustr_asciil_reverseEquals_WithLength(
    1069         876 :                 pData->buffer + pData->length - asciiStrLength, asciiStr,
    1070        1752 :                 asciiStrLength);
    1071             :     }
    1072             : 
    1073             :     /**
    1074             :       Check whether this string ends with a given string, ignoring the case of
    1075             :       ASCII letters.
    1076             : 
    1077             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
    1078             :       values between 97 and 122 (ASCII a-z).
    1079             :       This function can't be used for language specific comparison.
    1080             : 
    1081             :       @param    str         the object (substring) to be compared.
    1082             :       @return true if this string ends with str, ignoring the case of ASCII
    1083             :       letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
    1084             :       @since LibreOffice 3.6
    1085             :     */
    1086        4703 :     sal_Bool endsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
    1087             :     {
    1088        4703 :         return str.getLength() <= getLength()
    1089        4703 :             && matchIgnoreAsciiCase(str, getLength() - str.getLength());
    1090             :     }
    1091             : 
    1092             :     /**
    1093             :      @overload
    1094             :      This function accepts an ASCII string literal as its argument.
    1095             :      @since LibreOffice 3.6
    1096             :     */
    1097             :     template< typename T >
    1098           1 :     typename internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
    1099             :     {
    1100             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1101             :         return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
    1102             :             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1103             :                     pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ),
    1104             :                     internal::ConstCharArrayDetector< T, void >::size - 1, literal,
    1105             :                     internal::ConstCharArrayDetector< T, void >::size - 1)
    1106           1 :                 == 0);
    1107             :     }
    1108             : 
    1109             :     /**
    1110             :       Check whether this string ends with a given ASCII string, ignoring the
    1111             :       case of ASCII letters.
    1112             : 
    1113             :       @param asciiStr a sequence of at least asciiStrLength ASCII characters
    1114             :           (bytes in the range 0x00--0x7F)
    1115             :       @param asciiStrLength the length of asciiStr; must be non-negative
    1116             :       @return true if this string ends with asciiStr, ignoring the case of ASCII
    1117             :       letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
    1118             :      */
    1119      370328 :     inline bool endsWithIgnoreAsciiCaseAsciiL(
    1120             :         char const * asciiStr, sal_Int32 asciiStrLength) const
    1121             :     {
    1122             :         return asciiStrLength <= pData->length
    1123             :             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1124      249550 :                     pData->buffer + pData->length - asciiStrLength,
    1125      249550 :                     asciiStrLength, asciiStr, asciiStrLength)
    1126      619878 :                 == 0);
    1127             :     }
    1128             : 
    1129     7864268 :     friend sal_Bool     operator == ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
    1130     7864268 :                         { return rStr1.equals(rStr2); }
    1131           0 :     friend sal_Bool     operator == ( const OUString& rStr1,    const sal_Unicode * pStr2 ) SAL_THROW(())
    1132           0 :                         { return rStr1.compareTo( pStr2 ) == 0; }
    1133             :     friend sal_Bool     operator == ( const sal_Unicode * pStr1,    const OUString& rStr2 ) SAL_THROW(())
    1134             :                         { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
    1135             : 
    1136      249872 :     friend sal_Bool     operator != ( const OUString& rStr1,        const OUString& rStr2 ) SAL_THROW(())
    1137      249872 :                         { return !(operator == ( rStr1, rStr2 )); }
    1138           0 :     friend sal_Bool     operator != ( const OUString& rStr1,    const sal_Unicode * pStr2 ) SAL_THROW(())
    1139           0 :                         { return !(operator == ( rStr1, pStr2 )); }
    1140             :     friend sal_Bool     operator != ( const sal_Unicode * pStr1,    const OUString& rStr2 ) SAL_THROW(())
    1141             :                         { return !(operator == ( pStr1, rStr2 )); }
    1142             : 
    1143    17795115 :     friend sal_Bool     operator <  ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
    1144    17795115 :                         { return rStr1.compareTo( rStr2 ) < 0; }
    1145       31973 :     friend sal_Bool     operator >  ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
    1146       31973 :                         { return rStr1.compareTo( rStr2 ) > 0; }
    1147           0 :     friend sal_Bool     operator <= ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
    1148           0 :                         { return rStr1.compareTo( rStr2 ) <= 0; }
    1149        6500 :     friend sal_Bool     operator >= ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
    1150        6500 :                         { return rStr1.compareTo( rStr2 ) >= 0; }
    1151             : 
    1152             :     /**
    1153             :      * Compare string to an ASCII string literal.
    1154             :      *
    1155             :      * This operator is equal to calling equalsAsciiL().
    1156             :      *
    1157             :      * @since LibreOffice 3.6
    1158             :      */
    1159             :     template< typename T >
    1160     4900837 :     friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
    1161             :     {
    1162             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1163     4900837 :         return string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
    1164             :     }
    1165             :     /**
    1166             :      * Compare string to an ASCII string literal.
    1167             :      *
    1168             :      * This operator is equal to calling equalsAsciiL().
    1169             :      *
    1170             :      * @since LibreOffice 3.6
    1171             :      */
    1172             :     template< typename T >
    1173           1 :     friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
    1174             :     {
    1175             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1176           1 :         return string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
    1177             :     }
    1178             :     /**
    1179             :      * Compare string to an ASCII string literal.
    1180             :      *
    1181             :      * This operator is equal to calling !equalsAsciiL().
    1182             :      *
    1183             :      * @since LibreOffice 3.6
    1184             :      */
    1185             :     template< typename T >
    1186      118978 :     friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
    1187             :     {
    1188             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1189      118978 :         return !string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
    1190             :     }
    1191             :     /**
    1192             :      * Compare string to an ASCII string literal.
    1193             :      *
    1194             :      * This operator is equal to calling !equalsAsciiL().
    1195             :      *
    1196             :      * @since LibreOffice 3.6
    1197             :      */
    1198             :     template< typename T >
    1199           1 :     friend inline typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
    1200             :     {
    1201             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1202           1 :         return !string.equalsAsciiL( literal, internal::ConstCharArrayDetector< T, void >::size - 1 );
    1203             :     }
    1204             : 
    1205             :     /**
    1206             :       Returns a hashcode for this string.
    1207             : 
    1208             :       @return   a hash code value for this object.
    1209             : 
    1210             :       @see rtl::OUStringHash for convenient use of boost::unordered_map
    1211             :     */
    1212     3808675 :     sal_Int32 hashCode() const SAL_THROW(())
    1213             :     {
    1214     3808675 :         return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
    1215             :     }
    1216             : 
    1217             :     /**
    1218             :       Returns the index within this string of the first occurrence of the
    1219             :       specified character, starting the search at the specified index.
    1220             : 
    1221             :       @param    ch          character to be located.
    1222             :       @param    fromIndex   the index to start the search from.
    1223             :                             The index must be greater than or equal to 0
    1224             :                             and less than or equal to the string length.
    1225             :       @return   the index of the first occurrence of the character in the
    1226             :                 character sequence represented by this string that is
    1227             :                 greater than or equal to fromIndex, or
    1228             :                 -1 if the character does not occur.
    1229             :     */
    1230      517859 :     sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
    1231             :     {
    1232      517859 :         sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
    1233      517859 :         return (ret < 0 ? ret : ret+fromIndex);
    1234             :     }
    1235             : 
    1236             :     /**
    1237             :       Returns the index within this string of the last occurrence of the
    1238             :       specified character, searching backward starting at the end.
    1239             : 
    1240             :       @param    ch          character to be located.
    1241             :       @return   the index of the last occurrence of the character in the
    1242             :                 character sequence represented by this string, or
    1243             :                 -1 if the character does not occur.
    1244             :     */
    1245      721693 :     sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
    1246             :     {
    1247      721693 :         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
    1248             :     }
    1249             : 
    1250             :     /**
    1251             :       Returns the index within this string of the last occurrence of the
    1252             :       specified character, searching backward starting before the specified
    1253             :       index.
    1254             : 
    1255             :       @param    ch          character to be located.
    1256             :       @param    fromIndex   the index before which to start the search.
    1257             :       @return   the index of the last occurrence of the character in the
    1258             :                 character sequence represented by this string that
    1259             :                 is less than fromIndex, or -1
    1260             :                 if the character does not occur before that point.
    1261             :     */
    1262        2122 :     sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
    1263             :     {
    1264        2122 :         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
    1265             :     }
    1266             : 
    1267             :     /**
    1268             :       Returns the index within this string of the first occurrence of the
    1269             :       specified substring, starting at the specified index.
    1270             : 
    1271             :       If str doesn't include any character, always -1 is
    1272             :       returned. This is also the case, if both strings are empty.
    1273             : 
    1274             :       @param    str         the substring to search for.
    1275             :       @param    fromIndex   the index to start the search from.
    1276             :       @return   If the string argument occurs one or more times as a substring
    1277             :                 within this string at the starting index, then the index
    1278             :                 of the first character of the first such substring is
    1279             :                 returned. If it does not occur as a substring starting
    1280             :                 at fromIndex or beyond, -1 is returned.
    1281             :     */
    1282     1861410 :     sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
    1283             :     {
    1284     1861410 :         sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
    1285     3722820 :                                                         str.pData->buffer, str.pData->length );
    1286     1861410 :         return (ret < 0 ? ret : ret+fromIndex);
    1287             :     }
    1288             : 
    1289             :     /**
    1290             :      @overload
    1291             :      This function accepts an ASCII string literal as its argument.
    1292             :      @since LibreOffice 3.6
    1293             :     */
    1294             :     template< typename T >
    1295       40960 :     typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
    1296             :     {
    1297             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1298             :         sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
    1299             :             pData->buffer + fromIndex, pData->length - fromIndex, literal,
    1300       40960 :             internal::ConstCharArrayDetector< T, void >::size - 1);
    1301       40960 :         return ret < 0 ? ret : ret + fromIndex;
    1302             :     }
    1303             : 
    1304             :     /**
    1305             :        Returns the index within this string of the first occurrence of the
    1306             :        specified ASCII substring, starting at the specified index.
    1307             : 
    1308             :        @param str
    1309             :        the substring to be searched for.  Need not be null-terminated, but must
    1310             :        be at least as long as the specified len.  Must only contain characters
    1311             :        in the ASCII range 0x00--7F.
    1312             : 
    1313             :        @param len
    1314             :        the length of the substring; must be non-negative.
    1315             : 
    1316             :        @param fromIndex
    1317             :        the index to start the search from.  Must be in the range from zero to
    1318             :        the length of this string, inclusive.
    1319             : 
    1320             :        @return
    1321             :        the index (starting at 0) of the first character of the first occurrence
    1322             :        of the substring within this string starting at the given fromIndex, or
    1323             :        -1 if the substring does not occur.  If len is zero, -1 is returned.
    1324             : 
    1325             :        @since UDK 3.2.7
    1326             :     */
    1327         772 :     sal_Int32 indexOfAsciiL(
    1328             :         char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
    1329             :         SAL_THROW(())
    1330             :     {
    1331             :         sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
    1332         772 :             pData->buffer + fromIndex, pData->length - fromIndex, str, len);
    1333         772 :         return ret < 0 ? ret : ret + fromIndex;
    1334             :     }
    1335             : 
    1336             :     // This overload is left undefined, to detect calls of indexOfAsciiL that
    1337             :     // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
    1338             :     // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
    1339             :     // platforms):
    1340             : #if SAL_TYPES_SIZEOFLONG == 8
    1341             :     void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
    1342             : #endif
    1343             : 
    1344             :     /**
    1345             :       Returns the index within this string of the last occurrence of
    1346             :       the specified substring, searching backward starting at the end.
    1347             : 
    1348             :       The returned index indicates the starting index of the substring
    1349             :       in this string.
    1350             :       If str doesn't include any character, always -1 is
    1351             :       returned. This is also the case, if both strings are empty.
    1352             : 
    1353             :       @param    str         the substring to search for.
    1354             :       @return   If the string argument occurs one or more times as a substring
    1355             :                 within this string, then the index of the first character of
    1356             :                 the last such substring is returned. If it does not occur as
    1357             :                 a substring, -1 is returned.
    1358             :     */
    1359        8171 :     sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
    1360             :     {
    1361             :         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
    1362        8171 :                                                    str.pData->buffer, str.pData->length );
    1363             :     }
    1364             : 
    1365             :     /**
    1366             :       Returns the index within this string of the last occurrence of
    1367             :       the specified substring, searching backward starting before the specified
    1368             :       index.
    1369             : 
    1370             :       The returned index indicates the starting index of the substring
    1371             :       in this string.
    1372             :       If str doesn't include any character, always -1 is
    1373             :       returned. This is also the case, if both strings are empty.
    1374             : 
    1375             :       @param    str         the substring to search for.
    1376             :       @param    fromIndex   the index before which to start the search.
    1377             :       @return   If the string argument occurs one or more times as a substring
    1378             :                 within this string before the starting index, then the index
    1379             :                 of the first character of the last such substring is
    1380             :                 returned. Otherwise, -1 is returned.
    1381             :     */
    1382           0 :     sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
    1383             :     {
    1384             :         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
    1385           0 :                                                    str.pData->buffer, str.pData->length );
    1386             :     }
    1387             : 
    1388             :     /**
    1389             :      @overload
    1390             :      This function accepts an ASCII string literal as its argument.
    1391             :      @since LibreOffice 3.6
    1392             :     */
    1393             :     template< typename T >
    1394        5286 :     typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const SAL_THROW(())
    1395             :     {
    1396             :         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1397             :         return rtl_ustr_lastIndexOfAscii_WithLength(
    1398        5286 :             pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
    1399             :     }
    1400             : 
    1401             :     /**
    1402             :        Returns the index within this string of the last occurrence of the
    1403             :        specified ASCII substring.
    1404             : 
    1405             :        @param str
    1406             :        the substring to be searched for.  Need not be null-terminated, but must
    1407             :        be at least as long as the specified len.  Must only contain characters
    1408             :        in the ASCII range 0x00--7F.
    1409             : 
    1410             :        @param len
    1411             :        the length of the substring; must be non-negative.
    1412             : 
    1413             :        @return
    1414             :        the index (starting at 0) of the first character of the last occurrence
    1415             :        of the substring within this string, or -1 if the substring does not
    1416             :        occur.  If len is zero, -1 is returned.
    1417             : 
    1418             :        @since UDK 3.2.7
    1419             :     */
    1420           0 :     sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
    1421             :         SAL_THROW(())
    1422             :     {
    1423             :         return rtl_ustr_lastIndexOfAscii_WithLength(
    1424           0 :             pData->buffer, pData->length, str, len);
    1425             :     }
    1426             : 
    1427             :     /**
    1428             :       Returns a new string that is a substring of this string.
    1429             : 
    1430             :       The substring begins at the specified beginIndex. If
    1431             :       beginIndex is negative or be greater than the length of
    1432             :       this string, behaviour is undefined.
    1433             : 
    1434             :       @param     beginIndex   the beginning index, inclusive.
    1435             :       @return    the specified substring.
    1436             :     */
    1437      880239 :     OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
    1438             :     {
    1439      880239 :         rtl_uString *pNew = 0;
    1440      880239 :         rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
    1441      880239 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1442             :     }
    1443             : 
    1444             :     /**
    1445             :       Returns a new string that is a substring of this string.
    1446             : 
    1447             :       The substring begins at the specified beginIndex and contains count
    1448             :       characters.  If either beginIndex or count are negative,
    1449             :       or beginIndex + count are greater than the length of this string
    1450             :       then behaviour is undefined.
    1451             : 
    1452             :       @param     beginIndex   the beginning index, inclusive.
    1453             :       @param     count        the number of characters.
    1454             :       @return    the specified substring.
    1455             :     */
    1456     1017198 :     OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
    1457             :     {
    1458     1017198 :         rtl_uString *pNew = 0;
    1459     1017198 :         rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
    1460     1017198 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1461             :     }
    1462             : 
    1463             :     /**
    1464             :       Concatenates the specified string to the end of this string.
    1465             : 
    1466             :       @param    str   the string that is concatenated to the end
    1467             :                       of this string.
    1468             :       @return   a string that represents the concatenation of this string
    1469             :                 followed by the string argument.
    1470             :     */
    1471           0 :     SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const SAL_THROW(())
    1472             :     {
    1473           0 :         rtl_uString* pNew = 0;
    1474           0 :         rtl_uString_newConcat( &pNew, pData, str.pData );
    1475           0 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1476             :     }
    1477             : 
    1478             : #ifndef RTL_FAST_STRING
    1479             :     friend OUString operator+( const OUString& rStr1, const OUString& rStr2  ) SAL_THROW(())
    1480             :     {
    1481             :         return rStr1.concat( rStr2 );
    1482             :     }
    1483             : #endif
    1484             : 
    1485             :     /**
    1486             :       Returns a new string resulting from replacing n = count characters
    1487             :       from position index in this string with newStr.
    1488             : 
    1489             :       @param  index   the replacing index in str.
    1490             :                       The index must be greater than or equal to 0 and
    1491             :                       less than or equal to the length of the string.
    1492             :       @param  count   the count of charcters that will be replaced
    1493             :                       The count must be greater than or equal to 0 and
    1494             :                       less than or equal to the length of the string minus index.
    1495             :       @param  newStr  the new substring.
    1496             :       @return the new string.
    1497             :     */
    1498       87010 :     SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
    1499             :     {
    1500       87010 :         rtl_uString* pNew = 0;
    1501       87010 :         rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
    1502       87010 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1503             :     }
    1504             : 
    1505             :     /**
    1506             :       Returns a new string resulting from replacing all occurrences of
    1507             :       oldChar in this string with newChar.
    1508             : 
    1509             :       If the character oldChar does not occur in the character sequence
    1510             :       represented by this object, then the string is assigned with
    1511             :       str.
    1512             : 
    1513             :       @param    oldChar     the old character.
    1514             :       @param    newChar     the new character.
    1515             :       @return   a string derived from this string by replacing every
    1516             :                 occurrence of oldChar with newChar.
    1517             :     */
    1518       29268 :     SAL_WARN_UNUSED_RESULT OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
    1519             :     {
    1520       29268 :         rtl_uString* pNew = 0;
    1521       29268 :         rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
    1522       29268 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1523             :     }
    1524             : 
    1525             :     /**
    1526             :       Returns a new string resulting from replacing the first occurrence of a
    1527             :       given substring with another substring.
    1528             : 
    1529             :       @param from  the substring to be replaced
    1530             : 
    1531             :       @param to  the replacing substring
    1532             : 
    1533             :       @param[in,out] index  pointer to a start index; if the pointer is
    1534             :       non-null: upon entry to the function, its value is the index into this
    1535             :       string at which to start searching for the \p from substring, the value
    1536             :       must be non-negative and not greater than this string's length; upon exiting
    1537             :       the function its value is the index into this string at which the
    1538             :       replacement took place or -1 if no replacement took place; if the pointer
    1539             :       is null, searching always starts at index 0
    1540             : 
    1541             :       @since LibreOffice 3.6
    1542             :     */
    1543           8 :     SAL_WARN_UNUSED_RESULT OUString replaceFirst(
    1544             :         OUString const & from, OUString const & to, sal_Int32 * index = 0) const
    1545             :     {
    1546           8 :         rtl_uString * s = 0;
    1547           8 :         sal_Int32 i = 0;
    1548             :         rtl_uString_newReplaceFirst(
    1549           8 :             &s, pData, from.pData, to.pData, index == 0 ? &i : index);
    1550           8 :         return OUString(s, SAL_NO_ACQUIRE);
    1551             :     }
    1552             : 
    1553             :     /**
    1554             :       Returns a new string resulting from replacing the first occurrence of a
    1555             :       given substring with another substring.
    1556             : 
    1557             :       @param from  ASCII string literal, the substring to be replaced
    1558             : 
    1559             :       @param to  the replacing substring
    1560             : 
    1561             :       @param[in,out] index  pointer to a start index; if the pointer is
    1562             :       non-null: upon entry to the function, its value is the index into the this
    1563             :       string at which to start searching for the \p from substring, the value
    1564             :       must be non-negative and not greater than this string's length; upon exiting
    1565             :       the function its value is the index into this string at which the
    1566             :       replacement took place or -1 if no replacement took place; if the pointer
    1567             :       is null, searching always starts at index 0
    1568             : 
    1569             :       @since LibreOffice 3.6
    1570             :     */
    1571             :     template< typename T >
    1572           6 :     SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
    1573             :                                                                                                         sal_Int32 * index = 0) const
    1574             :     {
    1575           6 :         rtl_uString * s = 0;
    1576           6 :         sal_Int32 i = 0;
    1577             :         assert( strlen( from ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1578           6 :         rtl_uString_newReplaceFirstAsciiL(
    1579             :             &s, pData, from, internal::ConstCharArrayDetector< T, void >::size - 1, to.pData, index == 0 ? &i : index);
    1580           6 :         return OUString(s, SAL_NO_ACQUIRE);
    1581             :     }
    1582             : 
    1583             :     /**
    1584             :       Returns a new string resulting from replacing the first occurrence of a
    1585             :       given substring with another substring.
    1586             : 
    1587             :       @param from  ASCII string literal, the substring to be replaced
    1588             : 
    1589             :       @param to  ASCII string literal, the substring to be replaced
    1590             : 
    1591             :       @param[in,out] index  pointer to a start index; if the pointer is
    1592             :       non-null: upon entry to the function, its value is the index into the this
    1593             :       string at which to start searching for the \p from substring, the value
    1594             :       must be non-negative and not greater than this string's length; upon exiting
    1595             :       the function its value is the index into this string at which the
    1596             :       replacement took place or -1 if no replacement took place; if the pointer
    1597             :       is null, searching always starts at index 0
    1598             : 
    1599             :       @since LibreOffice 3.6
    1600             :     */
    1601             :     template< typename T1, typename T2 >
    1602             :         SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
    1603           6 :         replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
    1604             :     {
    1605           6 :         rtl_uString * s = 0;
    1606           6 :         sal_Int32 i = 0;
    1607             :         assert( strlen( from ) == internal::ConstCharArrayDetector< T1 >::size - 1 );
    1608             :         assert( strlen( to ) == internal::ConstCharArrayDetector< T2 >::size - 1 );
    1609           6 :         rtl_uString_newReplaceFirstAsciiLAsciiL(
    1610             :             &s, pData, from, internal::ConstCharArrayDetector< T1, void >::size - 1, to,
    1611             :             internal::ConstCharArrayDetector< T2, void >::size - 1, index == 0 ? &i : index);
    1612           6 :         return OUString(s, SAL_NO_ACQUIRE);
    1613             :     }
    1614             : 
    1615             :     /**
    1616             :       Returns a new string resulting from replacing all occurrences of a given
    1617             :       substring with another substring.
    1618             : 
    1619             :       Replacing subsequent occurrences picks up only after a given replacement.
    1620             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1621             : 
    1622             :       @param from  the substring to be replaced
    1623             : 
    1624             :       @param to  the replacing substring
    1625             : 
    1626             :       @param fromIndex  the position in the string where we will begin searching
    1627             : 
    1628             :       @since LibreOffice 4.0
    1629             :     */
    1630        2041 :     SAL_WARN_UNUSED_RESULT OUString replaceAll(
    1631             :         OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
    1632             :     {
    1633        2041 :         rtl_uString * s = 0;
    1634        2041 :         rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
    1635        2041 :         return OUString(s, SAL_NO_ACQUIRE);
    1636             :     }
    1637             : 
    1638             :     /**
    1639             :       Returns a new string resulting from replacing all occurrences of a given
    1640             :       substring with another substring.
    1641             : 
    1642             :       Replacing subsequent occurrences picks up only after a given replacement.
    1643             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1644             : 
    1645             :       @param from ASCII string literal, the substring to be replaced
    1646             : 
    1647             :       @param to  the replacing substring
    1648             : 
    1649             :       @since LibreOffice 3.6
    1650             :     */
    1651             :     template< typename T >
    1652          12 :     SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T, OUString >::Type replaceAll( T& from, OUString const & to) const
    1653             :     {
    1654          12 :         rtl_uString * s = 0;
    1655             :         assert( strlen( from ) == internal::ConstCharArrayDetector< T >::size - 1 );
    1656          12 :         rtl_uString_newReplaceAllAsciiL(&s, pData, from, internal::ConstCharArrayDetector< T, void >::size - 1, to.pData);
    1657          12 :         return OUString(s, SAL_NO_ACQUIRE);
    1658             :     }
    1659             : 
    1660             :     /**
    1661             :       Returns a new string resulting from replacing all occurrences of a given
    1662             :       substring with another substring.
    1663             : 
    1664             :       Replacing subsequent occurrences picks up only after a given replacement.
    1665             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1666             : 
    1667             :       @param from  ASCII string literal, the substring to be replaced
    1668             : 
    1669             :       @param to  ASCII string literal, the substring to be replaced
    1670             : 
    1671             :       @since LibreOffice 3.6
    1672             :     */
    1673             :     template< typename T1, typename T2 >
    1674             :     SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
    1675        2980 :         replaceAll( T1& from, T2& to ) const
    1676             :     {
    1677        2980 :         rtl_uString * s = 0;
    1678             :         assert( strlen( from ) == internal::ConstCharArrayDetector< T1 >::size - 1 );
    1679             :         assert( strlen( to ) == internal::ConstCharArrayDetector< T2 >::size - 1 );
    1680        2980 :         rtl_uString_newReplaceAllAsciiLAsciiL(
    1681             :             &s, pData, from, internal::ConstCharArrayDetector< T1, void >::size - 1,
    1682             :             to, internal::ConstCharArrayDetector< T2, void >::size - 1);
    1683        2980 :         return OUString(s, SAL_NO_ACQUIRE);
    1684             :     }
    1685             : 
    1686             :     /**
    1687             :       Converts from this string all ASCII uppercase characters (65-90)
    1688             :       to ASCII lowercase characters (97-122).
    1689             : 
    1690             :       This function can't be used for language specific conversion.
    1691             :       If the string doesn't contain characters which must be converted,
    1692             :       then the new string is assigned with str.
    1693             : 
    1694             :       @return   the string, converted to ASCII lowercase.
    1695             :     */
    1696      110843 :     SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const SAL_THROW(())
    1697             :     {
    1698      110843 :         rtl_uString* pNew = 0;
    1699      110843 :         rtl_uString_newToAsciiLowerCase( &pNew, pData );
    1700      110843 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1701             :     }
    1702             : 
    1703             :     /**
    1704             :       Converts from this string all ASCII lowercase characters (97-122)
    1705             :       to ASCII uppercase characters (65-90).
    1706             : 
    1707             :       This function can't be used for language specific conversion.
    1708             :       If the string doesn't contain characters which must be converted,
    1709             :       then the new string is assigned with str.
    1710             : 
    1711             :       @return   the string, converted to ASCII uppercase.
    1712             :     */
    1713      109279 :     SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const SAL_THROW(())
    1714             :     {
    1715      109279 :         rtl_uString* pNew = 0;
    1716      109279 :         rtl_uString_newToAsciiUpperCase( &pNew, pData );
    1717      109279 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1718             :     }
    1719             : 
    1720             :     /**
    1721             :       Returns a new string resulting from removing white space from both ends
    1722             :       of the string.
    1723             : 
    1724             :       All characters that have codes less than or equal to
    1725             :       32 (the space character) are considered to be white space.
    1726             :       If the string doesn't contain white spaces at both ends,
    1727             :       then the new string is assigned with str.
    1728             : 
    1729             :       @return   the string, with white space removed from the front and end.
    1730             :     */
    1731       36202 :     SAL_WARN_UNUSED_RESULT OUString trim() const SAL_THROW(())
    1732             :     {
    1733       36202 :         rtl_uString* pNew = 0;
    1734       36202 :         rtl_uString_newTrim( &pNew, pData );
    1735       36202 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    1736             :     }
    1737             : 
    1738             :     /**
    1739             :       Returns a token in the string.
    1740             : 
    1741             :       Example:
    1742             :         sal_Int32 nIndex = 0;
    1743             :         do
    1744             :         {
    1745             :             ...
    1746             :             OUString aToken = aStr.getToken( 0, ';', nIndex );
    1747             :             ...
    1748             :         }
    1749             :         while ( nIndex >= 0 );
    1750             : 
    1751             :       @param    token       the number of the token to return
    1752             :       @param    cTok        the character which seperate the tokens.
    1753             :       @param    index       the position at which the token is searched in the
    1754             :                             string.
    1755             :                             The index must not be greater than the length of the
    1756             :                             string.
    1757             :                             This param is set to the position of the
    1758             :                             next token or to -1, if it is the last token.
    1759             :       @return   the token; if either token or index is negative, an empty token
    1760             :                 is returned (and index is set to -1)
    1761             :     */
    1762      359151 :     OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
    1763             :     {
    1764      359151 :         rtl_uString * pNew = 0;
    1765      359151 :         index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
    1766      359151 :         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
    1767             :     }
    1768             : 
    1769             :     /**
    1770             :       Returns a token from the string.
    1771             : 
    1772             :       The same as getToken(sal_Int32, sal_Unicode, sal_Int32 &), but always
    1773             :       passing in 0 as the start index in the third argument.
    1774             : 
    1775             :       @param count  the number of the token to return, starting with 0
    1776             :       @param separator  the character which separates the tokens
    1777             : 
    1778             :       @return  the given token, or an empty string
    1779             : 
    1780             :       @since LibreOffice 3.6
    1781             :      */
    1782         770 :     OUString getToken(sal_Int32 count, sal_Unicode separator) const {
    1783         770 :         sal_Int32 n = 0;
    1784         770 :         return getToken(count, separator, n);
    1785             :     }
    1786             : 
    1787             :     /**
    1788             :       Returns the Boolean value from this string.
    1789             : 
    1790             :       This function can't be used for language specific conversion.
    1791             : 
    1792             :       @return   sal_True, if the string is 1 or "True" in any ASCII case.
    1793             :                 sal_False in any other case.
    1794             :     */
    1795         216 :     sal_Bool toBoolean() const SAL_THROW(())
    1796             :     {
    1797         216 :         return rtl_ustr_toBoolean( pData->buffer );
    1798             :     }
    1799             : 
    1800             :     /**
    1801             :       Returns the first character from this string.
    1802             : 
    1803             :       @return   the first character from this string or 0, if this string
    1804             :                 is emptry.
    1805             :     */
    1806       10164 :     sal_Unicode toChar() const SAL_THROW(())
    1807             :     {
    1808       10164 :         return pData->buffer[0];
    1809             :     }
    1810             : 
    1811             :     /**
    1812             :       Returns the int32 value from this string.
    1813             : 
    1814             :       This function can't be used for language specific conversion.
    1815             : 
    1816             :       @param    radix       the radix (between 2 and 36)
    1817             :       @return   the int32 represented from this string.
    1818             :                 0 if this string represents no number.
    1819             :     */
    1820       57359 :     sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
    1821             :     {
    1822       57359 :         return rtl_ustr_toInt32( pData->buffer, radix );
    1823             :     }
    1824             : 
    1825             :     /**
    1826             :       Returns the int64 value from this string.
    1827             : 
    1828             :       This function can't be used for language specific conversion.
    1829             : 
    1830             :       @param    radix       the radix (between 2 and 36)
    1831             :       @return   the int64 represented from this string.
    1832             :                 0 if this string represents no number.
    1833             :     */
    1834         248 :     sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
    1835             :     {
    1836         248 :         return rtl_ustr_toInt64( pData->buffer, radix );
    1837             :     }
    1838             : 
    1839             :     /**
    1840             :       Returns the float value from this string.
    1841             : 
    1842             :       This function can't be used for language specific conversion.
    1843             : 
    1844             :       @return   the float represented from this string.
    1845             :                 0.0 if this string represents no number.
    1846             :     */
    1847           0 :     float toFloat() const SAL_THROW(())
    1848             :     {
    1849           0 :         return rtl_ustr_toFloat( pData->buffer );
    1850             :     }
    1851             : 
    1852             :     /**
    1853             :       Returns the double value from this string.
    1854             : 
    1855             :       This function can't be used for language specific conversion.
    1856             : 
    1857             :       @return   the double represented from this string.
    1858             :                 0.0 if this string represents no number.
    1859             :     */
    1860        1062 :     double toDouble() const SAL_THROW(())
    1861             :     {
    1862        1062 :         return rtl_ustr_toDouble( pData->buffer );
    1863             :     }
    1864             : 
    1865             : 
    1866             :     /**
    1867             :        Return a canonical representation for a string.
    1868             : 
    1869             :        A pool of strings, initially empty is maintained privately
    1870             :        by the string class. On invocation, if present in the pool
    1871             :        the original string will be returned. Otherwise this string,
    1872             :        or a copy thereof will be added to the pool and returned.
    1873             : 
    1874             :        @return
    1875             :        a version of the string from the pool.
    1876             : 
    1877             :        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
    1878             : 
    1879             :        @since UDK 3.2.7
    1880             :     */
    1881       12345 :     OUString intern() const
    1882             :     {
    1883       12345 :         rtl_uString * pNew = 0;
    1884       12345 :         rtl_uString_intern( &pNew, pData );
    1885       12345 :         if (pNew == 0) {
    1886             : #if defined EXCEPTIONS_OFF
    1887             :             abort();
    1888             : #else
    1889           0 :             throw std::bad_alloc();
    1890             : #endif
    1891             :         }
    1892       12345 :         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
    1893             :     }
    1894             : 
    1895             :     /**
    1896             :        Return a canonical representation for a converted string.
    1897             : 
    1898             :        A pool of strings, initially empty is maintained privately
    1899             :        by the string class. On invocation, if present in the pool
    1900             :        the original string will be returned. Otherwise this string,
    1901             :        or a copy thereof will be added to the pool and returned.
    1902             : 
    1903             :        @param    value           a 8-Bit character array.
    1904             :        @param    length          the number of character which should be converted.
    1905             :                                  The 8-Bit character array length must be
    1906             :                                  greater than or equal to this value.
    1907             :        @param    encoding        the text encoding from which the 8-Bit character
    1908             :                                  sequence should be converted.
    1909             :        @param    convertFlags    flags which controls the conversion.
    1910             :                                  see RTL_TEXTTOUNICODE_FLAGS_...
    1911             :        @param    pInfo           pointer to return conversion status or NULL.
    1912             : 
    1913             :        @return
    1914             :        a version of the converted string from the pool.
    1915             : 
    1916             :        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
    1917             : 
    1918             :        @since UDK 3.2.7
    1919             :     */
    1920       13747 :     static OUString intern( const sal_Char * value, sal_Int32 length,
    1921             :                             rtl_TextEncoding encoding,
    1922             :                             sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
    1923             :                             sal_uInt32 *pInfo = NULL )
    1924             :     {
    1925       13747 :         rtl_uString * pNew = 0;
    1926             :         rtl_uString_internConvert( &pNew, value, length, encoding,
    1927       13747 :                                    convertFlags, pInfo );
    1928       13747 :         if (pNew == 0) {
    1929             : #if defined EXCEPTIONS_OFF
    1930             :             abort();
    1931             : #else
    1932           0 :             throw std::bad_alloc();
    1933             : #endif
    1934             :         }
    1935       13747 :         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
    1936             :     }
    1937             : 
    1938             :     /**
    1939             :       Converts to an OString, signalling failure.
    1940             : 
    1941             :       @param pTarget
    1942             :       An out parameter receiving the converted OString.  Must not be null; the
    1943             :       contents are not modified if conversion fails (convertToOString returns
    1944             :       false).
    1945             : 
    1946             :       @param nEncoding
    1947             :       The text encoding to convert into.  Must be an octet encoding (i.e.,
    1948             :       rtl_isOctetTextEncoding(nEncoding) must return true).
    1949             : 
    1950             :       @param nFlags
    1951             :       A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the
    1952             :       conversion (see rtl_convertUnicodeToText).  RTL_UNICODETOTEXT_FLAGS_FLUSH
    1953             :       need not be included, it is implicitly assumed.  Typical uses are either
    1954             :       RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
    1955             :       RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot
    1956             :       be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS
    1957             :       (make a best efforts conversion).
    1958             : 
    1959             :       @return
    1960             :       True if the conversion succeeded, false otherwise.
    1961             :      */
    1962      122868 :     inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
    1963             :                                 sal_uInt32 nFlags) const
    1964             :     {
    1965             :         return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
    1966      122868 :                                             pData->length, nEncoding, nFlags);
    1967             :     }
    1968             : 
    1969             :     /** Iterate through this string based on code points instead of UTF-16 code
    1970             :         units.
    1971             : 
    1972             :         See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
    1973             :         definitions of the various terms used in this description.
    1974             : 
    1975             :         This string is interpreted as a sequence of zero or more UTF-16 code
    1976             :         units.  For each index into this sequence (from zero to one less than
    1977             :         the length of the sequence, inclusive), a code point represented
    1978             :         starting at the given index is computed as follows:
    1979             : 
    1980             :         - If the UTF-16 code unit addressed by the index constitutes a
    1981             :         well-formed UTF-16 code unit sequence, the computed code point is the
    1982             :         scalar value encoded by that UTF-16 code unit sequence.
    1983             : 
    1984             :         - Otherwise, if the index is at least two UTF-16 code units away from
    1985             :         the end of the sequence, and the sequence of two UTF-16 code units
    1986             :         addressed by the index constitutes a well-formed UTF-16 code unit
    1987             :         sequence, the computed code point is the scalar value encoded by that
    1988             :         UTF-16 code unit sequence.
    1989             : 
    1990             :         - Otherwise, the computed code point is the UTF-16 code unit addressed
    1991             :         by the index.  (This last case catches unmatched surrogates as well as
    1992             :         indices pointing into the middle of surrogate pairs.)
    1993             : 
    1994             :         @param indexUtf16
    1995             :         pointer to a UTF-16 based index into this string; must not be null.  On
    1996             :         entry, the index must be in the range from zero to the length of this
    1997             :         string (in UTF-16 code units), inclusive.  Upon successful return, the
    1998             :         index will be updated to address the UTF-16 code unit that is the given
    1999             :         incrementCodePoints away from the initial index.
    2000             : 
    2001             :         @param incrementCodePoints
    2002             :         the number of code points to move the given *indexUtf16.  If
    2003             :         non-negative, moving is done after determining the code point at the
    2004             :         index.  If negative, moving is done before determining the code point
    2005             :         at the (then updated) index.  The value must be such that the resulting
    2006             :         UTF-16 based index is in the range from zero to the length of this
    2007             :         string (in UTF-16 code units), inclusive.
    2008             : 
    2009             :         @return
    2010             :         the code point (an integer in the range from 0 to 0x10FFFF, inclusive)
    2011             :         that is represented within this string starting at the index computed as
    2012             :         follows:  If incrementCodePoints is non-negative, the index is the
    2013             :         initial value of *indexUtf16; if incrementCodePoints is negative, the
    2014             :         index is the updated value of *indexUtf16.  In either case, the computed
    2015             :         index must be in the range from zero to one less than the length of this
    2016             :         string (in UTF-16 code units), inclusive.
    2017             : 
    2018             :         @since UDK 3.2.7
    2019             :     */
    2020     1640520 :     inline sal_uInt32 iterateCodePoints(
    2021             :         sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
    2022             :     {
    2023             :         return rtl_uString_iterateCodePoints(
    2024     1640520 :             pData, indexUtf16, incrementCodePoints);
    2025             :     }
    2026             : 
    2027             :     /**
    2028             :       Returns the string representation of the sal_Bool argument.
    2029             : 
    2030             :       If the sal_Bool is true, the string "true" is returned.
    2031             :       If the sal_Bool is false, the string "false" is returned.
    2032             :       This function can't be used for language specific conversion.
    2033             : 
    2034             :       @param    b   a sal_Bool.
    2035             :       @return   a string with the string representation of the argument.
    2036             :     */
    2037           0 :     static OUString valueOf( sal_Bool b ) SAL_THROW(())
    2038             :     {
    2039             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
    2040           0 :         rtl_uString* pNewData = 0;
    2041           0 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
    2042           0 :         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
    2043             :     }
    2044             : 
    2045             :     /**
    2046             :       Returns the string representation of the char argument.
    2047             : 
    2048             :       @param    c   a character.
    2049             :       @return   a string with the string representation of the argument.
    2050             :     */
    2051         274 :     static OUString valueOf( sal_Unicode c ) SAL_THROW(())
    2052             :     {
    2053         274 :         return OUString( &c, 1 );
    2054             :     }
    2055             : 
    2056             :     /**
    2057             :       Returns the string representation of the int argument.
    2058             : 
    2059             :       This function can't be used for language specific conversion.
    2060             : 
    2061             :       @param    i           a int32.
    2062             :       @param    radix       the radix (between 2 and 36)
    2063             :       @return   a string with the string representation of the argument.
    2064             :     */
    2065       86528 :     static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
    2066             :     {
    2067             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
    2068       86528 :         rtl_uString* pNewData = 0;
    2069       86528 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
    2070       86528 :         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
    2071             :     }
    2072             : 
    2073             :     /**
    2074             :       Returns the string representation of the long argument.
    2075             : 
    2076             :       This function can't be used for language specific conversion.
    2077             : 
    2078             :       @param    ll          a int64.
    2079             :       @param    radix       the radix (between 2 and 36)
    2080             :       @return   a string with the string representation of the argument.
    2081             :     */
    2082        3576 :     static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
    2083             :     {
    2084             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT64];
    2085        3576 :         rtl_uString* pNewData = 0;
    2086        3576 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
    2087        3576 :         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
    2088             :     }
    2089             : 
    2090             :     /**
    2091             :       Returns the string representation of the float argument.
    2092             : 
    2093             :       This function can't be used for language specific conversion.
    2094             : 
    2095             :       @param    f           a float.
    2096             :       @return   a string with the string representation of the argument.
    2097             :     */
    2098           0 :     static OUString valueOf( float f ) SAL_THROW(())
    2099             :     {
    2100             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
    2101           0 :         rtl_uString* pNewData = 0;
    2102           0 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
    2103           0 :         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
    2104             :     }
    2105             : 
    2106             :     /**
    2107             :       Returns the string representation of the double argument.
    2108             : 
    2109             :       This function can't be used for language specific conversion.
    2110             : 
    2111             :       @param    d           a double.
    2112             :       @return   a string with the string representation of the argument.
    2113             :     */
    2114        1123 :     static OUString valueOf( double d ) SAL_THROW(())
    2115             :     {
    2116             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
    2117        1123 :         rtl_uString* pNewData = 0;
    2118        1123 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
    2119        1123 :         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
    2120             :     }
    2121             : 
    2122             :     /**
    2123             :       Returns a OUString copied without conversion from an ASCII
    2124             :       character string.
    2125             : 
    2126             :       Since this method is optimized for performance, the ASCII character
    2127             :       values are not converted in any way. The caller has to make sure that
    2128             :       all ASCII characters are in the allowed range between 0 and
    2129             :       127. The ASCII string must be NULL-terminated.
    2130             : 
    2131             :       Note that for string literals it is simpler and more efficient
    2132             :       to directly use the OUString constructor.
    2133             : 
    2134             :       @param    value       the 8-Bit ASCII character string
    2135             :       @return   a string with the string representation of the argument.
    2136             :      */
    2137      449114 :     static OUString createFromAscii( const sal_Char * value ) SAL_THROW(())
    2138             :     {
    2139      449114 :         rtl_uString* pNew = 0;
    2140      449114 :         rtl_uString_newFromAscii( &pNew, value );
    2141      449114 :         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
    2142             :     }
    2143             : };
    2144             : 
    2145             : /* ======================================================================= */
    2146             : 
    2147             : #ifdef RTL_FAST_STRING
    2148             : /**
    2149             : A simple wrapper around string literal. It is usually not necessary to use, can
    2150             : be mostly used to force OUString operator+ working with operands that otherwise would
    2151             : not trigger it.
    2152             : 
    2153             : This class is not part of public API and is meant to be used only in LibreOffice code.
    2154             : @since LibreOffice 4.0
    2155             : */
    2156             : struct SAL_WARN_UNUSED OUStringLiteral
    2157             : {
    2158             :     template< int N >
    2159           4 :     OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
    2160             :     int size;
    2161             :     const char* data;
    2162             : };
    2163             : 
    2164             : /**
    2165             :  @internal
    2166             : */
    2167             : template<>
    2168             : struct ToStringHelper< OUString >
    2169             :     {
    2170     1068405 :     static int length( const OUString& s ) { return s.getLength(); }
    2171     1068401 :     static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
    2172             :     static const bool allowOStringConcat = false;
    2173             :     static const bool allowOUStringConcat = true;
    2174             :     };
    2175             : 
    2176             : /**
    2177             :  @internal
    2178             : */
    2179             : template<>
    2180             : struct ToStringHelper< OUStringLiteral >
    2181             :     {
    2182           3 :     static int length( const OUStringLiteral& str ) { return str.size; }
    2183           3 :     static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
    2184             :     static const bool allowOStringConcat = false;
    2185             :     static const bool allowOUStringConcat = true;
    2186             :     };
    2187             : 
    2188             : /**
    2189             :  @internal
    2190             : */
    2191             : template< typename charT, typename traits, typename T1, typename T2 >
    2192             : inline std::basic_ostream<charT, traits> & operator <<(
    2193             :     std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
    2194             : {
    2195             :     return stream << OUString( concat );
    2196             : }
    2197             : #else
    2198             : // non-RTL_FAST_CODE needs this to compile
    2199             : typedef OUString OUStringLiteral;
    2200             : #endif
    2201             : 
    2202             : /** A helper to use OUStrings with hash maps.
    2203             : 
    2204             :     Instances of this class are unary function objects that can be used as
    2205             :     hash function arguments to boost::unordered_map and similar constructs.
    2206             :  */
    2207             : struct OUStringHash
    2208             : {
    2209             :     /** Compute a hash code for a string.
    2210             : 
    2211             :         @param rString
    2212             :         a string.
    2213             : 
    2214             :         @return
    2215             :         a hash code for the string.  This hash code should not be stored
    2216             :         persistently, as its computation may change in later revisions.
    2217             :      */
    2218     2983559 :     size_t operator()(const OUString& rString) const
    2219     2983559 :         { return (size_t)rString.hashCode(); }
    2220             : };
    2221             : 
    2222             : /* ======================================================================= */
    2223             : 
    2224             : /** Convert an OString to an OUString, using a specific text encoding.
    2225             : 
    2226             :     The lengths of the two strings may differ (e.g., for double-byte
    2227             :     encodings, UTF-7, UTF-8).
    2228             : 
    2229             :     @param rStr
    2230             :     an OString to convert.
    2231             : 
    2232             :     @param encoding
    2233             :     the text encoding to use for conversion.
    2234             : 
    2235             :     @param convertFlags
    2236             :     flags which control the conversion.  Either use
    2237             :     OSTRING_TO_OUSTRING_CVTFLAGS, or see
    2238             :     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
    2239             :     details.
    2240             :  */
    2241     1210978 : inline OUString OStringToOUString( const OString & rStr,
    2242             :                                    rtl_TextEncoding encoding,
    2243             :                                    sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
    2244             : {
    2245     1210978 :     return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
    2246             : }
    2247             : 
    2248             : /** Convert an OUString to an OString, using a specific text encoding.
    2249             : 
    2250             :     The lengths of the two strings may differ (e.g., for double-byte
    2251             :     encodings, UTF-7, UTF-8).
    2252             : 
    2253             :     @param rUnicode
    2254             :     an OUString to convert.
    2255             : 
    2256             :     @param encoding
    2257             :     the text encoding to use for conversion.
    2258             : 
    2259             :     @param convertFlags
    2260             :     flags which control the conversion.  Either use
    2261             :     OUSTRING_TO_OSTRING_CVTFLAGS, or see
    2262             :     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
    2263             :     details.
    2264             :  */
    2265     1527286 : inline OString OUStringToOString( const OUString & rUnicode,
    2266             :                                   rtl_TextEncoding encoding,
    2267             :                                   sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
    2268             : {
    2269     1527286 :     return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
    2270             : }
    2271             : 
    2272             : /* ======================================================================= */
    2273             : 
    2274             : /**
    2275             :     Support for rtl::OUString in std::ostream (and thus in
    2276             :     CPPUNIT_ASSERT or SAL_INFO macros, for example).
    2277             : 
    2278             :     The rtl::OUString is converted to UTF-8.
    2279             : 
    2280             :     @since LibreOffice 3.5.
    2281             : */
    2282             : template< typename charT, typename traits >
    2283         201 : inline std::basic_ostream<charT, traits> & operator <<(
    2284             :     std::basic_ostream<charT, traits> & stream, OUString const & string)
    2285             : {
    2286             :     return stream <<
    2287         201 :         OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
    2288             :         // best effort; potentially loses data due to conversion failures
    2289             :         // (stray surrogate halves) and embedded null characters
    2290             : }
    2291             : 
    2292             : } // namespace
    2293             : 
    2294             : #ifdef RTL_STRING_UNITTEST
    2295             : namespace rtl
    2296             : {
    2297             : typedef rtlunittest::OUString OUString;
    2298             : }
    2299             : #endif
    2300             : 
    2301             : // RTL_USING is defined by gbuild for all modules except those with stable public API
    2302             : // (as listed in ure/source/README). It allows to use classes like OUString without
    2303             : // having to explicitly refer to the rtl namespace, which is kind of superfluous
    2304             : // given that OUString itself is namespaced by its OU prefix.
    2305             : #ifdef RTL_USING
    2306             : using ::rtl::OUString;
    2307             : using ::rtl::OUStringHash;
    2308             : using ::rtl::OStringToOUString;
    2309             : using ::rtl::OUStringToOString;
    2310             : using ::rtl::OUStringLiteral;
    2311             : #endif
    2312             : 
    2313             : #endif /* _RTL_USTRING_HXX */
    2314             : 
    2315             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10