LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 6.3 SDK C/C++ API Reference

strbuf.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 #ifndef INCLUDED_RTL_STRBUF_HXX
21 #define INCLUDED_RTL_STRBUF_HXX
22
23 #include "sal/config.h"
24
25 #include <cassert>
26 #include <cstring>
27
28 #include "rtl/strbuf.h"
29 #include "rtl/string.hxx"
30 #include "rtl/stringutils.hxx"
31
32 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
33 #include "rtl/stringconcat.hxx"
34 #endif
35
36 #ifdef RTL_STRING_UNITTEST
37 extern bool rtl_string_unittest_const_literal;
38 extern bool rtl_string_unittest_const_literal_function;
39 #endif
40
41 // The unittest uses slightly different code to help check that the proper
42 // calls are made. The class is put into a different namespace to make
43 // sure the compiler generates a different (if generating also non-inline)
44 // copy of the function and does not merge them together. The class
45 // is "brought" into the proper rtl namespace by a typedef below.
46 #ifdef RTL_STRING_UNITTEST
47 #define rtl rtlunittest
48 #endif
49
50 namespace rtl
51 {
52
54 #ifdef RTL_STRING_UNITTEST
55 #undef rtl
56 // helper macro to make functions appear more readable
57 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
58 #else
59 #define RTL_STRING_CONST_FUNCTION
60 #endif
61
65 class SAL_WARN_UNUSED OStringBuffer
66 {
67 public:
72 OStringBuffer()
73 : pData(NULL)
74 , nCapacity( 16 )
75 {
76 rtl_string_new_WithLength( &pData, nCapacity );
77 }
78
85 OStringBuffer( const OStringBuffer & value )
86 : pData(NULL)
87 , nCapacity( value.nCapacity )
88 {
89 rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
90 }
91
98 explicit OStringBuffer(int length)
99 : pData(NULL)
100 , nCapacity( length )
101 {
102 rtl_string_new_WithLength( &pData, length );
103 }
104 #if __cplusplus >= 201103L
105 explicit OStringBuffer(unsigned int length)
106 : OStringBuffer(static_cast<int>(length))
107 {
108 }
109 #if SAL_TYPES_SIZEOFLONG == 4
110 // additional overloads for sal_Int32 sal_uInt32
111 explicit OStringBuffer(long length)
112 : OStringBuffer(static_cast<int>(length))
113 {
114 }
115 explicit OStringBuffer(unsigned long length)
116 : OStringBuffer(static_cast<int>(length))
117 {
118 }
119 #endif
120 // avoid obvious bugs
121 explicit OStringBuffer(char) = delete;
122 explicit OStringBuffer(sal_Unicode) = delete;
123 #endif
124
135 OStringBuffer(const OString& value)
136 : pData(NULL)
137 , nCapacity( value.getLength() + 16 )
138 {
139 rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
140 }
141
146 template< typename T >
147 OStringBuffer( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
148 : pData(NULL)
149 {
150 sal_Int32 length = rtl_str_getLength( value );
151 nCapacity = length + 16;
152 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
153 }
154
155 template< typename T >
156 OStringBuffer( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
157 : pData(NULL)
158 {
159 sal_Int32 length = rtl_str_getLength( value );
160 nCapacity = length + 16;
161 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
162 }
163
175 template< typename T >
176 OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
177 : pData(NULL)
178 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
179 {
180 assert(
181 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
182 rtl_string_newFromLiteral(
183 &pData,
184 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
185 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
186 #ifdef RTL_STRING_UNITTEST
187 rtl_string_unittest_const_literal = true;
188 #endif
189 }
190
203 OStringBuffer(const sal_Char * value, sal_Int32 length)
204 : pData(NULL)
205 , nCapacity( length + 16 )
206 {
207 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
208 }
209
210 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
211
215 template< typename T1, typename T2 >
216 OStringBuffer( OStringConcat< T1, T2 >&& c )
217 {
218 const sal_Int32 l = c.length();
219 nCapacity = l + 16;
220 pData = rtl_string_alloc( nCapacity );
221 char* end = c.addData( pData->buffer );
222 *end = '\0';
223 pData->length = l;
224 }
225 #endif
226
229 OStringBuffer& operator = ( const OStringBuffer& value )
230 {
231 if (this != &value)
232 {
233 rtl_stringbuffer_newFromStringBuffer(&pData,
234 value.nCapacity,
235 value.pData);
236 nCapacity = value.nCapacity;
237 }
238 return *this;
239 }
240
245 OStringBuffer & operator =(OString const & string) {
246 sal_Int32 n = string.getLength();
247 if (n >= nCapacity) {
248 ensureCapacity(n + 16); //TODO: check for overflow
249 }
250 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
251 pData->length = n;
252 return *this;
253 }
254
259 template<typename T>
260 typename
261 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
262 operator =(T & literal) {
263 assert(
264 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
265 sal_Int32 const n
266 = libreoffice_internal::ConstCharArrayDetector<T>::length;
267 if (n >= nCapacity) {
268 ensureCapacity(n + 16); //TODO: check for overflow
269 }
270 std::memcpy(
271 pData->buffer,
272 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
273 n + 1);
274 pData->length = n;
275 return *this;
276 }
277
278 #if defined LIBO_INTERNAL_ONLY
279
280 template<typename T1, typename T2>
281 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
282 sal_Int32 const n = concat.length();
283 if (n >= nCapacity) {
284 ensureCapacity(n + 16); //TODO: check for overflow
285 }
286 *concat.addData(pData->buffer) = 0;
287 pData->length = n;
288 return *this;
289 }
290 #endif
291
295 ~OStringBuffer()
296 {
297 rtl_string_release( pData );
298 }
299
308 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
309 {
310 OString aRet( pData );
311 rtl_string_new(&pData);
312 nCapacity = 0;
313 return aRet;
314 }
315
321 sal_Int32 getLength() const
322 {
323 return pData->length;
324 }
325
334 bool isEmpty() const
335 {
336 return pData->length == 0;
337 }
338
349 sal_Int32 getCapacity() const
350 {
351 return nCapacity;
352 }
353
365 void ensureCapacity(sal_Int32 minimumCapacity)
366 {
367 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
368 }
369
388 void setLength(sal_Int32 newLength)
389 {
390 assert(newLength >= 0);
391 // Avoid modifications if pData points to const empty string:
392 if( newLength != pData->length )
393 {
394 if( newLength > nCapacity )
395 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
396 else
397 pData->buffer[newLength] = '\0';
398 pData->length = newLength;
399 }
400 }
401
415 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
416 sal_Char charAt( sal_Int32 index )
417 {
418 assert(index >= 0 && index < pData->length);
419 return pData->buffer[ index ];
420 }
421
432 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
433 OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
434 {
435 assert(index >= 0 && index < pData->length);
436 pData->buffer[ index ] = ch;
437 return *this;
438 }
439
443 const sal_Char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
444
454 sal_Char & operator [](sal_Int32 index)
455 {
456 assert(index >= 0 && index < pData->length);
457 return pData->buffer[index];
458 }
459
464 const OString toString() const
465 {
466 return OString(pData->buffer, pData->length);
467 }
468
479 OStringBuffer & append(const OString &str)
480 {
481 return append( str.getStr(), str.getLength() );
482 }
483
495 template< typename T >
496 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
497 {
498 return append( str, rtl_str_getLength( str ) );
499 }
500
501 template< typename T >
502 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
503 {
504 return append( str, rtl_str_getLength( str ) );
505 }
506
512 template< typename T >
513 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
514 {
515 RTL_STRING_CONST_FUNCTION
516 assert(
517 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
518 rtl_stringbuffer_insert(
519 &pData, &nCapacity, getLength(),
520 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
521 libreoffice_internal::ConstCharArrayDetector<T>::length);
522 return *this;
523 }
524
538 OStringBuffer & append( const sal_Char * str, sal_Int32 len)
539 {
540 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
541 rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
542 return *this;
543 }
544
545 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
546
550 template< typename T1, typename T2 >
551 OStringBuffer& append( OStringConcat< T1, T2 >&& c )
552 {
553 sal_Int32 l = c.length();
554 if( l == 0 )
555 return *this;
556 l += pData->length;
557 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
558 char* end = c.addData( pData->buffer + pData->length );
559 *end = '\0';
560 pData->length = l;
561 return *this;
562 }
563 #endif
564
576 OStringBuffer & append(sal_Bool b)
577 {
578 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
579 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
580 }
581
595 OStringBuffer & append(bool b)
596 {
597 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
598 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
599 }
600
602 // Pointer can be automatically converted to bool, which is unwanted here.
603 // Explicitly delete all pointer append() overloads to prevent this
604 // (except for char* overload, which is handled elsewhere).
605 template< typename T >
606 typename libreoffice_internal::Enable< void,
607 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
608 append( T* ) SAL_DELETED_FUNCTION;
610
621 OStringBuffer & append(sal_Char c)
622 {
623 return append( &c, 1 );
624 }
625
638 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
639 {
640 sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
641 return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
642 }
643
656 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
657 {
658 sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
659 return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
660 }
661
673 OStringBuffer & append(float f)
674 {
675 sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
676 return append( sz, rtl_str_valueOfFloat( sz, f ) );
677 }
678
690 OStringBuffer & append(double d)
691 {
692 sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
693 return append( sz, rtl_str_valueOfDouble( sz, d ) );
694 }
695
711 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
712 sal_Int32 n = getLength();
713 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
714 return pData->buffer + n;
715 }
716
732 OStringBuffer & insert(sal_Int32 offset, const OString & str)
733 {
734 return insert( offset, str.getStr(), str.getLength() );
735 }
736
754 template< typename T >
755 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
756 {
757 return insert( offset, str, rtl_str_getLength( str ) );
758 }
759
760 template< typename T >
761 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
762 {
763 return insert( offset, str, rtl_str_getLength( str ) );
764 }
765
771 template< typename T >
772 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
773 {
774 RTL_STRING_CONST_FUNCTION
775 assert(
776 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
777 rtl_stringbuffer_insert(
778 &pData, &nCapacity, offset,
779 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
780 libreoffice_internal::ConstCharArrayDetector<T>::length);
781 return *this;
782 }
783
802 OStringBuffer & insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len)
803 {
804 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
805 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
806 return *this;
807 }
808
826 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
827 {
828 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
829 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
830 }
831
851 OStringBuffer & insert(sal_Int32 offset, bool b)
852 {
853 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
854 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
855 }
856
873 OStringBuffer & insert(sal_Int32 offset, sal_Char c)
874 {
875 return insert( offset, &c, 1 );
876 }
877
896 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
897 {
898 sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
899 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
900 }
901
920 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
921 {
922 sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
923 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
924 }
925
943 OStringBuffer insert(sal_Int32 offset, float f)
944 {
945 sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
946 return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
947 }
948
966 OStringBuffer & insert(sal_Int32 offset, double d)
967 {
968 sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
969 return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
970 }
971
984 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
985 {
986 rtl_stringbuffer_remove( &pData, start, len );
987 return *this;
988 }
989
1007 void accessInternals(
1008 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1009 {
1010 *pInternalData = &pData;
1011 *pInternalCapacity = &nCapacity;
1012 }
1013
1014 private:
1018 rtl_String * pData;
1019
1023 sal_Int32 nCapacity;
1024 };
1025
1026 }
1027
1028 #ifdef RTL_STRING_UNITTEST
1029 namespace rtl
1030 {
1031 typedef rtlunittest::OStringBuffer OStringBuffer;
1032 }
1033 #undef RTL_STRING_CONST_FUNCTION
1034 #endif
1035
1036 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1037 using ::rtl::OStringBuffer;
1038 #endif
1039
1040 #endif // INCLUDED_RTL_STRBUF_HXX
1041
1042
1043 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const sal_Char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:802
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:321
strbuf.h
rtl_stringbuffer_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_stringbuffer_newFromStr_WithLength(rtl_String **newStr, const sal_Char *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
rtl::OStringBuffer::append
OStringBuffer & append(const sal_Char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:538
rtl::OStringBuffer::OStringBuffer
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:98
rtl_string_alloc
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:120
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.hxx:123
rtl::OStringBuffer::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:443
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:349
rtl::OStringBuffer::append
OStringBuffer & append(sal_Char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:621
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:147
rtl::OStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:388
rtl::libreoffice_internal::Enable
Definition: stringutils.hxx:299
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:85
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
rtl::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:690
rtl_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:673
rtl_stringbuffer_ensureCapacity
SAL_DLLPUBLIC void rtl_stringbuffer_ensureCapacity(rtl_String **This, sal_Int32 *capacity, sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Constructs a string buffer so that it represents the same sequence of characters as the string litera...
Definition: strbuf.hxx:176
rtl_str_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(sal_Char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:405
stringutils.hxx
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:146
rtl_str_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_str_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl::OStringBuffer::append
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:502
string.hxx
rtl::OStringBuffer::OStringBuffer
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:72
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
config.h
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
rtl_stringbuffer_newFromStringBuffer
SAL_DLLPUBLIC sal_Int32 rtl_stringbuffer_newFromStringBuffer(rtl_String **newStr, sal_Int32 capacity, rtl_String *oldStr)
Allocates a new String that contains the same sequence of characters as the string argument.
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const sal_Char *value, sal_Int32 length)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:203
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:966
rtl::OStringBuffer::appendUninitialized
char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL
Unsafe way to make space for a fixed amount of characters to be appended into this OStringBuffer.
Definition: strbuf.hxx:711
rtl::OStringBuffer::ensureCapacity
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:365
rtl::OStringBuffer::toString
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:464
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:334
rtl::OStringBuffer::append
OStringBuffer & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition: strbuf.hxx:638
rtl::OStringBuffer::append
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:479
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:732
rtl_str_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
rtl::OStringBuffer::insert
libreoffice_internal::CharPtrDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, const T &str)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:755
rtl::OStringBuffer::accessInternals
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1007
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:465
rtl_stringbuffer_insert
SAL_DLLPUBLIC void rtl_stringbuffer_insert(rtl_String **This, sal_Int32 *capacity, sal_Int32 offset, const sal_Char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:295
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:302
rtl::OStringBuffer::insert
OStringBuffer & 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: strbuf.hxx:896
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:851
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:105
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:135
rtl::OStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:308
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:576
rtl
Definition: bootstrap.hxx:29
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:156
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:826
rtl_str_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
RTL_STR_MAX_VALUEOFINT32
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
rtl::OStringBuffer::append
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:656
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:141
rtl::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:984
rtl_stringbuffer_remove
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:595
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:97
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix=10)
Inserts the string representation of the long argument into this string buffer.
Definition: strbuf.hxx:920
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:103
rtl::OString::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:431
rtl_string_newFromLiteral
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
rtl::OStringBuffer::append
libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer & >::Type append(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:513
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:873
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
rtl::OStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:65
rtl::OStringBuffer::insert
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:943
rtl_str_getLength
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
rtl::OStringBuffer::append
libreoffice_internal::CharPtrDetector< T, OStringBuffer & >::Type append(const T &str)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:496
rtl_string_new_WithLength
SAL_DLLPUBLIC void rtl_string_new_WithLength(rtl_String **newStr, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl::OStringBuffer::insert
libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:772
rtl::OStringBuffer::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:761
stringconcat.hxx