LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 6.4 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
230 template< typename T >
231 OStringBuffer( OStringNumber< T >&& n )
232 : OStringBuffer( OString( n ))
233 {}
234 #endif
235
238 OStringBuffer& operator = ( const OStringBuffer& value )
239 {
240 if (this != &value)
241 {
242 rtl_stringbuffer_newFromStringBuffer(&pData,
243 value.nCapacity,
244 value.pData);
245 nCapacity = value.nCapacity;
246 }
247 return *this;
248 }
249
254 OStringBuffer & operator =(OString const & string) {
255 sal_Int32 n = string.getLength();
256 if (n >= nCapacity) {
257 ensureCapacity(n + 16); //TODO: check for overflow
258 }
259 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
260 pData->length = n;
261 return *this;
262 }
263
268 template<typename T>
269 typename
270 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
271 operator =(T & literal) {
272 assert(
273 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
274 sal_Int32 const n
275 = libreoffice_internal::ConstCharArrayDetector<T>::length;
276 if (n >= nCapacity) {
277 ensureCapacity(n + 16); //TODO: check for overflow
278 }
279 std::memcpy(
280 pData->buffer,
281 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
282 n + 1);
283 pData->length = n;
284 return *this;
285 }
286
287 #if defined LIBO_INTERNAL_ONLY
288
289 template<typename T1, typename T2>
290 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
291 sal_Int32 const n = concat.length();
292 if (n >= nCapacity) {
293 ensureCapacity(n + 16); //TODO: check for overflow
294 }
295 *concat.addData(pData->buffer) = 0;
296 pData->length = n;
297 return *this;
298 }
299
301 template<typename T>
302 OStringBuffer & operator =(OStringNumber<T> && n)
303 {
304 return *this = OStringBuffer( std::move ( n ));
305 }
306 #endif
307
311 ~OStringBuffer()
312 {
313 rtl_string_release( pData );
314 }
315
324 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
325 {
326 OString aRet( pData );
327 rtl_string_new(&pData);
328 nCapacity = 0;
329 return aRet;
330 }
331
337 sal_Int32 getLength() const
338 {
339 return pData->length;
340 }
341
350 bool isEmpty() const
351 {
352 return pData->length == 0;
353 }
354
365 sal_Int32 getCapacity() const
366 {
367 return nCapacity;
368 }
369
381 void ensureCapacity(sal_Int32 minimumCapacity)
382 {
383 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
384 }
385
404 void setLength(sal_Int32 newLength)
405 {
406 assert(newLength >= 0);
407 // Avoid modifications if pData points to const empty string:
408 if( newLength != pData->length )
409 {
410 if( newLength > nCapacity )
411 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
412 else
413 pData->buffer[newLength] = '\0';
414 pData->length = newLength;
415 }
416 }
417
431 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
432 sal_Char charAt( sal_Int32 index )
433 {
434 assert(index >= 0 && index < pData->length);
435 return pData->buffer[ index ];
436 }
437
448 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
449 OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
450 {
451 assert(index >= 0 && index < pData->length);
452 pData->buffer[ index ] = ch;
453 return *this;
454 }
455
459 const sal_Char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
460
470 sal_Char & operator [](sal_Int32 index)
471 {
472 assert(index >= 0 && index < pData->length);
473 return pData->buffer[index];
474 }
475
480 const OString toString() const
481 {
482 return OString(pData->buffer, pData->length);
483 }
484
495 OStringBuffer & append(const OString &str)
496 {
497 return append( str.getStr(), str.getLength() );
498 }
499
511 template< typename T >
512 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
513 {
514 return append( str, rtl_str_getLength( str ) );
515 }
516
517 template< typename T >
518 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
519 {
520 return append( str, rtl_str_getLength( str ) );
521 }
522
528 template< typename T >
529 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
530 {
531 RTL_STRING_CONST_FUNCTION
532 assert(
533 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
534 return append(
535 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
536 libreoffice_internal::ConstCharArrayDetector<T>::length);
537 }
538
552 OStringBuffer & append( const sal_Char * str, sal_Int32 len)
553 {
554 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
555 rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
556 return *this;
557 }
558
559 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
560
564 template< typename T1, typename T2 >
565 OStringBuffer& append( OStringConcat< T1, T2 >&& c )
566 {
567 sal_Int32 l = c.length();
568 if( l == 0 )
569 return *this;
570 l += pData->length;
571 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
572 char* end = c.addData( pData->buffer + pData->length );
573 *end = '\0';
574 pData->length = l;
575 return *this;
576 }
577
582 template< typename T >
583 OStringBuffer& append( OStringNumber< T >&& c )
584 {
585 return append( c.buf, c.length );
586 }
587
588 #endif
589
601 OStringBuffer & append(sal_Bool b)
602 {
603 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
604 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
605 }
606
620 OStringBuffer & append(bool b)
621 {
622 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
623 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
624 }
625
627 // Pointer can be automatically converted to bool, which is unwanted here.
628 // Explicitly delete all pointer append() overloads to prevent this
629 // (except for char* overload, which is handled elsewhere).
630 template< typename T >
631 typename libreoffice_internal::Enable< void,
632 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
633 append( T* ) SAL_DELETED_FUNCTION;
635
646 OStringBuffer & append(sal_Char c)
647 {
648 return append( &c, 1 );
649 }
650
663 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
664 {
665 sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
666 return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
667 }
668
681 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
682 {
683 sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
684 return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
685 }
686
698 OStringBuffer & append(float f)
699 {
700 sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
701 return append( sz, rtl_str_valueOfFloat( sz, f ) );
702 }
703
715 OStringBuffer & append(double d)
716 {
717 sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
718 return append( sz, rtl_str_valueOfDouble( sz, d ) );
719 }
720
736 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
737 sal_Int32 n = getLength();
738 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
739 return pData->buffer + n;
740 }
741
757 OStringBuffer & insert(sal_Int32 offset, const OString & str)
758 {
759 return insert( offset, str.getStr(), str.getLength() );
760 }
761
779 template< typename T >
780 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
781 {
782 return insert( offset, str, rtl_str_getLength( str ) );
783 }
784
785 template< typename T >
786 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
787 {
788 return insert( offset, str, rtl_str_getLength( str ) );
789 }
790
796 template< typename T >
797 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
798 {
799 RTL_STRING_CONST_FUNCTION
800 assert(
801 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
802 return insert(
803 offset,
804 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
805 libreoffice_internal::ConstCharArrayDetector<T>::length);
806 }
807
826 OStringBuffer & insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len)
827 {
828 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
829 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
830 return *this;
831 }
832
850 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
851 {
852 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
853 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
854 }
855
875 OStringBuffer & insert(sal_Int32 offset, bool b)
876 {
877 sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
878 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
879 }
880
897 OStringBuffer & insert(sal_Int32 offset, sal_Char c)
898 {
899 return insert( offset, &c, 1 );
900 }
901
920 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
921 {
922 sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
923 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
924 }
925
944 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
945 {
946 sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
947 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
948 }
949
967 OStringBuffer insert(sal_Int32 offset, float f)
968 {
969 sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
970 return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
971 }
972
990 OStringBuffer & insert(sal_Int32 offset, double d)
991 {
992 sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
993 return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
994 }
995
1008 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1009 {
1010 rtl_stringbuffer_remove( &pData, start, len );
1011 return *this;
1012 }
1013
1031 void accessInternals(
1032 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1033 {
1034 *pInternalData = &pData;
1035 *pInternalCapacity = &nCapacity;
1036 }
1037
1038 #if defined LIBO_INTERNAL_ONLY
1039 explicit operator OStringView() const
1040 {
1041 return OStringView(getStr(), getLength());
1042 }
1043 #endif
1044
1045 private:
1049 rtl_String * pData;
1050
1054 sal_Int32 nCapacity;
1055 };
1056
1057 }
1058
1059 #ifdef RTL_STRING_UNITTEST
1060 namespace rtl
1061 {
1062 typedef rtlunittest::OStringBuffer OStringBuffer;
1063 }
1064 #undef RTL_STRING_CONST_FUNCTION
1065 #endif
1066
1067 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1068 using ::rtl::OStringBuffer;
1069 #endif
1070
1071 #endif // INCLUDED_RTL_STRBUF_HXX
1072
1073
1074 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:757
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::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1008
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:433
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:920
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:875
rtl::OStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:404
RTL_STR_MAX_VALUEOFINT32
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:601
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:897
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
rtl::OStringBuffer::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:459
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_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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_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
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:495
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:552
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:311
rtl::OStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:65
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:620
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::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:736
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
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:826
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
rtl::OStringBuffer::toString
const OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:480
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::insert
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:967
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_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:130
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
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
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::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:184
rtl::OStringBuffer::append
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:518
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:780
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:365
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_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
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:663
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:141
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:337
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:381
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
rtl::OString::getStr
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:459
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
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:797
rtl::OStringBuffer::append
OStringBuffer & append(sal_Char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:646
rtl::libreoffice_internal::Enable
Definition: stringutils.hxx:337
rtl::OStringBuffer::OStringBuffer
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:72
rtl
Definition: bootstrap.hxx:29
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.
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::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:786
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:97
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:698
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::insert
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:990
string.hxx
rtl::OStringBuffer::operator []
sal_Char & operator [](sal_Int32 index)
Access to individual characters.
Definition: strbuf.hxx:470
config.h
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:156
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:529
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.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:850
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:132
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.
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
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:120
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:512
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:944
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_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::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:715
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:350
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_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
stringutils.hxx
rtl::OStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:324
strbuf.h
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::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:681
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.
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:1031