xref: /aoo41x/main/sal/inc/rtl/ustrbuf.hxx (revision 565d668c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _RTL_USTRBUF_HXX_
25 #define _RTL_USTRBUF_HXX_
26 
27 #include <osl/diagnose.h>
28 #include <rtl/ustrbuf.h>
29 #ifndef _RTL_USTRING_HXX
30 #include <rtl/ustring.hxx>
31 #endif
32 
33 #ifdef __cplusplus
34 
35 namespace rtl
36 {
37 
38 /** @HTML
39     A string buffer implements a mutable sequence of characters.
40     <p>
41     String buffers are safe for use by multiple threads. The methods
42     are synchronized where necessary so that all the operations on any
43     particular instance behave as if they occur in some serial order.
44     <p>
45     String buffers are used by the compiler to implement the binary
46     string concatenation operator <code>+</code>. For example, the code:
47     <p><blockquote><pre>
48         x = "a" + 4 + "c"
49     </pre></blockquote><p>
50     is compiled to the equivalent of:
51     <p><blockquote><pre>
52         x = new OUStringBuffer().append("a").append(4).append("c")
53                               .toString()
54     </pre></blockquote><p>
55     The principal operations on a <code>OUStringBuffer</code> are the
56     <code>append</code> and <code>insert</code> methods, which are
57     overloaded so as to accept data of any type. Each effectively
58     converts a given datum to a string and then appends or inserts the
59     characters of that string to the string buffer. The
60     <code>append</code> method always adds these characters at the end
61     of the buffer; the <code>insert</code> method adds the characters at
62     a specified point.
63     <p>
64     For example, if <code>z</code> refers to a string buffer object
65     whose current contents are "<code>start</code>", then
66     the method call <code>z.append("le")</code> would cause the string
67     buffer to contain "<code>startle</code>", whereas
68     <code>z.insert(4, "le")</code> would alter the string buffer to
69     contain "<code>starlet</code>".
70     <p>
71     Every string buffer has a capacity. As long as the length of the
72     character sequence contained in the string buffer does not exceed
73     the capacity, it is not necessary to allocate a new internal
74     buffer array. If the internal buffer overflows, it is
75     automatically made larger.
76  */
77 class OUStringBuffer
78 {
79 public:
80     /**
81         Constructs a string buffer with no characters in it and an
82         initial capacity of 16 characters.
83      */
OUStringBuffer()84     OUStringBuffer()
85         : pData(NULL)
86         , nCapacity( 16 )
87     {
88         rtl_uString_new_WithLength( &pData, nCapacity );
89     }
90 
91     /**
92         Allocates a new string buffer that contains the same sequence of
93         characters as the string buffer argument.
94 
95         @param   value   a <code>OStringBuffer</code>.
96      */
OUStringBuffer(const OUStringBuffer & value)97     OUStringBuffer( const OUStringBuffer & value )
98         : pData(NULL)
99         , nCapacity( value.nCapacity )
100     {
101         rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
102     }
103 
104     /**
105         Constructs a string buffer with no characters in it and an
106         initial capacity specified by the <code>length</code> argument.
107 
108         @param      length   the initial capacity.
109      */
OUStringBuffer(sal_Int32 length)110     OUStringBuffer(sal_Int32 length)
111         : pData(NULL)
112         , nCapacity( length )
113     {
114         rtl_uString_new_WithLength( &pData, length );
115     }
116 
117     /**
118         Constructs a string buffer so that it represents the same
119         sequence of characters as the string argument.
120 
121         The initial
122         capacity of the string buffer is <code>16</code> plus the length
123         of the string argument.
124 
125         @param   str   the initial contents of the buffer.
126      */
OUStringBuffer(OUString value)127     OUStringBuffer(OUString value)
128         : pData(NULL)
129         , nCapacity( value.getLength() + 16 )
130     {
131         rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
132     }
133 
134     /** Assign to this a copy of value.
135      */
operator =(const OUStringBuffer & value)136     OUStringBuffer& operator = ( const OUStringBuffer& value )
137     {
138         if (this != &value)
139         {
140             rtl_uStringbuffer_newFromStringBuffer(&pData,
141                                                   value.nCapacity,
142                                                   value.pData);
143             nCapacity = value.nCapacity;
144         }
145         return *this;
146     }
147 
148     /**
149         Release the string data.
150      */
~OUStringBuffer()151     ~OUStringBuffer()
152     {
153         rtl_uString_release( pData );
154     }
155 
156     /**
157         Fill the string data in the new string and clear the buffer.
158 
159         This method is more efficient than the contructor of the string. It does
160         not copy the buffer.
161 
162         @return the string previously contained in the buffer.
163      */
makeStringAndClear()164     OUString makeStringAndClear()
165     {
166         OUString aRet( pData );
167         rtl_uString_new(&pData);
168         nCapacity = 0;
169         return aRet;
170     }
171 
172     /**
173         Returns the length (character count) of this string buffer.
174 
175         @return  the number of characters in this string buffer.
176      */
getLength() const177     sal_Int32 getLength() const
178     {
179         return pData->length;
180     }
181 
182     /**
183         Returns the current capacity of the String buffer.
184 
185         The capacity
186         is the amount of storage available for newly inserted
187         characters. The real buffer size is 2 bytes longer, because
188         all strings are 0 terminated.
189 
190         @return  the current capacity of this string buffer.
191      */
getCapacity() const192     sal_Int32 getCapacity() const
193     {
194         return nCapacity;
195     }
196 
197     /**
198         Ensures that the capacity of the buffer is at least equal to the
199         specified minimum.
200 
201         The new capacity will be at least as large as the maximum of the current
202         length (so that no contents of the buffer is destroyed) and the given
203         minimumCapacity.  If the given minimumCapacity is negative, nothing is
204         changed.
205 
206         @param   minimumCapacity   the minimum desired capacity.
207      */
ensureCapacity(sal_Int32 minimumCapacity)208     void ensureCapacity(sal_Int32 minimumCapacity)
209     {
210         rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
211     }
212 
213     /**
214         Sets the length of this String buffer.
215 
216         If the <code>newLength</code> argument is less than the current
217         length of the string buffer, the string buffer is truncated to
218         contain exactly the number of characters given by the
219         <code>newLength</code> argument.
220         <p>
221         If the <code>newLength</code> argument is greater than or equal
222         to the current length, sufficient null characters
223         (<code>'&#92;u0000'</code>) are appended to the string buffer so that
224         length becomes the <code>newLength</code> argument.
225         <p>
226         The <code>newLength</code> argument must be greater than or equal
227         to <code>0</code>.
228 
229         @param      newLength   the new length of the buffer.
230      */
setLength(sal_Int32 newLength)231     void setLength(sal_Int32 newLength)
232     {
233         OSL_ASSERT(newLength >= 0);
234         // Avoid modifications if pData points to const empty string:
235         if( newLength != pData->length )
236         {
237             if( newLength > nCapacity )
238                 rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
239             else
240                 pData->buffer[newLength] = 0;
241             pData->length = newLength;
242         }
243     }
244 
245     /**
246         Returns the character at a specific index in this string buffer.
247 
248         The first character of a string buffer is at index
249         <code>0</code>, the next at index <code>1</code>, and so on, for
250         array indexing.
251         <p>
252         The index argument must be greater than or equal to
253         <code>0</code>, and less than the length of this string buffer.
254 
255         @param      index   the index of the desired character.
256         @return     the character at the specified index of this string buffer.
257      */
charAt(sal_Int32 index) const258     sal_Unicode charAt( sal_Int32 index ) const
259     {
260         OSL_ASSERT(index >= 0 && index < pData->length);
261         return pData->buffer[ index ];
262     }
263 
264     /**
265         Return a null terminated unicode character array.
266      */
267     operator        const sal_Unicode *() const { return pData->buffer; }
268 
269     /**
270         Return a null terminated unicode character array.
271      */
getStr() const272     const sal_Unicode*  getStr() const { return pData->buffer; }
273 
274 
275     /**
276         The character at the specified index of this string buffer is set
277         to <code>ch</code>.
278 
279         The index argument must be greater than or equal to
280         <code>0</code>, and less than the length of this string buffer.
281 
282         @param      index   the index of the character to modify.
283         @param      ch      the new character.
284      */
setCharAt(sal_Int32 index,sal_Unicode ch)285     OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
286     {
287         OSL_ASSERT(index >= 0 && index < pData->length);
288         pData->buffer[ index ] = ch;
289         return *this;
290     }
291 
292     /**
293         Appends the string to this string buffer.
294 
295         The characters of the <code>String</code> argument are appended, in
296         order, to the contents of this string buffer, increasing the
297         length of this string buffer by the length of the argument.
298 
299         @param   str   a string.
300         @return  this string buffer.
301      */
append(const OUString & str)302     OUStringBuffer & append(const OUString &str)
303     {
304         return append( str.getStr(), str.getLength() );
305     }
306 
307     /**
308         Appends the string representation of the <code>char</code> array
309         argument to this string buffer.
310 
311         The characters of the array argument are appended, in order, to
312         the contents of this string buffer. The length of this string
313         buffer increases by the length of the argument.
314 
315         @param   str   the characters to be appended.
316         @return  this string buffer.
317      */
append(const sal_Unicode * str)318     OUStringBuffer & append( const sal_Unicode * str )
319     {
320         return append( str, rtl_ustr_getLength( str ) );
321     }
322 
323     /**
324         Appends the string representation of the <code>char</code> array
325         argument to this string buffer.
326 
327         Characters of the character array <code>str</code> are appended,
328         in order, to the contents of this string buffer. The length of this
329         string buffer increases by the value of <code>len</code>.
330 
331         @param str the characters to be appended; must be non-null, and must
332         point to at least len characters
333         @param len the number of characters to append; must be non-negative
334         @return  this string buffer.
335      */
append(const sal_Unicode * str,sal_Int32 len)336     OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
337     {
338         // insert behind the last character
339         rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
340         return *this;
341     }
342 
343     /**
344         Appends a 8-Bit ASCII character string to this string buffer.
345 
346        Since this method is optimized for performance. the ASCII
347         character values are not converted in any way. The caller
348         has to make sure that all ASCII characters are in the
349         allowed range between 0 and 127. The ASCII string must be
350         NULL-terminated.
351         <p>
352         The characters of the array argument are appended, in order, to
353         the contents of this string buffer. The length of this string
354         buffer increases by the length of the argument.
355 
356         @param   str   the 8-Bit ASCII characters to be appended.
357         @return  this string buffer.
358      */
appendAscii(const sal_Char * str)359     OUStringBuffer & appendAscii( const sal_Char * str )
360     {
361         return appendAscii( str, rtl_str_getLength( str ) );
362     }
363 
364     /**
365         Appends a 8-Bit ASCII character string to this string buffer.
366 
367         Since this method is optimized for performance. the ASCII
368         character values are not converted in any way. The caller
369         has to make sure that all ASCII characters are in the
370         allowed range between 0 and 127. The ASCII string must be
371         NULL-terminated.
372         <p>
373         Characters of the character array <code>str</code> are appended,
374         in order, to the contents of this string buffer. The length of this
375         string buffer increases by the value of <code>len</code>.
376 
377         @param str the 8-Bit ASCII characters to be appended; must be non-null,
378         and must point to at least len characters
379         @param len the number of characters to append; must be non-negative
380         @return  this string buffer.
381      */
appendAscii(const sal_Char * str,sal_Int32 len)382     OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
383     {
384         rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
385         return *this;
386     }
387 
388 
389     /**
390         Appends the string representation of the <code>sal_Bool</code>
391         argument to the string buffer.
392 
393         The argument is converted to a string as if by the method
394         <code>String.valueOf</code>, and the characters of that
395         string are then appended to this string buffer.
396 
397         @param   b   a <code>sal_Bool</code>.
398         @return  this string buffer.
399      */
append(sal_Bool b)400     OUStringBuffer & append(sal_Bool b)
401     {
402         sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
403         return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
404     }
405 
406     /**
407         Appends the string representation of the <code>char</code>
408         argument to this string buffer.
409 
410         The argument is appended to the contents of this string buffer.
411         The length of this string buffer increases by <code>1</code>.
412 
413         @param   ch   a <code>char</code>.
414         @return  this string buffer.
415      */
append(sal_Unicode c)416     OUStringBuffer & append(sal_Unicode c)
417     {
418         return append( &c, 1 );
419     }
420 
421     /**
422         Appends the string representation of the <code>sal_Int32</code>
423         argument to this string buffer.
424 
425         The argument is converted to a string as if by the method
426         <code>String.valueOf</code>, and the characters of that
427         string are then appended to this string buffer.
428 
429         @param   i   an <code>sal_Int32</code>.
430         @return  this string buffer.
431      */
append(sal_Int32 i,sal_Int16 radix=10)432     OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
433     {
434         sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
435         return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
436     }
437 
438     /**
439         Appends the string representation of the <code>long</code>
440         argument to this string buffer.
441 
442         The argument is converted to a string as if by the method
443         <code>String.valueOf</code>, and the characters of that
444         string are then appended to this string buffer.
445 
446         @param   l   a <code>long</code>.
447         @return  this string buffer.
448      */
append(sal_Int64 l,sal_Int16 radix=10)449     OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
450     {
451         sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
452         return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
453     }
454 
455     /**
456         Appends the string representation of the <code>float</code>
457         argument to this string buffer.
458 
459         The argument is converted to a string as if by the method
460         <code>String.valueOf</code>, and the characters of that
461         string are then appended to this string buffer.
462 
463         @param   f   a <code>float</code>.
464         @return  this string buffer.
465      */
append(float f)466     OUStringBuffer & append(float f)
467     {
468         sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
469         return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
470     }
471 
472     /**
473         Appends the string representation of the <code>double</code>
474         argument to this string buffer.
475 
476         The argument is converted to a string as if by the method
477         <code>String.valueOf</code>, and the characters of that
478         string are then appended to this string buffer.
479 
480         @param   d   a <code>double</code>.
481         @return  this string buffer.
482      */
append(double d)483     OUStringBuffer & append(double d)
484     {
485         sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
486         return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
487     }
488 
489     /**
490        Appends a single UTF-32 character to this string buffer.
491 
492        <p>The single UTF-32 character will be represented within the string
493        buffer as either one or two UTF-16 code units.</p>
494 
495        @param c a well-formed UTF-32 code unit (that is, a value in the range
496        <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
497        <code>0xD800</code>&ndash;<code>0xDFFF</code>)
498 
499        @return
500        this string buffer
501      */
appendUtf32(sal_uInt32 c)502     OUStringBuffer & appendUtf32(sal_uInt32 c) {
503         return insertUtf32(getLength(), c);
504     }
505 
506     /**
507         Inserts the string into this string buffer.
508 
509         The characters of the <code>String</code> argument are inserted, in
510         order, into this string buffer at the indicated offset. The length
511         of this string buffer is increased by the length of the argument.
512         <p>
513         The offset argument must be greater than or equal to
514         <code>0</code>, and less than or equal to the length of this
515         string buffer.
516 
517         @param      offset   the offset.
518         @param      str      a string.
519         @return     this string buffer.
520      */
insert(sal_Int32 offset,const OUString & str)521     OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
522     {
523         return insert( offset, str.getStr(), str.getLength() );
524     }
525 
526     /**
527         Inserts the string representation of the <code>char</code> array
528         argument into this string buffer.
529 
530         The characters of the array argument are inserted into the
531         contents of this string buffer at the position indicated by
532         <code>offset</code>. The length of this string buffer increases by
533         the length of the argument.
534         <p>
535         The offset argument must be greater than or equal to
536         <code>0</code>, and less than or equal to the length of this
537         string buffer.
538 
539         @param      offset   the offset.
540         @param      ch       a character array.
541         @return     this string buffer.
542      */
insert(sal_Int32 offset,const sal_Unicode * str)543     OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
544     {
545         return insert( offset, str, rtl_ustr_getLength( str ) );
546     }
547 
548     /**
549         Inserts the string representation of the <code>char</code> array
550         argument into this string buffer.
551 
552         The characters of the array argument are inserted into the
553         contents of this string buffer at the position indicated by
554         <code>offset</code>. The length of this string buffer increases by
555         the length of the argument.
556         <p>
557         The offset argument must be greater than or equal to
558         <code>0</code>, and less than or equal to the length of this
559         string buffer.
560 
561         @param      offset   the offset.
562         @param      ch       a character array.
563         @param      len     the number of characters to append.
564         @return     this string buffer.
565      */
insert(sal_Int32 offset,const sal_Unicode * str,sal_Int32 len)566     OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
567     {
568         // insert behind the last character
569         rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
570         return *this;
571     }
572 
573     /**
574         Inserts the string representation of the <code>sal_Bool</code>
575         argument into this string buffer.
576 
577         The second argument is converted to a string as if by the method
578         <code>String.valueOf</code>, and the characters of that
579         string are then inserted into this string buffer at the indicated
580         offset.
581         <p>
582         The offset argument must be greater than or equal to
583         <code>0</code>, and less than or equal to the length of this
584         string buffer.
585 
586         @param      offset   the offset.
587         @param      b        a <code>sal_Bool</code>.
588         @return     this string buffer.
589      */
insert(sal_Int32 offset,sal_Bool b)590     OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
591     {
592         sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
593         return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
594     }
595 
596     /**
597         Inserts the string representation of the <code>char</code>
598         argument into this string buffer.
599 
600         The second argument is inserted into the contents of this string
601         buffer at the position indicated by <code>offset</code>. The length
602         of this string buffer increases by one.
603         <p>
604         The offset argument must be greater than or equal to
605         <code>0</code>, and less than or equal to the length of this
606         string buffer.
607 
608         @param      offset   the offset.
609         @param      ch       a <code>char</code>.
610         @return     this string buffer.
611      */
insert(sal_Int32 offset,sal_Unicode c)612     OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
613     {
614         return insert( offset, &c, 1 );
615     }
616 
617     /**
618         Inserts the string representation of the second <code>sal_Int32</code>
619         argument into this string buffer.
620 
621         The second argument is converted to a string as if by the method
622         <code>String.valueOf</code>, and the characters of that
623         string are then inserted into this string buffer at the indicated
624         offset.
625         <p>
626         The offset argument must be greater than or equal to
627         <code>0</code>, and less than or equal to the length of this
628         string buffer.
629 
630         @param      offset   the offset.
631         @param      b        an <code>sal_Int32</code>.
632         @return     this string buffer.
633         @exception  StringIndexOutOfBoundsException  if the offset is invalid.
634      */
insert(sal_Int32 offset,sal_Int32 i,sal_Int16 radix=10)635     OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
636     {
637         sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
638         return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
639     }
640 
641     /**
642         Inserts the string representation of the <code>long</code>
643         argument into this string buffer.
644 
645         The second argument is converted to a string as if by the method
646         <code>String.valueOf</code>, and the characters of that
647         string are then inserted into this string buffer at the indicated
648         offset.
649         <p>
650         The offset argument must be greater than or equal to
651         <code>0</code>, and less than or equal to the length of this
652         string buffer.
653 
654         @param      offset   the offset.
655         @param      b        a <code>long</code>.
656         @return     this string buffer.
657         @exception  StringIndexOutOfBoundsException  if the offset is invalid.
658      */
insert(sal_Int32 offset,sal_Int64 l,sal_Int16 radix=10)659     OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
660     {
661         sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
662         return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
663     }
664 
665     /**
666         Inserts the string representation of the <code>float</code>
667         argument into this string buffer.
668 
669         The second argument is converted to a string as if by the method
670         <code>String.valueOf</code>, and the characters of that
671         string are then inserted into this string buffer at the indicated
672         offset.
673         <p>
674         The offset argument must be greater than or equal to
675         <code>0</code>, and less than or equal to the length of this
676         string buffer.
677 
678         @param      offset   the offset.
679         @param      b        a <code>float</code>.
680         @return     this string buffer.
681         @exception  StringIndexOutOfBoundsException  if the offset is invalid.
682      */
insert(sal_Int32 offset,float f)683     OUStringBuffer insert(sal_Int32 offset, float f)
684     {
685         sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
686         return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
687     }
688 
689     /**
690         Inserts the string representation of the <code>double</code>
691         argument into this string buffer.
692 
693         The second argument is converted to a string as if by the method
694         <code>String.valueOf</code>, and the characters of that
695         string are then inserted into this string buffer at the indicated
696         offset.
697         <p>
698         The offset argument must be greater than or equal to
699         <code>0</code>, and less than or equal to the length of this
700         string buffer.
701 
702         @param      offset   the offset.
703         @param      b        a <code>double</code>.
704         @return     this string buffer.
705         @exception  StringIndexOutOfBoundsException  if the offset is invalid.
706      */
insert(sal_Int32 offset,double d)707     OUStringBuffer & insert(sal_Int32 offset, double d)
708     {
709         sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
710         return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
711     }
712 
713     /**
714        Inserts a single UTF-32 character into this string buffer.
715 
716        <p>The single UTF-32 character will be represented within the string
717        buffer as either one or two UTF-16 code units.</p>
718 
719        @param offset the offset into this string buffer (from zero to the length
720        of this string buffer, inclusive)
721 
722        @param c a well-formed UTF-32 code unit (that is, a value in the range
723        <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
724        <code>0xD800</code>&ndash;<code>0xDFFF</code>)
725 
726        @return this string buffer
727      */
insertUtf32(sal_Int32 offset,sal_uInt32 c)728     OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
729         rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
730         return *this;
731     }
732 
733     /** Allows access to the internal data of this OUStringBuffer, for effective
734         manipulation.
735 
736         This method should be used with care.  After you have called this
737         method, you may use the returned pInternalData or pInternalCapacity only
738         as long as you make no other method call on this OUStringBuffer.
739 
740         @param pInternalData
741         This output parameter receives a pointer to the internal data
742         (rtl_uString pointer).  pInternalData itself must not be null.
743 
744         @param pInternalCapacity
745         This output parameter receives a pointer to the internal capacity.
746         pInternalCapacity itself must not be null.
747      */
accessInternals(rtl_uString *** pInternalData,sal_Int32 ** pInternalCapacity)748     inline void accessInternals(rtl_uString *** pInternalData,
749                                 sal_Int32 ** pInternalCapacity)
750     {
751         *pInternalData = &pData;
752         *pInternalCapacity = &nCapacity;
753     }
754 
755 private:
756     /**
757         A pointer to the data structur which contains the data.
758      */
759     rtl_uString * pData;
760 
761     /**
762         The len of the pData->buffer.
763      */
764     sal_Int32       nCapacity;
765 };
766 
767 }
768 
769 #endif  /* __cplusplus */
770 #endif  /* _RTL_USTRBUF_HXX_ */
771