LibreOffice: rtl/ustrbuf.hxx Source File

LibreOffice LibreOffice 24.2 SDK C/C++ API Reference |

Loading...
Searching...
No Matches
ustrbuf.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_RTL_USTRBUF_HXX
25#define INCLUDED_RTL_USTRBUF_HXX
26
27#include "sal/config.h"
28
29#include <cassert>
30#include <cstring>
31#include <limits>
32#include <new>
33
34#if defined LIBO_INTERNAL_ONLY
35#include <string_view>
36#include <type_traits>
37#include <utility>
38#endif
39
40#include "rtl/ustrbuf.h"
41#include "rtl/ustring.hxx"
42#include "rtl/stringutils.hxx"
43#include "sal/types.h"
44
45#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
46#include "o3tl/safeint.hxx"
47#include "rtl/stringconcat.hxx"
48#endif
49
50#ifdef RTL_STRING_UNITTEST
51extern bool rtl_string_unittest_invalid_conversion;
52#endif
53
54// The unittest uses slightly different code to help check that the proper
55// calls are made. The class is put into a different namespace to make
56// sure the compiler generates a different (if generating also non-inline)
57// copy of the function and does not merge them together. The class
58// is "brought" into the proper rtl namespace by a typedef below.
59#ifdef RTL_STRING_UNITTEST
60#define rtl rtlunittest
61#endif
62
63namespace rtl
64{
65
66#ifdef RTL_STRING_UNITTEST
67#undef rtl
68#endif
69
72 class SAL_WARN_UNUSED OUStringBuffer
73{
74 friend class OUString;
75public:
80 OUStringBuffer()
81 : pData(NULL)
82 , nCapacity( 16 )
83 {
84 rtl_uString_new_WithLength( &pData, nCapacity );
85 }
86
93 OUStringBuffer( const OUStringBuffer & value )
94 : pData(NULL)
95 , nCapacity( value.nCapacity )
96 {
97 rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
98 }
99
106 explicit OUStringBuffer(sal_Int32 length)
107 : pData(NULL)
108 , nCapacity( length )
109 {
110 rtl_uString_new_WithLength( &pData, length );
111 }
112#if defined LIBO_INTERNAL_ONLY
113 template<typename T>
114 explicit OUStringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
115 : OUStringBuffer(static_cast<sal_Int32>(length))
116 {
117 assert(
118 length >= 0
119 && static_cast<std::make_unsigned_t<T>>(length)
120 <= static_cast<std::make_unsigned_t<sal_Int32>>(
121 std::numeric_limits<sal_Int32>::max()));
122 }
123 // avoid (obvious) bugs
124 explicit OUStringBuffer(bool) = delete;
125 explicit OUStringBuffer(char) = delete;
126 explicit OUStringBuffer(wchar_t) = delete;
127#if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1939 && defined _MANAGED)
128 explicit OUStringBuffer(char8_t) = delete;
129#endif
130 explicit OUStringBuffer(char16_t) = delete;
131 explicit OUStringBuffer(char32_t) = delete;
132#endif
133
144#if defined LIBO_INTERNAL_ONLY
145 OUStringBuffer(std::u16string_view sv)
146 : pData(nullptr)
147 , nCapacity( sv.length() + 16 )
148 {
149 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
150 throw std::bad_alloc();
151 }
152 rtl_uStringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
153 }
154#else
155 OUStringBuffer(const OUString& value)
156 : pData(NULL)
157 , nCapacity( value.getLength() + 16 )
158 {
159 rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
160 }
161#endif
162
163 template< typename T >
164 OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
165 : pData(NULL)
166 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
167 {
168 assert(
169 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
170 rtl_uString_newFromLiteral(
171 &pData,
172 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
173 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
174#ifdef RTL_STRING_UNITTEST
175 rtl_string_unittest_const_literal = true;
176#endif
177 }
178
179#if defined LIBO_INTERNAL_ONLY
181 template<typename T>
182 OUStringBuffer(
183 T & literal,
184 typename libreoffice_internal::ConstCharArrayDetector<
185 T, libreoffice_internal::Dummy>::TypeUtf16
186 = libreoffice_internal::Dummy()):
187 pData(nullptr),
188 nCapacity(libreoffice_internal::ConstCharArrayDetector<T>::length + 16)
189 {
190 rtl_uStringbuffer_newFromStr_WithLength(
191 &pData,
192 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
193 libreoffice_internal::ConstCharArrayDetector<T>::length);
194 }
195#endif
196
197#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
199
203 template< typename T >
204 OUStringBuffer( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
205 {
206 pData = NULL;
207 nCapacity = 10;
208 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
209 rtl_string_unittest_invalid_conversion = true;
210 }
215 template< typename T >
216 OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
217 {
218 pData = NULL;
219 nCapacity = 10;
220 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
221 rtl_string_unittest_invalid_conversion = true;
222 }
224#endif
225
226#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
231 template< typename T1, typename T2 >
232 OUStringBuffer( OUStringConcat< T1, T2 >&& c )
233 {
234 const sal_Int32 l = c.length();
235 nCapacity = l + 16;
236 pData = rtl_uString_alloc( nCapacity );
237 sal_Unicode* end = c.addData( pData->buffer );
238 *end = '\0';
239 pData->length = l;
240 }
241
246 template< std::size_t N >
247 OUStringBuffer( OUStringNumber< N >&& n )
248 : pData(NULL)
249 , nCapacity( n.length + 16 )
250 {
251 rtl_uStringbuffer_newFromStr_WithLength( &pData, n.buf, n.length );
252 }
253#endif
254
255#if defined LIBO_INTERNAL_ONLY
256 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
257#endif
258
261 OUStringBuffer& operator = ( const OUStringBuffer& value )
262 {
263 if (this != &value)
264 {
265 rtl_uStringbuffer_newFromStringBuffer(&pData,
266 value.nCapacity,
267 value.pData);
268 nCapacity = value.nCapacity;
269 }
270 return *this;
271 }
272
273#if defined LIBO_INTERNAL_ONLY
277 OUStringBuffer& operator = ( OUStringBuffer&& value ) noexcept
278 {
279 rtl_uString_release( pData );
280 pData = value.pData;
281 nCapacity = value.nCapacity;
282 value.pData = nullptr;
283 value.nCapacity = 0;
284 rtl_uString_new( &value.pData );
285 return *this;
286 }
287#endif
288
293#if defined LIBO_INTERNAL_ONLY
294 OUStringBuffer & operator =(std::u16string_view string) {
295 sal_Int32 n = string.length();
296 if (n >= nCapacity) {
297 ensureCapacity(n + 16); //TODO: check for overflow
298 }
299 std::memcpy(
300 pData->buffer, string.data(),
301 n * sizeof (sal_Unicode));
302 pData->buffer[n] = '\0';
303 pData->length = n;
304 return *this;
305 }
306#else
307 OUStringBuffer & operator =(OUString const & string) {
308 sal_Int32 n = string.getLength();
309 if (n >= nCapacity) {
310 ensureCapacity(n + 16); //TODO: check for overflow
311 }
312 std::memcpy(
313 pData->buffer, string.pData->buffer,
314 (n + 1) * sizeof (sal_Unicode));
315 pData->length = n;
316 return *this;
317 }
318#endif
319
324 template<typename T>
325 typename
326 libreoffice_internal::ConstCharArrayDetector<T, OUStringBuffer &>::Type
327 operator =(T & literal) {
328 assert(
329 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
330 sal_Int32 const n
331 = libreoffice_internal::ConstCharArrayDetector<T>::length;
332 if (n >= nCapacity) {
333 ensureCapacity(n + 16); //TODO: check for overflow
334 }
335 char const * from
336 = libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
337 literal);
338 sal_Unicode * to = pData->buffer;
339 for (sal_Int32 i = 0; i <= n; ++i) {
340 to[i] = from[i];
341 }
342 pData->length = n;
343 return *this;
344 }
345
346#if defined LIBO_INTERNAL_ONLY
348 template<typename T>
349 typename libreoffice_internal::ConstCharArrayDetector<
350 T, OUStringBuffer &>::TypeUtf16
351 operator =(T & literal) {
352 sal_Int32 const n
353 = libreoffice_internal::ConstCharArrayDetector<T>::length;
354 if (n >= nCapacity) {
355 ensureCapacity(n + 16); //TODO: check for overflow
356 }
357 // For OUStringChar, which is covered by this template's ConstCharArrayDetector TypeUtf16
358 // check, toPointer does not return a NUL-terminated string, so we can't just memcpy n+1
359 // elements but rather need to add the terminating NUL manually:
360 std::memcpy(
361 pData->buffer,
362 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
363 n * sizeof (sal_Unicode));
364 pData->buffer[n] = '\0';
365 pData->length = n;
366 return *this;
367 }
368#endif
369
370#if defined LIBO_INTERNAL_ONLY
372 template<typename T1, typename T2>
373 OUStringBuffer & operator =(OUStringConcat<T1, T2> && concat) {
374 sal_Int32 const n = concat.length();
375 if (n >= nCapacity) {
376 ensureCapacity(n + 16); //TODO: check for overflow
377 }
378 *concat.addData(pData->buffer) = 0;
379 pData->length = n;
380 return *this;
381 }
382
384 template<std::size_t N>
385 OUStringBuffer & operator =(OUStringNumber<N> && n)
386 {
387 return operator =(std::u16string_view(n));
388 }
389#endif
390
394 ~OUStringBuffer()
395 {
396 rtl_uString_release( pData );
397 }
398
407 SAL_WARN_UNUSED_RESULT OUString makeStringAndClear()
408 {
409 return OUString(
410 rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
411 SAL_NO_ACQUIRE );
412 }
413
419 sal_Int32 getLength() const
420 {
421 return pData->length;
422 }
423
432 bool isEmpty() const
433 {
434 return pData->length == 0;
435 }
436
447 sal_Int32 getCapacity() const
448 {
449 return nCapacity;
450 }
451
463 void ensureCapacity(sal_Int32 minimumCapacity)
464 {
465 rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
466 }
467
486 void setLength(sal_Int32 newLength)
487 {
488 assert(newLength >= 0);
489 // Avoid modifications if pData points to const empty string:
490 if( newLength != pData->length )
491 {
492 if( newLength > nCapacity )
493 rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
494 else
495 pData->buffer[newLength] = 0;
496 pData->length = newLength;
497 }
498 }
499
513 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
514 sal_Unicode charAt( sal_Int32 index ) const
515 {
516 assert(index >= 0 && index < pData->length);
517 return pData->buffer[ index ];
518 }
519
530 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
531 OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
532 {
533 assert(index >= 0 && index < pData->length);
534 pData->buffer[ index ] = ch;
535 return *this;
536 }
537
541 const sal_Unicode* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
542
552 sal_Unicode & operator [](sal_Int32 index)
553 {
554 assert(index >= 0 && index < pData->length);
555 return pData->buffer[index];
556 }
557
567 const sal_Unicode & operator [](sal_Int32 index) const
568 {
569 assert(index >= 0 && index < pData->length);
570 return pData->buffer[index];
571 }
572
577 OUString toString() const
578 {
579 return OUString(pData->buffer, pData->length);
580 }
581
592#if !defined LIBO_INTERNAL_ONLY
593 OUStringBuffer & append(const OUString &str)
594#else
595 OUStringBuffer & append(std::u16string_view str)
596#endif
597 {
598 return insert(getLength(), str);
599 }
600
601#if !defined LIBO_INTERNAL_ONLY
614 OUStringBuffer & append(const OUStringBuffer &str)
615 {
616 if(!str.isEmpty())
617 {
618 append( str.getStr(), str.getLength() );
619 }
620 return *this;
621 }
622#endif
623
635#if defined LIBO_INTERNAL_ONLY
636 template<typename T>
637 typename libreoffice_internal::CharPtrDetector<T, OUStringBuffer &>::TypeUtf16
638 append(T const & str)
639#else
640 OUStringBuffer & append( const sal_Unicode * str )
641#endif
642 {
643 return insert(getLength(), str);
644 }
645
659 OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
660 {
661 return insert(getLength(), str, len);
662 }
663
669 template< typename T >
670 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
671 {
672 return insert(getLength(), literal);
673 }
674
675#if defined LIBO_INTERNAL_ONLY
676 template<typename T>
677 typename libreoffice_internal::NonConstCharArrayDetector<T, OUStringBuffer &>::TypeUtf16
678 append(T & value) { return append(static_cast<sal_Unicode *>(value)); }
679
681 template<typename T>
682 typename libreoffice_internal::ConstCharArrayDetector<
683 T, OUStringBuffer &>::TypeUtf16
684 append(T & literal) {
685 return insert(getLength(), literal);
686 }
687#endif
688
689#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
694 template< typename T1, typename T2 >
695 OUStringBuffer& append( OUStringConcat< T1, T2 >&& c )
696 {
697 return insert(getLength(), std::move(c));
698 }
699#endif
700
717 OUStringBuffer & appendAscii( const char * str )
718 {
719 return appendAscii( str, rtl_str_getLength( str ) );
720 }
721
739 OUStringBuffer & appendAscii( const char * str, sal_Int32 len)
740 {
741 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
742 return *this;
743 }
744
758 OUStringBuffer & append(bool b)
759 {
760 return insert(getLength(), b);
761 }
762
764 // Pointer can be automatically converted to bool, which is unwanted here.
765 // Explicitly delete all pointer append() overloads to prevent this
766 // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
767 template< typename T >
768 typename libreoffice_internal::Enable< void,
769 !libreoffice_internal::CharPtrDetector< T* >::ok && !libreoffice_internal::SalUnicodePtrDetector< T* >::ok >::Type
770 append( T* ) SAL_DELETED_FUNCTION;
772
773 // This overload is needed because OUString has a ctor from rtl_uString*, but
774 // the bool overload above would be preferred to the conversion.
778 OUStringBuffer & append(rtl_uString* str)
779 {
780 return append( OUString::unacquired( &str ));
781 }
782
794 OUStringBuffer & append(sal_Bool b)
795 {
796 return insert(getLength(), b);
797 }
798
811 OUStringBuffer & append(char c)
812 {
813 assert(static_cast< unsigned char >(c) <= 0x7F);
814 return insert(getLength(), c);
815 }
816
827 OUStringBuffer & append(sal_Unicode c)
828 {
829 return insert(getLength(), c);
830 }
831
832#if defined LIBO_INTERNAL_ONLY
833 void append(sal_uInt16) = delete;
834#endif
835
848 OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
849 {
850 return insert(getLength(), i, radix);
851 }
852
865 OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
866 {
867 return insert(getLength(), l, radix);
868 }
869
881 OUStringBuffer & append(float f)
882 {
883 return insert(getLength(), f);
884 }
885
897 OUStringBuffer & append(double d)
898 {
899 return insert(getLength(), d);
900 }
901
915 OUStringBuffer & appendUtf32(sal_uInt32 c) {
916 return insertUtf32(getLength(), c);
917 }
918
934 sal_Unicode * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
935 sal_Int32 n = getLength();
936 rtl_uStringbuffer_insert(&pData, &nCapacity, n, NULL, length);
937 return pData->buffer + n;
938 }
939
940#if defined LIBO_INTERNAL_ONLY
947 template<typename T>
948 OUStringBuffer& operator<<(T&& rValue)
949 {
950 return append(std::forward<T>(rValue));
951 }
952#endif
953
969#if defined LIBO_INTERNAL_ONLY
970 OUStringBuffer & insert(sal_Int32 offset, std::u16string_view str)
971 {
972 if (str.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
973 throw std::bad_alloc();
974 }
975 return insert( offset, str.data(), str.length() );
976 }
977#else
978 OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
979 {
980 return insert( offset, str.getStr(), str.getLength() );
981 }
982#endif
983
984#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
989 template <typename T1, typename T2>
990 OUStringBuffer& insert(sal_Int32 offset, OUStringConcat<T1, T2>&& c)
991 {
992 const size_t l = c.length();
993 if (l == 0)
994 return *this;
995 if (l > o3tl::make_unsigned(std::numeric_limits<sal_Int32>::max() - pData->length))
996 throw std::bad_alloc();
997
998 rtl_uStringbuffer_insert(&pData, &nCapacity, offset, nullptr, l);
999
1000 /* insert the new characters */
1001 c.addData(pData->buffer + offset);
1002 return *this;
1003 }
1004#endif
1005
1023 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
1024 {
1025 return insert( offset, str, rtl_ustr_getLength( str ) );
1026 }
1027
1046 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
1047 {
1048 assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
1049 rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
1050 return *this;
1051 }
1052
1058 template< typename T >
1059 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
1060 {
1061 assert(
1062 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1063 rtl_uStringbuffer_insert_ascii(
1064 &pData, &nCapacity, offset,
1065 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1066 libreoffice_internal::ConstCharArrayDetector<T>::length);
1067 return *this;
1068 }
1069
1070#if defined LIBO_INTERNAL_ONLY
1072 template<typename T>
1073 typename libreoffice_internal::ConstCharArrayDetector<
1074 T, OUStringBuffer &>::TypeUtf16
1075 insert(sal_Int32 offset, T & literal) {
1076 return insert(
1077 offset,
1078 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1079 libreoffice_internal::ConstCharArrayDetector<T>::length);
1080 }
1081#endif
1082
1100 OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
1101 {
1102 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1103 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1104 }
1105
1125 OUStringBuffer & insert(sal_Int32 offset, bool b)
1126 {
1127 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1128 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1129 }
1130
1149 OUStringBuffer & insert(sal_Int32 offset, char c)
1150 {
1151 sal_Unicode u = c;
1152 return insert( offset, &u, 1 );
1153 }
1154
1171 OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
1172 {
1173 return insert( offset, &c, 1 );
1174 }
1175
1195 OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
1196 {
1197 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
1198 return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
1199 }
1200
1220 OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
1221 {
1222 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
1223 return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
1224 }
1225
1244 OUStringBuffer & insert(sal_Int32 offset, float f)
1245 {
1246 // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfFloat
1247 rtl_math_doubleToUString(&pData, &nCapacity, offset, f, rtl_math_StringFormat_G,
1248 RTL_USTR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1249 NULL, 0, true);
1250 return *this;
1251 }
1252
1271 OUStringBuffer & insert(sal_Int32 offset, double d)
1272 {
1273 // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfDouble
1274 rtl_math_doubleToUString(&pData, &nCapacity, offset, d, rtl_math_StringFormat_G,
1275 RTL_USTR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1276 NULL, 0, true);
1277 return *this;
1278 }
1279
1295 OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1296 rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1297 return *this;
1298 }
1299
1312 OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1313 {
1314 rtl_uStringbuffer_remove( &pData, start, len );
1315 return *this;
1316 }
1317
1328 OUStringBuffer & truncate( sal_Int32 start = 0 )
1329 {
1330 rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1331 return *this;
1332 }
1333
1344 OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar )
1345 {
1346 sal_Int32 index = 0;
1347 while((index = indexOf(oldChar, index)) >= 0)
1348 {
1349 pData->buffer[ index ] = newChar;
1350 }
1351 return *this;
1352 }
1353
1369 void accessInternals(rtl_uString *** pInternalData,
1370 sal_Int32 ** pInternalCapacity)
1371 {
1372 *pInternalData = &pData;
1373 *pInternalCapacity = &nCapacity;
1374 }
1375
1376
1392 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1393 {
1394 assert( fromIndex >= 0 && fromIndex <= pData->length );
1395 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1396 return (ret < 0 ? ret : ret+fromIndex);
1397 }
1398
1410 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1411 {
1412 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1413 }
1414
1429 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1430 {
1431 assert( fromIndex >= 0 && fromIndex <= pData->length );
1432 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1433 }
1434
1452#if defined LIBO_INTERNAL_ONLY
1453 sal_Int32 indexOf( std::u16string_view str, sal_Int32 fromIndex = 0 ) const
1454 {
1455 assert( fromIndex >= 0 && fromIndex <= pData->length );
1456 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1457 str.data(), str.length() );
1458 return (ret < 0 ? ret : ret+fromIndex);
1459 }
1460#else
1461 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1462 {
1463 assert( fromIndex >= 0 && fromIndex <= pData->length );
1464 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1465 str.pData->buffer, str.pData->length );
1466 return (ret < 0 ? ret : ret+fromIndex);
1467 }
1468#endif
1469
1476 template< typename T >
1477 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1478 {
1479 assert(
1480 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1481 sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1482 pData->buffer + fromIndex, pData->length - fromIndex,
1483 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1484 libreoffice_internal::ConstCharArrayDetector<T>::length);
1485 return n < 0 ? n : n + fromIndex;
1486 }
1487
1488#if defined LIBO_INTERNAL_ONLY
1490 template<typename T>
1491 typename
1492 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1493 indexOf(T & literal, sal_Int32 fromIndex = 0) const {
1494 assert(fromIndex >= 0);
1495 auto n = rtl_ustr_indexOfStr_WithLength(
1496 pData->buffer + fromIndex, pData->length - fromIndex,
1497 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1498 libreoffice_internal::ConstCharArrayDetector<T>::length);
1499 return n < 0 ? n : n + fromIndex;
1500 }
1501#endif
1502
1520#if defined LIBO_INTERNAL_ONLY
1521 sal_Int32 lastIndexOf( std::u16string_view str ) const
1522 {
1523 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1524 str.data(), str.length() );
1525 }
1526#else
1527 sal_Int32 lastIndexOf( const OUString & str ) const
1528 {
1529 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1530 str.pData->buffer, str.pData->length );
1531 }
1532#endif
1533
1553#if defined LIBO_INTERNAL_ONLY
1554 sal_Int32 lastIndexOf( std::u16string_view str, sal_Int32 fromIndex ) const
1555 {
1556 assert( fromIndex >= 0 && fromIndex <= pData->length );
1557 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1558 str.data(), str.length() );
1559 }
1560#else
1561 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1562 {
1563 assert( fromIndex >= 0 && fromIndex <= pData->length );
1564 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1565 str.pData->buffer, str.pData->length );
1566 }
1567#endif
1568
1574 template< typename T >
1575 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
1576 {
1577 assert(
1578 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1579 return rtl_ustr_lastIndexOfAscii_WithLength(
1580 pData->buffer, pData->length,
1581 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1582 libreoffice_internal::ConstCharArrayDetector<T>::length);
1583 }
1584
1585#if defined LIBO_INTERNAL_ONLY
1587 template<typename T>
1588 typename
1589 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1590 lastIndexOf(T & literal) const {
1591 return rtl_ustr_lastIndexOfStr_WithLength(
1592 pData->buffer, pData->length,
1593 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1594 libreoffice_internal::ConstCharArrayDetector<T>::length);
1595 }
1596#endif
1597
1607 sal_Int32 stripStart(sal_Unicode c = ' ')
1608 {
1609 sal_Int32 index;
1610 for(index = 0; index < getLength() ; index++)
1611 {
1612 if(pData->buffer[ index ] != c)
1613 {
1614 break;
1615 }
1616 }
1617 if(index)
1618 {
1619 remove(0, index);
1620 }
1621 return index;
1622 }
1623
1633 sal_Int32 stripEnd(sal_Unicode c = ' ')
1634 {
1635 sal_Int32 result = getLength();
1636 sal_Int32 index;
1637 for(index = getLength(); index > 0 ; index--)
1638 {
1639 if(pData->buffer[ index - 1 ] != c)
1640 {
1641 break;
1642 }
1643 }
1644 if(index < getLength())
1645 {
1646 truncate(index);
1647 }
1648 return result - getLength();
1649 }
1650
1659 sal_Int32 strip(sal_Unicode c = ' ')
1660 {
1661 return stripStart(c) + stripEnd(c);
1662 }
1663
1664#if defined LIBO_INTERNAL_ONLY
1675 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
1676 {
1677 assert(beginIndex >= 0);
1678 assert(beginIndex <= getLength());
1679 return subView(beginIndex, getLength() - beginIndex);
1680 }
1681
1694 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1695 {
1696 assert(beginIndex >= 0);
1697 assert(count >= 0);
1698 assert(beginIndex <= getLength());
1699 assert(count <= getLength() - beginIndex);
1700 return std::u16string_view(pData->buffer, sal_uInt32(pData->length)).substr(beginIndex, count);
1701 }
1702#endif
1703
1715 OUStringBuffer copy( sal_Int32 beginIndex ) const
1716 {
1717 return copy( beginIndex, getLength() - beginIndex );
1718 }
1719
1733 OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1734 {
1735 assert(beginIndex >= 0 && beginIndex <= getLength());
1736 assert(count >= 0 && count <= getLength() - beginIndex);
1737 rtl_uString *pNew = NULL;
1738 rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1739 return OUStringBuffer( pNew, count + 16 );
1740 }
1741
1742private:
1743 OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1744 {
1745 pData = value;
1746 nCapacity = capacity;
1747 }
1748
1752 rtl_uString * pData;
1753
1757 sal_Int32 nCapacity;
1758};
1759
1760#if defined LIBO_INTERNAL_ONLY
1761template<> struct ToStringHelper<OUStringBuffer> {
1762 static std::size_t length(OUStringBuffer const & s) { return s.getLength(); }
1763
1764 sal_Unicode * operator()(sal_Unicode * buffer, OUStringBuffer const & s) const SAL_RETURNS_NONNULL
1765 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1766};
1767#endif
1768
1769#if defined LIBO_INTERNAL_ONLY
1770 // Define this here to avoid circular includes
1771 inline OUString & OUString::operator+=( const OUStringBuffer & str ) &
1772 {
1773 // Call operator= if this is empty, otherwise rtl_uString_newConcat will attempt to
1774 // acquire() the str.pData buffer, which is part of the OUStringBuffer mutable state.
1775 if (isEmpty())
1776 return operator=(str.toString());
1777 else
1778 return internalAppend(str.pData);
1779 }
1780
1781 inline OUString const& OUString::unacquired(const OUStringBuffer& str)
1782 {
1783 return unacquired(&str.pData);
1784 }
1785#endif
1786}
1787
1788#ifdef RTL_STRING_UNITTEST
1789namespace rtl
1790{
1791typedef rtlunittest::OUStringBuffer OUStringBuffer;
1792}
1793#endif
1794
1795#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1796using ::rtl::OUStringBuffer;
1797#endif
1798
1799#endif // INCLUDED_RTL_USTRBUF_HXX
1800
1801/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
SAL_N_ELEMENTS
#define SAL_N_ELEMENTS(arr)
Definition macros.h:51
types.h
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition types.h:474
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:378
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition types.h:356
sal_Bool
unsigned char sal_Bool
Definition types.h:38
sal_Unicode
sal_uInt16 sal_Unicode
Definition types.h:123
SAL_WARN_UNUSED_RESULT
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition types.h:284
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:587
rtl_uString_new
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
RTL_USTR_MAX_VALUEOFFLOAT
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition ustring.h:1026
RTL_USTR_MAX_VALUEOFDOUBLE
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition ustring.h:1045
rtl_uString_newFromLiteral
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
rtl_ustr_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
RTL_USTR_MAX_VALUEOFINT64
#define RTL_USTR_MAX_VALUEOFINT64
Definition ustring.h:984
rtl_ustr_indexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
rtl_uString_release
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
rtl_ustr_getLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
rtl_ustr_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_ustr_lastIndexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
rtl_ustr_indexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
rtl_uString_alloc
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_uString_new_WithLength
SAL_DLLPUBLIC void rtl_uString_new_WithLength(rtl_uString **newStr, sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_ustr_lastIndexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
RTL_USTR_MAX_VALUEOFBOOLEAN
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition ustring.h:919
rtl_ustr_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl_ustr_lastIndexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
rtl_ustr_indexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
RTL_USTR_MAX_VALUEOFINT32
#define RTL_USTR_MAX_VALUEOFINT32
Definition ustring.h:961
ustring.hxx
ustrbuf.h
rtl_uStringbuffer_insert_ascii
SAL_DLLPUBLIC void rtl_uStringbuffer_insert_ascii(rtl_uString **This, sal_Int32 *capacity, sal_Int32 offset, const char *str, sal_Int32 len)
Inserts the 8-Bit ASCII string representation of the str array argument into this string buffer.
rtl_uStringbuffer_remove
SAL_DLLPUBLIC void rtl_uStringbuffer_remove(rtl_uString **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
rtl_uStringBuffer_makeStringAndClear
SAL_DLLPUBLIC rtl_uString * rtl_uStringBuffer_makeStringAndClear(rtl_uString **ppThis, sal_Int32 *nCapacity) SAL_RETURNS_NONNULL
Returns an immutable rtl_uString object, while clearing the string buffer.
rtl_uStringbuffer_insertUtf32
SAL_DLLPUBLIC void rtl_uStringbuffer_insertUtf32(rtl_uString **pThis, sal_Int32 *capacity, sal_Int32 offset, sal_uInt32 c) SAL_THROW_EXTERN_C()
Inserts a single UTF-32 character into this string buffer.
rtl_uStringbuffer_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_uStringbuffer_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
rtl_uStringbuffer_newFromStringBuffer
SAL_DLLPUBLIC sal_Int32 rtl_uStringbuffer_newFromStringBuffer(rtl_uString **newStr, sal_Int32 capacity, rtl_uString *oldStr)
Allocates a new String that contains the same sequence of characters as the string argument.
rtl_uStringbuffer_ensureCapacity
SAL_DLLPUBLIC void rtl_uStringbuffer_ensureCapacity(rtl_uString **This, sal_Int32 *capacity, sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
rtl_uStringbuffer_insert
SAL_DLLPUBLIC void rtl_uStringbuffer_insert(rtl_uString **This, sal_Int32 *capacity, sal_Int32 offset, const sal_Unicode *str, sal_Int32 len)
Inserts the string representation of the str array argument into this string buffer.
stringutils.hxx
rtl_str_getLength
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
rtl_math_doubleToUString
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
rtl_math_StringFormat_G
@ rtl_math_StringFormat_G
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition math.h:53
rtl
Definition bootstrap.hxx:34
rtl::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros,...
Definition string.hxx:2355
rtl::libreoffice_internal
Definition stringutils.hxx:117
rtl::libreoffice_internal::Dummy
Definition stringutils.hxx:146
rtl::libreoffice_internal::CharPtrDetector
Definition stringutils.hxx:149
rtl::libreoffice_internal::CharPtrDetector::ok
static const bool ok
Definition stringutils.hxx:150
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition stringutils.hxx:173
rtl::libreoffice_internal::ConstCharArrayDetector
Definition stringutils.hxx:201
rtl::libreoffice_internal::SalUnicodePtrDetector::ok
static const bool ok
Definition stringutils.hxx:364
rtl::libreoffice_internal::Enable
Definition stringutils.hxx:382
rtl::OUStringBuffer
A string buffer implements a mutable sequence of characters.
Definition ustrbuf.hxx:73
rtl::OUStringBuffer::setCharAt
OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
The character at the specified index of this string buffer is set to ch.
Definition ustrbuf.hxx:531
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition ustrbuf.hxx:1429
rtl::OUStringBuffer::stripStart
sal_Int32 stripStart(sal_Unicode c=' ')
Strip the given character from the start of the buffer.
Definition ustrbuf.hxx:1607
rtl::OUStringBuffer::insert
libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type insert(sal_Int32 offset, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustrbuf.hxx:1059
rtl::OUStringBuffer::append
OUStringBuffer & append(rtl_uString *str)
Definition ustrbuf.hxx:778
rtl::OUStringBuffer::append
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition ustrbuf.hxx:758
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition ustrbuf.hxx:1715
rtl::OUStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition ustrbuf.hxx:432
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition ustrbuf.hxx:1733
rtl::OUStringBuffer::append
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition ustrbuf.hxx:811
rtl::OUStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition ustrbuf.hxx:447
rtl::OUStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition ustrbuf.hxx:419
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition ustrbuf.hxx:1125
rtl::OUStringBuffer::replace
OUStringBuffer & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition ustrbuf.hxx:1344
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition ustrbuf.hxx:1244
rtl::OUStringBuffer::strip
sal_Int32 strip(sal_Unicode c=' ')
Strip the given character from the both end of the buffer.
Definition ustrbuf.hxx:1659
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition ustrbuf.hxx:80
rtl::OUStringBuffer::indexOf
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring,...
Definition ustrbuf.hxx:1461
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition ustrbuf.hxx:739
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition ustrbuf.hxx:794
rtl::OUStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition ustrbuf.hxx:486
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(const OUStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition ustrbuf.hxx:93
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition ustrbuf.hxx:164
rtl::OUStringBuffer::append
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition ustrbuf.hxx:897
rtl::OUStringBuffer::indexOf
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character,...
Definition ustrbuf.hxx:1392
rtl::OUStringBuffer::toString
OUString toString() const
Return an OUString instance reflecting the current content of this OUStringBuffer.
Definition ustrbuf.hxx:577
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition ustrbuf.hxx:865
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition ustrbuf.hxx:827
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition ustrbuf.hxx:593
rtl::OUStringBuffer::remove
OUStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition ustrbuf.hxx:1312
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(sal_Int32 length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition ustrbuf.hxx:106
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition ustrbuf.hxx:848
rtl::OUStringBuffer::appendUninitialized
sal_Unicode * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL
Unsafe way to make space for a fixed amount of characters to be appended into this OUStringBuffer.
Definition ustrbuf.hxx:934
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition ustrbuf.hxx:1561
rtl::OUStringBuffer::stripEnd
sal_Int32 stripEnd(sal_Unicode c=' ')
Strip the given character from the end of the buffer.
Definition ustrbuf.hxx:1633
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition ustrbuf.hxx:1171
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition ustrbuf.hxx:1100
rtl::OUStringBuffer::indexOf
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustrbuf.hxx:1477
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition ustrbuf.hxx:614
rtl::OUStringBuffer::append
OUStringBuffer & append(const sal_Unicode *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition ustrbuf.hxx:659
rtl::OUStringBuffer::appendUtf32
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition ustrbuf.hxx:915
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition ustrbuf.hxx:717
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition ustrbuf.hxx:1410
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(const OUString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition ustrbuf.hxx:155
rtl::OUStringBuffer::~OUStringBuffer
~OUStringBuffer()
Release the string data.
Definition ustrbuf.hxx:394
rtl::OUStringBuffer::OUString
friend class OUString
Definition ustrbuf.hxx:74
rtl::OUStringBuffer::append
libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type append(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustrbuf.hxx:670
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix=10)
Inserts the string representation of the second sal_Int32 argument into this string buffer.
Definition ustrbuf.hxx:1195
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const sal_Unicode *str)
Inserts the string representation of the char array argument into this string buffer.
Definition ustrbuf.hxx:1023
rtl::OUStringBuffer::truncate
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition ustrbuf.hxx:1328
rtl::OUStringBuffer::append
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition ustrbuf.hxx:881
rtl::OUStringBuffer::lastIndexOf
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition ustrbuf.hxx:1575
rtl::OUStringBuffer::ensureCapacity
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition ustrbuf.hxx:463
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition ustrbuf.hxx:978
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const sal_Unicode *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition ustrbuf.hxx:1046
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition ustrbuf.hxx:1271
rtl::OUStringBuffer::append
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition ustrbuf.hxx:640
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition ustrbuf.hxx:1149
rtl::OUStringBuffer::getStr
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Return a null terminated unicode character array.
Definition ustrbuf.hxx:541
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix=10)
Inserts the string representation of the long argument into this string buffer.
Definition ustrbuf.hxx:1220
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition ustrbuf.hxx:1527
rtl::OUStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition ustrbuf.hxx:407
rtl::OUStringBuffer::insertUtf32
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition ustrbuf.hxx:1295
rtl::OUStringBuffer::accessInternals
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition ustrbuf.hxx:1369
rtl::OUStringBuffer::charAt
sal_Unicode charAt(sal_Int32 index) const
Returns the character at a specific index in this string buffer.
Definition ustrbuf.hxx:514
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:171
rtl::OUString::getStr
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition ustring.hxx:838
rtl::OUString::unacquired
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition ustring.hxx:557
rtl::OUString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition ustring.hxx:816
rtl::OUString::operator+=
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition ustring.hxx:687