LCOV - code coverage report
Current view: top level - include/rtl - ustring.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 427 447 95.5 %
Date: 2015-06-13 12:38:46 Functions: 1006 2061 48.8 %
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 INCLUDED_RTL_USTRING_HXX
      21             : #define INCLUDED_RTL_USTRING_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <cassert>
      26             : #include <new>
      27             : #include <ostream>
      28             : #include <string.h>
      29             : 
      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 LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
      37             : #include <rtl/stringconcat.hxx>
      38             : #endif
      39             : 
      40             : // The unittest uses slightly different code to help check that the proper
      41             : // calls are made. The class is put into a different namespace to make
      42             : // sure the compiler generates a different (if generating also non-inline)
      43             : // copy of the function and does not merge them together. The class
      44             : // is "brought" into the proper rtl namespace by a typedef below.
      45             : #ifdef RTL_STRING_UNITTEST
      46             : #define rtl rtlunittest
      47             : #endif
      48             : 
      49             : namespace rtl
      50             : {
      51             : 
      52             : #ifdef RTL_STRING_UNITTEST
      53             : #undef rtl
      54             : #endif
      55             : 
      56             : #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
      57             : /// @cond INTERNAL
      58             : 
      59             : /**
      60             : A simple wrapper around string literal. It is usually not necessary to use, can
      61             : be mostly used to force OUString operator+ working with operands that otherwise would
      62             : not trigger it.
      63             : 
      64             : This class is not part of public API and is meant to be used only in LibreOffice code.
      65             : @since LibreOffice 4.0
      66             : */
      67             : struct SAL_WARN_UNUSED OUStringLiteral
      68             : {
      69             :     template< int N >
      70          13 :     explicit SAL_CONSTEXPR OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str )
      71          13 :     { /* only C++14 constexpr: assert( strlen( str ) == N - 1 ); */ }
      72             :     int size;
      73             :     const char* data;
      74             : };
      75             : 
      76             : /** A simple wrapper around an ASCII character literal, for use in certain
      77             :     OUString functions designed for efficient processing of string literals.
      78             : 
      79             :     @since LibreOffice 5.0
      80             : */
      81             : template<char C> struct SAL_WARN_UNUSED OUStringLiteral1 {
      82             :     static_assert(
      83             :         static_cast<unsigned char>(C) < 0x80,
      84             :         "non-ASCII character in OUStringLiteral1");
      85             : };
      86             : 
      87             : /// @endcond
      88             : #endif
      89             : 
      90             : /* ======================================================================= */
      91             : 
      92             : /**
      93             :   This String class provides base functionality for C++ like Unicode
      94             :   character array handling. The advantage of this class is that it
      95             :   handles all the memory management for you - and it does it
      96             :   more efficiently. If you assign a string to another string, the
      97             :   data of both strings are shared (without any copy operation or
      98             :   memory allocation) as long as you do not change the string. This class
      99             :   also stores the length of the string, so that many operations are
     100             :   faster than the C-str-functions.
     101             : 
     102             :   This class provides only readonly string handling. So you could create
     103             :   a string and you could only query the content from this string.
     104             :   It provides also functionality to change the string, but this results
     105             :   in every case in a new string instance (in the most cases with a
     106             :   memory allocation). You don't have functionality to change the
     107             :   content of the string. If you want to change the string content, then
     108             :   you should use the OStringBuffer class, which provides these
     109             :   functionalities and avoids too much memory allocation.
     110             : 
     111             :   The design of this class is similar to the string classes in Java so
     112             :   less people should have understanding problems when they use this class.
     113             : */
     114             : 
     115             : class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
     116             : {
     117             : public:
     118             :     /// @cond INTERNAL
     119             :     rtl_uString * pData;
     120             :     /// @endcond
     121             : 
     122             :     /**
     123             :       New string containing no characters.
     124             :     */
     125  9509885220 :     OUString()
     126             :     {
     127  9509885220 :         pData = 0;
     128  9509885220 :         rtl_uString_new( &pData );
     129  9509885239 :     }
     130             : 
     131             :     /**
     132             :       New string from OUString.
     133             : 
     134             :       @param    str         a OUString.
     135             :     */
     136 15312909076 :     OUString( const OUString & str )
     137             :     {
     138 15312909076 :         pData = str.pData;
     139 15312909076 :         rtl_uString_acquire( pData );
     140 15312909083 :     }
     141             : 
     142             :     /**
     143             :       New string from OUString data.
     144             : 
     145             :       @param    str         a OUString data.
     146             :     */
     147    11958906 :     OUString( rtl_uString * str )
     148             :     {
     149    11958906 :         pData = str;
     150    11958906 :         rtl_uString_acquire( pData );
     151    11958912 :     }
     152             : 
     153             :     /** New OUString from OUString data without acquiring it.  Takeover of ownership.
     154             : 
     155             :         The SAL_NO_ACQUIRE dummy parameter is only there to distinguish this
     156             :         from other constructors.
     157             : 
     158             :         @param str
     159             :                OUString data
     160             :     */
     161   720355309 :     inline OUString( rtl_uString * str, __sal_NoAcquire )
     162   720355309 :         { pData = str; }
     163             : 
     164             :     /**
     165             :       New string from a single Unicode character.
     166             : 
     167             :       @param    value       a Unicode character.
     168             :     */
     169   270372638 :     explicit OUString( sal_Unicode value )
     170   270372638 :         : pData (0)
     171             :     {
     172   270372638 :         rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
     173   270372638 :     }
     174             : 
     175             :     /**
     176             :       New string from a Unicode character buffer array.
     177             : 
     178             :       @param    value       a NULL-terminated Unicode character array.
     179             :     */
     180   438205521 :     OUString( const sal_Unicode * value )
     181             :     {
     182   438205521 :         pData = 0;
     183   438205521 :         rtl_uString_newFromStr( &pData, value );
     184   438205521 :     }
     185             : 
     186             :     /**
     187             :       New string from a Unicode character buffer array.
     188             : 
     189             :       @param    value       a Unicode character array.
     190             :       @param    length      the number of character which should be copied.
     191             :                             The character array length must be greater than
     192             :                             or equal to this value.
     193             :     */
     194    16911880 :     OUString( const sal_Unicode * value, sal_Int32 length )
     195             :     {
     196    16911880 :         pData = 0;
     197    16911880 :         rtl_uString_newFromStr_WithLength( &pData, value, length );
     198    16911880 :     }
     199             : 
     200             :     /**
     201             :       New string from an 8-Bit string literal that is expected to contain only
     202             :       characters in the ASCII set (i.e. first 128 characters). This constructor
     203             :       allows an efficient and convenient way to create OUString
     204             :       instances from ASCII literals. When creating strings from data that
     205             :       is not pure ASCII, it needs to be converted to OUString by explicitly
     206             :       providing the encoding to use for the conversion.
     207             : 
     208             :       If there are any embedded \0's in the string literal, the result is undefined.
     209             :       Use the overload that explicitly accepts length.
     210             : 
     211             :       @param    literal         the 8-bit ASCII string literal
     212             : 
     213             :       @since LibreOffice 3.6
     214             :     */
     215             :     template< typename T >
     216   699654175 :     OUString( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
     217             :     {
     218             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     219   699654175 :         pData = 0;
     220             :         if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
     221      916489 :             rtl_uString_new( &pData );
     222             :         else
     223   698737686 :             rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
     224             : #ifdef RTL_STRING_UNITTEST
     225          36 :         rtl_string_unittest_const_literal = true;
     226             : #endif
     227   699654184 :     }
     228             : 
     229             : #ifdef RTL_STRING_UNITTEST
     230             :     /**
     231             :      * Only used by unittests to detect incorrect conversions.
     232             :      * @internal
     233             :      */
     234             :     template< typename T >
     235          18 :     OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
     236             :     {
     237          18 :         pData = 0;
     238          18 :         rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
     239          18 :         rtl_string_unittest_invalid_conversion = true;
     240          18 :     }
     241             :     /**
     242             :      * Only used by unittests to detect incorrect conversions.
     243             :      * @internal
     244             :      */
     245             :     template< typename T >
     246           2 :     OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
     247             :     {
     248           2 :         pData = 0;
     249           2 :         rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
     250           2 :         rtl_string_unittest_invalid_conversion = true;
     251           2 :     }
     252             : #endif
     253             : 
     254             : #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     255             :     /// @cond INTERNAL
     256             :     /**
     257             :       New string from an 8-Bit string literal that is expected to contain only
     258             :       characters in the ASCII set (i.e. first 128 characters).
     259             : 
     260             :       This constructor is similar to the "direct template" one, but can be
     261             :       useful in cases where the latter does not work, like in
     262             : 
     263             :         OUString(flag ? "a" : "bb")
     264             : 
     265             :       written as
     266             : 
     267             :         OUString(flag ? OUStringLiteral("a") : OUStringLiteral("bb"))
     268             : 
     269             :       @since LibreOffice 5.0
     270             :     */
     271           4 :     OUString(OUStringLiteral literal): pData(0) {
     272           4 :         rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
     273           4 :     }
     274             :     /// @endcond
     275             : #endif
     276             : 
     277             :     /**
     278             :       New string from an 8-Bit character buffer array.
     279             : 
     280             :       @param    value           An 8-Bit character array.
     281             :       @param    length          The number of character which should be converted.
     282             :                                 The 8-Bit character array length must be
     283             :                                 greater than or equal to this value.
     284             :       @param    encoding        The text encoding from which the 8-Bit character
     285             :                                 sequence should be converted.
     286             :       @param    convertFlags    Flags which control the conversion.
     287             :                                 see RTL_TEXTTOUNICODE_FLAGS_...
     288             : 
     289             :       @exception std::bad_alloc is thrown if an out-of-memory condition occurs
     290             :     */
     291    16415864 :     OUString( const sal_Char * value, sal_Int32 length,
     292             :               rtl_TextEncoding encoding,
     293             :               sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
     294             :     {
     295    16415864 :         pData = 0;
     296    16415864 :         rtl_string2UString( &pData, value, length, encoding, convertFlags );
     297    16415864 :         if (pData == 0) {
     298           0 :             throw std::bad_alloc();
     299             :         }
     300    16415864 :     }
     301             : 
     302             :     /** Create a new string from an array of Unicode code points.
     303             : 
     304             :         @param codePoints
     305             :         an array of at least codePointCount code points, which each must be in
     306             :         the range from 0 to 0x10FFFF, inclusive.  May be null if codePointCount
     307             :         is zero.
     308             : 
     309             :         @param codePointCount
     310             :         the non-negative number of code points.
     311             : 
     312             :         @exception std::bad_alloc
     313             :         is thrown if either an out-of-memory condition occurs or the resulting
     314             :         number of UTF-16 code units would have been larger than SAL_MAX_INT32.
     315             : 
     316             :         @since UDK 3.2.7
     317             :     */
     318       18310 :     inline explicit OUString(
     319             :         sal_uInt32 const * codePoints, sal_Int32 codePointCount):
     320       18310 :         pData(NULL)
     321             :     {
     322       18310 :         rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
     323       18310 :         if (pData == NULL) {
     324           0 :             throw std::bad_alloc();
     325             :         }
     326       18310 :     }
     327             : 
     328             : #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     329             :     /**
     330             :      @overload
     331             :      @internal
     332             :     */
     333             :     template< typename T1, typename T2 >
     334   948241752 :     OUString( const OUStringConcat< T1, T2 >& c )
     335             :     {
     336   948241752 :         const sal_Int32 l = c.length();
     337   948241752 :         pData = rtl_uString_alloc( l );
     338   948241752 :         if (l != 0)
     339             :         {
     340   948241013 :             sal_Unicode* end = c.addData( pData->buffer );
     341   948241013 :             pData->length = end - pData->buffer;
     342   948241013 :             *end = '\0';
     343             :             // TODO realloc in case pData->length is noticeably smaller than l?
     344             :         }
     345   948241752 :     }
     346             : #endif
     347             : 
     348             :     /**
     349             :       Release the string data.
     350             :     */
     351 27943533626 :     ~OUString()
     352             :     {
     353 27943533626 :         rtl_uString_release( pData );
     354 27943533981 :     }
     355             : 
     356             :     /** Provides an OUString const & passing a storage pointer of an
     357             :         rtl_uString * handle.
     358             :         It is more convenient to use C++ OUString member functions when dealing
     359             :         with rtl_uString * handles.  Using this function avoids unnecessary
     360             :         acquire()/release() calls for a temporary OUString object.
     361             : 
     362             :         @param ppHandle
     363             :                pointer to storage
     364             :         @return
     365             :                OUString const & based on given storage
     366             :     */
     367  4984426876 :     static inline OUString const & unacquired( rtl_uString * const * ppHandle )
     368  4984426876 :         { return * reinterpret_cast< OUString const * >( ppHandle ); }
     369             : 
     370             :     /**
     371             :       Assign a new string.
     372             : 
     373             :       @param    str         a OUString.
     374             :     */
     375 15352890115 :     OUString & operator=( const OUString & str )
     376             :     {
     377 15352890115 :         rtl_uString_assign( &pData, str.pData );
     378 15352890117 :         return *this;
     379             :     }
     380             : 
     381             :     /**
     382             :       Assign a new string from an 8-Bit string literal that is expected to contain only
     383             :       characters in the ASCII set (i.e. first 128 characters). This operator
     384             :       allows an efficient and convenient way to assign OUString
     385             :       instances from ASCII literals. When assigning strings from data that
     386             :       is not pure ASCII, it needs to be converted to OUString by explicitly
     387             :       providing the encoding to use for the conversion.
     388             : 
     389             :       @param    literal         the 8-bit ASCII string literal
     390             : 
     391             :       @since LibreOffice 3.6
     392             :     */
     393             :     template< typename T >
     394    32409375 :     typename libreoffice_internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal )
     395             :     {
     396             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     397             :         if( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
     398         539 :             rtl_uString_new( &pData );
     399             :         else
     400    32408836 :             rtl_uString_newFromLiteral( &pData, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
     401    32409375 :         return *this;
     402             :     }
     403             : 
     404             : #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     405             :     /// @cond INTERNAL
     406             :     /** Assign a new string from a single ASCII character literal.
     407             : 
     408             :         @since LibreOffice 5.0
     409             :     */
     410           2 :     template<char C> OUString & operator =(OUStringLiteral1<C>) {
     411           2 :         sal_Unicode const c = C;
     412           2 :         rtl_uString_newFromStr_WithLength(&pData, &c, 1);
     413           2 :         return *this;
     414             :     }
     415             :     /// @endcond
     416             : #endif
     417             : 
     418             :     /**
     419             :       Append a string to this string.
     420             : 
     421             :       @param    str         a OUString.
     422             :     */
     423    10721415 :     OUString & operator+=( const OUString & str )
     424             :     {
     425    10721415 :         rtl_uString_newConcat( &pData, pData, str.pData );
     426    10721415 :         return *this;
     427             :     }
     428             : 
     429             : #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     430             :     /**
     431             :      @overload
     432             :      @internal
     433             :     */
     434             :     template< typename T1, typename T2 >
     435        8427 :     OUString& operator+=( const OUStringConcat< T1, T2 >& c )
     436             :     {
     437        8427 :         const int l = c.length();
     438        8427 :         if( l == 0 )
     439           0 :             return *this;
     440        8427 :         rtl_uString_ensureCapacity( &pData, pData->length + l );
     441        8427 :         sal_Unicode* end = c.addData( pData->buffer + pData->length );
     442        8427 :         *end = '\0';
     443        8427 :         pData->length = end - pData->buffer;
     444        8427 :         return *this;
     445             :     }
     446             : #endif
     447             : 
     448             :     /**
     449             :       Clears the string, i.e, makes a zero-character string
     450             :       @since LibreOffice 4.4
     451             :     */
     452    17849302 :     void clear()
     453             :     {
     454    17849302 :         rtl_uString_new( &pData );
     455    17849301 :     }
     456             : 
     457             :     /**
     458             :       Returns the length of this string.
     459             : 
     460             :       The length is equal to the number of Unicode characters in this string.
     461             : 
     462             :       @return   the length of the sequence of characters represented by this
     463             :                 object.
     464             :     */
     465 15369144452 :     sal_Int32 getLength() const { return pData->length; }
     466             : 
     467             :     /**
     468             :       Checks if a string is empty.
     469             : 
     470             :       @return   true if the string is empty;
     471             :                 false, otherwise.
     472             : 
     473             :       @since LibreOffice 3.4
     474             :     */
     475 10689379829 :     bool isEmpty() const
     476             :     {
     477 10689379829 :         return pData->length == 0;
     478             :     }
     479             : 
     480             :     /**
     481             :       Returns a pointer to the Unicode character buffer for this string.
     482             : 
     483             :       It isn't necessarily NULL terminated.
     484             : 
     485             :       @return   a pointer to the Unicode characters buffer for this object.
     486             :     */
     487 11789136370 :     const sal_Unicode * getStr() const { return pData->buffer; }
     488             : 
     489             :     /**
     490             :       Access to individual characters.
     491             : 
     492             :       @param index must be non-negative and less than length.
     493             : 
     494             :       @return the character at the given index.
     495             : 
     496             :       @since LibreOffice 3.5
     497             :     */
     498  9548548317 :     sal_Unicode operator [](sal_Int32 index) const {
     499             :         // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
     500             :         assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
     501  9548548317 :         return getStr()[index];
     502             :     }
     503             : 
     504             :     /**
     505             :       Compares two strings.
     506             : 
     507             :       The comparison is based on the numeric value of each character in
     508             :       the strings and return a value indicating their relationship.
     509             :       This function can't be used for language specific sorting.
     510             : 
     511             :       @param    str         the object to be compared.
     512             :       @return   0 - if both strings are equal
     513             :                 < 0 - if this string is less than the string argument
     514             :                 > 0 - if this string is greater than the string argument
     515             :     */
     516  3404217008 :     sal_Int32 compareTo( const OUString & str ) const
     517             :     {
     518             :         return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
     519  3404217008 :                                             str.pData->buffer, str.pData->length );
     520             :     }
     521             : 
     522             :     /**
     523             :       Compares two strings with a maximum count of characters.
     524             : 
     525             :       The comparison is based on the numeric value of each character in
     526             :       the strings and return a value indicating their relationship.
     527             :       This function can't be used for language specific sorting.
     528             : 
     529             :       @param    str         the object to be compared.
     530             :       @param    maxLength   the maximum count of characters to be compared.
     531             :       @return   0 - if both strings are equal
     532             :                 < 0 - if this string is less than the string argument
     533             :                 > 0 - if this string is greater than the string argument
     534             : 
     535             :       @since UDK 3.2.7
     536             :     */
     537        4696 :     sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
     538             :     {
     539             :         return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
     540        4696 :                                                      str.pData->buffer, str.pData->length, maxLength );
     541             :     }
     542             : 
     543             :     /**
     544             :       Compares two strings in reverse order.
     545             : 
     546             :       The comparison is based on the numeric value of each character in
     547             :       the strings and return a value indicating their relationship.
     548             :       This function can't be used for language specific sorting.
     549             : 
     550             :       @param    str         the object to be compared.
     551             :       @return   0 - if both strings are equal
     552             :                 < 0 - if this string is less than the string argument
     553             :                 > 0 - if this string is greater than the string argument
     554             :     */
     555           0 :     sal_Int32 reverseCompareTo( const OUString & str ) const
     556             :     {
     557             :         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
     558           0 :                                                    str.pData->buffer, str.pData->length );
     559             :     }
     560             : 
     561             :     /**
     562             :      @overload
     563             :      This function accepts an ASCII string literal as its argument.
     564             :      @since LibreOffice 4.1
     565             :     */
     566             :     template< typename T >
     567           1 :     typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const
     568             :     {
     569             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     570             :         return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
     571           1 :             literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
     572             :     }
     573             : 
     574             :     /**
     575             :       Perform a comparison of two strings.
     576             : 
     577             :       The result is true if and only if second string
     578             :       represents the same sequence of characters as the first string.
     579             :       This function can't be used for language specific comparison.
     580             : 
     581             :       @param    str         the object to be compared.
     582             :       @return   true if the strings are equal;
     583             :                 false, otherwise.
     584             :     */
     585 10601818038 :     bool equals( const OUString & str ) const
     586             :     {
     587 10601818038 :         if ( pData->length != str.pData->length )
     588  2915660730 :             return false;
     589  7686157308 :         if ( pData == str.pData )
     590  4495429417 :             return true;
     591             :         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
     592  3190727891 :                                                    str.pData->buffer, str.pData->length ) == 0;
     593             :     }
     594             : 
     595             :     /**
     596             :       Perform a ASCII lowercase comparison of two strings.
     597             : 
     598             :       The result is true if and only if second string
     599             :       represents the same sequence of characters as the first string,
     600             :       ignoring the case.
     601             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     602             :       values between 97 and 122 (ASCII a-z).
     603             :       This function can't be used for language specific comparison.
     604             : 
     605             :       @param    str         the object to be compared.
     606             :       @return   true if the strings are equal;
     607             :                 false, otherwise.
     608             :     */
     609     2749664 :     bool equalsIgnoreAsciiCase( const OUString & str ) const
     610             :     {
     611     2749664 :         if ( pData->length != str.pData->length )
     612     2010578 :             return false;
     613      739086 :         if ( pData == str.pData )
     614      104210 :             return true;
     615             :         return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
     616      634876 :                                                            str.pData->buffer, str.pData->length ) == 0;
     617             :     }
     618             : 
     619             :     /**
     620             :       Perform a ASCII lowercase comparison of two strings.
     621             : 
     622             :       Compare the two strings with uppercase ASCII
     623             :       character values between 65 and 90 (ASCII A-Z) interpreted as
     624             :       values between 97 and 122 (ASCII a-z).
     625             :       This function can't be used for language specific comparison.
     626             : 
     627             :       @param    str         the object to be compared.
     628             :       @return   0 - if both strings are equal
     629             :                 < 0 - if this string is less than the string argument
     630             :                 > 0 - if this string is greater than the string argument
     631             : 
     632             :       @since LibreOffice 4.0
     633             :     */
     634  8563571388 :     sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
     635             :     {
     636             :         return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
     637  8563571388 :                                                            str.pData->buffer, str.pData->length );
     638             :     }
     639             : 
     640             : 
     641             :     /**
     642             :      @overload
     643             :      This function accepts an ASCII string literal as its argument.
     644             :      @since LibreOffice 3.6
     645             :     */
     646             :     template< typename T >
     647    30148565 :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const
     648             :     {
     649             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     650    30148565 :         if ( pData->length != libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 )
     651     2406993 :             return false;
     652             : 
     653    27741572 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, literal ) == 0;
     654             :     }
     655             : 
     656             :    /**
     657             :       Match against a substring appearing in this string.
     658             : 
     659             :       The result is true if and only if the second string appears as a substring
     660             :       of this string, at the given position.
     661             :       This function can't be used for language specific comparison.
     662             : 
     663             :       @param    str         the object (substring) to be compared.
     664             :       @param    fromIndex   the index to start the comparion from.
     665             :                             The index must be greater than or equal to 0
     666             :                             and less or equal as the string length.
     667             :       @return   true if str match with the characters in the string
     668             :                 at the given position;
     669             :                 false, otherwise.
     670             :     */
     671    38585059 :     bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
     672             :     {
     673    38585059 :         return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     674    77170118 :                                                      str.pData->buffer, str.pData->length, str.pData->length ) == 0;
     675             :     }
     676             : 
     677             :     /**
     678             :      @overload
     679             :      This function accepts an ASCII string literal as its argument.
     680             :      @since LibreOffice 3.6
     681             :     */
     682             :     template< typename T >
     683   143128675 :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
     684             :     {
     685             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     686   143128675 :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     687   286257350 :             literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
     688             :     }
     689             : 
     690             :     /**
     691             :       Match against a substring appearing in this string, ignoring the case of
     692             :       ASCII letters.
     693             : 
     694             :       The result is true if and only if the second string appears as a substring
     695             :       of this string, at the given position.
     696             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     697             :       values between 97 and 122 (ASCII a-z).
     698             :       This function can't be used for language specific comparison.
     699             : 
     700             :       @param    str         the object (substring) to be compared.
     701             :       @param    fromIndex   the index to start the comparion from.
     702             :                             The index must be greater than or equal to 0
     703             :                             and less than or equal to the string length.
     704             :       @return   true if str match with the characters in the string
     705             :                 at the given position;
     706             :                 false, otherwise.
     707             :     */
     708       87687 :     bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
     709             :     {
     710       87687 :         return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     711             :                                                                     str.pData->buffer, str.pData->length,
     712      175374 :                                                                     str.pData->length ) == 0;
     713             :     }
     714             : 
     715             :     /**
     716             :      @overload
     717             :      This function accepts an ASCII string literal as its argument.
     718             :      @since LibreOffice 3.6
     719             :     */
     720             :     template< typename T >
     721        2831 :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
     722             :     {
     723             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
     724        2831 :         return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     725        5662 :             literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
     726             :     }
     727             : 
     728             :     /**
     729             :       Compares two strings.
     730             : 
     731             :       The comparison is based on the numeric value of each character in
     732             :       the strings and return a value indicating their relationship.
     733             :       Since this method is optimized for performance, the ASCII character
     734             :       values are not converted in any way. The caller has to make sure that
     735             :       all ASCII characters are in the allowed range between 0 and
     736             :       127. The ASCII string must be NULL-terminated.
     737             :       This function can't be used for language specific sorting.
     738             : 
     739             :       @param  asciiStr      the 8-Bit ASCII character string to be compared.
     740             :       @return   0 - if both strings are equal
     741             :                 < 0 - if this string is less than the string argument
     742             :                 > 0 - if this string is greater than the string argument
     743             :     */
     744       48137 :     sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
     745             :     {
     746       48137 :         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
     747             :     }
     748             : 
     749             :     /**
     750             :       Compares two strings with a maximum count of characters.
     751             : 
     752             :       The comparison is based on the numeric value of each character in
     753             :       the strings and return a value indicating their relationship.
     754             :       Since this method is optimized for performance, the ASCII character
     755             :       values are not converted in any way. The caller has to make sure that
     756             :       all ASCII characters are in the allowed range between 0 and
     757             :       127. The ASCII string must be NULL-terminated.
     758             :       This function can't be used for language specific sorting.
     759             : 
     760             :       @deprecated  This is a confusing overload with unexpectedly different
     761             :       semantics from the one-parameter form, so it is marked as deprecated.
     762             :       Practically all uses compare the return value against zero and can thus
     763             :       be replaced with uses of startsWith.
     764             : 
     765             :       @param  asciiStr          the 8-Bit ASCII character string to be compared.
     766             :       @param  maxLength         the maximum count of characters to be compared.
     767             :       @return   0 - if both strings are equal
     768             :                 < 0 - if this string is less than the string argument
     769             :                 > 0 - if this string is greater than the string argument
     770             :     */
     771             :     SAL_DEPRECATED(
     772             :         "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
     773             :     sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
     774             :     {
     775             :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
     776             :                                                            asciiStr, maxLength );
     777             :     }
     778             : 
     779             :     /**
     780             :       Compares two strings in reverse order.
     781             : 
     782             :       This could be useful, if normally both strings start with the same
     783             :       content. The comparison is based on the numeric value of each character
     784             :       in the strings and return a value indicating their relationship.
     785             :       Since this method is optimized for performance, the ASCII character
     786             :       values are not converted in any way. The caller has to make sure that
     787             :       all ASCII characters are in the allowed range between 0 and 127.
     788             :       The ASCII string must be NULL-terminated and must be greater than
     789             :       or equal to asciiStrLength.
     790             :       This function can't be used for language specific sorting.
     791             : 
     792             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     793             :       @param    asciiStrLength  the length of the ascii string
     794             :       @return   0 - if both strings are equal
     795             :                 < 0 - if this string is less than the string argument
     796             :                 > 0 - if this string is greater than the string argument
     797             :     */
     798        7627 :     sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
     799             :     {
     800             :         return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
     801        7627 :                                                           asciiStr, asciiStrLength );
     802             :     }
     803             : 
     804             :     /**
     805             :       Perform a comparison of two strings.
     806             : 
     807             :       The result is true if and only if second string
     808             :       represents the same sequence of characters as the first string.
     809             :       Since this method is optimized for performance, the ASCII character
     810             :       values are not converted in any way. The caller has to make sure that
     811             :       all ASCII characters are in the allowed range between 0 and
     812             :       127. The ASCII string must be NULL-terminated.
     813             :       This function can't be used for language specific comparison.
     814             : 
     815             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     816             :       @return   true if the strings are equal;
     817             :                 false, otherwise.
     818             :     */
     819  1514150379 :     bool equalsAscii( const sal_Char* asciiStr ) const
     820             :     {
     821             :         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
     822  1514150379 :                                                   asciiStr ) == 0;
     823             :     }
     824             : 
     825             :     /**
     826             :       Perform a comparison of two strings.
     827             : 
     828             :       The result is true if and only if second string
     829             :       represents the same sequence of characters as the first string.
     830             :       Since this method is optimized for performance, the ASCII character
     831             :       values are not converted in any way. The caller has to make sure that
     832             :       all ASCII characters are in the allowed range between 0 and
     833             :       127. The ASCII string must be NULL-terminated and must be greater than
     834             :       or equal to asciiStrLength.
     835             :       This function can't be used for language specific comparison.
     836             : 
     837             :       @param    asciiStr         the 8-Bit ASCII character string to be compared.
     838             :       @param    asciiStrLength   the length of the ascii string
     839             :       @return   true if the strings are equal;
     840             :                 false, otherwise.
     841             :     */
     842  3811622126 :     bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
     843             :     {
     844  3811622126 :         if ( pData->length != asciiStrLength )
     845  3121343174 :             return false;
     846             : 
     847             :         return rtl_ustr_asciil_reverseEquals_WithLength(
     848   690278952 :                     pData->buffer, asciiStr, asciiStrLength );
     849             :     }
     850             : 
     851             :     /**
     852             :       Perform a ASCII lowercase comparison of two strings.
     853             : 
     854             :       The result is true if and only if second string
     855             :       represents the same sequence of characters as the first string,
     856             :       ignoring the case.
     857             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     858             :       values between 97 and 122 (ASCII a-z).
     859             :       Since this method is optimized for performance, the ASCII character
     860             :       values are not converted in any way. The caller has to make sure that
     861             :       all ASCII characters are in the allowed range between 0 and
     862             :       127. The ASCII string must be NULL-terminated.
     863             :       This function can't be used for language specific comparison.
     864             : 
     865             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     866             :       @return   true if the strings are equal;
     867             :                 false, otherwise.
     868             :     */
     869     1407126 :     bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
     870             :     {
     871     1407126 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
     872             :     }
     873             : 
     874             :     /**
     875             :       Compares two ASCII strings ignoring case
     876             : 
     877             :       The comparison is based on the numeric value of each character in
     878             :       the strings and return a value indicating their relationship.
     879             :       Since this method is optimized for performance, the ASCII character
     880             :       values are not converted in any way. The caller has to make sure that
     881             :       all ASCII characters are in the allowed range between 0 and
     882             :       127. The ASCII string must be NULL-terminated.
     883             :       This function can't be used for language specific sorting.
     884             : 
     885             :       @param  asciiStr      the 8-Bit ASCII character string to be compared.
     886             :       @return   0 - if both strings are equal
     887             :                 < 0 - if this string is less than the string argument
     888             :                 > 0 - if this string is greater than the string argument
     889             : 
     890             :       @since LibreOffice 3.5
     891             :     */
     892   282485295 :     sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
     893             :     {
     894   282485295 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
     895             :     }
     896             : 
     897             :     /**
     898             :       Perform an ASCII lowercase comparison of two strings.
     899             : 
     900             :       The result is true if and only if second string
     901             :       represents the same sequence of characters as the first string,
     902             :       ignoring the case.
     903             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     904             :       values between 97 and 122 (ASCII a-z).
     905             :       Since this method is optimized for performance, the ASCII character
     906             :       values are not converted in any way. The caller has to make sure that
     907             :       all ASCII characters are in the allowed range between 0 and 127.
     908             :       The ASCII string must be NULL-terminated and must be greater than
     909             :       or equal to asciiStrLength.
     910             :       This function can't be used for language specific comparison.
     911             : 
     912             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     913             :       @param    asciiStrLength  the length of the ascii string
     914             :       @return   true if the strings are equal;
     915             :                 false, otherwise.
     916             :     */
     917           2 :     bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
     918             :     {
     919           2 :         if ( pData->length != asciiStrLength )
     920           2 :             return false;
     921             : 
     922           0 :         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
     923             :     }
     924             : 
     925             :     /**
     926             :       Match against a substring appearing in this string.
     927             : 
     928             :       The result is true if and only if the second string appears as a substring
     929             :       of this string, at the given position.
     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 object (substring) to be compared.
     938             :       @param    asciiStrLength the length of asciiStr.
     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   true if str match with the characters in the string
     943             :                 at the given position;
     944             :                 false, otherwise.
     945             :     */
     946      240798 :     bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
     947             :     {
     948      240798 :         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     949      481596 :                                                            asciiStr, asciiStrLength ) == 0;
     950             :     }
     951             : 
     952             :     // This overload is left undefined, to detect calls of matchAsciiL that
     953             :     // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
     954             :     // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
     955             :     // platforms):
     956             : #if SAL_TYPES_SIZEOFLONG == 8
     957             :     void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
     958             : #endif
     959             : 
     960             :     /**
     961             :       Match against a substring appearing in this string, ignoring the case of
     962             :       ASCII letters.
     963             : 
     964             :       The result is true if and only if the second string appears as a substring
     965             :       of this string, at the given position.
     966             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
     967             :       values between 97 and 122 (ASCII a-z).
     968             :       Since this method is optimized for performance, the ASCII character
     969             :       values are not converted in any way. The caller has to make sure that
     970             :       all ASCII characters are in the allowed range between 0 and
     971             :       127. The ASCII string must be NULL-terminated and must be greater than or
     972             :       equal to asciiStrLength.
     973             :       This function can't be used for language specific comparison.
     974             : 
     975             :       @param    asciiStr        the 8-Bit ASCII character string to be compared.
     976             :       @param    asciiStrLength  the length of the ascii string
     977             :       @param    fromIndex       the index to start the comparion from.
     978             :                                 The index must be greater than or equal to 0
     979             :                                 and less than or equal to the string length.
     980             :       @return   true if str match with the characters in the string
     981             :                 at the given position;
     982             :                 false, otherwise.
     983             :     */
     984     4094765 :     bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
     985             :     {
     986     4094765 :         return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
     987     8189530 :                                                                           asciiStr, asciiStrLength ) == 0;
     988             :     }
     989             : 
     990             :     // This overload is left undefined, to detect calls of
     991             :     // matchIgnoreAsciiCaseAsciiL that erroneously use
     992             :     // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
     993             :     // would lead to ambiguities on 32 bit platforms):
     994             : #if SAL_TYPES_SIZEOFLONG == 8
     995             :     void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
     996             :         const;
     997             : #endif
     998             : 
     999             :     /**
    1000             :       Check whether this string starts with a given substring.
    1001             : 
    1002             :       @param str the substring to be compared
    1003             : 
    1004             :       @param rest if non-null, and this function returns true, then assign a
    1005             :       copy of the remainder of this string to *rest. Available since
    1006             :       LibreOffice 4.2
    1007             : 
    1008             :       @return true if and only if the given str appears as a substring at the
    1009             :       start of this string
    1010             : 
    1011             :       @since LibreOffice 4.0
    1012             :     */
    1013    37956315 :     bool startsWith(OUString const & str, OUString * rest = 0) const {
    1014    37956315 :         bool b = match(str, 0);
    1015    37956315 :         if (b && rest != 0) {
    1016           0 :             *rest = copy(str.getLength());
    1017             :         }
    1018    37956315 :         return b;
    1019             :     }
    1020             : 
    1021             :     /**
    1022             :      @overload
    1023             :      This function accepts an ASCII string literal as its argument.
    1024             :      @since LibreOffice 4.0
    1025             :     */
    1026             :     template< typename T >
    1027    16622914 :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(
    1028             :         T & literal, OUString * rest = 0) const
    1029             :     {
    1030             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1031             :         bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
    1032             :             && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
    1033    16622914 :                 libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1034    16622914 :         if (b && rest != 0) {
    1035      388478 :             *rest = copy(libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1036             :         }
    1037    16622914 :         return b;
    1038             :     }
    1039             : 
    1040             :     /**
    1041             :       Check whether this string starts with a given string, ignoring the case of
    1042             :       ASCII letters.
    1043             : 
    1044             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
    1045             :       values between 97 and 122 (ASCII a-z).
    1046             :       This function can't be used for language specific comparison.
    1047             : 
    1048             :       @param str the substring to be compared
    1049             : 
    1050             :       @param rest if non-null, and this function returns true, then assign a
    1051             :       copy of the remainder of this string to *rest. Available since
    1052             :       LibreOffice 4.2
    1053             : 
    1054             :       @return true if and only if the given str appears as a substring at the
    1055             :       start of this string, ignoring the case of ASCII letters ("A"--"Z" and
    1056             :       "a"--"z")
    1057             : 
    1058             :       @since LibreOffice 4.0
    1059             :     */
    1060         584 :     bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0)
    1061             :         const
    1062             :     {
    1063         584 :         bool b = matchIgnoreAsciiCase(str, 0);
    1064         584 :         if (b && rest != 0) {
    1065           0 :             *rest = copy(str.getLength());
    1066             :         }
    1067         584 :         return b;
    1068             :     }
    1069             : 
    1070             :     /**
    1071             :      @overload
    1072             :      This function accepts an ASCII string literal as its argument.
    1073             :      @since LibreOffice 4.0
    1074             :     */
    1075             :     template< typename T >
    1076             :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
    1077      226323 :     startsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
    1078             :     {
    1079             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1080             :         bool b = (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1081             :                     pData->buffer,
    1082             :                     libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, literal,
    1083      226323 :                     libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)
    1084      226323 :                 == 0);
    1085      226323 :         if (b && rest != 0) {
    1086          66 :             *rest = copy(libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1087             :         }
    1088      226323 :         return b;
    1089             :     }
    1090             : 
    1091             :     /**
    1092             :       Check whether this string ends with a given substring.
    1093             : 
    1094             :       @param str the substring to be compared
    1095             : 
    1096             :       @param rest if non-null, and this function returns true, then assign a
    1097             :       copy of the remainder of this string to *rest. Available since
    1098             :       LibreOffice 4.2
    1099             : 
    1100             :       @return true if and only if the given str appears as a substring at the
    1101             :       end of this string
    1102             : 
    1103             :       @since LibreOffice 3.6
    1104             :     */
    1105       10037 :     bool endsWith(OUString const & str, OUString * rest = 0) const {
    1106       10037 :         bool b = str.getLength() <= getLength()
    1107       10037 :             && match(str, getLength() - str.getLength());
    1108       10037 :         if (b && rest != 0) {
    1109           0 :             *rest = copy(0, getLength() - str.getLength());
    1110             :         }
    1111       10037 :         return b;
    1112             :     }
    1113             : 
    1114             :     /**
    1115             :      @overload
    1116             :      This function accepts an ASCII string literal as its argument.
    1117             :      @since LibreOffice 3.6
    1118             :     */
    1119             :     template< typename T >
    1120             :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
    1121      464744 :     endsWith(T & literal, OUString * rest = 0) const
    1122             :     {
    1123             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1124             :         bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
    1125             :             && rtl_ustr_asciil_reverseEquals_WithLength(
    1126      461469 :                 pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
    1127      926213 :                 libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1128      464744 :         if (b && rest != 0) {
    1129        6133 :             *rest = copy(
    1130             :                 0,
    1131        6133 :                 (getLength()
    1132             :                  - (libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)));
    1133             :         }
    1134      464744 :         return b;
    1135             :     }
    1136             : 
    1137             :     /**
    1138             :       Check whether this string ends with a given ASCII string.
    1139             : 
    1140             :       @param asciiStr a sequence of at least asciiStrLength ASCII characters
    1141             :           (bytes in the range 0x00--0x7F)
    1142             :       @param asciiStrLength the length of asciiStr; must be non-negative
    1143             :       @return true if this string ends with asciiStr; otherwise, false is
    1144             :       returned
    1145             : 
    1146             :       @since UDK 3.2.7
    1147             :      */
    1148          78 :     inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
    1149             :         const
    1150             :     {
    1151          78 :         return asciiStrLength <= pData->length
    1152         155 :             && rtl_ustr_asciil_reverseEquals_WithLength(
    1153          77 :                 pData->buffer + pData->length - asciiStrLength, asciiStr,
    1154         155 :                 asciiStrLength);
    1155             :     }
    1156             : 
    1157             :     /**
    1158             :       Check whether this string ends with a given string, ignoring the case of
    1159             :       ASCII letters.
    1160             : 
    1161             :       Character values between 65 and 90 (ASCII A-Z) are interpreted as
    1162             :       values between 97 and 122 (ASCII a-z).
    1163             :       This function can't be used for language specific comparison.
    1164             : 
    1165             :       @param str the substring to be compared
    1166             : 
    1167             :       @param rest if non-null, and this function returns true, then assign a
    1168             :       copy of the remainder of this string to *rest. Available since
    1169             :       LibreOffice 4.2
    1170             : 
    1171             :       @return true if and only if the given str appears as a substring at the
    1172             :       end of this string, ignoring the case of ASCII letters ("A"--"Z" and
    1173             :       "a"--"z")
    1174             : 
    1175             :       @since LibreOffice 3.6
    1176             :     */
    1177         137 :     bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0) const
    1178             :     {
    1179         137 :         bool b =  str.getLength() <= getLength()
    1180         137 :             && matchIgnoreAsciiCase(str, getLength() - str.getLength());
    1181         137 :         if (b && rest != 0) {
    1182           0 :             *rest = copy(0, getLength() - str.getLength());
    1183             :         }
    1184         137 :         return b;
    1185             :     }
    1186             : 
    1187             :     /**
    1188             :      @overload
    1189             :      This function accepts an ASCII string literal as its argument.
    1190             :      @since LibreOffice 3.6
    1191             :     */
    1192             :     template< typename T >
    1193             :     typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
    1194      195859 :     endsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
    1195             :     {
    1196             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1197             :         bool b = libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
    1198             :             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1199      195801 :                     pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ),
    1200             :                     libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, literal,
    1201      195801 :                     libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)
    1202      391660 :                 == 0);
    1203      195859 :         if (b && rest != 0) {
    1204           0 :             *rest = copy(
    1205             :                 0,
    1206           0 :                 (getLength()
    1207             :                  - (libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1)));
    1208             :         }
    1209      195859 :         return b;
    1210             :     }
    1211             : 
    1212             :     /**
    1213             :       Check whether this string ends with a given ASCII string, ignoring the
    1214             :       case of ASCII letters.
    1215             : 
    1216             :       @param asciiStr a sequence of at least asciiStrLength ASCII characters
    1217             :           (bytes in the range 0x00--0x7F)
    1218             :       @param asciiStrLength the length of asciiStr; must be non-negative
    1219             :       @return true if this string ends with asciiStr, ignoring the case of ASCII
    1220             :       letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
    1221             :      */
    1222       81348 :     inline bool endsWithIgnoreAsciiCaseAsciiL(
    1223             :         char const * asciiStr, sal_Int32 asciiStrLength) const
    1224             :     {
    1225       81348 :         return asciiStrLength <= pData->length
    1226      137301 :             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
    1227       55953 :                     pData->buffer + pData->length - asciiStrLength,
    1228       55953 :                     asciiStrLength, asciiStr, asciiStrLength)
    1229       81348 :                 == 0);
    1230             :     }
    1231             : 
    1232 10572845848 :     friend bool     operator == ( const OUString& rStr1,    const OUString& rStr2 )
    1233 10572845848 :                         { return rStr1.equals(rStr2); }
    1234       47558 :     friend bool     operator == ( const OUString& rStr1,    const sal_Unicode * pStr2 )
    1235       47558 :                         { return rStr1.compareTo( pStr2 ) == 0; }
    1236           0 :     friend bool     operator == ( const sal_Unicode * pStr1,    const OUString& rStr2 )
    1237           0 :                         { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
    1238             : 
    1239   455875220 :     friend bool     operator != ( const OUString& rStr1,        const OUString& rStr2 )
    1240   455875220 :                         { return !(operator == ( rStr1, rStr2 )); }
    1241       47233 :     friend bool     operator != ( const OUString& rStr1,    const sal_Unicode * pStr2 )
    1242       47233 :                         { return !(operator == ( rStr1, pStr2 )); }
    1243           0 :     friend bool     operator != ( const sal_Unicode * pStr1,    const OUString& rStr2 )
    1244           0 :                         { return !(operator == ( pStr1, rStr2 )); }
    1245             : 
    1246  3350381815 :     friend bool     operator <  ( const OUString& rStr1,    const OUString& rStr2 )
    1247  3350381815 :                         { return rStr1.compareTo( rStr2 ) < 0; }
    1248     7171396 :     friend bool     operator >  ( const OUString& rStr1,    const OUString& rStr2 )
    1249     7171396 :                         { return rStr1.compareTo( rStr2 ) > 0; }
    1250           0 :     friend bool     operator <= ( const OUString& rStr1,    const OUString& rStr2 )
    1251           0 :                         { return rStr1.compareTo( rStr2 ) <= 0; }
    1252      422509 :     friend bool     operator >= ( const OUString& rStr1,    const OUString& rStr2 )
    1253      422509 :                         { return rStr1.compareTo( rStr2 ) >= 0; }
    1254             : 
    1255             :     /**
    1256             :      * Compare string to an ASCII string literal.
    1257             :      *
    1258             :      * This operator is equal to calling equalsAsciiL().
    1259             :      *
    1260             :      * @since LibreOffice 3.6
    1261             :      */
    1262             :     template< typename T >
    1263  3577015853 :     friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
    1264             :     {
    1265             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1266  3577015853 :         return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
    1267             :     }
    1268             :     /**
    1269             :      * Compare string to an ASCII string literal.
    1270             :      *
    1271             :      * This operator is equal to calling equalsAsciiL().
    1272             :      *
    1273             :      * @since LibreOffice 3.6
    1274             :      */
    1275             :     template< typename T >
    1276        5271 :     friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
    1277             :     {
    1278             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1279        5271 :         return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
    1280             :     }
    1281             :     /**
    1282             :      * Compare string to an ASCII string literal.
    1283             :      *
    1284             :      * This operator is equal to calling !equalsAsciiL().
    1285             :      *
    1286             :      * @since LibreOffice 3.6
    1287             :      */
    1288             :     template< typename T >
    1289   223254692 :     friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
    1290             :     {
    1291             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1292   223254692 :         return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
    1293             :     }
    1294             :     /**
    1295             :      * Compare string to an ASCII string literal.
    1296             :      *
    1297             :      * This operator is equal to calling !equalsAsciiL().
    1298             :      *
    1299             :      * @since LibreOffice 3.6
    1300             :      */
    1301             :     template< typename T >
    1302           1 :     friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
    1303             :     {
    1304             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1305           1 :         return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
    1306             :     }
    1307             : 
    1308             : #if defined LIBO_INTERNAL_ONLY
    1309             :     /// @cond INTERNAL
    1310             : 
    1311             :     /* Comparison between OUString and OUStringLiteral.
    1312             : 
    1313             :        @since LibreOffice 5.0
    1314             :     */
    1315             : 
    1316             :     friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
    1317             :         return lhs.equalsAsciiL(rhs.data, rhs.size);
    1318             :     }
    1319             : 
    1320             :     friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
    1321             :         return !lhs.equalsAsciiL(rhs.data, rhs.size);
    1322             :     }
    1323             : 
    1324             :     friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
    1325             :         return
    1326             :             (rtl_ustr_ascii_compare_WithLength(
    1327             :                 lhs.pData->buffer, lhs.pData->length, rhs.data))
    1328             :             < 0;
    1329             :     }
    1330             : 
    1331             :     friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
    1332             :         return
    1333             :             (rtl_ustr_ascii_compare_WithLength(
    1334             :                 lhs.pData->buffer, lhs.pData->length, rhs.data))
    1335             :             <= 0;
    1336             :     }
    1337             : 
    1338             :     friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
    1339             :         return
    1340             :             (rtl_ustr_ascii_compare_WithLength(
    1341             :                 lhs.pData->buffer, lhs.pData->length, rhs.data))
    1342             :             > 0;
    1343             :     }
    1344             : 
    1345             :     friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
    1346             :         return
    1347             :             (rtl_ustr_ascii_compare_WithLength(
    1348             :                 lhs.pData->buffer, lhs.pData->length, rhs.data))
    1349             :             >= 0;
    1350             :     }
    1351             : 
    1352        5286 :     friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
    1353        5286 :         return rhs.equalsAsciiL(lhs.data, lhs.size);
    1354             :     }
    1355             : 
    1356             :     friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
    1357             :         return !rhs.equalsAsciiL(lhs.data, lhs.size);
    1358             :     }
    1359             : 
    1360             :     friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
    1361             :         return
    1362             :             (rtl_ustr_ascii_compare_WithLength(
    1363             :                 rhs.pData->buffer, rhs.pData->length, lhs.data))
    1364             :             >= 0;
    1365             :     }
    1366             : 
    1367             :     friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
    1368             :         return
    1369             :             (rtl_ustr_ascii_compare_WithLength(
    1370             :                 rhs.pData->buffer, rhs.pData->length, lhs.data))
    1371             :             > 0;
    1372             :     }
    1373             : 
    1374             :     friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
    1375             :         return
    1376             :             (rtl_ustr_ascii_compare_WithLength(
    1377             :                 rhs.pData->buffer, rhs.pData->length, lhs.data))
    1378             :             <= 0;
    1379             :     }
    1380             : 
    1381             :     friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
    1382             :         return
    1383             :             (rtl_ustr_ascii_compare_WithLength(
    1384             :                 rhs.pData->buffer, rhs.pData->length, lhs.data))
    1385             :             < 0;
    1386             :     }
    1387             : 
    1388             :     /// @endcond
    1389             : #endif
    1390             : 
    1391             :     /**
    1392             :       Returns a hashcode for this string.
    1393             : 
    1394             :       @return   a hash code value for this object.
    1395             : 
    1396             :       @see rtl::OUStringHash for convenient use of std::unordered_map
    1397             :     */
    1398   102203403 :     sal_Int32 hashCode() const
    1399             :     {
    1400   102203403 :         return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
    1401             :     }
    1402             : 
    1403             :     /**
    1404             :       Returns the index within this string of the first occurrence of the
    1405             :       specified character, starting the search at the specified index.
    1406             : 
    1407             :       @param    ch          character to be located.
    1408             :       @param    fromIndex   the index to start the search from.
    1409             :                             The index must be greater than or equal to 0
    1410             :                             and less than or equal to the string length.
    1411             :       @return   the index of the first occurrence of the character in the
    1412             :                 character sequence represented by this string that is
    1413             :                 greater than or equal to fromIndex, or
    1414             :                 -1 if the character does not occur.
    1415             :     */
    1416    30398507 :     sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
    1417             :     {
    1418    30398507 :         sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
    1419    30398507 :         return (ret < 0 ? ret : ret+fromIndex);
    1420             :     }
    1421             : 
    1422             :     /**
    1423             :       Returns the index within this string of the last occurrence of the
    1424             :       specified character, searching backward starting at the end.
    1425             : 
    1426             :       @param    ch          character to be located.
    1427             :       @return   the index of the last occurrence of the character in the
    1428             :                 character sequence represented by this string, or
    1429             :                 -1 if the character does not occur.
    1430             :     */
    1431     1196153 :     sal_Int32 lastIndexOf( sal_Unicode ch ) const
    1432             :     {
    1433     1196153 :         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
    1434             :     }
    1435             : 
    1436             :     /**
    1437             :       Returns the index within this string of the last occurrence of the
    1438             :       specified character, searching backward starting before the specified
    1439             :       index.
    1440             : 
    1441             :       @param    ch          character to be located.
    1442             :       @param    fromIndex   the index before which to start the search.
    1443             :       @return   the index of the last occurrence of the character in the
    1444             :                 character sequence represented by this string that
    1445             :                 is less than fromIndex, or -1
    1446             :                 if the character does not occur before that point.
    1447             :     */
    1448       25766 :     sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
    1449             :     {
    1450       25766 :         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
    1451             :     }
    1452             : 
    1453             :     /**
    1454             :       Returns the index within this string of the first occurrence of the
    1455             :       specified substring, starting at the specified index.
    1456             : 
    1457             :       If str doesn't include any character, always -1 is
    1458             :       returned. This is also the case, if both strings are empty.
    1459             : 
    1460             :       @param    str         the substring to search for.
    1461             :       @param    fromIndex   the index to start the search from.
    1462             :       @return   If the string argument occurs one or more times as a substring
    1463             :                 within this string at the starting index, then the index
    1464             :                 of the first character of the first such substring is
    1465             :                 returned. If it does not occur as a substring starting
    1466             :                 at fromIndex or beyond, -1 is returned.
    1467             :     */
    1468    17736595 :     sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
    1469             :     {
    1470    17736595 :         sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
    1471    35473190 :                                                         str.pData->buffer, str.pData->length );
    1472    17736595 :         return (ret < 0 ? ret : ret+fromIndex);
    1473             :     }
    1474             : 
    1475             :     /**
    1476             :      @overload
    1477             :      This function accepts an ASCII string literal as its argument.
    1478             :      @since LibreOffice 3.6
    1479             :     */
    1480             :     template< typename T >
    1481     3083314 :     typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
    1482             :     {
    1483             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1484             :         sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
    1485     3083314 :             pData->buffer + fromIndex, pData->length - fromIndex, literal,
    1486     6166628 :             libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1487     3083314 :         return ret < 0 ? ret : ret + fromIndex;
    1488             :     }
    1489             : 
    1490             :     /**
    1491             :        Returns the index within this string of the first occurrence of the
    1492             :        specified ASCII substring, starting at the specified index.
    1493             : 
    1494             :        @param str
    1495             :        the substring to be searched for.  Need not be null-terminated, but must
    1496             :        be at least as long as the specified len.  Must only contain characters
    1497             :        in the ASCII range 0x00--7F.
    1498             : 
    1499             :        @param len
    1500             :        the length of the substring; must be non-negative.
    1501             : 
    1502             :        @param fromIndex
    1503             :        the index to start the search from.  Must be in the range from zero to
    1504             :        the length of this string, inclusive.
    1505             : 
    1506             :        @return
    1507             :        the index (starting at 0) of the first character of the first occurrence
    1508             :        of the substring within this string starting at the given fromIndex, or
    1509             :        -1 if the substring does not occur.  If len is zero, -1 is returned.
    1510             : 
    1511             :        @since UDK 3.2.7
    1512             :     */
    1513     1136654 :     sal_Int32 indexOfAsciiL(
    1514             :         char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
    1515             :     {
    1516             :         sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
    1517     1136654 :             pData->buffer + fromIndex, pData->length - fromIndex, str, len);
    1518     1136654 :         return ret < 0 ? ret : ret + fromIndex;
    1519             :     }
    1520             : 
    1521             :     // This overload is left undefined, to detect calls of indexOfAsciiL that
    1522             :     // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
    1523             :     // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
    1524             :     // platforms):
    1525             : #if SAL_TYPES_SIZEOFLONG == 8
    1526             :     void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
    1527             : #endif
    1528             : 
    1529             :     /**
    1530             :       Returns the index within this string of the last occurrence of
    1531             :       the specified substring, searching backward starting at the end.
    1532             : 
    1533             :       The returned index indicates the starting index of the substring
    1534             :       in this string.
    1535             :       If str doesn't include any character, always -1 is
    1536             :       returned. This is also the case, if both strings are empty.
    1537             : 
    1538             :       @param    str         the substring to search for.
    1539             :       @return   If the string argument occurs one or more times as a substring
    1540             :                 within this string, then the index of the first character of
    1541             :                 the last such substring is returned. If it does not occur as
    1542             :                 a substring, -1 is returned.
    1543             :     */
    1544      134671 :     sal_Int32 lastIndexOf( const OUString & str ) const
    1545             :     {
    1546             :         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
    1547      134671 :                                                    str.pData->buffer, str.pData->length );
    1548             :     }
    1549             : 
    1550             :     /**
    1551             :       Returns the index within this string of the last occurrence of
    1552             :       the specified substring, searching backward starting before the specified
    1553             :       index.
    1554             : 
    1555             :       The returned index indicates the starting index of the substring
    1556             :       in this string.
    1557             :       If str doesn't include any character, always -1 is
    1558             :       returned. This is also the case, if both strings are empty.
    1559             : 
    1560             :       @param    str         the substring to search for.
    1561             :       @param    fromIndex   the index before which to start the search.
    1562             :       @return   If the string argument occurs one or more times as a substring
    1563             :                 within this string before the starting index, then the index
    1564             :                 of the first character of the last such substring is
    1565             :                 returned. Otherwise, -1 is returned.
    1566             :     */
    1567           5 :     sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
    1568             :     {
    1569             :         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
    1570           5 :                                                    str.pData->buffer, str.pData->length );
    1571             :     }
    1572             : 
    1573             :     /**
    1574             :      @overload
    1575             :      This function accepts an ASCII string literal as its argument.
    1576             :      @since LibreOffice 3.6
    1577             :     */
    1578             :     template< typename T >
    1579        3381 :     typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
    1580             :     {
    1581             :         assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1582             :         return rtl_ustr_lastIndexOfAscii_WithLength(
    1583        3381 :             pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
    1584             :     }
    1585             : 
    1586             :     /**
    1587             :        Returns the index within this string of the last occurrence of the
    1588             :        specified ASCII substring.
    1589             : 
    1590             :        @param str
    1591             :        the substring to be searched for.  Need not be null-terminated, but must
    1592             :        be at least as long as the specified len.  Must only contain characters
    1593             :        in the ASCII range 0x00--7F.
    1594             : 
    1595             :        @param len
    1596             :        the length of the substring; must be non-negative.
    1597             : 
    1598             :        @return
    1599             :        the index (starting at 0) of the first character of the last occurrence
    1600             :        of the substring within this string, or -1 if the substring does not
    1601             :        occur.  If len is zero, -1 is returned.
    1602             : 
    1603             :        @since UDK 3.2.7
    1604             :     */
    1605           3 :     sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
    1606             :     {
    1607             :         return rtl_ustr_lastIndexOfAscii_WithLength(
    1608           3 :             pData->buffer, pData->length, str, len);
    1609             :     }
    1610             : 
    1611             :     /**
    1612             :       Returns a new string that is a substring of this string.
    1613             : 
    1614             :       The substring begins at the specified beginIndex. If
    1615             :       beginIndex is negative or be greater than the length of
    1616             :       this string, behaviour is undefined.
    1617             : 
    1618             :       @param     beginIndex   the beginning index, inclusive.
    1619             :       @return    the specified substring.
    1620             :     */
    1621     3397337 :     SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
    1622             :     {
    1623     3397337 :         rtl_uString *pNew = 0;
    1624     3397337 :         rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
    1625     3397337 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1626             :     }
    1627             : 
    1628             :     /**
    1629             :       Returns a new string that is a substring of this string.
    1630             : 
    1631             :       The substring begins at the specified beginIndex and contains count
    1632             :       characters.  If either beginIndex or count are negative,
    1633             :       or beginIndex + count are greater than the length of this string
    1634             :       then behaviour is undefined.
    1635             : 
    1636             :       @param     beginIndex   the beginning index, inclusive.
    1637             :       @param     count        the number of characters.
    1638             :       @return    the specified substring.
    1639             :     */
    1640   212056170 :     SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
    1641             :     {
    1642   212056170 :         rtl_uString *pNew = 0;
    1643   212056170 :         rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
    1644   212056171 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1645             :     }
    1646             : 
    1647             :     /**
    1648             :       Concatenates the specified string to the end of this string.
    1649             : 
    1650             :       @param    str   the string that is concatenated to the end
    1651             :                       of this string.
    1652             :       @return   a string that represents the concatenation of this string
    1653             :                 followed by the string argument.
    1654             :     */
    1655         300 :     SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
    1656             :     {
    1657         300 :         rtl_uString* pNew = 0;
    1658         300 :         rtl_uString_newConcat( &pNew, pData, str.pData );
    1659         300 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1660             :     }
    1661             : 
    1662             : #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
    1663             :     friend OUString operator+( const OUString& rStr1, const OUString& rStr2  )
    1664             :     {
    1665             :         return rStr1.concat( rStr2 );
    1666             :     }
    1667             : #endif
    1668             : 
    1669             :     /**
    1670             :       Returns a new string resulting from replacing n = count characters
    1671             :       from position index in this string with newStr.
    1672             : 
    1673             :       @param  index   the replacing index in str.
    1674             :                       The index must be greater than or equal to 0 and
    1675             :                       less than or equal to the length of the string.
    1676             :       @param  count   the count of characters that will be replaced
    1677             :                       The count must be greater than or equal to 0 and
    1678             :                       less than or equal to the length of the string minus index.
    1679             :       @param  newStr  the new substring.
    1680             :       @return the new string.
    1681             :     */
    1682     2392036 :     SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
    1683             :     {
    1684     2392036 :         rtl_uString* pNew = 0;
    1685     2392036 :         rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
    1686     2392036 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1687             :     }
    1688             : 
    1689             :     /**
    1690             :       Returns a new string resulting from replacing all occurrences of
    1691             :       oldChar in this string with newChar.
    1692             : 
    1693             :       If the character oldChar does not occur in the character sequence
    1694             :       represented by this object, then the string is assigned with
    1695             :       str.
    1696             : 
    1697             :       @param    oldChar     the old character.
    1698             :       @param    newChar     the new character.
    1699             :       @return   a string derived from this string by replacing every
    1700             :                 occurrence of oldChar with newChar.
    1701             :     */
    1702    85488759 :     SAL_WARN_UNUSED_RESULT OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const
    1703             :     {
    1704    85488759 :         rtl_uString* pNew = 0;
    1705    85488759 :         rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
    1706    85488759 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1707             :     }
    1708             : 
    1709             :     /**
    1710             :       Returns a new string resulting from replacing the first occurrence of a
    1711             :       given substring with another substring.
    1712             : 
    1713             :       @param from  the substring to be replaced
    1714             : 
    1715             :       @param to  the replacing substring
    1716             : 
    1717             :       @param[in,out] index  pointer to a start index; if the pointer is
    1718             :       non-null: upon entry to the function, its value is the index into this
    1719             :       string at which to start searching for the \p from substring, the value
    1720             :       must be non-negative and not greater than this string's length; upon exiting
    1721             :       the function its value is the index into this string at which the
    1722             :       replacement took place or -1 if no replacement took place; if the pointer
    1723             :       is null, searching always starts at index 0
    1724             : 
    1725             :       @since LibreOffice 3.6
    1726             :     */
    1727        2027 :     SAL_WARN_UNUSED_RESULT OUString replaceFirst(
    1728             :         OUString const & from, OUString const & to, sal_Int32 * index = 0) const
    1729             :     {
    1730        2027 :         rtl_uString * s = 0;
    1731        2027 :         sal_Int32 i = 0;
    1732             :         rtl_uString_newReplaceFirst(
    1733        2027 :             &s, pData, from.pData, to.pData, index == 0 ? &i : index);
    1734        2027 :         return OUString(s, SAL_NO_ACQUIRE);
    1735             :     }
    1736             : 
    1737             :     /**
    1738             :       Returns a new string resulting from replacing the first occurrence of a
    1739             :       given substring with another substring.
    1740             : 
    1741             :       @param from  ASCII string literal, the substring to be replaced
    1742             : 
    1743             :       @param to  the replacing substring
    1744             : 
    1745             :       @param[in,out] index  pointer to a start index; if the pointer is
    1746             :       non-null: upon entry to the function, its value is the index into the this
    1747             :       string at which to start searching for the \p from substring, the value
    1748             :       must be non-negative and not greater than this string's length; upon exiting
    1749             :       the function its value is the index into this string at which the
    1750             :       replacement took place or -1 if no replacement took place; if the pointer
    1751             :       is null, searching always starts at index 0
    1752             : 
    1753             :       @since LibreOffice 3.6
    1754             :     */
    1755             :     template< typename T >
    1756       17919 :     SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
    1757             :                                                                                                         sal_Int32 * index = 0) const
    1758             :     {
    1759       17919 :         rtl_uString * s = 0;
    1760       17919 :         sal_Int32 i = 0;
    1761             :         assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1762       17919 :         rtl_uString_newReplaceFirstAsciiL(
    1763       17919 :             &s, pData, from, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, to.pData, index == 0 ? &i : index);
    1764       17919 :         return OUString(s, SAL_NO_ACQUIRE);
    1765             :     }
    1766             : 
    1767             :     /**
    1768             :       Returns a new string resulting from replacing the first occurrence of a
    1769             :       given substring with another substring.
    1770             : 
    1771             :       @param from  ASCII string literal, the substring to be replaced
    1772             : 
    1773             :       @param to  ASCII string literal, the substring to be replaced
    1774             : 
    1775             :       @param[in,out] index  pointer to a start index; if the pointer is
    1776             :       non-null: upon entry to the function, its value is the index into the this
    1777             :       string at which to start searching for the \p from substring, the value
    1778             :       must be non-negative and not greater than this string's length; upon exiting
    1779             :       the function its value is the index into this string at which the
    1780             :       replacement took place or -1 if no replacement took place; if the pointer
    1781             :       is null, searching always starts at index 0
    1782             : 
    1783             :       @since LibreOffice 3.6
    1784             :     */
    1785             :     template< typename T1, typename T2 >
    1786             :         SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
    1787         708 :         replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
    1788             :     {
    1789         708 :         rtl_uString * s = 0;
    1790         708 :         sal_Int32 i = 0;
    1791             :         assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T1 >::size - 1 );
    1792             :         assert( strlen( to ) == libreoffice_internal::ConstCharArrayDetector< T2 >::size - 1 );
    1793         708 :         rtl_uString_newReplaceFirstAsciiLAsciiL(
    1794             :             &s, pData, from, libreoffice_internal::ConstCharArrayDetector< T1, void >::size - 1, to,
    1795         708 :             libreoffice_internal::ConstCharArrayDetector< T2, void >::size - 1, index == 0 ? &i : index);
    1796         708 :         return OUString(s, SAL_NO_ACQUIRE);
    1797             :     }
    1798             : 
    1799             :     /**
    1800             :       Returns a new string resulting from replacing all occurrences of a given
    1801             :       substring with another substring.
    1802             : 
    1803             :       Replacing subsequent occurrences picks up only after a given replacement.
    1804             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1805             : 
    1806             :       @param from  the substring to be replaced
    1807             : 
    1808             :       @param to  the replacing substring
    1809             : 
    1810             :       @param fromIndex  the position in the string where we will begin searching
    1811             : 
    1812             :       @since LibreOffice 4.0
    1813             :     */
    1814   171109973 :     SAL_WARN_UNUSED_RESULT OUString replaceAll(
    1815             :         OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
    1816             :     {
    1817   171109973 :         rtl_uString * s = 0;
    1818   171109973 :         rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
    1819   171109973 :         return OUString(s, SAL_NO_ACQUIRE);
    1820             :     }
    1821             : 
    1822             :     /**
    1823             :       Returns a new string resulting from replacing all occurrences of a given
    1824             :       substring with another substring.
    1825             : 
    1826             :       Replacing subsequent occurrences picks up only after a given replacement.
    1827             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1828             : 
    1829             :       @param from ASCII string literal, the substring to be replaced
    1830             : 
    1831             :       @param to  the replacing substring
    1832             : 
    1833             :       @since LibreOffice 3.6
    1834             :     */
    1835             :     template< typename T >
    1836       16259 :     SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll( T& from, OUString const & to) const
    1837             :     {
    1838       16259 :         rtl_uString * s = 0;
    1839             :         assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
    1840       16259 :         rtl_uString_newReplaceAllAsciiL(&s, pData, from, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, to.pData);
    1841       16259 :         return OUString(s, SAL_NO_ACQUIRE);
    1842             :     }
    1843             : 
    1844             :     /**
    1845             :       Returns a new string resulting from replacing all occurrences of a given
    1846             :       substring with another substring.
    1847             : 
    1848             :       Replacing subsequent occurrences picks up only after a given replacement.
    1849             :       That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
    1850             : 
    1851             :       @param from  ASCII string literal, the substring to be replaced
    1852             : 
    1853             :       @param to  ASCII string literal, the substring to be replaced
    1854             : 
    1855             :       @since LibreOffice 3.6
    1856             :     */
    1857             :     template< typename T1, typename T2 >
    1858             :     SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
    1859       13606 :         replaceAll( T1& from, T2& to ) const
    1860             :     {
    1861       13606 :         rtl_uString * s = 0;
    1862             :         assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T1 >::size - 1 );
    1863             :         assert( strlen( to ) == libreoffice_internal::ConstCharArrayDetector< T2 >::size - 1 );
    1864       13606 :         rtl_uString_newReplaceAllAsciiLAsciiL(
    1865             :             &s, pData, from, libreoffice_internal::ConstCharArrayDetector< T1, void >::size - 1,
    1866       13606 :             to, libreoffice_internal::ConstCharArrayDetector< T2, void >::size - 1);
    1867       13606 :         return OUString(s, SAL_NO_ACQUIRE);
    1868             :     }
    1869             : 
    1870             :     /**
    1871             :       Converts from this string all ASCII uppercase characters (65-90)
    1872             :       to ASCII lowercase characters (97-122).
    1873             : 
    1874             :       This function can't be used for language specific conversion.
    1875             :       If the string doesn't contain characters which must be converted,
    1876             :       then the new string is assigned with str.
    1877             : 
    1878             :       @return   the string, converted to ASCII lowercase.
    1879             :     */
    1880     4102722 :     SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
    1881             :     {
    1882     4102722 :         rtl_uString* pNew = 0;
    1883     4102722 :         rtl_uString_newToAsciiLowerCase( &pNew, pData );
    1884     4102722 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1885             :     }
    1886             : 
    1887             :     /**
    1888             :       Converts from this string all ASCII lowercase characters (97-122)
    1889             :       to ASCII uppercase characters (65-90).
    1890             : 
    1891             :       This function can't be used for language specific conversion.
    1892             :       If the string doesn't contain characters which must be converted,
    1893             :       then the new string is assigned with str.
    1894             : 
    1895             :       @return   the string, converted to ASCII uppercase.
    1896             :     */
    1897     1609574 :     SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const
    1898             :     {
    1899     1609574 :         rtl_uString* pNew = 0;
    1900     1609574 :         rtl_uString_newToAsciiUpperCase( &pNew, pData );
    1901     1609574 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1902             :     }
    1903             : 
    1904             :     /**
    1905             :       Returns a new string resulting from removing white space from both ends
    1906             :       of the string.
    1907             : 
    1908             :       All characters that have codes less than or equal to
    1909             :       32 (the space character) are considered to be white space.
    1910             :       If the string doesn't contain white spaces at both ends,
    1911             :       then the new string is assigned with str.
    1912             : 
    1913             :       @return   the string, with white space removed from the front and end.
    1914             :     */
    1915      235053 :     SAL_WARN_UNUSED_RESULT OUString trim() const
    1916             :     {
    1917      235053 :         rtl_uString* pNew = 0;
    1918      235053 :         rtl_uString_newTrim( &pNew, pData );
    1919      235053 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1920             :     }
    1921             : 
    1922             :     /**
    1923             :       Returns a token in the string.
    1924             : 
    1925             :       Example:
    1926             :         sal_Int32 nIndex = 0;
    1927             :         do
    1928             :         {
    1929             :             ...
    1930             :             OUString aToken = aStr.getToken( 0, ';', nIndex );
    1931             :             ...
    1932             :         }
    1933             :         while ( nIndex >= 0 );
    1934             : 
    1935             :       @param    token       the number of the token to return
    1936             :       @param    cTok        the character which separate the tokens.
    1937             :       @param    index       the position at which the token is searched in the
    1938             :                             string.
    1939             :                             The index must not be greater than the length of the
    1940             :                             string.
    1941             :                             This param is set to the position of the
    1942             :                             next token or to -1, if it is the last token.
    1943             :       @return   the token; if either token or index is negative, an empty token
    1944             :                 is returned (and index is set to -1)
    1945             :     */
    1946    13539787 :     OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
    1947             :     {
    1948    13539787 :         rtl_uString * pNew = 0;
    1949    13539787 :         index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
    1950    13539789 :         return OUString( pNew, SAL_NO_ACQUIRE );
    1951             :     }
    1952             : 
    1953             :     /**
    1954             :       Returns a token from the string.
    1955             : 
    1956             :       The same as getToken(sal_Int32, sal_Unicode, sal_Int32 &), but always
    1957             :       passing in 0 as the start index in the third argument.
    1958             : 
    1959             :       @param count  the number of the token to return, starting with 0
    1960             :       @param separator  the character which separates the tokens
    1961             : 
    1962             :       @return  the given token, or an empty string
    1963             : 
    1964             :       @since LibreOffice 3.6
    1965             :      */
    1966      112013 :     OUString getToken(sal_Int32 count, sal_Unicode separator) const {
    1967      112013 :         sal_Int32 n = 0;
    1968      112013 :         return getToken(count, separator, n);
    1969             :     }
    1970             : 
    1971             :     /**
    1972             :       Returns the Boolean value from this string.
    1973             : 
    1974             :       This function can't be used for language specific conversion.
    1975             : 
    1976             :       @return   true, if the string is 1 or "True" in any ASCII case.
    1977             :                 false in any other case.
    1978             :     */
    1979        6151 :     bool toBoolean() const
    1980             :     {
    1981        6151 :         return rtl_ustr_toBoolean( pData->buffer );
    1982             :     }
    1983             : 
    1984             :     /**
    1985             :       Returns the first character from this string.
    1986             : 
    1987             :       @return   the first character from this string or 0, if this string
    1988             :                 is emptry.
    1989             :     */
    1990      153936 :     sal_Unicode toChar() const
    1991             :     {
    1992      153936 :         return pData->buffer[0];
    1993             :     }
    1994             : 
    1995             :     /**
    1996             :       Returns the int32 value from this string.
    1997             : 
    1998             :       This function can't be used for language specific conversion.
    1999             : 
    2000             :       @param    radix       the radix (between 2 and 36)
    2001             :       @return   the int32 represented from this string.
    2002             :                 0 if this string represents no number or one of too large
    2003             :                 magnitude.
    2004             :     */
    2005      656945 :     sal_Int32 toInt32( sal_Int16 radix = 10 ) const
    2006             :     {
    2007      656945 :         return rtl_ustr_toInt32( pData->buffer, radix );
    2008             :     }
    2009             : 
    2010             :     /**
    2011             :       Returns the uint32 value from this string.
    2012             : 
    2013             :       This function can't be used for language specific conversion.
    2014             : 
    2015             :       @param    radix       the radix (between 2 and 36)
    2016             :       @return   the uint32 represented from this string.
    2017             :                 0 if this string represents no number or one of too large
    2018             :                 magnitude.
    2019             : 
    2020             :       @since LibreOffice 4.2
    2021             :     */
    2022       28138 :     sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
    2023             :     {
    2024       28138 :         return rtl_ustr_toUInt32( pData->buffer, radix );
    2025             :     }
    2026             : 
    2027             :     /**
    2028             :       Returns the int64 value from this string.
    2029             : 
    2030             :       This function can't be used for language specific conversion.
    2031             : 
    2032             :       @param    radix       the radix (between 2 and 36)
    2033             :       @return   the int64 represented from this string.
    2034             :                 0 if this string represents no number or one of too large
    2035             :                 magnitude.
    2036             :     */
    2037      124799 :     sal_Int64 toInt64( sal_Int16 radix = 10 ) const
    2038             :     {
    2039      124799 :         return rtl_ustr_toInt64( pData->buffer, radix );
    2040             :     }
    2041             : 
    2042             :     /**
    2043             :       Returns the uint64 value from this string.
    2044             : 
    2045             :       This function can't be used for language specific conversion.
    2046             : 
    2047             :       @param    radix       the radix (between 2 and 36)
    2048             :       @return   the uint64 represented from this string.
    2049             :                 0 if this string represents no number or one of too large
    2050             :                 magnitude.
    2051             : 
    2052             :       @since LibreOffice 4.1
    2053             :     */
    2054           3 :     sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
    2055             :     {
    2056           3 :         return rtl_ustr_toUInt64( pData->buffer, radix );
    2057             :     }
    2058             : 
    2059             :     /**
    2060             :       Returns the float value from this string.
    2061             : 
    2062             :       This function can't be used for language specific conversion.
    2063             : 
    2064             :       @return   the float represented from this string.
    2065             :                 0.0 if this string represents no number.
    2066             :     */
    2067         116 :     float toFloat() const
    2068             :     {
    2069         116 :         return rtl_ustr_toFloat( pData->buffer );
    2070             :     }
    2071             : 
    2072             :     /**
    2073             :       Returns the double value from this string.
    2074             : 
    2075             :       This function can't be used for language specific conversion.
    2076             : 
    2077             :       @return   the double represented from this string.
    2078             :                 0.0 if this string represents no number.
    2079             :     */
    2080       31534 :     double toDouble() const
    2081             :     {
    2082       31534 :         return rtl_ustr_toDouble( pData->buffer );
    2083             :     }
    2084             : 
    2085             : 
    2086             :     /**
    2087             :        Return a canonical representation for a string.
    2088             : 
    2089             :        A pool of strings, initially empty is maintained privately
    2090             :        by the string class. On invocation, if present in the pool
    2091             :        the original string will be returned. Otherwise this string,
    2092             :        or a copy thereof will be added to the pool and returned.
    2093             : 
    2094             :        @return
    2095             :        a version of the string from the pool.
    2096             : 
    2097             :        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
    2098             : 
    2099             :        @since UDK 3.2.7
    2100             :     */
    2101       38965 :     OUString intern() const
    2102             :     {
    2103       38965 :         rtl_uString * pNew = 0;
    2104       38965 :         rtl_uString_intern( &pNew, pData );
    2105       38965 :         if (pNew == 0) {
    2106           0 :             throw std::bad_alloc();
    2107             :         }
    2108       38965 :         return OUString( pNew, SAL_NO_ACQUIRE );
    2109             :     }
    2110             : 
    2111             :     /**
    2112             :        Return a canonical representation for a converted string.
    2113             : 
    2114             :        A pool of strings, initially empty is maintained privately
    2115             :        by the string class. On invocation, if present in the pool
    2116             :        the original string will be returned. Otherwise this string,
    2117             :        or a copy thereof will be added to the pool and returned.
    2118             : 
    2119             :        @param    value           a 8-Bit character array.
    2120             :        @param    length          the number of character which should be converted.
    2121             :                                  The 8-Bit character array length must be
    2122             :                                  greater than or equal to this value.
    2123             :        @param    encoding        the text encoding from which the 8-Bit character
    2124             :                                  sequence should be converted.
    2125             :        @param    convertFlags    flags which controls the conversion.
    2126             :                                  see RTL_TEXTTOUNICODE_FLAGS_...
    2127             :        @param    pInfo           pointer to return conversion status or NULL.
    2128             : 
    2129             :        @return
    2130             :        a version of the converted string from the pool.
    2131             : 
    2132             :        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
    2133             : 
    2134             :        @since UDK 3.2.7
    2135             :     */
    2136      978381 :     static OUString intern( const sal_Char * value, sal_Int32 length,
    2137             :                             rtl_TextEncoding encoding,
    2138             :                             sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
    2139             :                             sal_uInt32 *pInfo = NULL )
    2140             :     {
    2141      978381 :         rtl_uString * pNew = 0;
    2142             :         rtl_uString_internConvert( &pNew, value, length, encoding,
    2143      978381 :                                    convertFlags, pInfo );
    2144      978381 :         if (pNew == 0) {
    2145           0 :             throw std::bad_alloc();
    2146             :         }
    2147      978381 :         return OUString( pNew, SAL_NO_ACQUIRE );
    2148             :     }
    2149             : 
    2150             :     /**
    2151             :       Converts to an OString, signalling failure.
    2152             : 
    2153             :       @param pTarget
    2154             :       An out parameter receiving the converted OString.  Must not be null; the
    2155             :       contents are not modified if conversion fails (convertToOString returns
    2156             :       false).
    2157             : 
    2158             :       @param nEncoding
    2159             :       The text encoding to convert into.  Must be an octet encoding (i.e.,
    2160             :       rtl_isOctetTextEncoding(nEncoding) must return true).
    2161             : 
    2162             :       @param nFlags
    2163             :       A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the
    2164             :       conversion (see rtl_convertUnicodeToText).  RTL_UNICODETOTEXT_FLAGS_FLUSH
    2165             :       need not be included, it is implicitly assumed.  Typical uses are either
    2166             :       RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
    2167             :       RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot
    2168             :       be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS
    2169             :       (make a best efforts conversion).
    2170             : 
    2171             :       @return
    2172             :       True if the conversion succeeded, false otherwise.
    2173             :      */
    2174    85894239 :     inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
    2175             :                                 sal_uInt32 nFlags) const
    2176             :     {
    2177             :         return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
    2178    85894239 :                                             pData->length, nEncoding, nFlags);
    2179             :     }
    2180             : 
    2181             :     /** Iterate through this string based on code points instead of UTF-16 code
    2182             :         units.
    2183             : 
    2184             :         See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
    2185             :         definitions of the various terms used in this description.
    2186             : 
    2187             :         This string is interpreted as a sequence of zero or more UTF-16 code
    2188             :         units.  For each index into this sequence (from zero to one less than
    2189             :         the length of the sequence, inclusive), a code point represented
    2190             :         starting at the given index is computed as follows:
    2191             : 
    2192             :         - If the UTF-16 code unit addressed by the index constitutes a
    2193             :         well-formed UTF-16 code unit sequence, the computed code point is the
    2194             :         scalar value encoded by that UTF-16 code unit sequence.
    2195             : 
    2196             :         - Otherwise, if the index is at least two UTF-16 code units away from
    2197             :         the end of the sequence, and the sequence of two UTF-16 code units
    2198             :         addressed by the index constitutes a well-formed UTF-16 code unit
    2199             :         sequence, the computed code point is the scalar value encoded by that
    2200             :         UTF-16 code unit sequence.
    2201             : 
    2202             :         - Otherwise, the computed code point is the UTF-16 code unit addressed
    2203             :         by the index.  (This last case catches unmatched surrogates as well as
    2204             :         indices pointing into the middle of surrogate pairs.)
    2205             : 
    2206             :         @param indexUtf16
    2207             :         pointer to a UTF-16 based index into this string; must not be null.  On
    2208             :         entry, the index must be in the range from zero to the length of this
    2209             :         string (in UTF-16 code units), inclusive.  Upon successful return, the
    2210             :         index will be updated to address the UTF-16 code unit that is the given
    2211             :         incrementCodePoints away from the initial index.
    2212             : 
    2213             :         @param incrementCodePoints
    2214             :         the number of code points to move the given *indexUtf16.  If
    2215             :         non-negative, moving is done after determining the code point at the
    2216             :         index.  If negative, moving is done before determining the code point
    2217             :         at the (then updated) index.  The value must be such that the resulting
    2218             :         UTF-16 based index is in the range from zero to the length of this
    2219             :         string (in UTF-16 code units), inclusive.
    2220             : 
    2221             :         @return
    2222             :         the code point (an integer in the range from 0 to 0x10FFFF, inclusive)
    2223             :         that is represented within this string starting at the index computed as
    2224             :         follows:  If incrementCodePoints is non-negative, the index is the
    2225             :         initial value of *indexUtf16; if incrementCodePoints is negative, the
    2226             :         index is the updated value of *indexUtf16.  In either case, the computed
    2227             :         index must be in the range from zero to one less than the length of this
    2228             :         string (in UTF-16 code units), inclusive.
    2229             : 
    2230             :         @since UDK 3.2.7
    2231             :     */
    2232  3724359508 :     inline sal_uInt32 iterateCodePoints(
    2233             :         sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
    2234             :     {
    2235             :         return rtl_uString_iterateCodePoints(
    2236  3724359508 :             pData, indexUtf16, incrementCodePoints);
    2237             :     }
    2238             : 
    2239             :     /**
    2240             :      * Convert an OString to an OUString, assuming that the OString is
    2241             :      * UTF-8-encoded.
    2242             :      *
    2243             :      * @param rSource
    2244             :      * an OString to convert
    2245             :      *
    2246             :      * @since LibreOffice 4.4
    2247             :      */
    2248      158609 :     static inline OUString fromUtf8(const OString& rSource)
    2249             :     {
    2250      158609 :         OUString aTarget;
    2251             :         bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
    2252             :                                                    rSource.getStr(),
    2253             :                                                    rSource.getLength(),
    2254             :                                                    RTL_TEXTENCODING_UTF8,
    2255      158609 :                                                    RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR);
    2256             :         (void) bSuccess;
    2257             :         assert(bSuccess);
    2258      158609 :         return aTarget;
    2259             :     }
    2260             : 
    2261             :     /**
    2262             :      * Convert this string to an OString, assuming that the string can be
    2263             :      * UTF-8-encoded successfully.
    2264             :      *
    2265             :      * In other words, you must not use this method on a random sequence of
    2266             :      * UTF-16 code units, but only at places where it is assumed that the
    2267             :      * content is a proper string.
    2268             :      *
    2269             :      * @since LibreOffice 4.4
    2270             :      */
    2271       23881 :     inline OString toUtf8() const
    2272             :     {
    2273       23881 :         OString aTarget;
    2274             :         bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
    2275             :                                                    getStr(),
    2276             :                                                    getLength(),
    2277             :                                                    RTL_TEXTENCODING_UTF8,
    2278       23881 :                                                    RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR);
    2279             :         (void) bSuccess;
    2280             :         assert(bSuccess);
    2281       23881 :         return aTarget;
    2282             :     }
    2283             : 
    2284             :     /**
    2285             :       Returns the string representation of the integer argument.
    2286             : 
    2287             :       This function can't be used for language specific conversion.
    2288             : 
    2289             :       @param    i           an integer value
    2290             :       @param    radix       the radix (between 2 and 36)
    2291             :       @return   a string with the string representation of the argument.
    2292             :       @since LibreOffice 4.1
    2293             :     */
    2294      993146 :     static OUString number( int i, sal_Int16 radix = 10 )
    2295             :     {
    2296             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
    2297      993146 :         rtl_uString* pNewData = 0;
    2298      993146 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
    2299      993146 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2300             :     }
    2301             :     /// @overload
    2302             :     /// @since LibreOffice 4.1
    2303       31209 :     static OUString number( unsigned int i, sal_Int16 radix = 10 )
    2304             :     {
    2305       31209 :         return number( static_cast< unsigned long long >( i ), radix );
    2306             :     }
    2307             :     /// @overload
    2308             :     /// @since LibreOffice 4.1
    2309     1029365 :     static OUString number( long i, sal_Int16 radix = 10)
    2310             :     {
    2311     1029365 :         return number( static_cast< long long >( i ), radix );
    2312             :     }
    2313             :     /// @overload
    2314             :     /// @since LibreOffice 4.1
    2315       77027 :     static OUString number( unsigned long i, sal_Int16 radix = 10 )
    2316             :     {
    2317       77027 :         return number( static_cast< unsigned long long >( i ), radix );
    2318             :     }
    2319             :     /// @overload
    2320             :     /// @since LibreOffice 4.1
    2321     1029366 :     static OUString number( long long ll, sal_Int16 radix = 10 )
    2322             :     {
    2323             :         sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64];
    2324     1029366 :         rtl_uString* pNewData = 0;
    2325     1029366 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
    2326     1029366 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2327             :     }
    2328             :     /// @overload
    2329             :     /// @since LibreOffice 4.1
    2330      108237 :     static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
    2331             :     {
    2332             :         sal_Unicode aBuf[RTL_STR_MAX_VALUEOFUINT64];
    2333      108237 :         rtl_uString* pNewData = 0;
    2334      108237 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
    2335      108237 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2336             :     }
    2337             : 
    2338             :     /**
    2339             :       Returns the string representation of the float argument.
    2340             : 
    2341             :       This function can't be used for language specific conversion.
    2342             : 
    2343             :       @param    f           a float.
    2344             :       @return   a string with the string representation of the argument.
    2345             :       @since LibreOffice 4.1
    2346             :     */
    2347          61 :     static OUString number( float f )
    2348             :     {
    2349             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
    2350          61 :         rtl_uString* pNewData = 0;
    2351          61 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
    2352          61 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2353             :     }
    2354             : 
    2355             :     /**
    2356             :       Returns the string representation of the double argument.
    2357             : 
    2358             :       This function can't be used for language specific conversion.
    2359             : 
    2360             :       @param    d           a double.
    2361             :       @return   a string with the string representation of the argument.
    2362             :       @since LibreOffice 4.1
    2363             :     */
    2364       97063 :     static OUString number( double d )
    2365             :     {
    2366             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
    2367       97063 :         rtl_uString* pNewData = 0;
    2368       97063 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
    2369       97063 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2370             :     }
    2371             : 
    2372             :     /**
    2373             :       Returns the string representation of the sal_Bool argument.
    2374             : 
    2375             :       If the sal_Bool is true, the string "true" is returned.
    2376             :       If the sal_Bool is false, the string "false" is returned.
    2377             :       This function can't be used for language specific conversion.
    2378             : 
    2379             :       @param    b   a sal_Bool.
    2380             :       @return   a string with the string representation of the argument.
    2381             :       @deprecated use boolean()
    2382             :     */
    2383             :     SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
    2384             :     {
    2385             :         return boolean(b);
    2386             :     }
    2387             : 
    2388             :     /**
    2389             :       Returns the string representation of the boolean argument.
    2390             : 
    2391             :       If the argument is true, the string "true" is returned.
    2392             :       If the argument is false, the string "false" is returned.
    2393             :       This function can't be used for language specific conversion.
    2394             : 
    2395             :       @param    b   a bool.
    2396             :       @return   a string with the string representation of the argument.
    2397             :       @since LibreOffice 4.1
    2398             :     */
    2399          27 :     static OUString boolean( bool b )
    2400             :     {
    2401             :         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
    2402          27 :         rtl_uString* pNewData = 0;
    2403          27 :         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
    2404          27 :         return OUString( pNewData, SAL_NO_ACQUIRE );
    2405             :     }
    2406             : 
    2407             :     /**
    2408             :       Returns the string representation of the char argument.
    2409             : 
    2410             :       @param    c   a character.
    2411             :       @return   a string with the string representation of the argument.
    2412             :       @deprecated use operator, function or constructor taking char or sal_Unicode argument
    2413             :     */
    2414             :     SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
    2415             :     {
    2416             :         return OUString( &c, 1 );
    2417             :     }
    2418             : 
    2419             :     /**
    2420             :       Returns the string representation of the int argument.
    2421             : 
    2422             :       This function can't be used for language specific conversion.
    2423             : 
    2424             :       @param    i           a int32.
    2425             :       @param    radix       the radix (between 2 and 36)
    2426             :       @return   a string with the string representation of the argument.
    2427             :       @deprecated use number()
    2428             :     */
    2429             :     SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
    2430             :     {
    2431             :         return number( i, radix );
    2432             :     }
    2433             : 
    2434             :     /**
    2435             :       Returns the string representation of the long argument.
    2436             : 
    2437             :       This function can't be used for language specific conversion.
    2438             : 
    2439             :       @param    ll          a int64.
    2440             :       @param    radix       the radix (between 2 and 36)
    2441             :       @return   a string with the string representation of the argument.
    2442             :       @deprecated use number()
    2443             :     */
    2444             :     SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
    2445             :     {
    2446             :         return number( ll, radix );
    2447             :     }
    2448             : 
    2449             :     /**
    2450             :       Returns the string representation of the float argument.
    2451             : 
    2452             :       This function can't be used for language specific conversion.
    2453             : 
    2454             :       @param    f           a float.
    2455             :       @return   a string with the string representation of the argument.
    2456             :       @deprecated use number()
    2457             :     */
    2458             :     SAL_DEPRECATED("use number()") static OUString valueOf( float f )
    2459             :     {
    2460             :         return number(f);
    2461             :     }
    2462             : 
    2463             :     /**
    2464             :       Returns the string representation of the double argument.
    2465             : 
    2466             :       This function can't be used for language specific conversion.
    2467             : 
    2468             :       @param    d           a double.
    2469             :       @return   a string with the string representation of the argument.
    2470             :       @deprecated use number()
    2471             :     */
    2472             :     SAL_DEPRECATED("use number()") static OUString valueOf( double d )
    2473             :     {
    2474             :         return number(d);
    2475             :     }
    2476             : 
    2477             :     /**
    2478             :       Returns a OUString copied without conversion from an ASCII
    2479             :       character string.
    2480             : 
    2481             :       Since this method is optimized for performance, the ASCII character
    2482             :       values are not converted in any way. The caller has to make sure that
    2483             :       all ASCII characters are in the allowed range between 0 and
    2484             :       127. The ASCII string must be NULL-terminated.
    2485             : 
    2486             :       Note that for string literals it is simpler and more efficient
    2487             :       to directly use the OUString constructor.
    2488             : 
    2489             :       @param    value       the 8-Bit ASCII character string
    2490             :       @return   a string with the string representation of the argument.
    2491             :      */
    2492    14068170 :     static OUString createFromAscii( const sal_Char * value )
    2493             :     {
    2494    14068170 :         rtl_uString* pNew = 0;
    2495    14068170 :         rtl_uString_newFromAscii( &pNew, value );
    2496    14068170 :         return OUString( pNew, SAL_NO_ACQUIRE );
    2497             :     }
    2498             : };
    2499             : 
    2500             : #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
    2501             : /// @cond INTERNAL
    2502             : 
    2503             : /** Compare a string and an ASCII character literal for equality.
    2504             : 
    2505             :     @since LibreOffice 5.0
    2506             : */
    2507           4 : template<char C> bool operator ==(OUString const & string, OUStringLiteral1<C>)
    2508             : {
    2509           4 :     char const c = C;
    2510           4 :     return string.equalsAsciiL(&c, 1);
    2511             : }
    2512             : 
    2513             : /** Compare a string and an ASCII character literal for inequality.
    2514             : 
    2515             :     @since LibreOffice 5.0
    2516             : */
    2517           2 : template<char C> bool operator !=(
    2518             :     OUString const & string, OUStringLiteral1<C> literal)
    2519             : {
    2520           2 :     return !(string == literal);
    2521             : }
    2522             : 
    2523             : /**
    2524             :  @internal
    2525             : */
    2526             : template<>
    2527             : struct ToStringHelper< OUString >
    2528             :     {
    2529  1868915967 :     static int length( const OUString& s ) { return s.getLength(); }
    2530  1868913765 :     static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
    2531             :     static const bool allowOStringConcat = false;
    2532             :     static const bool allowOUStringConcat = true;
    2533             :     };
    2534             : 
    2535             : /**
    2536             :  @internal
    2537             : */
    2538             : template<>
    2539             : struct ToStringHelper< OUStringLiteral >
    2540             :     {
    2541           8 :     static int length( const OUStringLiteral& str ) { return str.size; }
    2542           8 :     static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
    2543             :     static const bool allowOStringConcat = false;
    2544             :     static const bool allowOUStringConcat = true;
    2545             :     };
    2546             : 
    2547             : /**
    2548             :  @internal
    2549             : */
    2550             : template<char C> struct ToStringHelper<OUStringLiteral1<C>>
    2551             : {
    2552         424 :     static int length(OUStringLiteral1<C>) { return 1; }
    2553         424 :     static sal_Unicode * addData(sal_Unicode * buffer, OUStringLiteral1<C>)
    2554         424 :     { *buffer++ = C; return buffer; }
    2555             :     static const bool allowOStringConcat = false;
    2556             :     static const bool allowOUStringConcat = true;
    2557             : };
    2558             : 
    2559             : /**
    2560             :  @internal
    2561             : */
    2562             : template< typename charT, typename traits, typename T1, typename T2 >
    2563             : inline std::basic_ostream<charT, traits> & operator <<(
    2564             :     std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
    2565             : {
    2566             :     return stream << OUString( concat );
    2567             : }
    2568             : 
    2569             : /// @endcond
    2570             : #endif
    2571             : 
    2572             : /** A helper to use OUStrings with hash maps.
    2573             : 
    2574             :     Instances of this class are unary function objects that can be used as
    2575             :     hash function arguments to std::unordered_map and similar constructs.
    2576             :  */
    2577             : struct OUStringHash
    2578             : {
    2579             :     /** Compute a hash code for a string.
    2580             : 
    2581             :         @param rString
    2582             :         a string.
    2583             : 
    2584             :         @return
    2585             :         a hash code for the string.  This hash code should not be stored
    2586             :         persistently, as its computation may change in later revisions.
    2587             :      */
    2588    97261644 :     size_t operator()(const OUString& rString) const
    2589    97261644 :         { return (size_t)rString.hashCode(); }
    2590             : };
    2591             : 
    2592             : /* ======================================================================= */
    2593             : 
    2594             : /** Convert an OString to an OUString, using a specific text encoding.
    2595             : 
    2596             :     The lengths of the two strings may differ (e.g., for double-byte
    2597             :     encodings, UTF-7, UTF-8).
    2598             : 
    2599             :     @param rStr
    2600             :     an OString to convert.
    2601             : 
    2602             :     @param encoding
    2603             :     the text encoding to use for conversion.
    2604             : 
    2605             :     @param convertFlags
    2606             :     flags which control the conversion.  Either use
    2607             :     OSTRING_TO_OUSTRING_CVTFLAGS, or see
    2608             :     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
    2609             :     details.
    2610             :  */
    2611     1477832 : inline OUString OStringToOUString( const OString & rStr,
    2612             :                                    rtl_TextEncoding encoding,
    2613             :                                    sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
    2614             : {
    2615     1477832 :     return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
    2616             : }
    2617             : 
    2618             : /** Convert an OUString to an OString, using a specific text encoding.
    2619             : 
    2620             :     The lengths of the two strings may differ (e.g., for double-byte
    2621             :     encodings, UTF-7, UTF-8).
    2622             : 
    2623             :     @param rUnicode
    2624             :     an OUString to convert.
    2625             : 
    2626             :     @param encoding
    2627             :     the text encoding to use for conversion.
    2628             : 
    2629             :     @param convertFlags
    2630             :     flags which control the conversion.  Either use
    2631             :     OUSTRING_TO_OSTRING_CVTFLAGS, or see
    2632             :     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
    2633             :     details.
    2634             :  */
    2635     9866830 : inline OString OUStringToOString( const OUString & rUnicode,
    2636             :                                   rtl_TextEncoding encoding,
    2637             :                                   sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
    2638             : {
    2639     9866830 :     return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
    2640             : }
    2641             : 
    2642             : /* ======================================================================= */
    2643             : 
    2644             : /**
    2645             :     Support for rtl::OUString in std::ostream (and thus in
    2646             :     CPPUNIT_ASSERT or SAL_INFO macros, for example).
    2647             : 
    2648             :     The rtl::OUString is converted to UTF-8.
    2649             : 
    2650             :     @since LibreOffice 3.5.
    2651             : */
    2652             : template< typename charT, typename traits >
    2653        2194 : inline std::basic_ostream<charT, traits> & operator <<(
    2654             :     std::basic_ostream<charT, traits> & stream, OUString const & string)
    2655             : {
    2656        4388 :     return stream <<
    2657        4388 :         OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
    2658             :         // best effort; potentially loses data due to conversion failures
    2659             :         // (stray surrogate halves) and embedded null characters
    2660             : }
    2661             : 
    2662             : } // namespace
    2663             : 
    2664             : #ifdef RTL_STRING_UNITTEST
    2665             : namespace rtl
    2666             : {
    2667             : typedef rtlunittest::OUString OUString;
    2668             : }
    2669             : #endif
    2670             : 
    2671             : // In internal code, allow to use classes like OUString without having to
    2672             : // explicitly refer to the rtl namespace, which is kind of superfluous given
    2673             : // that OUString itself is namespaced by its OU prefix:
    2674             : #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
    2675             : using ::rtl::OUString;
    2676             : using ::rtl::OUStringHash;
    2677             : using ::rtl::OStringToOUString;
    2678             : using ::rtl::OUStringToOString;
    2679             : using ::rtl::OUStringLiteral;
    2680             : using ::rtl::OUStringLiteral1;
    2681             : #endif
    2682             : 
    2683             : #endif /* _RTL_USTRING_HXX */
    2684             : 
    2685             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11