LibreOffice: rtl/ustrbuf.hxx Source File

LibreOffice LibreOffice 7.5 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 "rtl/stringconcat.hxx"
47#endif
48
49#ifdef RTL_STRING_UNITTEST
50extern bool rtl_string_unittest_invalid_conversion;
51#endif
52
53// The unittest uses slightly different code to help check that the proper
54// calls are made. The class is put into a different namespace to make
55// sure the compiler generates a different (if generating also non-inline)
56// copy of the function and does not merge them together. The class
57// is "brought" into the proper rtl namespace by a typedef below.
58#ifdef RTL_STRING_UNITTEST
59#define rtl rtlunittest
60#endif
61
62namespace rtl
63{
64
65#ifdef RTL_STRING_UNITTEST
66#undef rtl
67#endif
68
71 class SAL_WARN_UNUSED OUStringBuffer
72{
73 friend class OUString;
74public:
79 OUStringBuffer()
80 : pData(NULL)
81 , nCapacity( 16 )
82 {
83 rtl_uString_new_WithLength( &pData, nCapacity );
84 }
85
92 OUStringBuffer( const OUStringBuffer & value )
93 : pData(NULL)
94 , nCapacity( value.nCapacity )
95 {
96 rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
97 }
98
105 explicit OUStringBuffer(sal_Int32 length)
106 : pData(NULL)
107 , nCapacity( length )
108 {
109 rtl_uString_new_WithLength( &pData, length );
110 }
111#if defined LIBO_INTERNAL_ONLY
112 template<typename T>
113 explicit OUStringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
114 : OUStringBuffer(static_cast<sal_Int32>(length))
115 {
116 assert(
117 length >= 0
118 && static_cast<std::make_unsigned_t<T>>(length)
119 <= static_cast<std::make_unsigned_t<sal_Int32>>(
120 std::numeric_limits<sal_Int32>::max()));
121 }
122 // avoid (obvious) bugs
123 explicit OUStringBuffer(bool) = delete;
124 explicit OUStringBuffer(char) = delete;
125 explicit OUStringBuffer(wchar_t) = delete;
126#if defined __cpp_char8_t
127 explicit OUStringBuffer(char8_t) = delete;
128#endif
129 explicit OUStringBuffer(char16_t) = delete;
130 explicit OUStringBuffer(char32_t) = delete;
131#endif
132
143#if defined LIBO_INTERNAL_ONLY
144 OUStringBuffer(std::u16string_view sv)
145 : pData(nullptr)
146 , nCapacity( sv.length() + 16 )
147 {
148 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
149 throw std::bad_alloc();
150 }
151 rtl_uStringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
152 }
153#else
154 OUStringBuffer(const OUString& value)
155 : pData(NULL)
156 , nCapacity( value.getLength() + 16 )
157 {
158 rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
159 }
160#endif
161
162 template< typename T >
163 OUStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
164 : pData(NULL)
165 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
166 {
167 assert(
168 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
169 rtl_uString_newFromLiteral(
170 &pData,
171 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
172 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
173#ifdef RTL_STRING_UNITTEST
174 rtl_string_unittest_const_literal = true;
175#endif
176 }
177
178#if defined LIBO_INTERNAL_ONLY
180 template<typename T>
181 OUStringBuffer(
182 T & literal,
183 typename libreoffice_internal::ConstCharArrayDetector<
184 T, libreoffice_internal::Dummy>::TypeUtf16
185 = libreoffice_internal::Dummy()):
186 pData(nullptr),
187 nCapacity(libreoffice_internal::ConstCharArrayDetector<T>::length + 16)
188 {
189 rtl_uStringbuffer_newFromStr_WithLength(
190 &pData,
191 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
192 libreoffice_internal::ConstCharArrayDetector<T>::length);
193 }
194#endif
195
196#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
198
202 template< typename T >
203 OUStringBuffer( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
204 {
205 pData = NULL;
206 nCapacity = 10;
207 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
208 rtl_string_unittest_invalid_conversion = true;
209 }
214 template< typename T >
215 OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
216 {
217 pData = NULL;
218 nCapacity = 10;
219 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
220 rtl_string_unittest_invalid_conversion = true;
221 }
223#endif
224
225#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
230 template< typename T1, typename T2 >
231 OUStringBuffer( OUStringConcat< T1, T2 >&& c )
232 {
233 const sal_Int32 l = c.length();
234 nCapacity = l + 16;
235 pData = rtl_uString_alloc( nCapacity );
236 sal_Unicode* end = c.addData( pData->buffer );
237 *end = '\0';
238 pData->length = l;
239 }
240
245 template< typename T, std::size_t N >
246 OUStringBuffer( StringNumberBase< sal_Unicode, T, N >&& n )
247 : pData(NULL)
248 , nCapacity( n.length + 16 )
249 {
250 rtl_uStringbuffer_newFromStr_WithLength( &pData, n.buf, n.length );
251 }
252#endif
253
254#if defined LIBO_INTERNAL_ONLY
255 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
256#endif
257
260 OUStringBuffer& operator = ( const OUStringBuffer& value )
261 {
262 if (this != &value)
263 {
264 rtl_uStringbuffer_newFromStringBuffer(&pData,
265 value.nCapacity,
266 value.pData);
267 nCapacity = value.nCapacity;
268 }
269 return *this;
270 }
271
272#if defined LIBO_INTERNAL_ONLY
276 OUStringBuffer& operator = ( OUStringBuffer&& value ) noexcept
277 {
278 rtl_uString_release( pData );
279 pData = value.pData;
280 nCapacity = value.nCapacity;
281 value.pData = nullptr;
282 value.nCapacity = 0;
283 rtl_uString_new( &value.pData );
284 return *this;
285 }
286#endif
287
292#if defined LIBO_INTERNAL_ONLY
293 OUStringBuffer & operator =(std::u16string_view string) {
294 sal_Int32 n = string.length();
295 if (n >= nCapacity) {
296 ensureCapacity(n + 16); //TODO: check for overflow
297 }
298 std::memcpy(
299 pData->buffer, string.data(),
300 n * sizeof (sal_Unicode));
301 pData->buffer[n] = '\0';
302 pData->length = n;
303 return *this;
304 }
305#else
306 OUStringBuffer & operator =(OUString const & string) {
307 sal_Int32 n = string.getLength();
308 if (n >= nCapacity) {
309 ensureCapacity(n + 16); //TODO: check for overflow
310 }
311 std::memcpy(
312 pData->buffer, string.pData->buffer,
313 (n + 1) * sizeof (sal_Unicode));
314 pData->length = n;
315 return *this;
316 }
317#endif
318
323 template<typename T>
324 typename
325 libreoffice_internal::ConstCharArrayDetector<T, OUStringBuffer &>::Type
326 operator =(T & literal) {
327 assert(
328 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
329 sal_Int32 const n
330 = libreoffice_internal::ConstCharArrayDetector<T>::length;
331 if (n >= nCapacity) {
332 ensureCapacity(n + 16); //TODO: check for overflow
333 }
334 char const * from
335 = libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
336 literal);
337 sal_Unicode * to = pData->buffer;
338 for (sal_Int32 i = 0; i <= n; ++i) {
339 to[i] = from[i];
340 }
341 pData->length = n;
342 return *this;
343 }
344
345#if defined LIBO_INTERNAL_ONLY
347 template<typename T>
348 typename libreoffice_internal::ConstCharArrayDetector<
349 T, OUStringBuffer &>::TypeUtf16
350 operator =(T & literal) {
351 sal_Int32 const n
352 = libreoffice_internal::ConstCharArrayDetector<T>::length;
353 if (n >= nCapacity) {
354 ensureCapacity(n + 16); //TODO: check for overflow
355 }
356 // For OUStringChar, which is covered by this template's ConstCharArrayDetector TypeUtf16
357 // check, toPointer does not return a NUL-terminated string, so we can't just memcpy n+1
358 // elements but rather need to add the terminating NUL manually:
359 std::memcpy(
360 pData->buffer,
361 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
362 n * sizeof (sal_Unicode));
363 pData->buffer[n] = '\0';
364 pData->length = n;
365 return *this;
366 }
367#endif
368
369#if defined LIBO_INTERNAL_ONLY
371 template<typename T1, typename T2>
372 OUStringBuffer & operator =(OUStringConcat<T1, T2> && concat) {
373 sal_Int32 const n = concat.length();
374 if (n >= nCapacity) {
375 ensureCapacity(n + 16); //TODO: check for overflow
376 }
377 *concat.addData(pData->buffer) = 0;
378 pData->length = n;
379 return *this;
380 }
381
383 template<typename T, std::size_t N>
384 OUStringBuffer & operator =(StringNumberBase<sal_Unicode, T, N> && n)
385 {
386 *this = OUStringBuffer( std::move( n ) );
387 return *this;
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 {
595 return append( str.getStr(), str.getLength() );
596 }
597#else
598 OUStringBuffer & append(std::u16string_view sv) {
599 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
600 throw std::bad_alloc();
601 }
602 return append(sv.data(), sv.size());
603 }
604#endif
605
606#if !defined LIBO_INTERNAL_ONLY
619 OUStringBuffer & append(const OUStringBuffer &str)
620 {
621 if(!str.isEmpty())
622 {
623 append( str.getStr(), str.getLength() );
624 }
625 return *this;
626 }
627#endif
628
640#if defined LIBO_INTERNAL_ONLY
641 template<typename T>
642 typename libreoffice_internal::CharPtrDetector<T, OUStringBuffer &>::TypeUtf16
643 append(T const & str)
644#else
645 OUStringBuffer & append( const sal_Unicode * str )
646#endif
647 {
648 return append( str, rtl_ustr_getLength( str ) );
649 }
650
664 OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
665 {
666 assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
667 rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
668 return *this;
669 }
670
676 template< typename T >
677 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
678 {
679 assert(
680 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
681 return appendAscii(
682 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
683 libreoffice_internal::ConstCharArrayDetector<T>::length);
684 }
685
686#if defined LIBO_INTERNAL_ONLY
687 template<typename T>
688 typename libreoffice_internal::NonConstCharArrayDetector<T, OUStringBuffer &>::TypeUtf16
689 append(T & value) { return append(static_cast<sal_Unicode *>(value)); }
690
692 template<typename T>
693 typename libreoffice_internal::ConstCharArrayDetector<
694 T, OUStringBuffer &>::TypeUtf16
695 append(T & literal) {
696 return append(
697 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
698 libreoffice_internal::ConstCharArrayDetector<T>::length);
699 }
700#endif
701
702#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
707 template< typename T1, typename T2 >
708 OUStringBuffer& append( OUStringConcat< T1, T2 >&& c )
709 {
710 sal_Int32 l = c.length();
711 if( l == 0 )
712 return *this;
713 l += pData->length;
714 rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, l );
715 sal_Unicode* end = c.addData( pData->buffer + pData->length );
716 *end = '\0';
717 pData->length = l;
718 return *this;
719 }
720
725 template< typename T, std::size_t N >
726 OUStringBuffer& append( StringNumberBase< sal_Unicode, T, N >&& c )
727 {
728 return append( c.buf, c.length );
729 }
730#endif
731
748 OUStringBuffer & appendAscii( const char * str )
749 {
750 return appendAscii( str, rtl_str_getLength( str ) );
751 }
752
770 OUStringBuffer & appendAscii( const char * str, sal_Int32 len)
771 {
772 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
773 return *this;
774 }
775
789 OUStringBuffer & append(bool b)
790 {
791 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
792 return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
793 }
794
796 // Pointer can be automatically converted to bool, which is unwanted here.
797 // Explicitly delete all pointer append() overloads to prevent this
798 // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
799 template< typename T >
800 typename libreoffice_internal::Enable< void,
801 !libreoffice_internal::CharPtrDetector< T* >::ok && !libreoffice_internal::SalUnicodePtrDetector< T* >::ok >::Type
802 append( T* ) SAL_DELETED_FUNCTION;
804
805 // This overload is needed because OUString has a ctor from rtl_uString*, but
806 // the bool overload above would be preferred to the conversion.
810 OUStringBuffer & append(rtl_uString* str)
811 {
812 return append( OUString( str ));
813 }
814
826 OUStringBuffer & append(sal_Bool b)
827 {
828 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
829 return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
830 }
831
844 OUStringBuffer & append(char c)
845 {
846 assert(static_cast< unsigned char >(c) <= 0x7F);
847 return append(sal_Unicode(c));
848 }
849
860 OUStringBuffer & append(sal_Unicode c)
861 {
862 return append( &c, 1 );
863 }
864
865#if defined LIBO_INTERNAL_ONLY
866 void append(sal_uInt16) = delete;
867#endif
868
881 OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
882 {
883 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
884 return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
885 }
886
899 OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
900 {
901 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
902 return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
903 }
904
916 OUStringBuffer & append(float f)
917 {
918 sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
919 return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
920 }
921
933 OUStringBuffer & append(double d)
934 {
935 sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
936 return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
937 }
938
952 OUStringBuffer & appendUtf32(sal_uInt32 c) {
953 return insertUtf32(getLength(), c);
954 }
955
971 sal_Unicode * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
972 sal_Int32 n = getLength();
973 rtl_uStringbuffer_insert(&pData, &nCapacity, n, NULL, length);
974 return pData->buffer + n;
975 }
976
977#if defined LIBO_INTERNAL_ONLY
984 template<typename T>
985 OUStringBuffer& operator<<(T&& rValue)
986 {
987 return append(std::forward<T>(rValue));
988 }
989#endif
990
1006#if defined LIBO_INTERNAL_ONLY
1007 OUStringBuffer & insert(sal_Int32 offset, std::u16string_view str)
1008 {
1009 return insert( offset, str.data(), str.length() );
1010 }
1011#else
1012 OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
1013 {
1014 return insert( offset, str.getStr(), str.getLength() );
1015 }
1016#endif
1017
1035 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
1036 {
1037 return insert( offset, str, rtl_ustr_getLength( str ) );
1038 }
1039
1058 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
1059 {
1060 assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
1061 rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
1062 return *this;
1063 }
1064
1070 template< typename T >
1071 typename libreoffice_internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
1072 {
1073 assert(
1074 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1075 rtl_uStringbuffer_insert_ascii(
1076 &pData, &nCapacity, offset,
1077 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1078 libreoffice_internal::ConstCharArrayDetector<T>::length);
1079 return *this;
1080 }
1081
1082#if defined LIBO_INTERNAL_ONLY
1084 template<typename T>
1085 typename libreoffice_internal::ConstCharArrayDetector<
1086 T, OUStringBuffer &>::TypeUtf16
1087 insert(sal_Int32 offset, T & literal) {
1088 return insert(
1089 offset,
1090 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1091 libreoffice_internal::ConstCharArrayDetector<T>::length);
1092 }
1093#endif
1094
1112 OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
1113 {
1114 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1115 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1116 }
1117
1137 OUStringBuffer & insert(sal_Int32 offset, bool b)
1138 {
1139 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
1140 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
1141 }
1142
1161 OUStringBuffer & insert(sal_Int32 offset, char c)
1162 {
1163 sal_Unicode u = c;
1164 return insert( offset, &u, 1 );
1165 }
1166
1183 OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
1184 {
1185 return insert( offset, &c, 1 );
1186 }
1187
1207 OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
1208 {
1209 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
1210 return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
1211 }
1212
1232 OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
1233 {
1234 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
1235 return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
1236 }
1237
1256 OUStringBuffer insert(sal_Int32 offset, float f)
1257 {
1258 sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
1259 return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
1260 }
1261
1280 OUStringBuffer & insert(sal_Int32 offset, double d)
1281 {
1282 sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
1283 return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
1284 }
1285
1301 OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1302 rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1303 return *this;
1304 }
1305
1318 OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1319 {
1320 rtl_uStringbuffer_remove( &pData, start, len );
1321 return *this;
1322 }
1323
1334 OUStringBuffer & truncate( sal_Int32 start = 0 )
1335 {
1336 rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1337 return *this;
1338 }
1339
1350 OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar )
1351 {
1352 sal_Int32 index = 0;
1353 while((index = indexOf(oldChar, index)) >= 0)
1354 {
1355 pData->buffer[ index ] = newChar;
1356 }
1357 return *this;
1358 }
1359
1375 void accessInternals(rtl_uString *** pInternalData,
1376 sal_Int32 ** pInternalCapacity)
1377 {
1378 *pInternalData = &pData;
1379 *pInternalCapacity = &nCapacity;
1380 }
1381
1382
1398 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1399 {
1400 assert( fromIndex >= 0 && fromIndex <= pData->length );
1401 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1402 return (ret < 0 ? ret : ret+fromIndex);
1403 }
1404
1416 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1417 {
1418 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1419 }
1420
1435 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1436 {
1437 assert( fromIndex >= 0 && fromIndex <= pData->length );
1438 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1439 }
1440
1458#if defined LIBO_INTERNAL_ONLY
1459 sal_Int32 indexOf( std::u16string_view str, sal_Int32 fromIndex = 0 ) const
1460 {
1461 assert( fromIndex >= 0 && fromIndex <= pData->length );
1462 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1463 str.data(), str.length() );
1464 return (ret < 0 ? ret : ret+fromIndex);
1465 }
1466#else
1467 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1468 {
1469 assert( fromIndex >= 0 && fromIndex <= pData->length );
1470 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1471 str.pData->buffer, str.pData->length );
1472 return (ret < 0 ? ret : ret+fromIndex);
1473 }
1474#endif
1475
1482 template< typename T >
1483 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1484 {
1485 assert(
1486 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1487 sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1488 pData->buffer + fromIndex, pData->length - fromIndex,
1489 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1490 libreoffice_internal::ConstCharArrayDetector<T>::length);
1491 return n < 0 ? n : n + fromIndex;
1492 }
1493
1494#if defined LIBO_INTERNAL_ONLY
1496 template<typename T>
1497 typename
1498 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1499 indexOf(T & literal, sal_Int32 fromIndex = 0) const {
1500 assert(fromIndex >= 0);
1501 auto n = rtl_ustr_indexOfStr_WithLength(
1502 pData->buffer + fromIndex, pData->length - fromIndex,
1503 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1504 libreoffice_internal::ConstCharArrayDetector<T>::length);
1505 return n < 0 ? n : n + fromIndex;
1506 }
1507#endif
1508
1526#if defined LIBO_INTERNAL_ONLY
1527 sal_Int32 lastIndexOf( std::u16string_view str ) const
1528 {
1529 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1530 str.data(), str.length() );
1531 }
1532#else
1533 sal_Int32 lastIndexOf( const OUString & str ) const
1534 {
1535 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1536 str.pData->buffer, str.pData->length );
1537 }
1538#endif
1539
1559#if defined LIBO_INTERNAL_ONLY
1560 sal_Int32 lastIndexOf( std::u16string_view str, sal_Int32 fromIndex ) const
1561 {
1562 assert( fromIndex >= 0 && fromIndex <= pData->length );
1563 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1564 str.data(), str.length() );
1565 }
1566#else
1567 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1568 {
1569 assert( fromIndex >= 0 && fromIndex <= pData->length );
1570 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1571 str.pData->buffer, str.pData->length );
1572 }
1573#endif
1574
1580 template< typename T >
1581 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
1582 {
1583 assert(
1584 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1585 return rtl_ustr_lastIndexOfAscii_WithLength(
1586 pData->buffer, pData->length,
1587 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1588 libreoffice_internal::ConstCharArrayDetector<T>::length);
1589 }
1590
1591#if defined LIBO_INTERNAL_ONLY
1593 template<typename T>
1594 typename
1595 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1596 lastIndexOf(T & literal) const {
1597 return rtl_ustr_lastIndexOfStr_WithLength(
1598 pData->buffer, pData->length,
1599 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1600 libreoffice_internal::ConstCharArrayDetector<T>::length);
1601 }
1602#endif
1603
1613 sal_Int32 stripStart(sal_Unicode c = ' ')
1614 {
1615 sal_Int32 index;
1616 for(index = 0; index < getLength() ; index++)
1617 {
1618 if(pData->buffer[ index ] != c)
1619 {
1620 break;
1621 }
1622 }
1623 if(index)
1624 {
1625 remove(0, index);
1626 }
1627 return index;
1628 }
1629
1639 sal_Int32 stripEnd(sal_Unicode c = ' ')
1640 {
1641 sal_Int32 result = getLength();
1642 sal_Int32 index;
1643 for(index = getLength(); index > 0 ; index--)
1644 {
1645 if(pData->buffer[ index - 1 ] != c)
1646 {
1647 break;
1648 }
1649 }
1650 if(index < getLength())
1651 {
1652 truncate(index);
1653 }
1654 return result - getLength();
1655 }
1665 sal_Int32 strip(sal_Unicode c = ' ')
1666 {
1667 return stripStart(c) + stripEnd(c);
1668 }
1669
1670#if defined LIBO_INTERNAL_ONLY
1681 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
1682 {
1683 assert(beginIndex >= 0);
1684 assert(beginIndex <= getLength());
1685 return subView(beginIndex, getLength() - beginIndex);
1686 }
1687
1700 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1701 {
1702 assert(beginIndex >= 0);
1703 assert(count >= 0);
1704 assert(beginIndex <= getLength());
1705 assert(count <= getLength() - beginIndex);
1706 return std::u16string_view(pData->buffer, sal_uInt32(pData->length)).substr(beginIndex, count);
1707 }
1708#endif
1709
1721 OUStringBuffer copy( sal_Int32 beginIndex ) const
1722 {
1723 return copy( beginIndex, getLength() - beginIndex );
1724 }
1725
1739 OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1740 {
1741 assert(beginIndex >= 0 && beginIndex <= getLength());
1742 assert(count >= 0 && count <= getLength() - beginIndex);
1743 rtl_uString *pNew = NULL;
1744 rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1745 return OUStringBuffer( pNew, count + 16 );
1746 }
1747
1748private:
1749 OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1750 {
1751 pData = value;
1752 nCapacity = capacity;
1753 }
1754
1758 rtl_uString * pData;
1759
1763 sal_Int32 nCapacity;
1764};
1765
1766#if defined LIBO_INTERNAL_ONLY
1767template<> struct ToStringHelper<OUStringBuffer> {
1768 static std::size_t length(OUStringBuffer const & s) { return s.getLength(); }
1769
1770 sal_Unicode * operator()(sal_Unicode * buffer, OUStringBuffer const & s) const SAL_RETURNS_NONNULL
1771 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1772};
1773#endif
1774
1775#if defined LIBO_INTERNAL_ONLY
1776 // Define this here to avoid circular includes
1777 inline OUString & OUString::operator+=( const OUStringBuffer & str ) &
1778 {
1779 // Call operator= if this is empty, otherwise rtl_uString_newConcat will attempt to
1780 // acquire() the str.pData buffer, which is part of the OUStringBuffer mutable state.
1781 if (isEmpty())
1782 return operator=(str.toString());
1783 else
1784 return internalAppend(str.pData);
1785 }
1786
1787 inline OUString const& OUString::unacquired(const OUStringBuffer& str)
1788 {
1789 return unacquired(&str.pData);
1790 }
1791#endif
1792}
1793
1794#ifdef RTL_STRING_UNITTEST
1795namespace rtl
1796{
1797typedef rtlunittest::OUStringBuffer OUStringBuffer;
1798}
1799#endif
1800
1801#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1802using ::rtl::OUStringBuffer;
1803#endif
1804
1805#endif // INCLUDED_RTL_USTRBUF_HXX
1806
1807/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
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_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
rtl_ustr_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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
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.
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.
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:2325
rtl::libreoffice_internal::Dummy
Definition stringutils.hxx:140
rtl::libreoffice_internal::CharPtrDetector
Definition stringutils.hxx:143
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition stringutils.hxx:167
rtl::libreoffice_internal::ConstCharArrayDetector
Definition stringutils.hxx:195
rtl::libreoffice_internal::SalUnicodePtrDetector
Definition stringutils.hxx:356
rtl::libreoffice_internal::Enable
Definition stringutils.hxx:375
rtl::OUStringBuffer
A string buffer implements a mutable sequence of characters.
Definition ustrbuf.hxx:72
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:1435
rtl::OUStringBuffer::stripStart
sal_Int32 stripStart(sal_Unicode c=' ')
Strip the given character from the start of the buffer.
Definition ustrbuf.hxx:1613
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:1071
rtl::OUStringBuffer::append
OUStringBuffer & append(rtl_uString *str)
Definition ustrbuf.hxx:810
rtl::OUStringBuffer::append
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition ustrbuf.hxx:789
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition ustrbuf.hxx:1721
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:1739
rtl::OUStringBuffer::append
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition ustrbuf.hxx:844
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:1137
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:1350
rtl::OUStringBuffer::strip
sal_Int32 strip(sal_Unicode c=' ')
Strip the given character from the both end of the buffer.
Definition ustrbuf.hxx:1665
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition ustrbuf.hxx:79
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:1467
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:770
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition ustrbuf.hxx:826
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:92
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition ustrbuf.hxx:163
rtl::OUStringBuffer::append
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition ustrbuf.hxx:933
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:1398
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:899
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition ustrbuf.hxx:860
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:1318
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:105
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:881
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:971
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:1256
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:1567
rtl::OUStringBuffer::stripEnd
sal_Int32 stripEnd(sal_Unicode c=' ')
Strip the given character from the end of the buffer.
Definition ustrbuf.hxx:1639
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:1183
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:1112
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:1483
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition ustrbuf.hxx:619
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:664
rtl::OUStringBuffer::appendUtf32
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition ustrbuf.hxx:952
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition ustrbuf.hxx:748
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:1416
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:154
rtl::OUStringBuffer::~OUStringBuffer
~OUStringBuffer()
Release the string data.
Definition ustrbuf.hxx:394
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:677
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:1207
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:1035
rtl::OUStringBuffer::truncate
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition ustrbuf.hxx:1334
rtl::OUStringBuffer::append
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition ustrbuf.hxx:916
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:1581
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:1012
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:1058
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:1280
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:645
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:1161
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:1232
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:1533
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:1301
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:1375
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:203
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:826
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:540
rtl::OUString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition ustring.hxx:804
rtl::OUString::operator+=
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition ustring.hxx:675