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_USTRBUF_HXX
21 #define INCLUDED_RTL_USTRBUF_HXX
23 #include "sal/config.h"
30 #if defined LIBO_INTERNAL_ONLY
31 #include <string_view>
34 #include "rtl/ustrbuf.h"
35 #include "rtl/ustring.hxx"
36 #include "rtl/stringutils.hxx"
37 #include "sal/types.h"
39 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
40 #include "rtl/stringconcat.hxx"
43 #ifdef RTL_STRING_UNITTEST
44 extern bool rtl_string_unittest_invalid_conversion
;
47 // The unittest uses slightly different code to help check that the proper
48 // calls are made. The class is put into a different namespace to make
49 // sure the compiler generates a different (if generating also non-inline)
50 // copy of the function and does not merge them together. The class
51 // is "brought" into the proper rtl namespace by a typedef below.
52 #ifdef RTL_STRING_UNITTEST
53 #define rtl rtlunittest
59 #ifdef RTL_STRING_UNITTEST
63 /** A string buffer implements a mutable sequence of characters.
65 class SAL_WARN_UNUSED OUStringBuffer
67 friend class OUString
;
70 Constructs a string buffer with no characters in it and an
71 initial capacity of 16 characters.
77 rtl_uString_new_WithLength( &pData
, nCapacity
);
81 Allocates a new string buffer that contains the same sequence of
82 characters as the string buffer argument.
84 @param value a <code>OUStringBuffer</code>.
86 OUStringBuffer( const OUStringBuffer
& value
)
88 , nCapacity( value
.nCapacity
)
90 rtl_uStringbuffer_newFromStringBuffer( &pData
, value
.nCapacity
, value
.pData
);
94 Constructs a string buffer with no characters in it and an
95 initial capacity specified by the <code>length</code> argument.
97 @param length the initial capacity.
99 explicit OUStringBuffer(int length
)
101 , nCapacity( length
)
103 rtl_uString_new_WithLength( &pData
, length
);
105 #if __cplusplus >= 201103L
106 explicit OUStringBuffer(unsigned int length
)
107 : OUStringBuffer(static_cast<int>(length
))
110 #if SAL_TYPES_SIZEOFLONG == 4
111 // additional overloads for sal_Int32 sal_uInt32
112 explicit OUStringBuffer(long length
)
113 : OUStringBuffer(static_cast<int>(length
))
116 explicit OUStringBuffer(unsigned long length
)
117 : OUStringBuffer(static_cast<int>(length
))
121 // avoid obvious bugs
122 explicit OUStringBuffer(char) = delete;
123 explicit OUStringBuffer(sal_Unicode
) = delete;
127 Constructs a string buffer so that it represents the same
128 sequence of characters as the string argument.
131 capacity of the string buffer is <code>16</code> plus the length
132 of the string argument.
134 @param value the initial contents of the buffer.
136 OUStringBuffer(const OUString
& value
)
138 , nCapacity( value
.getLength() + 16 )
140 rtl_uStringbuffer_newFromStr_WithLength( &pData
, value
.getStr(), value
.getLength() );
143 template< typename T
>
144 OUStringBuffer( T
& literal
, typename
libreoffice_internal::ConstCharArrayDetector
< T
, libreoffice_internal::Dummy
>::Type
= libreoffice_internal::Dummy() )
146 , nCapacity( libreoffice_internal::ConstCharArrayDetector
<T
>::length
+ 16 )
149 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
150 rtl_uString_newFromLiteral(
152 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
153 libreoffice_internal::ConstCharArrayDetector
<T
>::length
, 16);
154 #ifdef RTL_STRING_UNITTEST
155 rtl_string_unittest_const_literal
= true;
159 #if defined LIBO_INTERNAL_ONLY
160 /** @overload @since LibreOffice 5.3 */
164 typename
libreoffice_internal::ConstCharArrayDetector
<
165 T
, libreoffice_internal::Dummy
>::TypeUtf16
166 = libreoffice_internal::Dummy()):
168 nCapacity(libreoffice_internal::ConstCharArrayDetector
<T
>::length
+ 16)
170 rtl_uStringbuffer_newFromStr_WithLength(
172 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
173 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
176 /** @overload @since LibreOffice 5.4 */
177 template<std::size_t N
> OUStringBuffer(OUStringLiteral
<N
> const & literal
):
178 pData(nullptr), nCapacity(literal
.getLength() + 16) //TODO: check for overflow
180 rtl_uStringbuffer_newFromStr_WithLength(&pData
, literal
.getStr(), literal
.getLength());
184 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
187 * Only used by unittests to detect incorrect conversions.
190 template< typename T
>
191 OUStringBuffer( T
&, typename
libreoffice_internal::ExceptConstCharArrayDetector
< T
>::Type
= libreoffice_internal::Dummy() )
195 rtl_uString_newFromLiteral( &pData
, "!!br0ken!!", 10, 0 ); // set to garbage
196 rtl_string_unittest_invalid_conversion
= true;
199 * Only used by unittests to detect incorrect conversions.
202 template< typename T
>
203 OUStringBuffer( const T
&, typename
libreoffice_internal::ExceptCharArrayDetector
< T
>::Type
= libreoffice_internal::Dummy() )
207 rtl_uString_newFromLiteral( &pData
, "!!br0ken!!", 10, 0 ); // set to garbage
208 rtl_string_unittest_invalid_conversion
= true;
213 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
218 template< typename T1
, typename T2
>
219 OUStringBuffer( OUStringConcat
< T1
, T2
>&& c
)
221 const sal_Int32 l
= c
.length();
223 pData
= rtl_uString_alloc( nCapacity
);
224 sal_Unicode
* end
= c
.addData( pData
->buffer
);
227 // TODO realloc in case pData->>length is noticeably smaller than l ?
234 template< typename T
>
235 OUStringBuffer( OUStringNumber
< T
>&& n
)
237 , nCapacity( n
.length
+ 16 )
239 rtl_uStringbuffer_newFromStr_WithLength( &pData
, n
.buf
, n
.length
);
242 /** Assign to this a copy of value.
244 OUStringBuffer
& operator = ( const OUStringBuffer
& value
)
248 rtl_uStringbuffer_newFromStringBuffer(&pData
,
251 nCapacity
= value
.nCapacity
;
256 /** Assign from a string.
258 @since LibreOffice 5.3
260 OUStringBuffer
& operator =(OUString
const & string
) {
261 sal_Int32 n
= string
.getLength();
262 if (n
>= nCapacity
) {
263 ensureCapacity(n
+ 16); //TODO: check for overflow
266 pData
->buffer
, string
.pData
->buffer
,
267 (n
+ 1) * sizeof (sal_Unicode
));
272 /** Assign from a string literal.
274 @since LibreOffice 5.3
278 libreoffice_internal::ConstCharArrayDetector
<T
, OUStringBuffer
&>::Type
279 operator =(T
& literal
) {
281 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
283 = libreoffice_internal::ConstCharArrayDetector
<T
>::length
;
284 if (n
>= nCapacity
) {
285 ensureCapacity(n
+ 16); //TODO: check for overflow
288 = libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(
290 sal_Unicode
* to
= pData
->buffer
;
291 for (sal_Int32 i
= 0; i
<= n
; ++i
) {
298 #if defined LIBO_INTERNAL_ONLY
299 /** @overload @since LibreOffice 5.3 */
301 typename
libreoffice_internal::ConstCharArrayDetector
<
302 T
, OUStringBuffer
&>::TypeUtf16
303 operator =(T
& literal
) {
305 = libreoffice_internal::ConstCharArrayDetector
<T
>::length
;
306 if (n
>= nCapacity
) {
307 ensureCapacity(n
+ 16); //TODO: check for overflow
311 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
312 (n
+ 1) * sizeof (sal_Unicode
)); //TODO: check for overflow
317 /** @overload @since LibreOffice 5.4 */
318 template<std::size_t N
> OUStringBuffer
& operator =(OUStringLiteral
<N
> const & literal
) {
319 sal_Int32
const n
= literal
.getLength();
320 if (n
>= nCapacity
) {
321 ensureCapacity(n
+ 16); //TODO: check for overflow
324 pData
->buffer
, literal
.getStr(),
325 (n
+ 1) * sizeof (sal_Unicode
)); //TODO: check for overflow
331 #if defined LIBO_INTERNAL_ONLY
332 /** @overload @since LibreOffice 5.3 */
333 template<typename T1
, typename T2
>
334 OUStringBuffer
& operator =(OUStringConcat
<T1
, T2
> && concat
) {
335 sal_Int32
const n
= concat
.length();
336 if (n
>= nCapacity
) {
337 ensureCapacity(n
+ 16); //TODO: check for overflow
339 *concat
.addData(pData
->buffer
) = 0;
344 /** @overload @internal */
346 OUStringBuffer
& operator =(OUStringNumber
<T
> && n
)
348 *this = OUStringBuffer( std::move( n
) );
354 Release the string data.
358 rtl_uString_release( pData
);
362 Fill the string data in the new string and clear the buffer.
364 This method is more efficient than the constructor of the string. It does
367 @return the string previously contained in the buffer.
369 SAL_WARN_UNUSED_RESULT OUString
makeStringAndClear()
372 rtl_uStringBuffer_makeStringAndClear( &pData
, &nCapacity
),
377 Returns the length (character count) of this string buffer.
379 @return the number of characters in this string buffer.
381 sal_Int32
getLength() const
383 return pData
->length
;
387 Checks if a string buffer is empty.
389 @return true if the string buffer is empty;
392 @since LibreOffice 4.1
396 return pData
->length
== 0;
400 Returns the current capacity of the String buffer.
403 is the amount of storage available for newly inserted
404 characters. The real buffer size is 2 bytes longer, because
405 all strings are 0 terminated.
407 @return the current capacity of this string buffer.
409 sal_Int32
getCapacity() const
415 Ensures that the capacity of the buffer is at least equal to the
418 The new capacity will be at least as large as the maximum of the current
419 length (so that no contents of the buffer is destroyed) and the given
420 minimumCapacity. If the given minimumCapacity is negative, nothing is
423 @param minimumCapacity the minimum desired capacity.
425 void ensureCapacity(sal_Int32 minimumCapacity
)
427 rtl_uStringbuffer_ensureCapacity( &pData
, &nCapacity
, minimumCapacity
);
431 Sets the length of this String buffer.
433 If the <code>newLength</code> argument is less than the current
434 length of the string buffer, the string buffer is truncated to
435 contain exactly the number of characters given by the
436 <code>newLength</code> argument.
438 If the <code>newLength</code> argument is greater than or equal
439 to the current length, sufficient null characters
440 (<code>'\u0000'</code>) are appended to the string buffer so that
441 length becomes the <code>newLength</code> argument.
443 The <code>newLength</code> argument must be greater than or equal
446 @param newLength the new length of the buffer.
448 void setLength(sal_Int32 newLength
)
450 assert(newLength
>= 0);
451 // Avoid modifications if pData points to const empty string:
452 if( newLength
!= pData
->length
)
454 if( newLength
> nCapacity
)
455 rtl_uStringbuffer_ensureCapacity(&pData
, &nCapacity
, newLength
);
457 pData
->buffer
[newLength
] = 0;
458 pData
->length
= newLength
;
463 Returns the character at a specific index in this string buffer.
465 The first character of a string buffer is at index
466 <code>0</code>, the next at index <code>1</code>, and so on, for
469 The index argument must be greater than or equal to
470 <code>0</code>, and less than the length of this string buffer.
472 @param index the index of the desired character.
473 @return the character at the specified index of this string buffer.
475 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
476 sal_Unicode
charAt( sal_Int32 index
) const
478 assert(index
>= 0 && index
< pData
->length
);
479 return pData
->buffer
[ index
];
483 The character at the specified index of this string buffer is set
486 The index argument must be greater than or equal to
487 <code>0</code>, and less than the length of this string buffer.
489 @param index the index of the character to modify.
490 @param ch the new character.
492 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
493 OUStringBuffer
& setCharAt(sal_Int32 index
, sal_Unicode ch
)
495 assert(index
>= 0 && index
< pData
->length
);
496 pData
->buffer
[ index
] = ch
;
501 Return a null terminated unicode character array.
503 const sal_Unicode
* getStr() const SAL_RETURNS_NONNULL
{ return pData
->buffer
; }
506 Access to individual characters.
508 @param index must be non-negative and less than length.
510 @return a reference to the character at the given index.
512 @since LibreOffice 3.5
514 sal_Unicode
& operator [](sal_Int32 index
)
516 assert(index
>= 0 && index
< pData
->length
);
517 return pData
->buffer
[index
];
521 Access to individual characters.
523 @param index must be non-negative and less than length.
525 @return a reference to the character at the given index.
527 @since LibreOffice 4.2
529 const sal_Unicode
& operator [](sal_Int32 index
) const
531 assert(index
>= 0 && index
< pData
->length
);
532 return pData
->buffer
[index
];
536 Return an OUString instance reflecting the current content
537 of this OUStringBuffer.
539 const OUString
toString() const
541 return OUString(pData
->buffer
, pData
->length
);
545 Appends the string to this string buffer.
547 The characters of the <code>OUString</code> argument are appended, in
548 order, to the contents of this string buffer, increasing the
549 length of this string buffer by the length of the argument.
552 @return this string buffer.
554 OUStringBuffer
& append(const OUString
&str
)
556 return append( str
.getStr(), str
.getLength() );
559 #if defined LIBO_INTERNAL_ONLY
560 OUStringBuffer
& append(std::u16string_view sv
) {
561 if (sv
.size() > sal_uInt32(std::numeric_limits
<sal_Int32
>::max())) {
562 throw std::bad_alloc();
564 return append(sv
.data(), sv
.size());
569 Appends the content of a stringbuffer to this string buffer.
571 The characters of the <code>OUStringBuffer</code> argument are appended, in
572 order, to the contents of this string buffer, increasing the
573 length of this string buffer by the length of the argument.
576 @return this string buffer.
578 @since LibreOffice 4.0
580 OUStringBuffer
& append(const OUStringBuffer
&str
)
584 append( str
.getStr(), str
.getLength() );
590 Appends the string representation of the <code>char</code> array
591 argument to this string buffer.
593 The characters of the array argument are appended, in order, to
594 the contents of this string buffer. The length of this string
595 buffer increases by the length of the argument.
597 @param str the characters to be appended.
598 @return this string buffer.
600 #if defined LIBO_INTERNAL_ONLY
602 typename
libreoffice_internal::CharPtrDetector
<T
, OUStringBuffer
&>::TypeUtf16
603 append(T
const & str
)
605 OUStringBuffer
& append( const sal_Unicode
* str
)
608 return append( str
, rtl_ustr_getLength( str
) );
612 Appends the string representation of the <code>char</code> array
613 argument to this string buffer.
615 Characters of the character array <code>str</code> are appended,
616 in order, to the contents of this string buffer. The length of this
617 string buffer increases by the value of <code>len</code>.
619 @param str the characters to be appended; must be non-null, and must
620 point to at least len characters
621 @param len the number of characters to append; must be non-negative
622 @return this string buffer.
624 OUStringBuffer
& append( const sal_Unicode
* str
, sal_Int32 len
)
626 assert( len
== 0 || str
!= NULL
); // cannot assert that in rtl_uStringbuffer_insert
627 rtl_uStringbuffer_insert( &pData
, &nCapacity
, getLength(), str
, len
);
633 This function accepts an ASCII string literal as its argument.
634 @since LibreOffice 3.6
636 template< typename T
>
637 typename
libreoffice_internal::ConstCharArrayDetector
< T
, OUStringBuffer
& >::Type
append( T
& literal
)
640 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
642 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
643 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
646 #if defined LIBO_INTERNAL_ONLY
648 typename
libreoffice_internal::NonConstCharArrayDetector
<T
, OUStringBuffer
&>::TypeUtf16
649 append(T
& value
) { return append(static_cast<sal_Unicode
*>(value
)); }
651 /** @overload @since LibreOffice 5.3 */
653 typename
libreoffice_internal::ConstCharArrayDetector
<
654 T
, OUStringBuffer
&>::TypeUtf16
655 append(T
& literal
) {
657 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
658 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
661 /** @overload @since LibreOffice 5.4 */
662 template<std::size_t N
> OUStringBuffer
& append(OUStringLiteral
<N
> const & literal
) {
663 return append(literal
.getStr(), literal
.getLength());
667 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
672 template< typename T1
, typename T2
>
673 OUStringBuffer
& append( OUStringConcat
< T1
, T2
>&& c
)
675 sal_Int32 l
= c
.length();
679 rtl_uStringbuffer_ensureCapacity( &pData
, &nCapacity
, l
);
680 sal_Unicode
* end
= c
.addData( pData
->buffer
+ pData
->length
);
690 template< typename T
>
691 OUStringBuffer
& append( OUStringNumber
< T
>&& c
)
693 return append( c
.buf
, c
.length
);
698 Appends a 8-Bit ASCII character string to this string buffer.
700 Since this method is optimized for performance. the ASCII
701 character values are not converted in any way. The caller
702 has to make sure that all ASCII characters are in the
703 allowed range between 0 and 127. The ASCII string must be
706 The characters of the array argument are appended, in order, to
707 the contents of this string buffer. The length of this string
708 buffer increases by the length of the argument.
710 @param str the 8-Bit ASCII characters to be appended.
711 @return this string buffer.
713 OUStringBuffer
& appendAscii( const char * str
)
715 return appendAscii( str
, rtl_str_getLength( str
) );
719 Appends a 8-Bit ASCII character string to this string buffer.
721 Since this method is optimized for performance. the ASCII
722 character values are not converted in any way. The caller
723 has to make sure that all ASCII characters are in the
724 allowed range between 0 and 127. The ASCII string must be
727 Characters of the character array <code>str</code> are appended,
728 in order, to the contents of this string buffer. The length of this
729 string buffer increases by the value of <code>len</code>.
731 @param str the 8-Bit ASCII characters to be appended; must be non-null,
732 and must point to at least len characters
733 @param len the number of characters to append; must be non-negative
734 @return this string buffer.
736 OUStringBuffer
& appendAscii( const char * str
, sal_Int32 len
)
738 rtl_uStringbuffer_insert_ascii( &pData
, &nCapacity
, getLength(), str
, len
);
743 Appends the string representation of the <code>bool</code>
744 argument to the string buffer.
746 The argument is converted to a string as if by the method
747 <code>String.valueOf</code>, and the characters of that
748 string are then appended to this string buffer.
750 @param b a <code>bool</code>.
751 @return this string buffer.
753 @since LibreOffice 4.1
755 OUStringBuffer
& append(bool b
)
757 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFBOOLEAN
];
758 return append( sz
, rtl_ustr_valueOfBoolean( sz
, b
) );
762 // Pointer can be automatically converted to bool, which is unwanted here.
763 // Explicitly delete all pointer append() overloads to prevent this
764 // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
765 template< typename T
>
766 typename
libreoffice_internal::Enable
< void,
767 !libreoffice_internal::CharPtrDetector
< T
* >::ok
&& !libreoffice_internal::SalUnicodePtrDetector
< T
* >::ok
>::Type
768 append( T
* ) SAL_DELETED_FUNCTION
;
771 // This overload is needed because OUString has a ctor from rtl_uString*, but
772 // the bool overload above would be preferred to the conversion.
776 OUStringBuffer
& append(rtl_uString
* str
)
778 return append( OUString( str
));
782 Appends the string representation of the <code>sal_Bool</code>
783 argument to the string buffer.
785 The argument is converted to a string as if by the method
786 <code>String.valueOf</code>, and the characters of that
787 string are then appended to this string buffer.
789 @param b a <code>sal_Bool</code>.
790 @return this string buffer.
792 OUStringBuffer
& append(sal_Bool b
)
794 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFBOOLEAN
];
795 return append( sz
, rtl_ustr_valueOfBoolean( sz
, b
) );
799 Appends the string representation of the ASCII <code>char</code>
800 argument to this string buffer.
802 The argument is appended to the contents of this string buffer.
803 The length of this string buffer increases by <code>1</code>.
805 @param c an ASCII <code>char</code>.
806 @return this string buffer.
808 @since LibreOffice 3.5
810 OUStringBuffer
& append(char c
)
812 assert(static_cast< unsigned char >(c
) <= 0x7F);
813 return append(sal_Unicode(c
));
817 Appends the string representation of the <code>char</code>
818 argument to this string buffer.
820 The argument is appended to the contents of this string buffer.
821 The length of this string buffer increases by <code>1</code>.
823 @param c a <code>char</code>.
824 @return this string buffer.
826 OUStringBuffer
& append(sal_Unicode c
)
828 return append( &c
, 1 );
831 #if defined LIBO_INTERNAL_ONLY
832 void append(sal_uInt16
) = delete;
836 Appends the string representation of the <code>sal_Int32</code>
837 argument to this string buffer.
839 The argument is converted to a string as if by the method
840 <code>String.valueOf</code>, and the characters of that
841 string are then appended to this string buffer.
843 @param i an <code>sal_Int32</code>.
844 @param radix the radix
845 @return this string buffer.
847 OUStringBuffer
& append(sal_Int32 i
, sal_Int16 radix
= 10 )
849 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFINT32
];
850 return append( sz
, rtl_ustr_valueOfInt32( sz
, i
, radix
) );
854 Appends the string representation of the <code>long</code>
855 argument to this string buffer.
857 The argument is converted to a string as if by the method
858 <code>String.valueOf</code>, and the characters of that
859 string are then appended to this string buffer.
861 @param l a <code>long</code>.
862 @param radix the radix
863 @return this string buffer.
865 OUStringBuffer
& append(sal_Int64 l
, sal_Int16 radix
= 10 )
867 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFINT64
];
868 return append( sz
, rtl_ustr_valueOfInt64( sz
, l
, radix
) );
872 Appends the string representation of the <code>float</code>
873 argument to this string buffer.
875 The argument is converted to a string as if by the method
876 <code>String.valueOf</code>, and the characters of that
877 string are then appended to this string buffer.
879 @param f a <code>float</code>.
880 @return this string buffer.
882 OUStringBuffer
& append(float f
)
884 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFFLOAT
];
885 return append( sz
, rtl_ustr_valueOfFloat( sz
, f
) );
889 Appends the string representation of the <code>double</code>
890 argument to this string buffer.
892 The argument is converted to a string as if by the method
893 <code>String.valueOf</code>, and the characters of that
894 string are then appended to this string buffer.
896 @param d a <code>double</code>.
897 @return this string buffer.
899 OUStringBuffer
& append(double d
)
901 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFDOUBLE
];
902 return append( sz
, rtl_ustr_valueOfDouble( sz
, d
) );
906 Appends a single UTF-32 character to this string buffer.
908 <p>The single UTF-32 character will be represented within the string
909 buffer as either one or two UTF-16 code units.</p>
911 @param c a well-formed UTF-32 code unit (that is, a value in the range
912 <code>0</code>–<code>0x10FFFF</code>, but excluding
913 <code>0xD800</code>–<code>0xDFFF</code>)
918 OUStringBuffer
& appendUtf32(sal_uInt32 c
) {
919 return insertUtf32(getLength(), c
);
923 Unsafe way to make space for a fixed amount of characters to be appended
924 into this OUStringBuffer.
926 A call to this function must immediately be followed by code that
927 completely fills the uninitialized block pointed to by the return value.
929 @param length the length of the uninitialized block of sal_Unicode
930 entities; must be non-negative
932 @return a pointer to the start of the uninitialized block; only valid
933 until this OUStringBuffer's capacity changes
935 @since LibreOffice 4.4
937 sal_Unicode
* appendUninitialized(sal_Int32 length
) SAL_RETURNS_NONNULL
{
938 sal_Int32 n
= getLength();
939 rtl_uStringbuffer_insert(&pData
, &nCapacity
, n
, NULL
, length
);
940 return pData
->buffer
+ n
;
944 Inserts the string into this string buffer.
946 The characters of the <code>String</code> argument are inserted, in
947 order, into this string buffer at the indicated offset. The length
948 of this string buffer is increased by the length of the argument.
950 The offset argument must be greater than or equal to
951 <code>0</code>, and less than or equal to the length of this
954 @param offset the offset.
956 @return this string buffer.
958 OUStringBuffer
& insert(sal_Int32 offset
, const OUString
& str
)
960 return insert( offset
, str
.getStr(), str
.getLength() );
964 Inserts the string representation of the <code>char</code> array
965 argument into this string buffer.
967 The characters of the array argument are inserted into the
968 contents of this string buffer at the position indicated by
969 <code>offset</code>. The length of this string buffer increases by
970 the length of the argument.
972 The offset argument must be greater than or equal to
973 <code>0</code>, and less than or equal to the length of this
976 @param offset the offset.
977 @param str a character array.
978 @return this string buffer.
980 OUStringBuffer
& insert( sal_Int32 offset
, const sal_Unicode
* str
)
982 return insert( offset
, str
, rtl_ustr_getLength( str
) );
986 Inserts the string representation of the <code>char</code> array
987 argument into this string buffer.
989 The characters of the array argument are inserted into the
990 contents of this string buffer at the position indicated by
991 <code>offset</code>. The length of this string buffer increases by
992 the length of the argument.
994 The offset argument must be greater than or equal to
995 <code>0</code>, and less than or equal to the length of this
998 @param offset the offset.
999 @param str a character array.
1000 @param len the number of characters to append.
1001 @return this string buffer.
1003 OUStringBuffer
& insert( sal_Int32 offset
, const sal_Unicode
* str
, sal_Int32 len
)
1005 assert( len
== 0 || str
!= NULL
); // cannot assert that in rtl_uStringbuffer_insert
1006 rtl_uStringbuffer_insert( &pData
, &nCapacity
, offset
, str
, len
);
1012 This function accepts an ASCII string literal as its argument.
1013 @since LibreOffice 3.6
1015 template< typename T
>
1016 typename
libreoffice_internal::ConstCharArrayDetector
< T
, OUStringBuffer
& >::Type
insert( sal_Int32 offset
, T
& literal
)
1019 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1020 rtl_uStringbuffer_insert_ascii(
1021 &pData
, &nCapacity
, offset
,
1022 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1023 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1027 #if defined LIBO_INTERNAL_ONLY
1028 /** @overload @since LibreOffice 5.3 */
1029 template<typename T
>
1030 typename
libreoffice_internal::ConstCharArrayDetector
<
1031 T
, OUStringBuffer
&>::TypeUtf16
1032 insert(sal_Int32 offset
, T
& literal
) {
1035 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1036 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1039 /** @overload @since LibreOffice 5.4 */
1040 template<std::size_t N
>
1041 OUStringBuffer
& insert(sal_Int32 offset
, OUStringLiteral
<N
> const & literal
) {
1042 return insert(offset
, literal
.getStr(), literal
.getLength());
1047 Inserts the string representation of the <code>sal_Bool</code>
1048 argument into this string buffer.
1050 The second argument is converted to a string as if by the method
1051 <code>String.valueOf</code>, and the characters of that
1052 string are then inserted into this string buffer at the indicated
1055 The offset argument must be greater than or equal to
1056 <code>0</code>, and less than or equal to the length of this
1059 @param offset the offset.
1060 @param b a <code>sal_Bool</code>.
1061 @return this string buffer.
1063 OUStringBuffer
& insert(sal_Int32 offset
, sal_Bool b
)
1065 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFBOOLEAN
];
1066 return insert( offset
, sz
, rtl_ustr_valueOfBoolean( sz
, b
) );
1070 Inserts the string representation of the <code>bool</code>
1071 argument into this string buffer.
1073 The second argument is converted to a string as if by the method
1074 <code>OUString::boolean</code>, and the characters of that
1075 string are then inserted into this string buffer at the indicated
1078 The offset argument must be greater than or equal to
1079 <code>0</code>, and less than or equal to the length of this
1082 @param offset the offset.
1083 @param b a <code>bool</code>.
1084 @return this string buffer.
1086 @since LibreOffice 4.3
1088 OUStringBuffer
& insert(sal_Int32 offset
, bool b
)
1090 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFBOOLEAN
];
1091 return insert( offset
, sz
, rtl_ustr_valueOfBoolean( sz
, b
) );
1095 Inserts the string representation of the <code>char</code>
1096 argument into this string buffer.
1098 The second argument is inserted into the contents of this string
1099 buffer at the position indicated by <code>offset</code>. The length
1100 of this string buffer increases by one.
1102 The offset argument must be greater than or equal to
1103 <code>0</code>, and less than or equal to the length of this
1106 @param offset the offset.
1107 @param c a <code>char</code>.
1108 @return this string buffer.
1110 @since LibreOffice 3.6
1112 OUStringBuffer
& insert(sal_Int32 offset
, char c
)
1115 return insert( offset
, &u
, 1 );
1119 Inserts the string representation of the <code>char</code>
1120 argument into this string buffer.
1122 The second argument is inserted into the contents of this string
1123 buffer at the position indicated by <code>offset</code>. The length
1124 of this string buffer increases by one.
1126 The offset argument must be greater than or equal to
1127 <code>0</code>, and less than or equal to the length of this
1130 @param offset the offset.
1131 @param c a <code>char</code>.
1132 @return this string buffer.
1134 OUStringBuffer
& insert(sal_Int32 offset
, sal_Unicode c
)
1136 return insert( offset
, &c
, 1 );
1140 Inserts the string representation of the second <code>sal_Int32</code>
1141 argument into this string buffer.
1143 The second argument is converted to a string as if by the method
1144 <code>String.valueOf</code>, and the characters of that
1145 string are then inserted into this string buffer at the indicated
1148 The offset argument must be greater than or equal to
1149 <code>0</code>, and less than or equal to the length of this
1152 @param offset the offset.
1153 @param i an <code>sal_Int32</code>.
1154 @param radix the radix.
1155 @return this string buffer.
1156 @exception StringIndexOutOfBoundsException if the offset is invalid.
1158 OUStringBuffer
& insert(sal_Int32 offset
, sal_Int32 i
, sal_Int16 radix
= 10 )
1160 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFINT32
];
1161 return insert( offset
, sz
, rtl_ustr_valueOfInt32( sz
, i
, radix
) );
1165 Inserts the string representation of the <code>long</code>
1166 argument into this string buffer.
1168 The second argument is converted to a string as if by the method
1169 <code>String.valueOf</code>, and the characters of that
1170 string are then inserted into this string buffer at the indicated
1173 The offset argument must be greater than or equal to
1174 <code>0</code>, and less than or equal to the length of this
1177 @param offset the offset.
1178 @param l a <code>long</code>.
1179 @param radix the radix.
1180 @return this string buffer.
1181 @exception StringIndexOutOfBoundsException if the offset is invalid.
1183 OUStringBuffer
& insert(sal_Int32 offset
, sal_Int64 l
, sal_Int16 radix
= 10 )
1185 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFINT64
];
1186 return insert( offset
, sz
, rtl_ustr_valueOfInt64( sz
, l
, radix
) );
1190 Inserts the string representation of the <code>float</code>
1191 argument into this string buffer.
1193 The second argument is converted to a string as if by the method
1194 <code>String.valueOf</code>, and the characters of that
1195 string are then inserted into this string buffer at the indicated
1198 The offset argument must be greater than or equal to
1199 <code>0</code>, and less than or equal to the length of this
1202 @param offset the offset.
1203 @param f a <code>float</code>.
1204 @return this string buffer.
1205 @exception StringIndexOutOfBoundsException if the offset is invalid.
1207 OUStringBuffer
insert(sal_Int32 offset
, float f
)
1209 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFFLOAT
];
1210 return insert( offset
, sz
, rtl_ustr_valueOfFloat( sz
, f
) );
1214 Inserts the string representation of the <code>double</code>
1215 argument into this string buffer.
1217 The second argument is converted to a string as if by the method
1218 <code>String.valueOf</code>, and the characters of that
1219 string are then inserted into this string buffer at the indicated
1222 The offset argument must be greater than or equal to
1223 <code>0</code>, and less than or equal to the length of this
1226 @param offset the offset.
1227 @param d a <code>double</code>.
1228 @return this string buffer.
1229 @exception StringIndexOutOfBoundsException if the offset is invalid.
1231 OUStringBuffer
& insert(sal_Int32 offset
, double d
)
1233 sal_Unicode sz
[RTL_USTR_MAX_VALUEOFDOUBLE
];
1234 return insert( offset
, sz
, rtl_ustr_valueOfDouble( sz
, d
) );
1238 Inserts a single UTF-32 character into this string buffer.
1240 <p>The single UTF-32 character will be represented within the string
1241 buffer as either one or two UTF-16 code units.</p>
1243 @param offset the offset into this string buffer (from zero to the length
1244 of this string buffer, inclusive)
1246 @param c a well-formed UTF-32 code unit (that is, a value in the range
1247 <code>0</code>–<code>0x10FFFF</code>, but excluding
1248 <code>0xD800</code>–<code>0xDFFF</code>)
1250 @return this string buffer
1252 OUStringBuffer
& insertUtf32(sal_Int32 offset
, sal_uInt32 c
) {
1253 rtl_uStringbuffer_insertUtf32(&pData
, &nCapacity
, offset
, c
);
1258 Removes the characters in a substring of this sequence.
1260 The substring begins at the specified <code>start</code> and
1261 is <code>len</code> characters long.
1263 start must be >= 0 && <= This->length
1265 @param start The beginning index, inclusive
1266 @param len The substring length
1267 @return this string buffer.
1269 OUStringBuffer
& remove( sal_Int32 start
, sal_Int32 len
)
1271 rtl_uStringbuffer_remove( &pData
, start
, len
);
1276 Removes the tail of a string buffer start at the indicate position
1278 start must be >= 0 && <= This->length
1280 @param start The beginning index, inclusive. default to 0
1281 @return this string buffer.
1283 @since LibreOffice 4.0
1285 OUStringBuffer
& truncate( sal_Int32 start
= 0 )
1287 rtl_uStringbuffer_remove( &pData
, start
, getLength() - start
);
1292 Replace all occurrences of
1293 oldChar in this string buffer with newChar.
1295 @since LibreOffice 4.0
1297 @param oldChar the old character.
1298 @param newChar the new character.
1299 @return this string buffer
1301 OUStringBuffer
& replace( sal_Unicode oldChar
, sal_Unicode newChar
)
1303 sal_Int32 index
= 0;
1304 while((index
= indexOf(oldChar
, index
)) >= 0)
1306 pData
->buffer
[ index
] = newChar
;
1311 /** Allows access to the internal data of this OUStringBuffer, for effective
1314 This method should be used with care. After you have called this
1315 method, you may use the returned pInternalData or pInternalCapacity only
1316 as long as you make no other method call on this OUStringBuffer.
1318 @param pInternalData
1319 This output parameter receives a pointer to the internal data
1320 (rtl_uString pointer). pInternalData itself must not be null.
1322 @param pInternalCapacity
1323 This output parameter receives a pointer to the internal capacity.
1324 pInternalCapacity itself must not be null.
1326 void accessInternals(rtl_uString
*** pInternalData
,
1327 sal_Int32
** pInternalCapacity
)
1329 *pInternalData
= &pData
;
1330 *pInternalCapacity
= &nCapacity
;
1335 Returns the index within this string of the first occurrence of the
1336 specified character, starting the search at the specified index.
1338 @since LibreOffice 4.0
1340 @param ch character to be located.
1341 @param fromIndex the index to start the search from.
1342 The index must be greater or equal than 0
1343 and less or equal as the string length.
1344 @return the index of the first occurrence of the character in the
1345 character sequence represented by this string that is
1346 greater than or equal to fromIndex, or
1347 -1 if the character does not occur.
1349 sal_Int32
indexOf( sal_Unicode ch
, sal_Int32 fromIndex
= 0 ) const
1351 assert( fromIndex
>= 0 && fromIndex
<= pData
->length
);
1352 sal_Int32 ret
= rtl_ustr_indexOfChar_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
, ch
);
1353 return (ret
< 0 ? ret
: ret
+fromIndex
);
1357 Returns the index within this string of the last occurrence of the
1358 specified character, searching backward starting at the end.
1360 @since LibreOffice 4.0
1362 @param ch character to be located.
1363 @return the index of the last occurrence of the character in the
1364 character sequence represented by this string, or
1365 -1 if the character does not occur.
1367 sal_Int32
lastIndexOf( sal_Unicode ch
) const
1369 return rtl_ustr_lastIndexOfChar_WithLength( pData
->buffer
, pData
->length
, ch
);
1373 Returns the index within this string of the last occurrence of the
1374 specified character, searching backward starting before the specified
1377 @since LibreOffice 4.0
1379 @param ch character to be located.
1380 @param fromIndex the index before which to start the search.
1381 @return the index of the last occurrence of the character in the
1382 character sequence represented by this string that
1383 is less than fromIndex, or -1
1384 if the character does not occur before that point.
1386 sal_Int32
lastIndexOf( sal_Unicode ch
, sal_Int32 fromIndex
) const
1388 assert( fromIndex
>= 0 && fromIndex
<= pData
->length
);
1389 return rtl_ustr_lastIndexOfChar_WithLength( pData
->buffer
, fromIndex
, ch
);
1393 Returns the index within this string of the first occurrence of the
1394 specified substring, starting at the specified index.
1396 If str doesn't include any character, always -1 is
1397 returned. This is also the case, if both strings are empty.
1399 @since LibreOffice 4.0
1401 @param str the substring to search for.
1402 @param fromIndex the index to start the search from.
1403 @return If the string argument occurs one or more times as a substring
1404 within this string at the starting index, then the index
1405 of the first character of the first such substring is
1406 returned. If it does not occur as a substring starting
1407 at fromIndex or beyond, -1 is returned.
1409 sal_Int32
indexOf( const OUString
& str
, sal_Int32 fromIndex
= 0 ) const
1411 assert( fromIndex
>= 0 && fromIndex
<= pData
->length
);
1412 sal_Int32 ret
= rtl_ustr_indexOfStr_WithLength( pData
->buffer
+fromIndex
, pData
->length
-fromIndex
,
1413 str
.pData
->buffer
, str
.pData
->length
);
1414 return (ret
< 0 ? ret
: ret
+fromIndex
);
1419 This function accepts an ASCII string literal as its argument.
1421 @since LibreOffice 4.0
1423 template< typename T
>
1424 typename
libreoffice_internal::ConstCharArrayDetector
< T
, sal_Int32
>::Type
indexOf( T
& literal
, sal_Int32 fromIndex
= 0 ) const
1427 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1428 sal_Int32 n
= rtl_ustr_indexOfAscii_WithLength(
1429 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
,
1430 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1431 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1432 return n
< 0 ? n
: n
+ fromIndex
;
1435 #if defined LIBO_INTERNAL_ONLY
1436 /** @overload @since LibreOffice 5.3 */
1437 template<typename T
>
1439 libreoffice_internal::ConstCharArrayDetector
<T
, sal_Int32
>::TypeUtf16
1440 indexOf(T
& literal
, sal_Int32 fromIndex
= 0) const {
1441 assert(fromIndex
>= 0);
1442 auto n
= rtl_ustr_indexOfStr_WithLength(
1443 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
,
1444 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1445 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1446 return n
< 0 ? n
: n
+ fromIndex
;
1449 /** @overload @since LibreOffice 5.4 */
1450 template<std::size_t N
>
1451 sal_Int32
indexOf(OUStringLiteral
<N
> const & literal
, sal_Int32 fromIndex
= 0)
1454 sal_Int32 n
= rtl_ustr_indexOfStr_WithLength(
1455 pData
->buffer
+ fromIndex
, pData
->length
- fromIndex
, literal
.getStr(),
1456 literal
.getLength());
1457 return n
< 0 ? n
: n
+ fromIndex
;
1462 Returns the index within this string of the last occurrence of
1463 the specified substring, searching backward starting at the end.
1465 The returned index indicates the starting index of the substring
1467 If str doesn't include any character, always -1 is
1468 returned. This is also the case, if both strings are empty.
1470 @since LibreOffice 4.0
1472 @param str the substring to search for.
1473 @return If the string argument occurs one or more times as a substring
1474 within this string, then the index of the first character of
1475 the last such substring is returned. If it does not occur as
1476 a substring, -1 is returned.
1478 sal_Int32
lastIndexOf( const OUString
& str
) const
1480 return rtl_ustr_lastIndexOfStr_WithLength( pData
->buffer
, pData
->length
,
1481 str
.pData
->buffer
, str
.pData
->length
);
1485 Returns the index within this string of the last occurrence of
1486 the specified substring, searching backward starting before the specified
1489 The returned index indicates the starting index of the substring
1491 If str doesn't include any character, always -1 is
1492 returned. This is also the case, if both strings are empty.
1494 @since LibreOffice 4.0
1496 @param str the substring to search for.
1497 @param fromIndex the index before which to start the search.
1498 @return If the string argument occurs one or more times as a substring
1499 within this string before the starting index, then the index
1500 of the first character of the last such substring is
1501 returned. Otherwise, -1 is returned.
1503 sal_Int32
lastIndexOf( const OUString
& str
, sal_Int32 fromIndex
) const
1505 assert( fromIndex
>= 0 && fromIndex
<= pData
->length
);
1506 return rtl_ustr_lastIndexOfStr_WithLength( pData
->buffer
, fromIndex
,
1507 str
.pData
->buffer
, str
.pData
->length
);
1512 This function accepts an ASCII string literal as its argument.
1513 @since LibreOffice 4.0
1515 template< typename T
>
1516 typename
libreoffice_internal::ConstCharArrayDetector
< T
, sal_Int32
>::Type
lastIndexOf( T
& literal
) const
1519 libreoffice_internal::ConstCharArrayDetector
<T
>::isValid(literal
));
1520 return rtl_ustr_lastIndexOfAscii_WithLength(
1521 pData
->buffer
, pData
->length
,
1522 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1523 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1526 #if defined LIBO_INTERNAL_ONLY
1527 /** @overload @since LibreOffice 5.3 */
1528 template<typename T
>
1530 libreoffice_internal::ConstCharArrayDetector
<T
, sal_Int32
>::TypeUtf16
1531 lastIndexOf(T
& literal
) const {
1532 return rtl_ustr_lastIndexOfStr_WithLength(
1533 pData
->buffer
, pData
->length
,
1534 libreoffice_internal::ConstCharArrayDetector
<T
>::toPointer(literal
),
1535 libreoffice_internal::ConstCharArrayDetector
<T
>::length
);
1538 /** @overload @since LibreOffice 5.4 */
1539 template<std::size_t N
> sal_Int32
lastIndexOf(OUStringLiteral
<N
> const & literal
) const {
1540 return rtl_ustr_lastIndexOfStr_WithLength(
1541 pData
->buffer
, pData
->length
, literal
.getStr(), literal
.getLength());
1546 Strip the given character from the start of the buffer.
1548 @since LibreOffice 4.0
1550 @param c the character to strip
1551 @return The number of characters stripped
1554 sal_Int32
stripStart(sal_Unicode c
= ' ')
1557 for(index
= 0; index
< getLength() ; index
++)
1559 if(pData
->buffer
[ index
] != c
)
1572 Strip the given character from the end of the buffer.
1574 @since LibreOffice 4.0
1576 @param c the character to strip
1577 @return The number of characters stripped
1580 sal_Int32
stripEnd(sal_Unicode c
= ' ')
1582 sal_Int32 result
= getLength();
1584 for(index
= getLength(); index
> 0 ; index
--)
1586 if(pData
->buffer
[ index
- 1 ] != c
)
1591 if(index
< getLength())
1595 return result
- getLength();
1598 Strip the given character from the both end of the buffer.
1600 @since LibreOffice 4.0
1602 @param c the character to strip
1603 @return The number of characters stripped
1606 sal_Int32
strip(sal_Unicode c
= ' ')
1608 return stripStart(c
) + stripEnd(c
);
1611 Returns a new string buffer that is a substring of this string.
1613 The substring begins at the specified beginIndex. If
1614 beginIndex is negative or be greater than the length of
1615 this string, behaviour is undefined.
1617 @param beginIndex the beginning index, inclusive.
1618 @return the specified substring.
1619 @since LibreOffice 4.1
1621 OUStringBuffer
copy( sal_Int32 beginIndex
) const
1623 return copy( beginIndex
, getLength() - beginIndex
);
1627 Returns a new string buffer that is a substring of this string.
1629 The substring begins at the specified beginIndex and contains count
1630 characters. If either beginIndex or count are negative,
1631 or beginIndex + count are greater than the length of this string
1632 then behaviour is undefined.
1634 @param beginIndex the beginning index, inclusive.
1635 @param count the number of characters.
1636 @return the specified substring.
1637 @since LibreOffice 4.1
1639 OUStringBuffer
copy( sal_Int32 beginIndex
, sal_Int32 count
) const
1641 assert(beginIndex
>= 0 && beginIndex
<= getLength());
1642 assert(count
>= 0 && count
<= getLength() - beginIndex
);
1643 rtl_uString
*pNew
= NULL
;
1644 rtl_uStringbuffer_newFromStr_WithLength( &pNew
, getStr() + beginIndex
, count
);
1645 return OUStringBuffer( pNew
, count
+ 16 );
1649 OUStringBuffer( rtl_uString
* value
, const sal_Int32 capacity
)
1652 nCapacity
= capacity
;
1656 A pointer to the data structure which contains the data.
1658 rtl_uString
* pData
;
1661 The len of the pData->buffer.
1663 sal_Int32 nCapacity
;
1666 #if defined LIBO_INTERNAL_ONLY
1667 template<> struct ToStringHelper
<OUStringBuffer
> {
1668 static std::size_t length(OUStringBuffer
const & s
) { return s
.getLength(); }
1670 static sal_Unicode
* addData(sal_Unicode
* buffer
, OUStringBuffer
const & s
) SAL_RETURNS_NONNULL
1671 { return addDataHelper(buffer
, s
.getStr(), s
.getLength()); }
1673 static constexpr bool allowOStringConcat
= false;
1674 static constexpr bool allowOUStringConcat
= true;
1678 #if defined LIBO_INTERNAL_ONLY
1679 // Define this here to avoid circular includes
1680 inline OUString
& OUString::operator+=( const OUStringBuffer
& str
) &
1682 // Call operator= if this is empty, otherwise rtl_uString_newConcat will attempt to
1683 // acquire() the str.pData buffer, which is part of the OUStringBuffer mutable state.
1685 return operator=(str
.toString());
1687 return internalAppend(str
.pData
);
1692 #ifdef RTL_STRING_UNITTEST
1695 typedef rtlunittest::OUStringBuffer OUStringBuffer
;
1699 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1700 using ::rtl::OUStringBuffer
;
1703 #endif // INCLUDED_RTL_USTRBUF_HXX
1705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */