LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/rtl - ustring.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 310 330 93.9 %
Date: 2012-08-25 Functions: 421 519 81.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 74 96 77.1 %

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

Generated by: LCOV version 1.10