1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_STRBUF_HXX
21 #define INCLUDED_RTL_STRBUF_HXX
23 #include <sal/config.h>
28 #include <rtl/strbuf.h>
29 #include <rtl/string.hxx>
30 #include <rtl/stringutils.hxx>
32 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
33 #include <rtl/stringconcat.hxx>
36 // The unittest uses slightly different code to help check that the proper
37 // calls are made. The class is put into a different namespace to make
38 // sure the compiler generates a different (if generating also non-inline)
39 // copy of the function and does not merge them together. The class
40 // is "brought" into the proper rtl namespace by a typedef below.
41 #ifdef RTL_STRING_UNITTEST
42 #define rtl rtlunittest
49 #ifdef RTL_STRING_UNITTEST
51 // helper macro to make functions appear more readable
52 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
54 #define RTL_STRING_CONST_FUNCTION
58 /** A string buffer implements a mutable sequence of characters.
60 class SAL_WARN_UNUSED OStringBuffer
64 Constructs a string buffer with no characters in it and an
65 initial capacity of 16 characters.
71 rtl_string_new_WithLength( &pData
, nCapacity
);
75 Allocates a new string buffer that contains the same sequence of
76 characters as the string buffer argument.
78 @param value a <code>OStringBuffer</code>.
80 OStringBuffer( const OStringBuffer
& value
)
82 , nCapacity( value
.nCapacity
)
84 rtl_stringbuffer_newFromStringBuffer( &pData
, value
.nCapacity
, value
.pData
);
88 Constructs a string buffer with no characters in it and an
89 initial capacity specified by the <code>length</code> argument.
91 @param length the initial capacity.
93 explicit OStringBuffer(int length
)
97 rtl_string_new_WithLength( &pData
, length
);
99 #if __cplusplus >= 201103L
100 explicit OStringBuffer(unsigned int length
)
101 : OStringBuffer(static_cast<int>(length
))
104 #if SAL_TYPES_SIZEOFLONG == 4
105 // additional overloads for sal_Int32 sal_uInt32
106 explicit OStringBuffer(long length
)
107 : OStringBuffer(static_cast<int>(length
))
110 explicit OStringBuffer(unsigned long length
)
111 : OStringBuffer(static_cast<int>(length
))
115 // avoid obvious bugs
116 explicit OStringBuffer(char) = delete;
117 explicit OStringBuffer(sal_Unicode
) = delete;
121 Constructs a string buffer so that it represents the same
122 sequence of characters as the string argument.
125 capacity of the string buffer is <code>16</code> plus the length
126 of the string argument.
128 @param value the initial string value.
130 OStringBuffer(const OString
& value
)
132 , nCapacity( value
.getLength() + 16 )
134 rtl_stringbuffer_newFromStr_WithLength( &pData
, value
.getStr(), value
.getLength() );
139 @since LibreOffice 3.6
141 template< typename T
>
142 OStringBuffer( const T
& value
, typename
libreoffice_internal::CharPtrDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy())
145 sal_Int32 length
= rtl_str_getLength( value
);
146 nCapacity
= length
+ 16;
147 rtl_stringbuffer_newFromStr_WithLength( &pData
, value
, length
);
150 template< typename T
>
151 OStringBuffer( T
& value
, typename
libreoffice_internal::NonConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy())
154 sal_Int32 length
= rtl_str_getLength( value
);
155 nCapacity
= length
+ 16;
156 rtl_stringbuffer_newFromStr_WithLength( &pData
, value
, length
);
160 Constructs a string buffer so that it represents the same
161 sequence of characters as the string literal.
163 If there are any embedded \0's in the string literal, the result is undefined.
164 Use the overload that explicitly accepts length.
166 @since LibreOffice 3.6
168 @param literal a string literal
170 template< typename T
>
171 OStringBuffer( T
& literal
, typename
libreoffice_internal::ConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy())
173 , nCapacity( libreoffice_internal::ConstCharArrayDetector
< T
, void >::size
- 1 + 16 )
175 assert( strlen( literal
) == libreoffice_internal::ConstCharArrayDetector
< T
>::size
- 1 );
176 rtl_string_newFromLiteral( &pData
, literal
, libreoffice_internal::ConstCharArrayDetector
< T
, void >::size
- 1, 16 );
177 #ifdef RTL_STRING_UNITTEST
178 rtl_string_unittest_const_literal
= true;
183 Constructs a string buffer so that it represents the same
184 sequence of characters as the string argument.
187 capacity of the string buffer is <code>16</code> plus length
189 @param value a character array.
190 @param length the number of character which should be copied.
191 The character array length must be greater or
192 equal than this value.
194 OStringBuffer(const sal_Char
* value
, sal_Int32 length
)
196 , nCapacity( length
+ 16 )
198 rtl_stringbuffer_newFromStr_WithLength( &pData
, value
, length
);
201 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
206 template< typename T1
, typename T2
>
207 OStringBuffer( const OStringConcat
< T1
, T2
>& c
)
209 const sal_Int32 l
= c
.length();
211 pData
= rtl_string_alloc( nCapacity
);
212 char* end
= c
.addData( pData
->buffer
);
214 pData
->length
= end
- pData
->buffer
;
218 /** Assign to this a copy of value.
220 OStringBuffer
& operator = ( const OStringBuffer
& value
)
224 rtl_stringbuffer_newFromStringBuffer(&pData
,
227 nCapacity
= value
.nCapacity
;
233 Release the string data.
237 rtl_string_release( pData
);
241 Fill the string data in the new string and clear the buffer.
243 This method is more efficient than the constructor of the string. It does
246 @return the string previously contained in the buffer.
248 OString
makeStringAndClear()
250 OString
aRet( pData
);
251 rtl_string_new(&pData
);
257 Returns the length (character count) of this string buffer.
259 @return the number of characters in this string buffer.
261 sal_Int32
getLength() const
263 return pData
->length
;
267 Checks if a string buffer is empty.
269 @return true if the string buffer is empty;
272 @since LibreOffice 4.1
276 return pData
->length
== 0;
280 Returns the current capacity of the String buffer.
283 is the amount of storage available for newly inserted
284 characters. The real buffer size is 2 bytes longer, because
285 all strings are 0 terminated.
287 @return the current capacity of this string buffer.
289 sal_Int32
getCapacity() const
295 Ensures that the capacity of the buffer is at least equal to the
298 The new capacity will be at least as large as the maximum of the current
299 length (so that no contents of the buffer is destroyed) and the given
300 minimumCapacity. If the given minimumCapacity is negative, nothing is
303 @param minimumCapacity the minimum desired capacity.
305 void ensureCapacity(sal_Int32 minimumCapacity
)
307 rtl_stringbuffer_ensureCapacity( &pData
, &nCapacity
, minimumCapacity
);
311 Sets the length of this String buffer.
313 If the <code>newLength</code> argument is less than the current
314 length of the string buffer, the string buffer is truncated to
315 contain exactly the number of characters given by the
316 <code>newLength</code> argument.
318 If the <code>newLength</code> argument is greater than or equal
319 to the current length, sufficient null characters
320 (<code>'\u0000'</code>) are appended to the string buffer so that
321 length becomes the <code>newLength</code> argument.
323 The <code>newLength</code> argument must be greater than or equal
326 @param newLength the new length of the buffer.
328 void setLength(sal_Int32 newLength
)
330 assert(newLength
>= 0);
331 // Avoid modifications if pData points to const empty string:
332 if( newLength
!= pData
->length
)
334 if( newLength
> nCapacity
)
335 rtl_stringbuffer_ensureCapacity(&pData
, &nCapacity
, newLength
);
337 pData
->buffer
[newLength
] = '\0';
338 pData
->length
= newLength
;
343 Returns the character at a specific index in this string buffer.
345 The first character of a string buffer is at index
346 <code>0</code>, the next at index <code>1</code>, and so on, for
349 The index argument must be greater than or equal to
350 <code>0</code>, and less than the length of this string buffer.
352 @param index the index of the desired character.
353 @return the character at the specified index of this string buffer.
355 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
356 sal_Char
charAt( sal_Int32 index
)
358 assert(index
>= 0 && index
< pData
->length
);
359 return pData
->buffer
[ index
];
363 The character at the specified index of this string buffer is set
366 The index argument must be greater than or equal to
367 <code>0</code>, and less than the length of this string buffer.
369 @param index the index of the character to modify.
370 @param ch the new character.
372 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
373 OStringBuffer
& setCharAt(sal_Int32 index
, sal_Char ch
)
375 assert(index
>= 0 && index
< pData
->length
);
376 pData
->buffer
[ index
] = ch
;
381 Return a null terminated character array.
383 const sal_Char
* getStr() const { return pData
->buffer
; }
386 Access to individual characters.
388 @param index must be non-negative and less than length.
390 @return a reference to the character at the given index.
392 @since LibreOffice 3.5
394 sal_Char
& operator [](sal_Int32 index
)
396 assert(index
>= 0 && index
< pData
->length
);
397 return pData
->buffer
[index
];
401 Return a OString instance reflecting the current content
402 of this OStringBuffer.
404 const OString
toString() const
406 return OString(pData
->buffer
, pData
->length
);
410 Appends the string to this string buffer.
412 The characters of the <code>String</code> argument are appended, in
413 order, to the contents of this string buffer, increasing the
414 length of this string buffer by the length of the argument.
417 @return this string buffer.
419 OStringBuffer
& append(const OString
&str
)
421 return append( str
.getStr(), str
.getLength() );
425 Appends the string representation of the <code>char</code> array
426 argument to this string buffer.
428 The characters of the array argument are appended, in order, to
429 the contents of this string buffer. The length of this string
430 buffer increases by the length of the argument.
432 @param str the characters to be appended.
433 @return this string buffer.
435 template< typename T
>
436 typename
libreoffice_internal::CharPtrDetector
< T
, OStringBuffer
& >::Type
append( const T
& str
)
438 return append( str
, rtl_str_getLength( str
) );
441 template< typename T
>
442 typename
libreoffice_internal::NonConstCharArrayDetector
< T
, OStringBuffer
& >::Type
append( T
& str
)
444 return append( str
, rtl_str_getLength( str
) );
449 This function accepts an ASCII string literal as its argument.
450 @since LibreOffice 3.6
452 template< typename T
>
453 typename
libreoffice_internal::ConstCharArrayDetector
< T
, OStringBuffer
& >::Type
append( T
& literal
)
455 RTL_STRING_CONST_FUNCTION
456 assert( strlen( literal
) == libreoffice_internal::ConstCharArrayDetector
< T
>::size
- 1 );
457 rtl_stringbuffer_insert( &pData
, &nCapacity
, getLength(), literal
, libreoffice_internal::ConstCharArrayDetector
< T
, void >::size
- 1 );
462 Appends the string representation of the <code>char</code> array
463 argument to this string buffer.
465 Characters of the character array <code>str</code> are appended,
466 in order, to the contents of this string buffer. The length of this
467 string buffer increases by the value of <code>len</code>.
469 @param str the characters to be appended; must be non-null, and must
470 point to at least len characters
471 @param len the number of characters to append; must be non-negative
472 @return this string buffer.
474 OStringBuffer
& append( const sal_Char
* str
, sal_Int32 len
)
476 assert( len
== 0 || str
!= 0 ); // cannot assert that in rtl_stringbuffer_insert
477 rtl_stringbuffer_insert( &pData
, &nCapacity
, getLength(), str
, len
);
481 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
486 template< typename T1
, typename T2
>
487 OStringBuffer
& append( const OStringConcat
< T1
, T2
>& c
)
489 const int l
= c
.length();
492 rtl_stringbuffer_ensureCapacity( &pData
, &nCapacity
, pData
->length
+ l
);
493 char* end
= c
.addData( pData
->buffer
+ pData
->length
);
495 pData
->length
= end
- pData
->buffer
;
501 Appends the string representation of the <code>sal_Bool</code>
502 argument to the string buffer.
504 The argument is converted to a string as if by the method
505 <code>String.valueOf</code>, and the characters of that
506 string are then appended to this string buffer.
508 @param b a <code>sal_Bool</code>.
509 @return this string buffer.
511 OStringBuffer
& append(sal_Bool b
)
513 sal_Char sz
[RTL_STR_MAX_VALUEOFBOOLEAN
];
514 return append( sz
, rtl_str_valueOfBoolean( sz
, b
) );
518 Appends the string representation of the <code>bool</code>
519 argument to the string buffer.
521 The argument is converted to a string as if by the method
522 <code>String.valueOf</code>, and the characters of that
523 string are then appended to this string buffer.
525 @param b a <code>bool</code>.
526 @return this string buffer.
528 @since LibreOffice 4.3
530 OStringBuffer
& append(bool b
)
532 sal_Char sz
[RTL_STR_MAX_VALUEOFBOOLEAN
];
533 return append( sz
, rtl_str_valueOfBoolean( sz
, b
) );
537 // Pointer can be automatically converted to bool, which is unwanted here.
538 // Explicitly delete all pointer append() overloads to prevent this
539 // (except for char* overload, which is handled elsewhere).
540 template< typename T
>
541 typename
libreoffice_internal::Enable
< void,
542 !libreoffice_internal::CharPtrDetector
< T
* >::ok
>::Type
543 append( T
* ) SAL_DELETED_FUNCTION
;
547 Appends the string representation of the <code>char</code>
548 argument to this string buffer.
550 The argument is appended to the contents of this string buffer.
551 The length of this string buffer increases by <code>1</code>.
553 @param c a <code>char</code>.
554 @return this string buffer.
556 OStringBuffer
& append(sal_Char c
)
558 return append( &c
, 1 );
562 Appends the string representation of the <code>sal_Int32</code>
563 argument to this string buffer.
565 The argument is converted to a string as if by the method
566 <code>String.valueOf</code>, and the characters of that
567 string are then appended to this string buffer.
569 @param i an <code>sal_Int32</code>.
570 @param radix the radix
571 @return this string buffer.
573 OStringBuffer
& append(sal_Int32 i
, sal_Int16 radix
= 10 )
575 sal_Char sz
[RTL_STR_MAX_VALUEOFINT32
];
576 return append( sz
, rtl_str_valueOfInt32( sz
, i
, radix
) );
580 Appends the string representation of the <code>long</code>
581 argument to this string buffer.
583 The argument is converted to a string as if by the method
584 <code>String.valueOf</code>, and the characters of that
585 string are then appended to this string buffer.
587 @param l a <code>long</code>.
588 @param radix the radix
589 @return this string buffer.
591 OStringBuffer
& append(sal_Int64 l
, sal_Int16 radix
= 10 )
593 sal_Char sz
[RTL_STR_MAX_VALUEOFINT64
];
594 return append( sz
, rtl_str_valueOfInt64( sz
, l
, radix
) );
598 Appends the string representation of the <code>float</code>
599 argument to this string buffer.
601 The argument is converted to a string as if by the method
602 <code>String.valueOf</code>, and the characters of that
603 string are then appended to this string buffer.
605 @param f a <code>float</code>.
606 @return this string buffer.
608 OStringBuffer
& append(float f
)
610 sal_Char sz
[RTL_STR_MAX_VALUEOFFLOAT
];
611 return append( sz
, rtl_str_valueOfFloat( sz
, f
) );
615 Appends the string representation of the <code>double</code>
616 argument to this string buffer.
618 The argument is converted to a string as if by the method
619 <code>String.valueOf</code>, and the characters of that
620 string are then appended to this string buffer.
622 @param d a <code>double</code>.
623 @return this string buffer.
625 OStringBuffer
& append(double d
)
627 sal_Char sz
[RTL_STR_MAX_VALUEOFDOUBLE
];
628 return append( sz
, rtl_str_valueOfDouble( sz
, d
) );
632 Unsafe way to make space for a fixed amount of characters to be appended
633 into this OStringBuffer.
635 A call to this function must immediately be followed by code that
636 completely fills the uninitialized block pointed to by the return value.
638 @param length the length of the uninitialized block of char entities;
641 @return a pointer to the start of the uninitialized block; only valid
642 until this OStringBuffer's capacity changes
644 @since LibreOffice 4.4
646 char * appendUninitialized(sal_Int32 length
) {
647 sal_Int32 n
= getLength();
648 rtl_stringbuffer_insert(&pData
, &nCapacity
, n
, 0, length
);
649 return pData
->buffer
+ n
;
653 Inserts the string into this string buffer.
655 The characters of the <code>String</code> argument are inserted, in
656 order, into this string buffer at the indicated offset. The length
657 of this string buffer is increased by the length of the argument.
659 The offset argument must be greater than or equal to
660 <code>0</code>, and less than or equal to the length of this
663 @param offset the offset.
665 @return this string buffer.
667 OStringBuffer
& insert(sal_Int32 offset
, const OString
& str
)
669 return insert( offset
, str
.getStr(), str
.getLength() );
673 Inserts the string representation of the <code>char</code> array
674 argument into this string buffer.
676 The characters of the array argument are inserted into the
677 contents of this string buffer at the position indicated by
678 <code>offset</code>. The length of this string buffer increases by
679 the length of the argument.
681 The offset argument must be greater than or equal to
682 <code>0</code>, and less than or equal to the length of this
685 @param offset the offset.
686 @param str a character array.
687 @return this string buffer.
689 template< typename T
>
690 typename
libreoffice_internal::CharPtrDetector
< T
, OStringBuffer
& >::Type
insert( sal_Int32 offset
, const T
& str
)
692 return insert( offset
, str
, rtl_str_getLength( str
) );
695 template< typename T
>
696 typename
libreoffice_internal::NonConstCharArrayDetector
< T
, OStringBuffer
& >::Type
insert( sal_Int32 offset
, T
& str
)
698 return insert( offset
, str
, rtl_str_getLength( str
) );
703 This function accepts an ASCII string literal as its argument.
704 @since LibreOffice 3.6
706 template< typename T
>
707 typename
libreoffice_internal::ConstCharArrayDetector
< T
, OStringBuffer
& >::Type
insert( sal_Int32 offset
, T
& literal
)
709 RTL_STRING_CONST_FUNCTION
710 assert( strlen( literal
) == libreoffice_internal::ConstCharArrayDetector
< T
>::size
- 1 );
711 rtl_stringbuffer_insert( &pData
, &nCapacity
, offset
, literal
, libreoffice_internal::ConstCharArrayDetector
< T
, void >::size
- 1 );
716 Inserts the string representation of the <code>char</code> array
717 argument into this string buffer.
719 The characters of the array argument are inserted into the
720 contents of this string buffer at the position indicated by
721 <code>offset</code>. The length of this string buffer increases by
722 the length of the argument.
724 The offset argument must be greater than or equal to
725 <code>0</code>, and less than or equal to the length of this
728 @param offset the offset.
729 @param str a character array.
730 @param len the number of characters to append.
731 @return this string buffer.
733 OStringBuffer
& insert( sal_Int32 offset
, const sal_Char
* str
, sal_Int32 len
)
735 assert( len
== 0 || str
!= 0 ); // cannot assert that in rtl_stringbuffer_insert
736 rtl_stringbuffer_insert( &pData
, &nCapacity
, offset
, str
, len
);
741 Inserts the string representation of the <code>sal_Bool</code>
742 argument into this string buffer.
744 The second argument is converted to a string as if by the method
745 <code>String.valueOf</code>, and the characters of that
746 string are then inserted into this string buffer at the indicated
749 The offset argument must be greater than or equal to
750 <code>0</code>, and less than or equal to the length of this
753 @param offset the offset.
754 @param b a <code>sal_Bool</code>.
755 @return this string buffer.
757 OStringBuffer
& insert(sal_Int32 offset
, sal_Bool b
)
759 sal_Char sz
[RTL_STR_MAX_VALUEOFBOOLEAN
];
760 return insert( offset
, sz
, rtl_str_valueOfBoolean( sz
, b
) );
764 Inserts the string representation of the <code>bool</code>
765 argument into this string buffer.
767 The second argument is converted to a string as if by the method
768 <code>OString::boolean</code>, and the characters of that
769 string are then inserted into this string buffer at the indicated
772 The offset argument must be greater than or equal to
773 <code>0</code>, and less than or equal to the length of this
776 @param offset the offset.
777 @param b a <code>bool</code>.
778 @return this string buffer.
780 @since LibreOffice 4.3
782 OStringBuffer
& insert(sal_Int32 offset
, bool b
)
784 sal_Char sz
[RTL_STR_MAX_VALUEOFBOOLEAN
];
785 return insert( offset
, sz
, rtl_str_valueOfBoolean( sz
, b
) );
789 Inserts the string representation of the <code>char</code>
790 argument into this string buffer.
792 The second argument is inserted into the contents of this string
793 buffer at the position indicated by <code>offset</code>. The length
794 of this string buffer increases by one.
796 The offset argument must be greater than or equal to
797 <code>0</code>, and less than or equal to the length of this
800 @param offset the offset.
801 @param c a <code>char</code>.
802 @return this string buffer.
804 OStringBuffer
& insert(sal_Int32 offset
, sal_Char c
)
806 return insert( offset
, &c
, 1 );
810 Inserts the string representation of the second <code>sal_Int32</code>
811 argument into this string buffer.
813 The second argument is converted to a string as if by the method
814 <code>String.valueOf</code>, and the characters of that
815 string are then inserted into this string buffer at the indicated
818 The offset argument must be greater than or equal to
819 <code>0</code>, and less than or equal to the length of this
822 @param offset the offset.
823 @param i an <code>sal_Int32</code>.
824 @param radix the radix
825 @return this string buffer.
827 OStringBuffer
& insert(sal_Int32 offset
, sal_Int32 i
, sal_Int16 radix
= 10 )
829 sal_Char sz
[RTL_STR_MAX_VALUEOFINT32
];
830 return insert( offset
, sz
, rtl_str_valueOfInt32( sz
, i
, radix
) );
834 Inserts the string representation of the <code>long</code>
835 argument into this string buffer.
837 The second argument is converted to a string as if by the method
838 <code>String.valueOf</code>, and the characters of that
839 string are then inserted into this string buffer at the indicated
842 The offset argument must be greater than or equal to
843 <code>0</code>, and less than or equal to the length of this
846 @param offset the offset.
847 @param l a <code>long</code>.
848 @param radix the radix
849 @return this string buffer.
851 OStringBuffer
& insert(sal_Int32 offset
, sal_Int64 l
, sal_Int16 radix
= 10 )
853 sal_Char sz
[RTL_STR_MAX_VALUEOFINT64
];
854 return insert( offset
, sz
, rtl_str_valueOfInt64( sz
, l
, radix
) );
858 Inserts the string representation of the <code>float</code>
859 argument into this string buffer.
861 The second argument is converted to a string as if by the method
862 <code>String.valueOf</code>, and the characters of that
863 string are then inserted into this string buffer at the indicated
866 The offset argument must be greater than or equal to
867 <code>0</code>, and less than or equal to the length of this
870 @param offset the offset.
871 @param f a <code>float</code>.
872 @return this string buffer.
874 OStringBuffer
insert(sal_Int32 offset
, float f
)
876 sal_Char sz
[RTL_STR_MAX_VALUEOFFLOAT
];
877 return insert( offset
, sz
, rtl_str_valueOfFloat( sz
, f
) );
881 Inserts the string representation of the <code>double</code>
882 argument into this string buffer.
884 The second argument is converted to a string as if by the method
885 <code>String.valueOf</code>, and the characters of that
886 string are then inserted into this string buffer at the indicated
889 The offset argument must be greater than or equal to
890 <code>0</code>, and less than or equal to the length of this
893 @param offset the offset.
894 @param d a <code>double</code>.
895 @return this string buffer.
897 OStringBuffer
& insert(sal_Int32 offset
, double d
)
899 sal_Char sz
[RTL_STR_MAX_VALUEOFDOUBLE
];
900 return insert( offset
, sz
, rtl_str_valueOfDouble( sz
, d
) );
904 Removes the characters in a substring of this sequence.
906 The substring begins at the specified <code>start</code> and
907 is <code>len</code> characters long.
909 start must be >= 0 && <= getLength() && <= end
911 @param start The beginning index, inclusive
912 @param len The substring length
913 @return this string buffer.
915 OStringBuffer
& remove( sal_Int32 start
, sal_Int32 len
)
917 rtl_stringbuffer_remove( &pData
, start
, len
);
923 A pointer to the data structure which contains the data.
928 The len of the pData->buffer.
933 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
938 struct ToStringHelper
< OStringBuffer
>
940 static int length( const OStringBuffer
& s
) { return s
.getLength(); }
941 static char* addData( char* buffer
, const OStringBuffer
& s
) { return addDataHelper( buffer
, s
.getStr(), s
.getLength()); }
942 static const bool allowOStringConcat
= true;
943 static const bool allowOUStringConcat
= false;
950 #ifdef RTL_STRING_UNITTEST
953 typedef rtlunittest::OStringBuffer OStringBuffer
;
955 #undef RTL_STRING_CONST_FUNCTION
958 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
959 using ::rtl::OStringBuffer
;
962 #endif // INCLUDED_RTL_STRBUF_HXX
965 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */