xref: /aoo42x/main/sal/inc/rtl/ustring.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX_
29*cdf0e10cSrcweir #define _RTL_USTRING_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifdef __cplusplus
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifndef _RTL_DIAGNOSE_H_
34*cdf0e10cSrcweir #include "osl/diagnose.h"
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <rtl/ustring.h>
37*cdf0e10cSrcweir #include <rtl/string.hxx>
38*cdf0e10cSrcweir #include <rtl/memory.h>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #if defined EXCEPTIONS_OFF
41*cdf0e10cSrcweir #include <stdlib.h>
42*cdf0e10cSrcweir #else
43*cdf0e10cSrcweir #include <new>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace rtl
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir /* ======================================================================= */
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /**
51*cdf0e10cSrcweir   This String class provide base functionality for C++ like Unicode
52*cdf0e10cSrcweir   character array handling. The advantage of this class is, that it
53*cdf0e10cSrcweir   handle all the memory managament for you - and it do it
54*cdf0e10cSrcweir   more efficient. If you assign a string to another string, the
55*cdf0e10cSrcweir   data of both strings are shared (without any copy operation or
56*cdf0e10cSrcweir   memory allocation) as long as you do not change the string. This class
57*cdf0e10cSrcweir   stores also the length of the string, so that many operations are
58*cdf0e10cSrcweir   faster as the C-str-functions.
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir   This class provide only readonly string handling. So you could create
61*cdf0e10cSrcweir   a string and you could only query the content from this string.
62*cdf0e10cSrcweir   It provide also functionality to change the string, but this results
63*cdf0e10cSrcweir   in every case in a new string instance (in the most cases with an
64*cdf0e10cSrcweir   memory allocation). You don't have functionality to change the
65*cdf0e10cSrcweir   content of the string. If you want change the string content, than
66*cdf0e10cSrcweir   you should us the OStringBuffer class, which provide these
67*cdf0e10cSrcweir   functionality and avoid to much memory allocation.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir   The design of this class is similar to the string classes in Java
70*cdf0e10cSrcweir   and so more people should have fewer understanding problems when they
71*cdf0e10cSrcweir   use this class.
72*cdf0e10cSrcweir */
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir class OUString
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir public:
77*cdf0e10cSrcweir     /** @internal */
78*cdf0e10cSrcweir     rtl_uString * pData;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir private:
81*cdf0e10cSrcweir     /** @internal */
82*cdf0e10cSrcweir     class DO_NOT_ACQUIRE{};
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     /** @internal */
85*cdf0e10cSrcweir     OUString( rtl_uString * value, DO_NOT_ACQUIRE * )
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir         pData = value;
88*cdf0e10cSrcweir     }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir public:
91*cdf0e10cSrcweir     /**
92*cdf0e10cSrcweir       New string containing no characters.
93*cdf0e10cSrcweir     */
94*cdf0e10cSrcweir     OUString() SAL_THROW(())
95*cdf0e10cSrcweir     {
96*cdf0e10cSrcweir         pData = 0;
97*cdf0e10cSrcweir         rtl_uString_new( &pData );
98*cdf0e10cSrcweir     }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     /**
101*cdf0e10cSrcweir       New string from OUString.
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir       @param    str         a OUString.
104*cdf0e10cSrcweir     */
105*cdf0e10cSrcweir     OUString( const OUString & str ) SAL_THROW(())
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         pData = str.pData;
108*cdf0e10cSrcweir         rtl_uString_acquire( pData );
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     /**
112*cdf0e10cSrcweir       New string from OUString data.
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir       @param    str         a OUString data.
115*cdf0e10cSrcweir     */
116*cdf0e10cSrcweir     OUString( rtl_uString * str )  SAL_THROW(())
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         pData = str;
119*cdf0e10cSrcweir         rtl_uString_acquire( pData );
120*cdf0e10cSrcweir     }
121*cdf0e10cSrcweir     /** New OUString from OUString data without acquiring it.  Takeover of ownership.
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         @param str
124*cdf0e10cSrcweir                OUString data
125*cdf0e10cSrcweir         @param dummy
126*cdf0e10cSrcweir                SAL_NO_ACQUIRE to distinguish from other ctors
127*cdf0e10cSrcweir     */
128*cdf0e10cSrcweir     inline OUString( rtl_uString * str, __sal_NoAcquire ) SAL_THROW( () )
129*cdf0e10cSrcweir         { pData = str; }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     /**
133*cdf0e10cSrcweir       New string from a single Unicode character.
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir       @param    value       a Unicode character.
136*cdf0e10cSrcweir     */
137*cdf0e10cSrcweir 	explicit OUString( sal_Unicode value ) SAL_THROW(())
138*cdf0e10cSrcweir         : pData (0)
139*cdf0e10cSrcweir 	{
140*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
141*cdf0e10cSrcweir 	}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     /**
144*cdf0e10cSrcweir       New string from a Unicode character buffer array.
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir       @param    value       a NULL-terminated Unicode character array.
147*cdf0e10cSrcweir     */
148*cdf0e10cSrcweir     OUString( const sal_Unicode * value ) SAL_THROW(())
149*cdf0e10cSrcweir     {
150*cdf0e10cSrcweir         pData = 0;
151*cdf0e10cSrcweir         rtl_uString_newFromStr( &pData, value );
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     /**
155*cdf0e10cSrcweir       New string from a Uniocde character buffer array.
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir       @param    value       a Unicode character array.
158*cdf0e10cSrcweir       @param    length      the number of character which should be copied.
159*cdf0e10cSrcweir                             The character array length must be greater or
160*cdf0e10cSrcweir                             equal than this value.
161*cdf0e10cSrcweir     */
162*cdf0e10cSrcweir     OUString( const sal_Unicode * value, sal_Int32 length ) SAL_THROW(())
163*cdf0e10cSrcweir     {
164*cdf0e10cSrcweir         pData = 0;
165*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pData, value, length );
166*cdf0e10cSrcweir     }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     /**
169*cdf0e10cSrcweir       New string from a 8-Bit character buffer array.
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir       @param    value           a 8-Bit character array.
172*cdf0e10cSrcweir       @param    length          the number of character which should be converted.
173*cdf0e10cSrcweir                                 The 8-Bit character array length must be
174*cdf0e10cSrcweir                                 greater or equal than this value.
175*cdf0e10cSrcweir       @param    encoding        the text encoding from which the 8-Bit character
176*cdf0e10cSrcweir                                 sequence should be converted.
177*cdf0e10cSrcweir       @param    convertFlags    flags which controls the conversion.
178*cdf0e10cSrcweir                                 see RTL_TEXTTOUNICODE_FLAGS_...
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir       @exception std::bad_alloc is thrown if an out-of-memory condition occurs
181*cdf0e10cSrcweir     */
182*cdf0e10cSrcweir     OUString( const sal_Char * value, sal_Int32 length,
183*cdf0e10cSrcweir               rtl_TextEncoding encoding,
184*cdf0e10cSrcweir               sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
185*cdf0e10cSrcweir     {
186*cdf0e10cSrcweir         pData = 0;
187*cdf0e10cSrcweir         rtl_string2UString( &pData, value, length, encoding, convertFlags );
188*cdf0e10cSrcweir #if defined EXCEPTIONS_OFF
189*cdf0e10cSrcweir         OSL_ASSERT(pData != NULL);
190*cdf0e10cSrcweir #else
191*cdf0e10cSrcweir         if (pData == 0) {
192*cdf0e10cSrcweir             throw std::bad_alloc();
193*cdf0e10cSrcweir         }
194*cdf0e10cSrcweir #endif
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     /** Create a new string from an array of Unicode code points.
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir         @param codePoints
200*cdf0e10cSrcweir         an array of at least codePointCount code points, which each must be in
201*cdf0e10cSrcweir         the range from 0 to 0x10FFFF, inclusive.  May be null if codePointCount
202*cdf0e10cSrcweir         is zero.
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir         @param codePointCount
205*cdf0e10cSrcweir         the non-negative number of code points.
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         @exception std::bad_alloc
208*cdf0e10cSrcweir         is thrown if either an out-of-memory condition occurs or the resulting
209*cdf0e10cSrcweir         number of UTF-16 code units would have been larger than SAL_MAX_INT32.
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir         @since UDK 3.2.7
212*cdf0e10cSrcweir     */
213*cdf0e10cSrcweir     inline explicit OUString(
214*cdf0e10cSrcweir         sal_uInt32 const * codePoints, sal_Int32 codePointCount):
215*cdf0e10cSrcweir         pData(NULL)
216*cdf0e10cSrcweir     {
217*cdf0e10cSrcweir         rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
218*cdf0e10cSrcweir         if (pData == NULL) {
219*cdf0e10cSrcweir #if defined EXCEPTIONS_OFF
220*cdf0e10cSrcweir             abort();
221*cdf0e10cSrcweir #else
222*cdf0e10cSrcweir             throw std::bad_alloc();
223*cdf0e10cSrcweir #endif
224*cdf0e10cSrcweir         }
225*cdf0e10cSrcweir     }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     /**
228*cdf0e10cSrcweir       Release the string data.
229*cdf0e10cSrcweir     */
230*cdf0e10cSrcweir     ~OUString() SAL_THROW(())
231*cdf0e10cSrcweir     {
232*cdf0e10cSrcweir         rtl_uString_release( pData );
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     /** Provides an OUString const & passing a storage pointer of an
236*cdf0e10cSrcweir         rtl_uString * handle.
237*cdf0e10cSrcweir         It is more convenient to use C++ OUString member functions when dealing
238*cdf0e10cSrcweir         with rtl_uString * handles.  Using this function avoids unnecessary
239*cdf0e10cSrcweir         acquire()/release() calls for a temporary OUString object.
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         @param ppHandle
242*cdf0e10cSrcweir                pointer to storage
243*cdf0e10cSrcweir         @return
244*cdf0e10cSrcweir                OUString const & based on given storage
245*cdf0e10cSrcweir     */
246*cdf0e10cSrcweir     static inline OUString const & unacquired( rtl_uString * const * ppHandle )
247*cdf0e10cSrcweir         { return * reinterpret_cast< OUString const * >( ppHandle ); }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     /**
250*cdf0e10cSrcweir       Assign a new string.
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir       @param    str         a OUString.
253*cdf0e10cSrcweir     */
254*cdf0e10cSrcweir     OUString & operator=( const OUString & str ) SAL_THROW(())
255*cdf0e10cSrcweir     {
256*cdf0e10cSrcweir         rtl_uString_assign( &pData, str.pData );
257*cdf0e10cSrcweir         return *this;
258*cdf0e10cSrcweir     }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir     /**
261*cdf0e10cSrcweir       Append a string to this string.
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir       @param    str         a OUString.
264*cdf0e10cSrcweir     */
265*cdf0e10cSrcweir     OUString & operator+=( const OUString & str ) SAL_THROW(())
266*cdf0e10cSrcweir     {
267*cdf0e10cSrcweir         rtl_uString_newConcat( &pData, pData, str.pData );
268*cdf0e10cSrcweir         return *this;
269*cdf0e10cSrcweir     }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     /**
272*cdf0e10cSrcweir       Returns the length of this string.
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir       The length is equal to the number of Unicode characters in this string.
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir       @return   the length of the sequence of characters represented by this
277*cdf0e10cSrcweir                 object.
278*cdf0e10cSrcweir     */
279*cdf0e10cSrcweir     sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     /**
282*cdf0e10cSrcweir       Returns a pointer to the Unicode character buffer from this string.
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir       It isn't necessarily NULL terminated.
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir       @return   a pointer to the Unicode characters buffer from this object.
287*cdf0e10cSrcweir     */
288*cdf0e10cSrcweir     operator const sal_Unicode *() const SAL_THROW(()) { return pData->buffer; }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     /**
291*cdf0e10cSrcweir       Returns a pointer to the Unicode character buffer from this string.
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir       It isn't necessarily NULL terminated.
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir       @return   a pointer to the Unicode characters buffer from this object.
296*cdf0e10cSrcweir     */
297*cdf0e10cSrcweir     const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     /**
300*cdf0e10cSrcweir       Compares two strings.
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir       The comparison is based on the numeric value of each character in
303*cdf0e10cSrcweir       the strings and return a value indicating their relationship.
304*cdf0e10cSrcweir       This function can't be used for language specific sorting.
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir       @param    str         the object to be compared.
307*cdf0e10cSrcweir       @return   0 - if both strings are equal
308*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
309*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
310*cdf0e10cSrcweir     */
311*cdf0e10cSrcweir     sal_Int32 compareTo( const OUString & str ) const SAL_THROW(())
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
314*cdf0e10cSrcweir                                             str.pData->buffer, str.pData->length );
315*cdf0e10cSrcweir     }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     /**
318*cdf0e10cSrcweir       Compares two strings with an maximum count of characters.
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir       The comparison is based on the numeric value of each character in
321*cdf0e10cSrcweir       the strings and return a value indicating their relationship.
322*cdf0e10cSrcweir       This function can't be used for language specific sorting.
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir       @param    str         the object to be compared.
325*cdf0e10cSrcweir       @param    maxLength   the maximum count of characters to be compared.
326*cdf0e10cSrcweir       @return   0 - if both strings are equal
327*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
328*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
329*cdf0e10cSrcweir     */
330*cdf0e10cSrcweir     sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const SAL_THROW(())
331*cdf0e10cSrcweir     {
332*cdf0e10cSrcweir         return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
333*cdf0e10cSrcweir                                                      str.pData->buffer, str.pData->length, maxLength );
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     /**
337*cdf0e10cSrcweir       Compares two strings in reverse order.
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir       The comparison is based on the numeric value of each character in
340*cdf0e10cSrcweir       the strings and return a value indicating their relationship.
341*cdf0e10cSrcweir       This function can't be used for language specific sorting.
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir       @param    str         the object to be compared.
344*cdf0e10cSrcweir       @return   0 - if both strings are equal
345*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
346*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
347*cdf0e10cSrcweir     */
348*cdf0e10cSrcweir     sal_Int32 reverseCompareTo( const OUString & str ) const SAL_THROW(())
349*cdf0e10cSrcweir     {
350*cdf0e10cSrcweir         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
351*cdf0e10cSrcweir                                                    str.pData->buffer, str.pData->length );
352*cdf0e10cSrcweir     }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     /**
355*cdf0e10cSrcweir       Perform a comparison of two strings.
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir       The result is true if and only if second string
358*cdf0e10cSrcweir       represents the same sequence of characters as the first string.
359*cdf0e10cSrcweir       This function can't be used for language specific comparison.
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir       @param    str         the object to be compared.
362*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
363*cdf0e10cSrcweir                 sal_False, otherwise.
364*cdf0e10cSrcweir     */
365*cdf0e10cSrcweir     sal_Bool equals( const OUString & str ) const SAL_THROW(())
366*cdf0e10cSrcweir     {
367*cdf0e10cSrcweir         if ( pData->length != str.pData->length )
368*cdf0e10cSrcweir             return sal_False;
369*cdf0e10cSrcweir         if ( pData == str.pData )
370*cdf0e10cSrcweir             return sal_True;
371*cdf0e10cSrcweir         return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
372*cdf0e10cSrcweir                                                    str.pData->buffer, str.pData->length ) == 0;
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     /**
376*cdf0e10cSrcweir       Perform a ASCII lowercase comparison of two strings.
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir       The result is true if and only if second string
379*cdf0e10cSrcweir       represents the same sequence of characters as the first string,
380*cdf0e10cSrcweir       ignoring the case.
381*cdf0e10cSrcweir       Character values between 65 and 90 (ASCII A-Z) are interpreted as
382*cdf0e10cSrcweir       values between 97 and 122 (ASCII a-z).
383*cdf0e10cSrcweir       This function can't be used for language specific comparison.
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir       @param    str         the object to be compared.
386*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
387*cdf0e10cSrcweir                 sal_False, otherwise.
388*cdf0e10cSrcweir     */
389*cdf0e10cSrcweir     sal_Bool equalsIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
390*cdf0e10cSrcweir     {
391*cdf0e10cSrcweir         if ( pData->length != str.pData->length )
392*cdf0e10cSrcweir             return sal_False;
393*cdf0e10cSrcweir         if ( pData == str.pData )
394*cdf0e10cSrcweir             return sal_True;
395*cdf0e10cSrcweir         return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
396*cdf0e10cSrcweir                                                            str.pData->buffer, str.pData->length ) == 0;
397*cdf0e10cSrcweir     }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir     /**
400*cdf0e10cSrcweir       Match against a substring appearing in this string.
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir       The result is true if and only if the second string appears as a substring
403*cdf0e10cSrcweir       of this string, at the given position.
404*cdf0e10cSrcweir       This function can't be used for language specific comparison.
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir       @param    str         the object (substring) to be compared.
407*cdf0e10cSrcweir       @param    fromIndex   the index to start the comparion from.
408*cdf0e10cSrcweir                             The index must be greater or equal than 0
409*cdf0e10cSrcweir                             and less or equal as the string length.
410*cdf0e10cSrcweir       @return   sal_True if str match with the characters in the string
411*cdf0e10cSrcweir                 at the given position;
412*cdf0e10cSrcweir                 sal_False, otherwise.
413*cdf0e10cSrcweir     */
414*cdf0e10cSrcweir     sal_Bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
415*cdf0e10cSrcweir     {
416*cdf0e10cSrcweir         return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
417*cdf0e10cSrcweir                                                      str.pData->buffer, str.pData->length, str.pData->length ) == 0;
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir     /**
421*cdf0e10cSrcweir       Match against a substring appearing in this string, ignoring the case of
422*cdf0e10cSrcweir       ASCII letters.
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir       The result is true if and only if the second string appears as a substring
425*cdf0e10cSrcweir       of this string, at the given position.
426*cdf0e10cSrcweir       Character values between 65 and 90 (ASCII A-Z) are interpreted as
427*cdf0e10cSrcweir       values between 97 and 122 (ASCII a-z).
428*cdf0e10cSrcweir       This function can't be used for language specific comparison.
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir       @param    str         the object (substring) to be compared.
431*cdf0e10cSrcweir       @param    fromIndex   the index to start the comparion from.
432*cdf0e10cSrcweir                             The index must be greater or equal than 0
433*cdf0e10cSrcweir                             and less or equal as the string length.
434*cdf0e10cSrcweir       @return   sal_True if str match with the characters in the string
435*cdf0e10cSrcweir                 at the given position;
436*cdf0e10cSrcweir                 sal_False, otherwise.
437*cdf0e10cSrcweir     */
438*cdf0e10cSrcweir     sal_Bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
439*cdf0e10cSrcweir     {
440*cdf0e10cSrcweir         return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
441*cdf0e10cSrcweir                                                                     str.pData->buffer, str.pData->length,
442*cdf0e10cSrcweir                                                                     str.pData->length ) == 0;
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir     /**
446*cdf0e10cSrcweir       Compares two strings.
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir       The comparison is based on the numeric value of each character in
449*cdf0e10cSrcweir       the strings and return a value indicating their relationship.
450*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
451*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
452*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
453*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated.
454*cdf0e10cSrcweir       This function can't be used for language specific sorting.
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir       @param  asciiStr      the 8-Bit ASCII character string to be compared.
457*cdf0e10cSrcweir       @return   0 - if both strings are equal
458*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
459*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
460*cdf0e10cSrcweir     */
461*cdf0e10cSrcweir     sal_Int32 compareToAscii( const sal_Char* asciiStr ) const SAL_THROW(())
462*cdf0e10cSrcweir     {
463*cdf0e10cSrcweir         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
464*cdf0e10cSrcweir     }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir     /**
467*cdf0e10cSrcweir       Compares two strings with an maximum count of characters.
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir       The comparison is based on the numeric value of each character in
470*cdf0e10cSrcweir       the strings and return a value indicating their relationship.
471*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
472*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
473*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
474*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated.
475*cdf0e10cSrcweir       This function can't be used for language specific sorting.
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir       @param  asciiStr          the 8-Bit ASCII character string to be compared.
478*cdf0e10cSrcweir       @param  maxLength         the maximum count of characters to be compared.
479*cdf0e10cSrcweir       @return   0 - if both strings are equal
480*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
481*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
482*cdf0e10cSrcweir     */
483*cdf0e10cSrcweir     sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const SAL_THROW(())
484*cdf0e10cSrcweir     {
485*cdf0e10cSrcweir         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
486*cdf0e10cSrcweir                                                            asciiStr, maxLength );
487*cdf0e10cSrcweir     }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir     /**
490*cdf0e10cSrcweir       Compares two strings in reverse order.
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir       This could be useful, if normally both strings start with the same
493*cdf0e10cSrcweir       content. The comparison is based on the numeric value of each character
494*cdf0e10cSrcweir       in the strings and return a value indicating their relationship.
495*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
496*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
497*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
498*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated and must be greater or
499*cdf0e10cSrcweir       equal as asciiStrLength.
500*cdf0e10cSrcweir       This function can't be used for language specific sorting.
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir       @param    asciiStr        the 8-Bit ASCII character string to be compared.
503*cdf0e10cSrcweir       @param    asciiStrLength  the length of the ascii string
504*cdf0e10cSrcweir       @return   0 - if both strings are equal
505*cdf0e10cSrcweir                 < 0 - if this string is less than the string argument
506*cdf0e10cSrcweir                 > 0 - if this string is greater than the string argument
507*cdf0e10cSrcweir     */
508*cdf0e10cSrcweir     sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
509*cdf0e10cSrcweir     {
510*cdf0e10cSrcweir         return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
511*cdf0e10cSrcweir                                                           asciiStr, asciiStrLength );
512*cdf0e10cSrcweir     }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir     /**
515*cdf0e10cSrcweir       Perform a comparison of two strings.
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir       The result is true if and only if second string
518*cdf0e10cSrcweir       represents the same sequence of characters as the first string.
519*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
520*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
521*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
522*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated.
523*cdf0e10cSrcweir       This function can't be used for language specific comparison.
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir       @param    asciiStr        the 8-Bit ASCII character string to be compared.
526*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
527*cdf0e10cSrcweir                 sal_False, otherwise.
528*cdf0e10cSrcweir     */
529*cdf0e10cSrcweir     sal_Bool equalsAscii( const sal_Char* asciiStr ) const SAL_THROW(())
530*cdf0e10cSrcweir     {
531*cdf0e10cSrcweir         return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
532*cdf0e10cSrcweir                                                   asciiStr ) == 0;
533*cdf0e10cSrcweir     }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     /**
536*cdf0e10cSrcweir       Perform a comparison of two strings.
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir       The result is true if and only if second string
539*cdf0e10cSrcweir       represents the same sequence of characters as the first string.
540*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
541*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
542*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
543*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated and must be greater or
544*cdf0e10cSrcweir       equal as asciiStrLength.
545*cdf0e10cSrcweir       This function can't be used for language specific comparison.
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir       @param    asciiStr         the 8-Bit ASCII character string to be compared.
548*cdf0e10cSrcweir       @param    asciiStrLength   the length of the ascii string
549*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
550*cdf0e10cSrcweir                 sal_False, otherwise.
551*cdf0e10cSrcweir     */
552*cdf0e10cSrcweir     sal_Bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
553*cdf0e10cSrcweir     {
554*cdf0e10cSrcweir         if ( pData->length != asciiStrLength )
555*cdf0e10cSrcweir             return sal_False;
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir         return rtl_ustr_asciil_reverseEquals_WithLength(
558*cdf0e10cSrcweir 					pData->buffer, asciiStr, asciiStrLength );
559*cdf0e10cSrcweir     }
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     /**
562*cdf0e10cSrcweir       Perform a ASCII lowercase comparison of two strings.
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir       The result is true if and only if second string
565*cdf0e10cSrcweir       represents the same sequence of characters as the first string,
566*cdf0e10cSrcweir       ignoring the case.
567*cdf0e10cSrcweir       Character values between 65 and 90 (ASCII A-Z) are interpreted as
568*cdf0e10cSrcweir       values between 97 and 122 (ASCII a-z).
569*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
570*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
571*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
572*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated.
573*cdf0e10cSrcweir       This function can't be used for language specific comparison.
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir       @param    asciiStr        the 8-Bit ASCII character string to be compared.
576*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
577*cdf0e10cSrcweir                 sal_False, otherwise.
578*cdf0e10cSrcweir     */
579*cdf0e10cSrcweir     sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
580*cdf0e10cSrcweir     {
581*cdf0e10cSrcweir         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
582*cdf0e10cSrcweir     }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir     /**
585*cdf0e10cSrcweir       Perform a ASCII lowercase comparison of two strings.
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir       The result is true if and only if second string
588*cdf0e10cSrcweir       represents the same sequence of characters as the first string,
589*cdf0e10cSrcweir       ignoring the case.
590*cdf0e10cSrcweir       Character values between 65 and 90 (ASCII A-Z) are interpreted as
591*cdf0e10cSrcweir       values between 97 and 122 (ASCII a-z).
592*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
593*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
594*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
595*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated and must be greater or
596*cdf0e10cSrcweir       equal as asciiStrLength.
597*cdf0e10cSrcweir       This function can't be used for language specific comparison.
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir       @param    asciiStr        the 8-Bit ASCII character string to be compared.
600*cdf0e10cSrcweir       @param    asciiStrLength  the length of the ascii string
601*cdf0e10cSrcweir       @return   sal_True if the strings are equal;
602*cdf0e10cSrcweir                 sal_False, otherwise.
603*cdf0e10cSrcweir     */
604*cdf0e10cSrcweir     sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
605*cdf0e10cSrcweir     {
606*cdf0e10cSrcweir         if ( pData->length != asciiStrLength )
607*cdf0e10cSrcweir             return sal_False;
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
610*cdf0e10cSrcweir     }
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir     /**
613*cdf0e10cSrcweir       Match against a substring appearing in this string.
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir       The result is true if and only if the second string appears as a substring
616*cdf0e10cSrcweir       of this string, at the given position.
617*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
618*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
619*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
620*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated and must be greater or
621*cdf0e10cSrcweir       equal as asciiStrLength.
622*cdf0e10cSrcweir       This function can't be used for language specific comparison.
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir       @param    str         the object (substring) to be compared.
625*cdf0e10cSrcweir       @param    fromIndex   the index to start the comparion from.
626*cdf0e10cSrcweir                             The index must be greater or equal than 0
627*cdf0e10cSrcweir                             and less or equal as the string length.
628*cdf0e10cSrcweir       @return   sal_True if str match with the characters in the string
629*cdf0e10cSrcweir                 at the given position;
630*cdf0e10cSrcweir                 sal_False, otherwise.
631*cdf0e10cSrcweir     */
632*cdf0e10cSrcweir     sal_Bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
633*cdf0e10cSrcweir     {
634*cdf0e10cSrcweir         return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
635*cdf0e10cSrcweir                                                            asciiStr, asciiStrLength ) == 0;
636*cdf0e10cSrcweir     }
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     /**
639*cdf0e10cSrcweir       Match against a substring appearing in this string, ignoring the case of
640*cdf0e10cSrcweir       ASCII letters.
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir       The result is true if and only if the second string appears as a substring
643*cdf0e10cSrcweir       of this string, at the given position.
644*cdf0e10cSrcweir       Character values between 65 and 90 (ASCII A-Z) are interpreted as
645*cdf0e10cSrcweir       values between 97 and 122 (ASCII a-z).
646*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
647*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
648*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
649*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated and must be greater or
650*cdf0e10cSrcweir       equal as asciiStrLength.
651*cdf0e10cSrcweir       This function can't be used for language specific comparison.
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir       @param    asciiStr        the 8-Bit ASCII character string to be compared.
654*cdf0e10cSrcweir       @param    asciiStrLength  the length of the ascii string
655*cdf0e10cSrcweir       @param    fromIndex       the index to start the comparion from.
656*cdf0e10cSrcweir                                 The index must be greater or equal than 0
657*cdf0e10cSrcweir                                 and less or equal as the string length.
658*cdf0e10cSrcweir       @return   sal_True if str match with the characters in the string
659*cdf0e10cSrcweir                 at the given position;
660*cdf0e10cSrcweir                 sal_False, otherwise.
661*cdf0e10cSrcweir     */
662*cdf0e10cSrcweir     sal_Bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
663*cdf0e10cSrcweir     {
664*cdf0e10cSrcweir         return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
665*cdf0e10cSrcweir                                                                           asciiStr, asciiStrLength ) == 0;
666*cdf0e10cSrcweir     }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir     /**
669*cdf0e10cSrcweir       Check whether this string ends with a given ASCII string.
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir       @param asciiStr a sequence of at least asciiStrLength ASCII characters
672*cdf0e10cSrcweir           (bytes in the range 0x00--0x7F)
673*cdf0e10cSrcweir       @param asciiStrLen the length of asciiStr; must be non-negative
674*cdf0e10cSrcweir       @return true if this string ends with asciiStr; otherwise, false is
675*cdf0e10cSrcweir       returned
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir       @since UDK 3.2.7
678*cdf0e10cSrcweir      */
679*cdf0e10cSrcweir     inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
680*cdf0e10cSrcweir         const
681*cdf0e10cSrcweir     {
682*cdf0e10cSrcweir         return asciiStrLength <= pData->length
683*cdf0e10cSrcweir             && rtl_ustr_asciil_reverseEquals_WithLength(
684*cdf0e10cSrcweir                 pData->buffer + pData->length - asciiStrLength, asciiStr,
685*cdf0e10cSrcweir                 asciiStrLength);
686*cdf0e10cSrcweir     }
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir     /**
689*cdf0e10cSrcweir       Check whether this string ends with a given ASCII string, ignoring the
690*cdf0e10cSrcweir       case of ASCII letters.
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir       @param asciiStr a sequence of at least asciiStrLength ASCII characters
693*cdf0e10cSrcweir           (bytes in the range 0x00--0x7F)
694*cdf0e10cSrcweir       @param asciiStrLen the length of asciiStr; must be non-negative
695*cdf0e10cSrcweir       @return true if this string ends with asciiStr, ignoring the case of ASCII
696*cdf0e10cSrcweir       letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
697*cdf0e10cSrcweir      */
698*cdf0e10cSrcweir     inline bool endsWithIgnoreAsciiCaseAsciiL(
699*cdf0e10cSrcweir         char const * asciiStr, sal_Int32 asciiStrLength) const
700*cdf0e10cSrcweir     {
701*cdf0e10cSrcweir         return asciiStrLength <= pData->length
702*cdf0e10cSrcweir             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
703*cdf0e10cSrcweir                     pData->buffer + pData->length - asciiStrLength,
704*cdf0e10cSrcweir                     asciiStrLength, asciiStr, asciiStrLength)
705*cdf0e10cSrcweir                 == 0);
706*cdf0e10cSrcweir     }
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     friend sal_Bool     operator == ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
709*cdf0e10cSrcweir                         { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; }
710*cdf0e10cSrcweir     friend sal_Bool     operator == ( const OUString& rStr1,    const sal_Unicode * pStr2 ) SAL_THROW(())
711*cdf0e10cSrcweir                         { return rStr1.compareTo( pStr2 ) == 0; }
712*cdf0e10cSrcweir     friend sal_Bool     operator == ( const sal_Unicode * pStr1,    const OUString& rStr2 ) SAL_THROW(())
713*cdf0e10cSrcweir                         { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir     friend sal_Bool     operator != ( const OUString& rStr1,        const OUString& rStr2 ) SAL_THROW(())
716*cdf0e10cSrcweir                         { return !(operator == ( rStr1, rStr2 )); }
717*cdf0e10cSrcweir     friend sal_Bool     operator != ( const OUString& rStr1,    const sal_Unicode * pStr2 ) SAL_THROW(())
718*cdf0e10cSrcweir                         { return !(operator == ( rStr1, pStr2 )); }
719*cdf0e10cSrcweir     friend sal_Bool     operator != ( const sal_Unicode * pStr1,    const OUString& rStr2 ) SAL_THROW(())
720*cdf0e10cSrcweir                         { return !(operator == ( pStr1, rStr2 )); }
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir     friend sal_Bool     operator <  ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
723*cdf0e10cSrcweir                         { return rStr1.compareTo( rStr2 ) < 0; }
724*cdf0e10cSrcweir     friend sal_Bool     operator >  ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
725*cdf0e10cSrcweir                         { return rStr1.compareTo( rStr2 ) > 0; }
726*cdf0e10cSrcweir     friend sal_Bool     operator <= ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
727*cdf0e10cSrcweir                         { return rStr1.compareTo( rStr2 ) <= 0; }
728*cdf0e10cSrcweir     friend sal_Bool     operator >= ( const OUString& rStr1,    const OUString& rStr2 ) SAL_THROW(())
729*cdf0e10cSrcweir                         { return rStr1.compareTo( rStr2 ) >= 0; }
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir     /**
732*cdf0e10cSrcweir       Returns a hashcode for this string.
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir       @return   a hash code value for this object.
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir       @see rtl::OUStringHash for convenient use of STLPort's hash_map
737*cdf0e10cSrcweir     */
738*cdf0e10cSrcweir     sal_Int32 hashCode() const SAL_THROW(())
739*cdf0e10cSrcweir     {
740*cdf0e10cSrcweir         return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
741*cdf0e10cSrcweir     }
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir     /**
744*cdf0e10cSrcweir       Returns the index within this string of the first occurrence of the
745*cdf0e10cSrcweir       specified character, starting the search at the specified index.
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir       @param    ch          character to be located.
748*cdf0e10cSrcweir       @param    fromIndex   the index to start the search from.
749*cdf0e10cSrcweir                             The index must be greater or equal than 0
750*cdf0e10cSrcweir                             and less or equal as the string length.
751*cdf0e10cSrcweir       @return   the index of the first occurrence of the character in the
752*cdf0e10cSrcweir                 character sequence represented by this string that is
753*cdf0e10cSrcweir                 greater than or equal to fromIndex, or
754*cdf0e10cSrcweir                 -1 if the character does not occur.
755*cdf0e10cSrcweir     */
756*cdf0e10cSrcweir     sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
757*cdf0e10cSrcweir     {
758*cdf0e10cSrcweir         sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
759*cdf0e10cSrcweir         return (ret < 0 ? ret : ret+fromIndex);
760*cdf0e10cSrcweir     }
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir     /**
763*cdf0e10cSrcweir       Returns the index within this string of the last occurrence of the
764*cdf0e10cSrcweir       specified character, searching backward starting at the end.
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir       @param    ch          character to be located.
767*cdf0e10cSrcweir       @return   the index of the last occurrence of the character in the
768*cdf0e10cSrcweir                 character sequence represented by this string, or
769*cdf0e10cSrcweir                 -1 if the character does not occur.
770*cdf0e10cSrcweir     */
771*cdf0e10cSrcweir     sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
772*cdf0e10cSrcweir     {
773*cdf0e10cSrcweir         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
774*cdf0e10cSrcweir     }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir     /**
777*cdf0e10cSrcweir       Returns the index within this string of the last occurrence of the
778*cdf0e10cSrcweir       specified character, searching backward starting before the specified
779*cdf0e10cSrcweir       index.
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir       @param    ch          character to be located.
782*cdf0e10cSrcweir       @param    fromIndex   the index before which to start the search.
783*cdf0e10cSrcweir       @return   the index of the last occurrence of the character in the
784*cdf0e10cSrcweir                 character sequence represented by this string that
785*cdf0e10cSrcweir                 is less than fromIndex, or -1
786*cdf0e10cSrcweir                 if the character does not occur before that point.
787*cdf0e10cSrcweir     */
788*cdf0e10cSrcweir     sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
789*cdf0e10cSrcweir     {
790*cdf0e10cSrcweir         return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
791*cdf0e10cSrcweir     }
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir     /**
794*cdf0e10cSrcweir       Returns the index within this string of the first occurrence of the
795*cdf0e10cSrcweir       specified substring, starting at the specified index.
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir       If str doesn't include any character, always -1 is
798*cdf0e10cSrcweir       returned. This is also the case, if both strings are empty.
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir       @param    str         the substring to search for.
801*cdf0e10cSrcweir       @param    fromIndex   the index to start the search from.
802*cdf0e10cSrcweir       @return   If the string argument occurs one or more times as a substring
803*cdf0e10cSrcweir                 within this string at the starting index, then the index
804*cdf0e10cSrcweir                 of the first character of the first such substring is
805*cdf0e10cSrcweir                 returned. If it does not occur as a substring starting
806*cdf0e10cSrcweir                 at fromIndex or beyond, -1 is returned.
807*cdf0e10cSrcweir     */
808*cdf0e10cSrcweir     sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
809*cdf0e10cSrcweir     {
810*cdf0e10cSrcweir         sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
811*cdf0e10cSrcweir                                                         str.pData->buffer, str.pData->length );
812*cdf0e10cSrcweir         return (ret < 0 ? ret : ret+fromIndex);
813*cdf0e10cSrcweir     }
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir     /**
816*cdf0e10cSrcweir        Returns the index within this string of the first occurrence of the
817*cdf0e10cSrcweir        specified ASCII substring, starting at the specified index.
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir        @param str
820*cdf0e10cSrcweir        the substring to be searched for.  Need not be null-terminated, but must
821*cdf0e10cSrcweir        be at least as long as the specified len.  Must only contain characters
822*cdf0e10cSrcweir        in the ASCII range 0x00--7F.
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir        @param len
825*cdf0e10cSrcweir        the length of the substring; must be non-negative.
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir        @param fromIndex
828*cdf0e10cSrcweir        the index to start the search from.  Must be in the range from zero to
829*cdf0e10cSrcweir        the length of this string, inclusive.
830*cdf0e10cSrcweir 
831*cdf0e10cSrcweir        @return
832*cdf0e10cSrcweir        the index (starting at 0) of the first character of the first occurrence
833*cdf0e10cSrcweir        of the substring within this string starting at the given fromIndex, or
834*cdf0e10cSrcweir        -1 if the substring does not occur.  If len is zero, -1 is returned.
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir        @since UDK 3.2.7
837*cdf0e10cSrcweir     */
838*cdf0e10cSrcweir     sal_Int32 indexOfAsciiL(
839*cdf0e10cSrcweir         char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
840*cdf0e10cSrcweir         SAL_THROW(())
841*cdf0e10cSrcweir     {
842*cdf0e10cSrcweir         sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
843*cdf0e10cSrcweir             pData->buffer + fromIndex, pData->length - fromIndex, str, len);
844*cdf0e10cSrcweir         return ret < 0 ? ret : ret + fromIndex;
845*cdf0e10cSrcweir     }
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir     /**
848*cdf0e10cSrcweir       Returns the index within this string of the last occurrence of
849*cdf0e10cSrcweir       the specified substring, searching backward starting at the end.
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir       The returned index indicates the starting index of the substring
852*cdf0e10cSrcweir       in this string.
853*cdf0e10cSrcweir       If str doesn't include any character, always -1 is
854*cdf0e10cSrcweir       returned. This is also the case, if both strings are empty.
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir       @param    str         the substring to search for.
857*cdf0e10cSrcweir       @return   If the string argument occurs one or more times as a substring
858*cdf0e10cSrcweir                 within this string, then the index of the first character of
859*cdf0e10cSrcweir                 the last such substring is returned. If it does not occur as
860*cdf0e10cSrcweir                 a substring, -1 is returned.
861*cdf0e10cSrcweir     */
862*cdf0e10cSrcweir     sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
863*cdf0e10cSrcweir     {
864*cdf0e10cSrcweir         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
865*cdf0e10cSrcweir                                                    str.pData->buffer, str.pData->length );
866*cdf0e10cSrcweir     }
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir     /**
869*cdf0e10cSrcweir       Returns the index within this string of the last occurrence of
870*cdf0e10cSrcweir       the specified substring, searching backward starting before the specified
871*cdf0e10cSrcweir       index.
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir       The returned index indicates the starting index of the substring
874*cdf0e10cSrcweir       in this string.
875*cdf0e10cSrcweir       If str doesn't include any character, always -1 is
876*cdf0e10cSrcweir       returned. This is also the case, if both strings are empty.
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir       @param    str         the substring to search for.
879*cdf0e10cSrcweir       @param    fromIndex   the index before which to start the search.
880*cdf0e10cSrcweir       @return   If the string argument occurs one or more times as a substring
881*cdf0e10cSrcweir                 within this string before the starting index, then the index
882*cdf0e10cSrcweir                 of the first character of the last such substring is
883*cdf0e10cSrcweir                 returned. Otherwise, -1 is returned.
884*cdf0e10cSrcweir     */
885*cdf0e10cSrcweir     sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
886*cdf0e10cSrcweir     {
887*cdf0e10cSrcweir         return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
888*cdf0e10cSrcweir                                                    str.pData->buffer, str.pData->length );
889*cdf0e10cSrcweir     }
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir     /**
892*cdf0e10cSrcweir        Returns the index within this string of the last occurrence of the
893*cdf0e10cSrcweir        specified ASCII substring.
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir        @param str
896*cdf0e10cSrcweir        the substring to be searched for.  Need not be null-terminated, but must
897*cdf0e10cSrcweir        be at least as long as the specified len.  Must only contain characters
898*cdf0e10cSrcweir        in the ASCII range 0x00--7F.
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir        @param len
901*cdf0e10cSrcweir        the length of the substring; must be non-negative.
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir        @return
904*cdf0e10cSrcweir        the index (starting at 0) of the first character of the last occurrence
905*cdf0e10cSrcweir        of the substring within this string, or -1 if the substring does not
906*cdf0e10cSrcweir        occur.  If len is zero, -1 is returned.
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir        @since UDK 3.2.7
909*cdf0e10cSrcweir     */
910*cdf0e10cSrcweir     sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
911*cdf0e10cSrcweir         SAL_THROW(())
912*cdf0e10cSrcweir     {
913*cdf0e10cSrcweir         return rtl_ustr_lastIndexOfAscii_WithLength(
914*cdf0e10cSrcweir             pData->buffer, pData->length, str, len);
915*cdf0e10cSrcweir     }
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir     /**
918*cdf0e10cSrcweir       Returns a new string that is a substring of this string.
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir       The substring begins at the specified beginIndex.  It is an error for
921*cdf0e10cSrcweir       beginIndex to be negative or to be greater than the length of this string.
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir       @param     beginIndex   the beginning index, inclusive.
924*cdf0e10cSrcweir       @return    the specified substring.
925*cdf0e10cSrcweir     */
926*cdf0e10cSrcweir     OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
927*cdf0e10cSrcweir     {
928*cdf0e10cSrcweir         OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
929*cdf0e10cSrcweir         if ( beginIndex == 0 )
930*cdf0e10cSrcweir             return *this;
931*cdf0e10cSrcweir         else
932*cdf0e10cSrcweir         {
933*cdf0e10cSrcweir             rtl_uString* pNew = 0;
934*cdf0e10cSrcweir             rtl_uString_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, getLength()-beginIndex );
935*cdf0e10cSrcweir             return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
936*cdf0e10cSrcweir         }
937*cdf0e10cSrcweir     }
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir     /**
940*cdf0e10cSrcweir       Returns a new string that is a substring of this string.
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir       The substring begins at the specified beginIndex and contains count
943*cdf0e10cSrcweir       characters.  It is an error for either beginIndex or count to be negative,
944*cdf0e10cSrcweir       or for beginIndex + count to be greater than the length of this string.
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir       @param     beginIndex   the beginning index, inclusive.
947*cdf0e10cSrcweir       @param     count        the number of characters.
948*cdf0e10cSrcweir       @return    the specified substring.
949*cdf0e10cSrcweir     */
950*cdf0e10cSrcweir     OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
951*cdf0e10cSrcweir     {
952*cdf0e10cSrcweir         OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength()
953*cdf0e10cSrcweir                    && count >= 0 && count <= getLength() - beginIndex);
954*cdf0e10cSrcweir         if ( (beginIndex == 0) && (count == getLength()) )
955*cdf0e10cSrcweir             return *this;
956*cdf0e10cSrcweir         else
957*cdf0e10cSrcweir         {
958*cdf0e10cSrcweir             rtl_uString* pNew = 0;
959*cdf0e10cSrcweir             rtl_uString_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, count );
960*cdf0e10cSrcweir             return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
961*cdf0e10cSrcweir         }
962*cdf0e10cSrcweir     }
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir     /**
965*cdf0e10cSrcweir       Concatenates the specified string to the end of this string.
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir       @param    str   the string that is concatenated to the end
968*cdf0e10cSrcweir                       of this string.
969*cdf0e10cSrcweir       @return   a string that represents the concatenation of this string
970*cdf0e10cSrcweir                 followed by the string argument.
971*cdf0e10cSrcweir     */
972*cdf0e10cSrcweir     OUString concat( const OUString & str ) const SAL_THROW(())
973*cdf0e10cSrcweir     {
974*cdf0e10cSrcweir         rtl_uString* pNew = 0;
975*cdf0e10cSrcweir         rtl_uString_newConcat( &pNew, pData, str.pData );
976*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
977*cdf0e10cSrcweir     }
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir     friend OUString operator+( const OUString& rStr1, const OUString& rStr2  ) SAL_THROW(())
980*cdf0e10cSrcweir     {
981*cdf0e10cSrcweir         return rStr1.concat( rStr2 );
982*cdf0e10cSrcweir     }
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir     /**
985*cdf0e10cSrcweir       Returns a new string resulting from replacing n = count characters
986*cdf0e10cSrcweir       from position index in this string with newStr.
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir       @param  index   the replacing index in str.
989*cdf0e10cSrcweir                       The index must be greater or equal as 0 and
990*cdf0e10cSrcweir                       less or equal as the length of the string.
991*cdf0e10cSrcweir       @param  count   the count of charcters that will replaced
992*cdf0e10cSrcweir                       The count must be greater or equal as 0 and
993*cdf0e10cSrcweir                       less or equal as the length of the string minus index.
994*cdf0e10cSrcweir       @param  newStr  the new substring.
995*cdf0e10cSrcweir       @return the new string.
996*cdf0e10cSrcweir     */
997*cdf0e10cSrcweir     OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
998*cdf0e10cSrcweir     {
999*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1000*cdf0e10cSrcweir         rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1001*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1002*cdf0e10cSrcweir     }
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir     /**
1005*cdf0e10cSrcweir       Returns a new string resulting from replacing all occurrences of
1006*cdf0e10cSrcweir       oldChar in this string with newChar.
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir       If the character oldChar does not occur in the character sequence
1009*cdf0e10cSrcweir       represented by this object, then the string is assigned with
1010*cdf0e10cSrcweir       str.
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir       @param    oldChar     the old character.
1013*cdf0e10cSrcweir       @param    newChar     the new character.
1014*cdf0e10cSrcweir       @return   a string derived from this string by replacing every
1015*cdf0e10cSrcweir                 occurrence of oldChar with newChar.
1016*cdf0e10cSrcweir     */
1017*cdf0e10cSrcweir     OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
1018*cdf0e10cSrcweir     {
1019*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1020*cdf0e10cSrcweir         rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
1021*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1022*cdf0e10cSrcweir     }
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir     /**
1025*cdf0e10cSrcweir       Converts from this string all ASCII uppercase characters (65-90)
1026*cdf0e10cSrcweir       to ASCII lowercase characters (97-122).
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1029*cdf0e10cSrcweir       If the string doesn't contain characters which must be converted,
1030*cdf0e10cSrcweir       then the new string is assigned with str.
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir       @return   the string, converted to ASCII lowercase.
1033*cdf0e10cSrcweir     */
1034*cdf0e10cSrcweir     OUString toAsciiLowerCase() const SAL_THROW(())
1035*cdf0e10cSrcweir     {
1036*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1037*cdf0e10cSrcweir         rtl_uString_newToAsciiLowerCase( &pNew, pData );
1038*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1039*cdf0e10cSrcweir     }
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir     /**
1042*cdf0e10cSrcweir       Converts from this string all ASCII lowercase characters (97-122)
1043*cdf0e10cSrcweir       to ASCII uppercase characters (65-90).
1044*cdf0e10cSrcweir 
1045*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1046*cdf0e10cSrcweir       If the string doesn't contain characters which must be converted,
1047*cdf0e10cSrcweir       then the new string is assigned with str.
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir       @return   the string, converted to ASCII uppercase.
1050*cdf0e10cSrcweir     */
1051*cdf0e10cSrcweir     OUString toAsciiUpperCase() const SAL_THROW(())
1052*cdf0e10cSrcweir     {
1053*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1054*cdf0e10cSrcweir         rtl_uString_newToAsciiUpperCase( &pNew, pData );
1055*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1056*cdf0e10cSrcweir     }
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir     /**
1059*cdf0e10cSrcweir       Returns a new string resulting from removing white space from both ends
1060*cdf0e10cSrcweir       of the string.
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir       All characters that have codes less than or equal to
1063*cdf0e10cSrcweir       32 (the space character) are considered to be white space.
1064*cdf0e10cSrcweir       If the string doesn't contain white spaces at both ends,
1065*cdf0e10cSrcweir       then the new string is assigned with str.
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir       @return   the string, with white space removed from the front and end.
1068*cdf0e10cSrcweir     */
1069*cdf0e10cSrcweir     OUString trim() const SAL_THROW(())
1070*cdf0e10cSrcweir     {
1071*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1072*cdf0e10cSrcweir         rtl_uString_newTrim( &pNew, pData );
1073*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1074*cdf0e10cSrcweir     }
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir     /**
1077*cdf0e10cSrcweir       Returns a token in the string.
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir       Example:
1080*cdf0e10cSrcweir         sal_Int32 nIndex = 0;
1081*cdf0e10cSrcweir         do
1082*cdf0e10cSrcweir         {
1083*cdf0e10cSrcweir             ...
1084*cdf0e10cSrcweir             OUString aToken = aStr.getToken( 0, ';', nIndex );
1085*cdf0e10cSrcweir             ...
1086*cdf0e10cSrcweir         }
1087*cdf0e10cSrcweir         while ( nIndex >= 0 );
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir       @param    token       the number of the token to return
1090*cdf0e10cSrcweir       @param    cTok        the character which seperate the tokens.
1091*cdf0e10cSrcweir       @param    index       the position at which the token is searched in the
1092*cdf0e10cSrcweir                             string.
1093*cdf0e10cSrcweir                             The index must not be greater than the length of the
1094*cdf0e10cSrcweir                             string.
1095*cdf0e10cSrcweir                             This param is set to the position of the
1096*cdf0e10cSrcweir                             next token or to -1, if it is the last token.
1097*cdf0e10cSrcweir       @return   the token; if either token or index is negative, an empty token
1098*cdf0e10cSrcweir                 is returned (and index is set to -1)
1099*cdf0e10cSrcweir     */
1100*cdf0e10cSrcweir     OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
1101*cdf0e10cSrcweir     {
1102*cdf0e10cSrcweir         rtl_uString * pNew = 0;
1103*cdf0e10cSrcweir         index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
1104*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
1105*cdf0e10cSrcweir     }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir     /**
1108*cdf0e10cSrcweir       Returns the Boolean value from this string.
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir       @return   sal_True, if the string is 1 or "True" in any ASCII case.
1113*cdf0e10cSrcweir                 sal_False in any other case.
1114*cdf0e10cSrcweir     */
1115*cdf0e10cSrcweir     sal_Bool toBoolean() const SAL_THROW(())
1116*cdf0e10cSrcweir     {
1117*cdf0e10cSrcweir         return rtl_ustr_toBoolean( pData->buffer );
1118*cdf0e10cSrcweir     }
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir     /**
1121*cdf0e10cSrcweir       Returns the first character from this string.
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir       @return   the first character from this string or 0, if this string
1124*cdf0e10cSrcweir                 is emptry.
1125*cdf0e10cSrcweir     */
1126*cdf0e10cSrcweir     sal_Unicode toChar() const SAL_THROW(())
1127*cdf0e10cSrcweir     {
1128*cdf0e10cSrcweir         return pData->buffer[0];
1129*cdf0e10cSrcweir     }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir     /**
1132*cdf0e10cSrcweir       Returns the int32 value from this string.
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir       @param    radix       the radix (between 2 and 36)
1137*cdf0e10cSrcweir       @return   the int32 represented from this string.
1138*cdf0e10cSrcweir                 0 if this string represents no number.
1139*cdf0e10cSrcweir     */
1140*cdf0e10cSrcweir     sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
1141*cdf0e10cSrcweir     {
1142*cdf0e10cSrcweir         return rtl_ustr_toInt32( pData->buffer, radix );
1143*cdf0e10cSrcweir     }
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir     /**
1146*cdf0e10cSrcweir       Returns the int64 value from this string.
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir       @param    radix       the radix (between 2 and 36)
1151*cdf0e10cSrcweir       @return   the int64 represented from this string.
1152*cdf0e10cSrcweir                 0 if this string represents no number.
1153*cdf0e10cSrcweir     */
1154*cdf0e10cSrcweir     sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
1155*cdf0e10cSrcweir     {
1156*cdf0e10cSrcweir         return rtl_ustr_toInt64( pData->buffer, radix );
1157*cdf0e10cSrcweir     }
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir     /**
1160*cdf0e10cSrcweir       Returns the float value from this string.
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir       @return   the float represented from this string.
1165*cdf0e10cSrcweir                 0.0 if this string represents no number.
1166*cdf0e10cSrcweir     */
1167*cdf0e10cSrcweir     float toFloat() const SAL_THROW(())
1168*cdf0e10cSrcweir     {
1169*cdf0e10cSrcweir         return rtl_ustr_toFloat( pData->buffer );
1170*cdf0e10cSrcweir     }
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir     /**
1173*cdf0e10cSrcweir       Returns the double value from this string.
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1176*cdf0e10cSrcweir 
1177*cdf0e10cSrcweir       @return   the double represented from this string.
1178*cdf0e10cSrcweir                 0.0 if this string represents no number.
1179*cdf0e10cSrcweir     */
1180*cdf0e10cSrcweir     double toDouble() const SAL_THROW(())
1181*cdf0e10cSrcweir     {
1182*cdf0e10cSrcweir         return rtl_ustr_toDouble( pData->buffer );
1183*cdf0e10cSrcweir     }
1184*cdf0e10cSrcweir 
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir     /**
1187*cdf0e10cSrcweir        Return a canonical representation for a string.
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir        A pool of strings, initially empty is maintained privately
1190*cdf0e10cSrcweir        by the string class. On invocation, if present in the pool
1191*cdf0e10cSrcweir        the original string will be returned. Otherwise this string,
1192*cdf0e10cSrcweir        or a copy thereof will be added to the pool and returned.
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir        @return
1195*cdf0e10cSrcweir        a version of the string from the pool.
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir        @since UDK 3.2.7
1200*cdf0e10cSrcweir     */
1201*cdf0e10cSrcweir     OUString intern() const
1202*cdf0e10cSrcweir     {
1203*cdf0e10cSrcweir         rtl_uString * pNew = 0;
1204*cdf0e10cSrcweir         rtl_uString_intern( &pNew, pData );
1205*cdf0e10cSrcweir #if defined EXCEPTIONS_OFF
1206*cdf0e10cSrcweir         OSL_ASSERT(pNew != NULL);
1207*cdf0e10cSrcweir #else
1208*cdf0e10cSrcweir         if (pNew == 0) {
1209*cdf0e10cSrcweir             throw std::bad_alloc();
1210*cdf0e10cSrcweir         }
1211*cdf0e10cSrcweir #endif
1212*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
1213*cdf0e10cSrcweir     }
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir     /**
1216*cdf0e10cSrcweir        Return a canonical representation for a converted string.
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir        A pool of strings, initially empty is maintained privately
1219*cdf0e10cSrcweir        by the string class. On invocation, if present in the pool
1220*cdf0e10cSrcweir        the original string will be returned. Otherwise this string,
1221*cdf0e10cSrcweir        or a copy thereof will be added to the pool and returned.
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir        @param    value           a 8-Bit character array.
1224*cdf0e10cSrcweir        @param    length          the number of character which should be converted.
1225*cdf0e10cSrcweir                                  The 8-Bit character array length must be
1226*cdf0e10cSrcweir                                  greater or equal than this value.
1227*cdf0e10cSrcweir        @param    encoding        the text encoding from which the 8-Bit character
1228*cdf0e10cSrcweir                                  sequence should be converted.
1229*cdf0e10cSrcweir        @param    convertFlags    flags which controls the conversion.
1230*cdf0e10cSrcweir                                  see RTL_TEXTTOUNICODE_FLAGS_...
1231*cdf0e10cSrcweir        @param    pInfo           pointer to return conversion status or NULL.
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir        @return
1234*cdf0e10cSrcweir        a version of the converted string from the pool.
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir        @exception std::bad_alloc is thrown if an out-of-memory condition occurs
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir        @since UDK 3.2.7
1239*cdf0e10cSrcweir     */
1240*cdf0e10cSrcweir     static OUString intern( const sal_Char * value, sal_Int32 length,
1241*cdf0e10cSrcweir                             rtl_TextEncoding encoding,
1242*cdf0e10cSrcweir                             sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
1243*cdf0e10cSrcweir                             sal_uInt32 *pInfo = NULL )
1244*cdf0e10cSrcweir     {
1245*cdf0e10cSrcweir         rtl_uString * pNew = 0;
1246*cdf0e10cSrcweir         rtl_uString_internConvert( &pNew, value, length, encoding,
1247*cdf0e10cSrcweir                                    convertFlags, pInfo );
1248*cdf0e10cSrcweir #if defined EXCEPTIONS_OFF
1249*cdf0e10cSrcweir         OSL_ASSERT(pNew != NULL);
1250*cdf0e10cSrcweir #else
1251*cdf0e10cSrcweir         if (pNew == 0) {
1252*cdf0e10cSrcweir             throw std::bad_alloc();
1253*cdf0e10cSrcweir         }
1254*cdf0e10cSrcweir #endif
1255*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
1256*cdf0e10cSrcweir     }
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir     /**
1259*cdf0e10cSrcweir       Converts to an OString, signalling failure.
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir       @param pTarget
1262*cdf0e10cSrcweir       An out parameter receiving the converted OString.  Must not be null; the
1263*cdf0e10cSrcweir       contents are not modified if conversion fails (convertToOString returns
1264*cdf0e10cSrcweir       false).
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir       @param nEncoding
1267*cdf0e10cSrcweir       The text encoding to convert into.  Must be an octet encoding (i.e.,
1268*cdf0e10cSrcweir       rtl_isOctetTextEncoding(nEncoding) must return true).
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir       @param nFlags
1271*cdf0e10cSrcweir       A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the
1272*cdf0e10cSrcweir       conversion (see rtl_convertUnicodeToText).  RTL_UNICODETOTEXT_FLAGS_FLUSH
1273*cdf0e10cSrcweir       need not be included, it is implicitly assumed.  Typical uses are either
1274*cdf0e10cSrcweir       RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
1275*cdf0e10cSrcweir       RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot
1276*cdf0e10cSrcweir       be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS
1277*cdf0e10cSrcweir       (make a best efforts conversion).
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir       @return
1280*cdf0e10cSrcweir       True if the conversion succeeded, false otherwise.
1281*cdf0e10cSrcweir      */
1282*cdf0e10cSrcweir     inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
1283*cdf0e10cSrcweir                                 sal_uInt32 nFlags) const
1284*cdf0e10cSrcweir     {
1285*cdf0e10cSrcweir         return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
1286*cdf0e10cSrcweir                                             pData->length, nEncoding, nFlags);
1287*cdf0e10cSrcweir     }
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir     /** Iterate through this string based on code points instead of UTF-16 code
1290*cdf0e10cSrcweir         units.
1291*cdf0e10cSrcweir 
1292*cdf0e10cSrcweir         See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
1293*cdf0e10cSrcweir         definitions of the various terms used in this description.
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir         This string is interpreted as a sequence of zero or more UTF-16 code
1296*cdf0e10cSrcweir         units.  For each index into this sequence (from zero to one less than
1297*cdf0e10cSrcweir         the length of the sequence, inclusive), a code point represented
1298*cdf0e10cSrcweir         starting at the given index is computed as follows:
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir         - If the UTF-16 code unit addressed by the index constitutes a
1301*cdf0e10cSrcweir         well-formed UTF-16 code unit sequence, the computed code point is the
1302*cdf0e10cSrcweir         scalar value encoded by that UTF-16 code unit sequence.
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir         - Otherwise, if the index is at least two UTF-16 code units away from
1305*cdf0e10cSrcweir         the end of the sequence, and the sequence of two UTF-16 code units
1306*cdf0e10cSrcweir         addressed by the index constitutes a well-formed UTF-16 code unit
1307*cdf0e10cSrcweir         sequence, the computed code point is the scalar value encoded by that
1308*cdf0e10cSrcweir         UTF-16 code unit sequence.
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir         - Otherwise, the computed code point is the UTF-16 code unit addressed
1311*cdf0e10cSrcweir         by the index.  (This last case catches unmatched surrogates as well as
1312*cdf0e10cSrcweir         indices pointing into the middle of surrogate pairs.)
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir         @param indexUtf16
1315*cdf0e10cSrcweir         pointer to a UTF-16 based index into this string; must not be null.  On
1316*cdf0e10cSrcweir         entry, the index must be in the range from zero to the length of this
1317*cdf0e10cSrcweir         string (in UTF-16 code units), inclusive.  Upon successful return, the
1318*cdf0e10cSrcweir         index will be updated to address the UTF-16 code unit that is the given
1319*cdf0e10cSrcweir         incrementCodePoints away from the initial index.
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir         @param incrementCodePoints
1322*cdf0e10cSrcweir         the number of code points to move the given *indexUtf16.  If
1323*cdf0e10cSrcweir         non-negative, moving is done after determining the code point at the
1324*cdf0e10cSrcweir         index.  If negative, moving is done before determining the code point
1325*cdf0e10cSrcweir         at the (then updated) index.  The value must be such that the resulting
1326*cdf0e10cSrcweir         UTF-16 based index is in the range from zero to the length of this
1327*cdf0e10cSrcweir         string (in UTF-16 code units), inclusive.
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir         @return
1330*cdf0e10cSrcweir         the code point (an integer in the range from 0 to 0x10FFFF, inclusive)
1331*cdf0e10cSrcweir         that is represented within this string starting at the index computed as
1332*cdf0e10cSrcweir         follows:  If incrementCodePoints is non-negative, the index is the
1333*cdf0e10cSrcweir         initial value of *indexUtf16; if incrementCodePoints is negative, the
1334*cdf0e10cSrcweir         index is the updated value of *indexUtf16.  In either case, the computed
1335*cdf0e10cSrcweir         index must be in the range from zero to one less than the length of this
1336*cdf0e10cSrcweir         string (in UTF-16 code units), inclusive.
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir         @since UDK 3.2.7
1339*cdf0e10cSrcweir     */
1340*cdf0e10cSrcweir     inline sal_uInt32 iterateCodePoints(
1341*cdf0e10cSrcweir         sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
1342*cdf0e10cSrcweir     {
1343*cdf0e10cSrcweir         return rtl_uString_iterateCodePoints(
1344*cdf0e10cSrcweir             pData, indexUtf16, incrementCodePoints);
1345*cdf0e10cSrcweir     }
1346*cdf0e10cSrcweir 
1347*cdf0e10cSrcweir     /**
1348*cdf0e10cSrcweir       Returns the string representation of the sal_Bool argument.
1349*cdf0e10cSrcweir 
1350*cdf0e10cSrcweir       If the sal_Bool is true, the string "true" is returned.
1351*cdf0e10cSrcweir       If the sal_Bool is false, the string "false" is returned.
1352*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir       @param    b   a sal_Bool.
1355*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1356*cdf0e10cSrcweir     */
1357*cdf0e10cSrcweir     static OUString valueOf( sal_Bool b ) SAL_THROW(())
1358*cdf0e10cSrcweir     {
1359*cdf0e10cSrcweir         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
1360*cdf0e10cSrcweir         rtl_uString* pNewData = 0;
1361*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
1362*cdf0e10cSrcweir         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
1363*cdf0e10cSrcweir     }
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir     /**
1366*cdf0e10cSrcweir       Returns the string representation of the char argument.
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir       @param    c   a character.
1369*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1370*cdf0e10cSrcweir     */
1371*cdf0e10cSrcweir     static OUString valueOf( sal_Unicode c ) SAL_THROW(())
1372*cdf0e10cSrcweir     {
1373*cdf0e10cSrcweir         return OUString( &c, 1 );
1374*cdf0e10cSrcweir     }
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir     /**
1377*cdf0e10cSrcweir       Returns the string representation of the int argument.
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1380*cdf0e10cSrcweir 
1381*cdf0e10cSrcweir       @param    i           a int32.
1382*cdf0e10cSrcweir       @param    radix       the radix (between 2 and 36)
1383*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1384*cdf0e10cSrcweir     */
1385*cdf0e10cSrcweir     static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
1386*cdf0e10cSrcweir     {
1387*cdf0e10cSrcweir         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
1388*cdf0e10cSrcweir         rtl_uString* pNewData = 0;
1389*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
1390*cdf0e10cSrcweir         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
1391*cdf0e10cSrcweir     }
1392*cdf0e10cSrcweir 
1393*cdf0e10cSrcweir     /**
1394*cdf0e10cSrcweir       Returns the string representation of the long argument.
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir       @param    ll          a int64.
1399*cdf0e10cSrcweir       @param    radix       the radix (between 2 and 36)
1400*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1401*cdf0e10cSrcweir     */
1402*cdf0e10cSrcweir     static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
1403*cdf0e10cSrcweir     {
1404*cdf0e10cSrcweir         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT64];
1405*cdf0e10cSrcweir         rtl_uString* pNewData = 0;
1406*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
1407*cdf0e10cSrcweir         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
1408*cdf0e10cSrcweir     }
1409*cdf0e10cSrcweir 
1410*cdf0e10cSrcweir     /**
1411*cdf0e10cSrcweir       Returns the string representation of the float argument.
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir       @param    f           a float.
1416*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1417*cdf0e10cSrcweir     */
1418*cdf0e10cSrcweir     static OUString valueOf( float f ) SAL_THROW(())
1419*cdf0e10cSrcweir     {
1420*cdf0e10cSrcweir         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
1421*cdf0e10cSrcweir         rtl_uString* pNewData = 0;
1422*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
1423*cdf0e10cSrcweir         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
1424*cdf0e10cSrcweir     }
1425*cdf0e10cSrcweir 
1426*cdf0e10cSrcweir     /**
1427*cdf0e10cSrcweir       Returns the string representation of the double argument.
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir       This function can't be used for language specific conversion.
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir       @param    d           a double.
1432*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1433*cdf0e10cSrcweir     */
1434*cdf0e10cSrcweir     static OUString valueOf( double d ) SAL_THROW(())
1435*cdf0e10cSrcweir     {
1436*cdf0e10cSrcweir         sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
1437*cdf0e10cSrcweir         rtl_uString* pNewData = 0;
1438*cdf0e10cSrcweir         rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
1439*cdf0e10cSrcweir         return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
1440*cdf0e10cSrcweir     }
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir     /**
1443*cdf0e10cSrcweir       Returns a OUString copied without conversion from an ASCII
1444*cdf0e10cSrcweir       character string.
1445*cdf0e10cSrcweir 
1446*cdf0e10cSrcweir       Since this method is optimized for performance, the ASCII character
1447*cdf0e10cSrcweir       values are not converted in any way. The caller has to make sure that
1448*cdf0e10cSrcweir       all ASCII characters are in the allowed range between 0 and
1449*cdf0e10cSrcweir       127. The ASCII string must be NULL-terminated.
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir       @param    value       the 8-Bit ASCII character string
1452*cdf0e10cSrcweir       @return   a string with the string representation of the argument.
1453*cdf0e10cSrcweir      */
1454*cdf0e10cSrcweir     static OUString createFromAscii( const sal_Char * value ) SAL_THROW(())
1455*cdf0e10cSrcweir     {
1456*cdf0e10cSrcweir         rtl_uString* pNew = 0;
1457*cdf0e10cSrcweir         rtl_uString_newFromAscii( &pNew, value );
1458*cdf0e10cSrcweir         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
1459*cdf0e10cSrcweir     }
1460*cdf0e10cSrcweir };
1461*cdf0e10cSrcweir 
1462*cdf0e10cSrcweir /* ======================================================================= */
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir /** A helper to use OUStrings with hash maps.
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir     Instances of this class are unary function objects that can be used as
1467*cdf0e10cSrcweir     hash function arguments to STLPort's hash_map and similar constructs.
1468*cdf0e10cSrcweir  */
1469*cdf0e10cSrcweir struct OUStringHash
1470*cdf0e10cSrcweir {
1471*cdf0e10cSrcweir     /** Compute a hash code for a string.
1472*cdf0e10cSrcweir 
1473*cdf0e10cSrcweir         @param rString
1474*cdf0e10cSrcweir         a string.
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir         @return
1477*cdf0e10cSrcweir         a hash code for the string.  This hash code should not be stored
1478*cdf0e10cSrcweir         persistently, as its computation may change in later revisions.
1479*cdf0e10cSrcweir      */
1480*cdf0e10cSrcweir     size_t operator()(const rtl::OUString& rString) const
1481*cdf0e10cSrcweir         { return (size_t)rString.hashCode(); }
1482*cdf0e10cSrcweir };
1483*cdf0e10cSrcweir 
1484*cdf0e10cSrcweir /* ======================================================================= */
1485*cdf0e10cSrcweir 
1486*cdf0e10cSrcweir /** Convert an OString to an OUString, using a specific text encoding.
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir     The lengths of the two strings may differ (e.g., for double-byte
1489*cdf0e10cSrcweir     encodings, UTF-7, UTF-8).
1490*cdf0e10cSrcweir 
1491*cdf0e10cSrcweir     @param rStr
1492*cdf0e10cSrcweir     an OString to convert.
1493*cdf0e10cSrcweir 
1494*cdf0e10cSrcweir     @param encoding
1495*cdf0e10cSrcweir     the text encoding to use for conversion.
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir     @param convertFlags
1498*cdf0e10cSrcweir     flags which control the conversion.  Either use
1499*cdf0e10cSrcweir     OSTRING_TO_OUSTRING_CVTFLAGS, or see
1500*cdf0e10cSrcweir     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
1501*cdf0e10cSrcweir     details.
1502*cdf0e10cSrcweir  */
1503*cdf0e10cSrcweir inline OUString OStringToOUString( const OString & rStr,
1504*cdf0e10cSrcweir                                    rtl_TextEncoding encoding,
1505*cdf0e10cSrcweir                                    sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
1506*cdf0e10cSrcweir {
1507*cdf0e10cSrcweir     return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
1508*cdf0e10cSrcweir }
1509*cdf0e10cSrcweir 
1510*cdf0e10cSrcweir /** Convert an OUString to an OString, using a specific text encoding.
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir     The lengths of the two strings may differ (e.g., for double-byte
1513*cdf0e10cSrcweir     encodings, UTF-7, UTF-8).
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir     @param rStr
1516*cdf0e10cSrcweir     an OUString to convert.
1517*cdf0e10cSrcweir 
1518*cdf0e10cSrcweir     @param encoding
1519*cdf0e10cSrcweir     the text encoding to use for conversion.
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir     @param convertFlags
1522*cdf0e10cSrcweir     flags which control the conversion.  Either use
1523*cdf0e10cSrcweir     OUSTRING_TO_OSTRING_CVTFLAGS, or see
1524*cdf0e10cSrcweir     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
1525*cdf0e10cSrcweir     details.
1526*cdf0e10cSrcweir  */
1527*cdf0e10cSrcweir inline OString OUStringToOString( const OUString & rUnicode,
1528*cdf0e10cSrcweir                                   rtl_TextEncoding encoding,
1529*cdf0e10cSrcweir                                   sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
1530*cdf0e10cSrcweir {
1531*cdf0e10cSrcweir     return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
1532*cdf0e10cSrcweir }
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir /* ======================================================================= */
1535*cdf0e10cSrcweir 
1536*cdf0e10cSrcweir } /* Namespace */
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir #endif /* __cplusplus */
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir #endif /* _RTL_USTRING_HXX */
1541