LibreOffice LibreOffice 25.8 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
51 extern 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
63 namespace 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;
75 public:
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(libreoffice_internal::IsValidStrLen(length));
118 }
119 // avoid (obvious) bugs
120 explicit OUStringBuffer(bool) = delete;
121 explicit OUStringBuffer(char) = delete;
122 explicit OUStringBuffer(wchar_t) = delete;
123#if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1939 && defined _MANAGED)
124 explicit OUStringBuffer(char8_t) = delete;
125#endif
126 explicit OUStringBuffer(char16_t) = delete;
127 explicit OUStringBuffer(char32_t) = delete;
128#endif
129
140#if defined LIBO_INTERNAL_ONLY
141 OUStringBuffer(std::u16string_view sv)
142 : pData(nullptr)
143 , nCapacity(libreoffice_internal::ThrowIfInvalidStrLen(sv.length(), 16) + 16)
144 {
145 rtl_uStringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
146 }
147#else
148 OUStringBuffer(const OUString& value)
149 : pData(NULL)
150 , nCapacity( value.getLength() + 16 )
151 {
152 rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
153 }
154#endif
155
156 template< typename T >
157 OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
158 : pData(NULL)
159 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
160 {
161 assert(
162 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
163 rtl_uString_newFromLiteral(
164 &pData,
165 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
166 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
167#ifdef RTL_STRING_UNITTEST
168 rtl_string_unittest_const_literal = true;
169#endif
170 }
171
172#if defined LIBO_INTERNAL_ONLY
174 template<typename T>
175 OUStringBuffer(
176 T & literal,
177 typename libreoffice_internal::ConstCharArrayDetector<
178 T, libreoffice_internal::Dummy>::TypeUtf16
179 = libreoffice_internal::Dummy()):
180 pData(nullptr),
181 nCapacity(libreoffice_internal::ConstCharArrayDetector<T>::length + 16)
182 {
183 rtl_uStringbuffer_newFromStr_WithLength(
184 &pData,
185 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
186 libreoffice_internal::ConstCharArrayDetector<T>::length);
187 }
188#endif
189
190#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
192
196 template< typename T >
197 OUStringBuffer( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
198 {
199 pData = NULL;
200 nCapacity = 10;
201 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
202 rtl_string_unittest_invalid_conversion = true;
203 }
208 template< typename T >
209 OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
210 {
211 pData = NULL;
212 nCapacity = 10;
213 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
214 rtl_string_unittest_invalid_conversion = true;
215 }
217#endif
218
219#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
224 template< typename T1, typename T2 >
225 OUStringBuffer( OUStringConcat< T1, T2 >&& c )
226 {
227 const sal_Int32 l = c.length();
228 nCapacity = l + 16;
229 pData = rtl_uString_alloc( nCapacity );
230 sal_Unicode* end = c.addData( pData->buffer );
231 *end = '\0';
232 pData->length = l;
233 }
234
239 template< std::size_t N >
240 OUStringBuffer( OUStringNumber< N >&& n )
241 : OUStringBuffer(std::u16string_view(n))
242 {
243 }
244#endif
245
246#if defined LIBO_INTERNAL_ONLY
247 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
248#endif
249
252 OUStringBuffer& operator = ( const OUStringBuffer& value )
253 {
254 if (this != &value)
255 {
256 rtl_uStringbuffer_newFromStringBuffer(&pData,
257 value.nCapacity,
258 value.pData);
259 nCapacity = value.nCapacity;
260 }
261 return *this;
262 }
263
264#if defined LIBO_INTERNAL_ONLY
268 OUStringBuffer& operator = ( OUStringBuffer&& value ) noexcept
269 {
270 rtl_uString_release( pData );
271 pData = value.pData;
272 nCapacity = value.nCapacity;
273 value.pData = nullptr;
274 value.nCapacity = 0;
275 rtl_uString_new( &value.pData );
276 return *this;
277 }
278#endif
279
284#if defined LIBO_INTERNAL_ONLY
285 OUStringBuffer & operator =(std::u16string_view string) {
286 sal_Int32 n = string.length();
287 if (n >= nCapacity) {
288 ensureCapacity(n + 16); //TODO: check for overflow
289 }
290 std::memcpy(
291 pData->buffer, string.data(),
292 n * sizeof (sal_Unicode));
293 pData->buffer[n] = '\0';
294 pData->length = n;
295 return *this;
296 }
297#else
298 OUStringBuffer & operator =(OUString const & string) {
299 sal_Int32 n = string.getLength();
300 if (n >= nCapacity) {
301 ensureCapacity(n + 16); //TODO: check for overflow
302 }
303 std::memcpy(
304 pData->buffer, string.pData->buffer,
305 (n + 1) * sizeof (sal_Unicode));
306 pData->length = n;
307 return *this;
308 }
309#endif
310
315 template<typename T>
316 typename
317 libreoffice_internal::ConstCharArrayDetector<T, OUStringBuffer &>::Type
318 operator =(T & literal) {
319 assert(
320 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
321 sal_Int32 const n
322 = libreoffice_internal::ConstCharArrayDetector<T>::length;
323 if (n >= nCapacity) {
324 ensureCapacity(n + 16); //TODO: check for overflow
325 }
326 char const * from
327 = libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
328 literal);
329 sal_Unicode * to = pData->buffer;
330 for (sal_Int32 i = 0; i <= n; ++i) {
331 to[i] = from[i];
332 }
333 pData->length = n;
334 return *this;
335 }
336
337#if defined LIBO_INTERNAL_ONLY
339 template<typename T>
340 typename libreoffice_internal::ConstCharArrayDetector<
341 T, OUStringBuffer &>::TypeUtf16
342 operator =(T & literal) {
343 return operator=(
344 std::u16string_view(libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
345 libreoffice_internal::ConstCharArrayDetector<T>::length));
346 }
347#endif
348
349#if defined LIBO_INTERNAL_ONLY
351 template<typename T1, typename T2>
352 OUStringBuffer & operator =(OUStringConcat<T1, T2> && concat) {
353 sal_Int32 const n = concat.length();
354 if (n >= nCapacity) {
355 ensureCapacity(n + 16); //TODO: check for overflow
356 }
357 *concat.addData(pData->buffer) = 0;
358 pData->length = n;
359 return *this;
360 }
361
363 template<std::size_t N>
364 OUStringBuffer & operator =(OUStringNumber<N> && n)
365 {
366 return operator =(std::u16string_view(n));
367 }
368#endif
369
373 ~OUStringBuffer()
374 {
375 rtl_uString_release( pData );
376 }
377
386 SAL_WARN_UNUSED_RESULT OUString makeStringAndClear()
387 {
388 return OUString(
389 rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
390 SAL_NO_ACQUIRE );
391 }
392
398 sal_Int32 getLength() const
399 {
400 return pData->length;
401 }
402
411 bool isEmpty() const
412 {
413 return pData->length == 0;
414 }
415
426 sal_Int32 getCapacity() const
427 {
428 return nCapacity;
429 }
430
442 void ensureCapacity(sal_Int32 minimumCapacity)
443 {
444 rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
445 }
446
465 void setLength(sal_Int32 newLength)
466 {
467 assert(newLength >= 0);
468 // Avoid modifications if pData points to const empty string:
469 if( newLength != pData->length )
470 {
471 if( newLength > nCapacity )
472 rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
473 else
474 pData->buffer[newLength] = 0;
475 pData->length = newLength;
476 }
477 }
478
492 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
493 sal_Unicode charAt( sal_Int32 index ) const
494 {
495 assert(index >= 0 && index < pData->length);
496 return pData->buffer[ index ];
497 }
498
509 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
510 OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
511 {
512 assert(index >= 0 && index < pData->length);
513 pData->buffer[ index ] = ch;
514 return *this;
515 }
516
520 const sal_Unicode* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
521
531 sal_Unicode & operator [](sal_Int32 index)
532 {
533 assert(index >= 0 && index < pData->length);
534 return pData->buffer[index];
535 }
536
546 const sal_Unicode & operator [](sal_Int32 index) const
547 {
548 assert(index >= 0 && index < pData->length);
549 return pData->buffer[index];
550 }
551
556 OUString toString() const
557 {
558 return OUString(pData->buffer, pData->length);
559 }
560
571#if !defined LIBO_INTERNAL_ONLY
572 OUStringBuffer & append(const OUString &str)
573#else
574 OUStringBuffer & append(std::u16string_view str)
575#endif
576 {
577 return insert(getLength(), str);
578 }
579
580#if !defined LIBO_INTERNAL_ONLY
593 OUStringBuffer & append(const OUStringBuffer &str)
594 {
595 if(!str.isEmpty())
596 {
597 append( str.getStr(), str.getLength() );
598 }
599 return *this;
600 }
601#endif
602
614#if defined LIBO_INTERNAL_ONLY
615 template<typename T>
616 typename libreoffice_internal::CharPtrDetector<T, OUStringBuffer &>::TypeUtf16
617 append(T const & str)
618#else
619 OUStringBuffer & append( const sal_Unicode * str )
620#endif
621 {
622 return insert(getLength(), str);
623 }
624
638 OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
639 {
640 return insert(getLength(), str, len);
641 }
642
648 template< typename T >
649 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
650 {
651 return insert(getLength(), literal);
652 }
653
654#if defined LIBO_INTERNAL_ONLY
655 template<typename T>
656 typename libreoffice_internal::NonConstCharArrayDetector<T, OUStringBuffer &>::TypeUtf16
657 append(T & value) { return append(static_cast<sal_Unicode *>(value)); }
658
660 template<typename T>
661 typename libreoffice_internal::ConstCharArrayDetector<
662 T, OUStringBuffer &>::TypeUtf16
663 append(T & literal) {
664 return insert(getLength(), literal);
665 }
666#endif
667
668#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
673 template< typename T1, typename T2 >
674 OUStringBuffer& append( OUStringConcat< T1, T2 >&& c )
675 {
676 return insert(getLength(), std::move(c));
677 }
678#endif
679
696 OUStringBuffer & appendAscii( const char * str )
697 {
698 return appendAscii( str, rtl_str_getLength( str ) );
699 }
700
718 OUStringBuffer & appendAscii( const char * str, sal_Int32 len)
719 {
720 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
721 return *this;
722 }
723
737 OUStringBuffer & append(bool b)
738 {
739 return insert(getLength(), b);
740 }
741
743 // Pointer can be automatically converted to bool, which is unwanted here.
744 // Explicitly delete all pointer append() overloads to prevent this
745 // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
746 template< typename T >
747 typename libreoffice_internal::Enable< void,
748 !libreoffice_internal::CharPtrDetector< T* >::ok && !libreoffice_internal::SalUnicodePtrDetector< T* >::ok >::Type
749 append( T* ) SAL_DELETED_FUNCTION;
751
752 // This overload is needed because OUString has a ctor from rtl_uString*, but
753 // the bool overload above would be preferred to the conversion.
757 OUStringBuffer & append(rtl_uString* str)
758 {
759 return append( OUString::unacquired( &str ));
760 }
761
773 OUStringBuffer & append(sal_Bool b)
774 {
775 return insert(getLength(), b);
776 }
777
790 OUStringBuffer & append(char c)
791 {
792 assert(static_cast< unsigned char >(c) <= 0x7F);
793 return insert(getLength(), c);
794 }
795
806 OUStringBuffer & append(sal_Unicode c)
807 {
808 return insert(getLength(), c);
809 }
810
811#if defined LIBO_INTERNAL_ONLY
812 void append(sal_uInt16) = delete;
813#endif
814
827 OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
828 {
829 return insert(getLength(), i, radix);
830 }
831
844 OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
845 {
846 return insert(getLength(), l, radix);
847 }
848
860 OUStringBuffer & append(float f)
861 {
862 return insert(getLength(), f);
863 }
864
876 OUStringBuffer & append(double d)
877 {
878 return insert(getLength(), d);
879 }
880
894 OUStringBuffer & appendUtf32(sal_uInt32 c) {
895 return insertUtf32(getLength(), c);
896 }
897
913 sal_Unicode * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
914 sal_Int32 n = getLength();
915 rtl_uStringbuffer_insert(&pData, &nCapacity, n, NULL, length);
916 return pData->buffer + n;
917 }
918
919#if defined LIBO_INTERNAL_ONLY
926 template<typename T>
927 OUStringBuffer& operator<<(T&& rValue)
928 {
929 return append(std::forward<T>(rValue));
930 }
931#endif
932
948#if defined LIBO_INTERNAL_ONLY
949 OUStringBuffer & insert(sal_Int32 offset, std::u16string_view str)
950 {
951 return insert(offset, str.data(), libreoffice_internal::ThrowIfInvalidStrLen(str.length()));
952 }
953#else
954 OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
955 {
956 return insert( offset, str.getStr(), str.getLength() );
957 }
958#endif
959
960#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
965 template <typename T1, typename T2>
966 OUStringBuffer& insert(sal_Int32 offset, OUStringConcat<T1, T2>&& c)
967 {
968 const size_t l = c.length();
969 if (l == 0)
970 return *this;
971 if (l > o3tl::make_unsigned(std::numeric_limits<sal_Int32>::max() - pData->length))
972 throw std::bad_alloc();
973
974 rtl_uStringbuffer_insert(&pData, &nCapacity, offset, nullptr, l);
975
976 /* insert the new characters */
977 c.addData(pData->buffer + offset);
978 return *this;
979 }
980#endif
981
999 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
1000 {
1001 return insert( offset, str, rtl_ustr_getLength( str ) );
1002 }
1003
1022 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
1023 {
1024 assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
1025 rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
1026 return *this;
1027 }
1028
1034 template< typename T >
1035 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
1036 {
1037 assert(
1038 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1039 rtl_uStringbuffer_insert_ascii(
1040 &pData, &nCapacity, offset,
1041 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1042 libreoffice_internal::ConstCharArrayDetector<T>::length);
1043 return *this;
1044 }
1045
1046#if defined LIBO_INTERNAL_ONLY
1048 template<typename T>
1049 typename libreoffice_internal::ConstCharArrayDetector<
1050 T, OUStringBuffer &>::TypeUtf16
1051 insert(sal_Int32 offset, T & literal) {
1052 return insert(
1053 offset,
1054 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1055 libreoffice_internal::ConstCharArrayDetector<T>::length);
1056 }
1057#endif
1058
1076 OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
1077 {
1078 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1079 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1080 }
1081
1101 OUStringBuffer & insert(sal_Int32 offset, bool b)
1102 {
1103 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1104 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1105 }
1106
1125 OUStringBuffer & insert(sal_Int32 offset, char c)
1126 {
1127 return insert(offset, sal_Unicode(c));
1128 }
1129
1146 OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
1147 {
1148 return insert( offset, &c, 1 );
1149 }
1150
1170 OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
1171 {
1172 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
1173 return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
1174 }
1175
1195 OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
1196 {
1197 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
1198 return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
1199 }
1200
1219 OUStringBuffer & insert(sal_Int32 offset, float f)
1220 {
1221 // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfFloat
1222 rtl_math_doubleToUString(&pData, &nCapacity, offset, f, rtl_math_StringFormat_G,
1223 RTL_USTR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1224 NULL, 0, true);
1225 return *this;
1226 }
1227
1246 OUStringBuffer & insert(sal_Int32 offset, double d)
1247 {
1248 // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfDouble
1249 rtl_math_doubleToUString(&pData, &nCapacity, offset, d, rtl_math_StringFormat_G,
1250 RTL_USTR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1251 NULL, 0, true);
1252 return *this;
1253 }
1254
1270 OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1271 rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1272 return *this;
1273 }
1274
1287 OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1288 {
1289 rtl_uStringbuffer_remove( &pData, start, len );
1290 return *this;
1291 }
1292
1303 OUStringBuffer & truncate( sal_Int32 start = 0 )
1304 {
1305 rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1306 return *this;
1307 }
1308
1319 OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar )
1320 {
1321 sal_Int32 index = 0;
1322 while((index = indexOf(oldChar, index)) >= 0)
1323 {
1324 pData->buffer[ index ] = newChar;
1325 }
1326 return *this;
1327 }
1328
1344 void accessInternals(rtl_uString *** pInternalData,
1345 sal_Int32 ** pInternalCapacity)
1346 {
1347 *pInternalData = &pData;
1348 *pInternalCapacity = &nCapacity;
1349 }
1350
1351
1367 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1368 {
1369 assert( fromIndex >= 0 && fromIndex <= pData->length );
1370 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1371 return (ret < 0 ? ret : ret+fromIndex);
1372 }
1373
1385 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1386 {
1387 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1388 }
1389
1404 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1405 {
1406 assert( fromIndex >= 0 && fromIndex <= pData->length );
1407 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1408 }
1409
1427#if defined LIBO_INTERNAL_ONLY
1428 sal_Int32 indexOf( std::u16string_view str, sal_Int32 fromIndex = 0 ) const
1429 {
1430 assert( fromIndex >= 0 && fromIndex <= pData->length );
1431 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1432 str.data(), str.length() );
1433 return (ret < 0 ? ret : ret+fromIndex);
1434 }
1435#else
1436 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1437 {
1438 assert( fromIndex >= 0 && fromIndex <= pData->length );
1439 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1440 str.pData->buffer, str.pData->length );
1441 return (ret < 0 ? ret : ret+fromIndex);
1442 }
1443#endif
1444
1451 template< typename T >
1452 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1453 {
1454 assert(
1455 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1456 sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1457 pData->buffer + fromIndex, pData->length - fromIndex,
1458 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1459 libreoffice_internal::ConstCharArrayDetector<T>::length);
1460 return n < 0 ? n : n + fromIndex;
1461 }
1462
1463#if defined LIBO_INTERNAL_ONLY
1465 template<typename T>
1466 typename
1467 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1468 indexOf(T & literal, sal_Int32 fromIndex = 0) const {
1469 return indexOf(
1470 std::u16string_view(libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1471 libreoffice_internal::ConstCharArrayDetector<T>::length),
1472 fromIndex);
1473 }
1474#endif
1475
1493#if defined LIBO_INTERNAL_ONLY
1494 sal_Int32 lastIndexOf( std::u16string_view str ) const
1495 {
1496 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1497 str.data(), str.length() );
1498 }
1499#else
1500 sal_Int32 lastIndexOf( const OUString & str ) const
1501 {
1502 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1503 str.pData->buffer, str.pData->length );
1504 }
1505#endif
1506
1526#if defined LIBO_INTERNAL_ONLY
1527 sal_Int32 lastIndexOf( std::u16string_view str, sal_Int32 fromIndex ) const
1528 {
1529 assert( fromIndex >= 0 && fromIndex <= pData->length );
1530 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1531 str.data(), str.length() );
1532 }
1533#else
1534 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1535 {
1536 assert( fromIndex >= 0 && fromIndex <= pData->length );
1537 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1538 str.pData->buffer, str.pData->length );
1539 }
1540#endif
1541
1547 template< typename T >
1548 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
1549 {
1550 assert(
1551 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1552 return rtl_ustr_lastIndexOfAscii_WithLength(
1553 pData->buffer, pData->length,
1554 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1555 libreoffice_internal::ConstCharArrayDetector<T>::length);
1556 }
1557
1558#if defined LIBO_INTERNAL_ONLY
1560 template<typename T>
1561 typename
1562 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1563 lastIndexOf(T & literal) const {
1564 return lastIndexOf(
1565 std::u16string_view(libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1566 libreoffice_internal::ConstCharArrayDetector<T>::length));
1567 }
1568#endif
1569
1579 sal_Int32 stripStart(sal_Unicode c = ' ')
1580 {
1581 sal_Int32 index;
1582 for(index = 0; index < getLength() ; index++)
1583 {
1584 if(pData->buffer[ index ] != c)
1585 {
1586 break;
1587 }
1588 }
1589 if(index)
1590 {
1591 remove(0, index);
1592 }
1593 return index;
1594 }
1595
1605 sal_Int32 stripEnd(sal_Unicode c = ' ')
1606 {
1607 sal_Int32 result = getLength();
1608 sal_Int32 index;
1609 for(index = getLength(); index > 0 ; index--)
1610 {
1611 if(pData->buffer[ index - 1 ] != c)
1612 {
1613 break;
1614 }
1615 }
1616 if(index < getLength())
1617 {
1618 truncate(index);
1619 }
1620 return result - getLength();
1621 }
1622
1631 sal_Int32 strip(sal_Unicode c = ' ')
1632 {
1633 return stripStart(c) + stripEnd(c);
1634 }
1635
1636#if defined LIBO_INTERNAL_ONLY
1647 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
1648 {
1649 assert(beginIndex >= 0);
1650 assert(beginIndex <= getLength());
1651 return subView(beginIndex, getLength() - beginIndex);
1652 }
1653
1666 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1667 {
1668 assert(beginIndex >= 0);
1669 assert(count >= 0);
1670 assert(beginIndex <= getLength());
1671 assert(count <= getLength() - beginIndex);
1672 return std::u16string_view(*this).substr(beginIndex, count);
1673 }
1674#endif
1675
1687 OUStringBuffer copy( sal_Int32 beginIndex ) const
1688 {
1689 return copy( beginIndex, getLength() - beginIndex );
1690 }
1691
1705 OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1706 {
1707 assert(beginIndex >= 0 && beginIndex <= getLength());
1708 assert(count >= 0 && count <= getLength() - beginIndex);
1709 rtl_uString *pNew = NULL;
1710 rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1711 return OUStringBuffer( pNew, count + 16 );
1712 }
1713
1714 private:
1715 OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1716 {
1717 pData = value;
1718 nCapacity = capacity;
1719 }
1720
1724 rtl_uString * pData;
1725
1729 sal_Int32 nCapacity;
1730};
1731
1732#if defined LIBO_INTERNAL_ONLY
1733 template<> struct ToStringHelper<OUStringBuffer> {
1734 static std::size_t length(OUStringBuffer const & s) { return s.getLength(); }
1735
1736 sal_Unicode * operator()(sal_Unicode * buffer, OUStringBuffer const & s) const SAL_RETURNS_NONNULL
1737 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1738};
1739#endif
1740
1741#if defined LIBO_INTERNAL_ONLY
1742 // Define this here to avoid circular includes
1743 inline OUString & OUString::operator+=( const OUStringBuffer & str ) &
1744 {
1745 // Call operator= if this is empty, otherwise rtl_uString_newConcat will attempt to
1746 // acquire() the str.pData buffer, which is part of the OUStringBuffer mutable state.
1747 if (isEmpty())
1748 return operator=(str.toString());
1749 else
1750 return internalAppend(str.pData);
1751 }
1752
1753 inline OUString const& OUString::unacquired(const OUStringBuffer& str)
1754 {
1755 return unacquired(&str.pData);
1756 }
1757#endif
1758}
1759
1760#ifdef RTL_STRING_UNITTEST
1761 namespace rtl
1762{
1763 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1764}
1765#endif
1766
1767#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1768 using ::rtl::OUStringBuffer;
1769#endif
1770
1771#endif // INCLUDED_RTL_USTRBUF_HXX
1772
1773/* 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:492
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:396
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition types.h:374
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 used.
Definition types.h:288
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
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:2702
rtl::libreoffice_internal
Definition stringutils.hxx:119
rtl::libreoffice_internal::Dummy
Definition stringutils.hxx:178
rtl::libreoffice_internal::CharPtrDetector
Definition stringutils.hxx:181
rtl::libreoffice_internal::CharPtrDetector::ok
static const bool ok
Definition stringutils.hxx:182
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition stringutils.hxx:205
rtl::libreoffice_internal::ConstCharArrayDetector
Definition stringutils.hxx:233
rtl::libreoffice_internal::SalUnicodePtrDetector::ok
static const bool ok
Definition stringutils.hxx:396
rtl::libreoffice_internal::Enable
Definition stringutils.hxx:414
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:510
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:1404
rtl::OUStringBuffer::stripStart
sal_Int32 stripStart(sal_Unicode c=' ')
Strip the given character from the start of the buffer.
Definition ustrbuf.hxx:1579
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:1035
rtl::OUStringBuffer::append
OUStringBuffer & append(rtl_uString *str)
Definition ustrbuf.hxx:757
rtl::OUStringBuffer::append
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition ustrbuf.hxx:737
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition ustrbuf.hxx:1687
rtl::OUStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition ustrbuf.hxx:411
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:1705
rtl::OUStringBuffer::append
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition ustrbuf.hxx:790
rtl::OUStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition ustrbuf.hxx:426
rtl::OUStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition ustrbuf.hxx:398
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:1101
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:1319
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:1219
rtl::OUStringBuffer::strip
sal_Int32 strip(sal_Unicode c=' ')
Strip the given character from the both end of the buffer.
Definition ustrbuf.hxx:1631
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:1436
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:718
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition ustrbuf.hxx:773
rtl::OUStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition ustrbuf.hxx:465
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:157
rtl::OUStringBuffer::append
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition ustrbuf.hxx:876
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:1367
rtl::OUStringBuffer::toString
OUString toString() const
Return an OUString instance reflecting the current content of this OUStringBuffer.
Definition ustrbuf.hxx:556
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:844
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition ustrbuf.hxx:806
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition ustrbuf.hxx:572
rtl::OUStringBuffer::remove
OUStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition ustrbuf.hxx:1287
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:827
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:913
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:1534
rtl::OUStringBuffer::stripEnd
sal_Int32 stripEnd(sal_Unicode c=' ')
Strip the given character from the end of the buffer.
Definition ustrbuf.hxx:1605
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:1146
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:1076
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:1452
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition ustrbuf.hxx:593
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:638
rtl::OUStringBuffer::appendUtf32
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition ustrbuf.hxx:894
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition ustrbuf.hxx:696
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:1385
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:148
rtl::OUStringBuffer::~OUStringBuffer
~OUStringBuffer()
Release the string data.
Definition ustrbuf.hxx:373
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:649
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:1170
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:999
rtl::OUStringBuffer::truncate
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition ustrbuf.hxx:1303
rtl::OUStringBuffer::append
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition ustrbuf.hxx:860
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:1548
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:442
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition ustrbuf.hxx:954
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:1022
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:1246
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:619
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:1125
rtl::OUStringBuffer::getStr
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Return a null terminated unicode character array.
Definition ustrbuf.hxx:520
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:1195
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:1500
rtl::OUStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition ustrbuf.hxx:386
rtl::OUStringBuffer::insertUtf32
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition ustrbuf.hxx:1270
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:1344
rtl::OUStringBuffer::charAt
sal_Unicode charAt(sal_Int32 index) const
Returns the character at a specific index in this string buffer.
Definition ustrbuf.hxx:493
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:172
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:843
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:560
rtl::OUString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition ustring.hxx:821
rtl::OUString::operator+=
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition ustring.hxx:692