LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 7.2 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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#pragma once
25
26#include "sal/config.h"
27
28#include <cassert>
29#include <cstring>
30
31#include "rtl/strbuf.h"
32#include "rtl/string.hxx"
33#include "rtl/stringutils.hxx"
34
35#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
36#include "rtl/stringconcat.hxx"
37#include <string_view>
38#endif
39
40#ifdef RTL_STRING_UNITTEST
41extern bool rtl_string_unittest_const_literal;
42extern bool rtl_string_unittest_const_literal_function;
43#endif
44
45// The unittest uses slightly different code to help check that the proper
46// calls are made. The class is put into a different namespace to make
47// sure the compiler generates a different (if generating also non-inline)
48// copy of the function and does not merge them together. The class
49// is "brought" into the proper rtl namespace by a typedef below.
50#ifdef RTL_STRING_UNITTEST
51#define rtl rtlunittest
52#endif
53
54namespace rtl
55{
56
58#ifdef RTL_STRING_UNITTEST
59#undef rtl
60// helper macro to make functions appear more readable
61#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
62#else
63#define RTL_STRING_CONST_FUNCTION
64#endif
66
69 class SAL_WARN_UNUSED OStringBuffer
70{
71public:
76 OStringBuffer()
77 : pData(NULL)
78 , nCapacity( 16 )
79 {
80 rtl_string_new_WithLength( &pData, nCapacity );
81 }
82
89 OStringBuffer( const OStringBuffer & value )
90 : pData(NULL)
91 , nCapacity( value.nCapacity )
92 {
93 rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
94 }
95
102 explicit OStringBuffer(int length)
103 : pData(NULL)
104 , nCapacity( length )
105 {
106 rtl_string_new_WithLength( &pData, length );
107 }
108#if __cplusplus >= 201103L
109 explicit OStringBuffer(unsigned int length)
110 : OStringBuffer(static_cast<int>(length))
111 {
112 }
113#if SAL_TYPES_SIZEOFLONG == 4
114 // additional overloads for sal_Int32 sal_uInt32
115 explicit OStringBuffer(long length)
116 : OStringBuffer(static_cast<int>(length))
117 {
118 }
119 explicit OStringBuffer(unsigned long length)
120 : OStringBuffer(static_cast<int>(length))
121 {
122 }
123#endif
124 // avoid obvious bugs
125 explicit OStringBuffer(char) = delete;
126 explicit OStringBuffer(sal_Unicode) = delete;
127#endif
128
139#if defined LIBO_INTERNAL_ONLY
140 explicit OStringBuffer(std::string_view sv)
141 : pData(nullptr)
142 , nCapacity( sv.length() + 16 )
143 {
144 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
145 throw std::bad_alloc();
146 }
147 rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
148 }
149#endif
150 OStringBuffer(const OString& value)
151 : pData(NULL)
152 , nCapacity( value.getLength() + 16 )
153 {
154 rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
155 }
156
161 template< typename T >
162 OStringBuffer( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
163 : pData(NULL)
164 {
165 sal_Int32 length = rtl_str_getLength( value );
166 nCapacity = length + 16;
167 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
168 }
169
170 template< typename T >
171 OStringBuffer( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
172 : pData(NULL)
173 {
174 sal_Int32 length = rtl_str_getLength( value );
175 nCapacity = length + 16;
176 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
177 }
178
190 template< typename T >
191 OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
192 : pData(NULL)
193 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
194 {
195 assert(
196 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
197 rtl_string_newFromLiteral(
198 &pData,
199 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
200 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
201#ifdef RTL_STRING_UNITTEST
202 rtl_string_unittest_const_literal = true;
203#endif
204 }
205
218 OStringBuffer(const char * value, sal_Int32 length)
219 : pData(NULL)
220 , nCapacity( length + 16 )
221 {
222 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
223 }
224
225#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
230 template< typename T1, typename T2 >
231 OStringBuffer( OStringConcat< T1, T2 >&& c )
232 {
233 const sal_Int32 l = c.length();
234 nCapacity = l + 16;
235 pData = rtl_string_alloc( nCapacity );
236 char* end = c.addData( pData->buffer );
237 *end = '\0';
238 pData->length = l;
239 }
240
245 template< typename T >
246 OStringBuffer( OStringNumber< T >&& n )
247 : OStringBuffer( OString( n ))
248 {}
249#endif
250
251#if defined LIBO_INTERNAL_ONLY
252 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
253#endif
254
257 OStringBuffer& operator = ( const OStringBuffer& value )
258 {
259 if (this != &value)
260 {
261 rtl_stringbuffer_newFromStringBuffer(&pData,
262 value.nCapacity,
263 value.pData);
264 nCapacity = value.nCapacity;
265 }
266 return *this;
267 }
268
273#if defined LIBO_INTERNAL_ONLY
274 OStringBuffer & operator =(std::string_view string) {
275 sal_Int32 n = string.length();
276 if (n >= nCapacity) {
277 ensureCapacity(n + 16); //TODO: check for overflow
278 }
279 std::memcpy(pData->buffer, string.data(), n + 1);
280 pData->length = n;
281 return *this;
282 }
283#endif
284 OStringBuffer & operator =(OString const & string) {
285 sal_Int32 n = string.getLength();
286 if (n >= nCapacity) {
287 ensureCapacity(n + 16); //TODO: check for overflow
288 }
289 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
290 pData->length = n;
291 return *this;
292 }
293
298 template<typename T>
299 typename
300 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
301 operator =(T & literal) {
302 assert(
303 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
304 sal_Int32 const n
305 = libreoffice_internal::ConstCharArrayDetector<T>::length;
306 if (n >= nCapacity) {
307 ensureCapacity(n + 16); //TODO: check for overflow
308 }
309 std::memcpy(
310 pData->buffer,
311 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
312 n + 1);
313 pData->length = n;
314 return *this;
315 }
316
317#if defined LIBO_INTERNAL_ONLY
319 template<typename T1, typename T2>
320 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
321 sal_Int32 const n = concat.length();
322 if (n >= nCapacity) {
323 ensureCapacity(n + 16); //TODO: check for overflow
324 }
325 *concat.addData(pData->buffer) = 0;
326 pData->length = n;
327 return *this;
328 }
329
331 template<typename T>
332 OStringBuffer & operator =(OStringNumber<T> && n)
333 {
334 *this = OStringBuffer( std::move ( n ));
335 return *this;
336 }
337#endif
338
342 ~OStringBuffer()
343 {
344 rtl_string_release( pData );
345 }
346
355 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
356 {
357 OString aRet( pData );
358 rtl_string_new(&pData);
359 nCapacity = 0;
360 return aRet;
361 }
362
368 sal_Int32 getLength() const
369 {
370 return pData->length;
371 }
372
381 bool isEmpty() const
382 {
383 return pData->length == 0;
384 }
385
396 sal_Int32 getCapacity() const
397 {
398 return nCapacity;
399 }
400
412 void ensureCapacity(sal_Int32 minimumCapacity)
413 {
414 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
415 }
416
435 void setLength(sal_Int32 newLength)
436 {
437 assert(newLength >= 0);
438 // Avoid modifications if pData points to const empty string:
439 if( newLength != pData->length )
440 {
441 if( newLength > nCapacity )
442 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
443 else
444 pData->buffer[newLength] = '\0';
445 pData->length = newLength;
446 }
447 }
448
462 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
463 char charAt( sal_Int32 index )
464 {
465 assert(index >= 0 && index < pData->length);
466 return pData->buffer[ index ];
467 }
468
479 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
480 OStringBuffer & setCharAt(sal_Int32 index, char ch)
481 {
482 assert(index >= 0 && index < pData->length);
483 pData->buffer[ index ] = ch;
484 return *this;
485 }
486
490 const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
491
501 char & operator [](sal_Int32 index)
502 {
503 assert(index >= 0 && index < pData->length);
504 return pData->buffer[index];
505 }
506
511 OString toString() const
512 {
513 return OString(pData->buffer, pData->length);
514 }
515
526 OStringBuffer & append(const OString &str)
527 {
528 return append( str.getStr(), str.getLength() );
529 }
530
542 template< typename T >
543 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
544 {
545 return append( str, rtl_str_getLength( str ) );
546 }
547
548 template< typename T >
549 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
550 {
551 return append( str, rtl_str_getLength( str ) );
552 }
553
559 template< typename T >
560 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
561 {
562 RTL_STRING_CONST_FUNCTION
563 assert(
564 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
565 return append(
566 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
567 libreoffice_internal::ConstCharArrayDetector<T>::length);
568 }
569
583 OStringBuffer & append( const char * str, sal_Int32 len)
584 {
585 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
586 rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
587 return *this;
588 }
589
590#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
595 template< typename T1, typename T2 >
596 OStringBuffer& append( OStringConcat< T1, T2 >&& c )
597 {
598 sal_Int32 l = c.length();
599 if( l == 0 )
600 return *this;
601 l += pData->length;
602 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
603 char* end = c.addData( pData->buffer + pData->length );
604 *end = '\0';
605 pData->length = l;
606 return *this;
607 }
608
613 template< typename T >
614 OStringBuffer& append( OStringNumber< T >&& c )
615 {
616 return append( c.buf, c.length );
617 }
618
623 OStringBuffer& append( std::string_view s )
624 {
625 return append( s.data(), s.size() );
626 }
627
628#endif
629
641 OStringBuffer & append(sal_Bool b)
642 {
643 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
644 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
645 }
646
660 OStringBuffer & append(bool b)
661 {
662 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
663 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
664 }
665
667 // Pointer can be automatically converted to bool, which is unwanted here.
668 // Explicitly delete all pointer append() overloads to prevent this
669 // (except for char* overload, which is handled elsewhere).
670 template< typename T >
671 typename libreoffice_internal::Enable< void,
672 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
673 append( T* ) SAL_DELETED_FUNCTION;
675
686 OStringBuffer & append(char c)
687 {
688 return append( &c, 1 );
689 }
690
703 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
704 {
705 char sz[RTL_STR_MAX_VALUEOFINT32];
706 return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
707 }
708
721 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
722 {
723 char sz[RTL_STR_MAX_VALUEOFINT64];
724 return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
725 }
726
738 OStringBuffer & append(float f)
739 {
740 char sz[RTL_STR_MAX_VALUEOFFLOAT];
741 return append( sz, rtl_str_valueOfFloat( sz, f ) );
742 }
743
755 OStringBuffer & append(double d)
756 {
757 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
758 return append( sz, rtl_str_valueOfDouble( sz, d ) );
759 }
760
776 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
777 sal_Int32 n = getLength();
778 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
779 return pData->buffer + n;
780 }
781
797#if defined LIBO_INTERNAL_ONLY
798 OStringBuffer & insert(sal_Int32 offset, std::string_view str)
799 {
800 return insert( offset, str.data(), str.length() );
801 }
802#endif
803 OStringBuffer & insert(sal_Int32 offset, const OString & str)
804 {
805 return insert( offset, str.getStr(), str.getLength() );
806 }
807
825 template< typename T >
826 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
827 {
828 return insert( offset, str, rtl_str_getLength( str ) );
829 }
830
831 template< typename T >
832 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
833 {
834 return insert( offset, str, rtl_str_getLength( str ) );
835 }
836
842 template< typename T >
843 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
844 {
845 RTL_STRING_CONST_FUNCTION
846 assert(
847 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
848 return insert(
849 offset,
850 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
851 libreoffice_internal::ConstCharArrayDetector<T>::length);
852 }
853
872 OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
873 {
874 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
875 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
876 return *this;
877 }
878
896 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
897 {
898 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
899 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
900 }
901
921 OStringBuffer & insert(sal_Int32 offset, bool b)
922 {
923 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
924 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
925 }
926
943 OStringBuffer & insert(sal_Int32 offset, char c)
944 {
945 return insert( offset, &c, 1 );
946 }
947
966 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
967 {
968 char sz[RTL_STR_MAX_VALUEOFINT32];
969 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
970 }
971
990 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
991 {
992 char sz[RTL_STR_MAX_VALUEOFINT64];
993 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
994 }
995
1013 OStringBuffer insert(sal_Int32 offset, float f)
1014 {
1015 char sz[RTL_STR_MAX_VALUEOFFLOAT];
1016 return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
1017 }
1018
1036 OStringBuffer & insert(sal_Int32 offset, double d)
1037 {
1038 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
1039 return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
1040 }
1041
1054 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1055 {
1056 rtl_stringbuffer_remove( &pData, start, len );
1057 return *this;
1058 }
1059
1077 void accessInternals(
1078 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1079 {
1080 *pInternalData = &pData;
1081 *pInternalCapacity = &nCapacity;
1082 }
1083
1084private:
1088 rtl_String * pData;
1089
1093 sal_Int32 nCapacity;
1094};
1095
1096#if defined LIBO_INTERNAL_ONLY
1097template<> struct ToStringHelper<OStringBuffer> {
1098 static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1099
1100 static char * addData(char * buffer, OStringBuffer const & s) SAL_RETURNS_NONNULL
1101 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1102
1103 static constexpr bool allowOStringConcat = true;
1104 static constexpr bool allowOUStringConcat = false;
1105};
1106#endif
1107
1108}
1109
1110#ifdef RTL_STRING_UNITTEST
1111namespace rtl
1112{
1113typedef rtlunittest::OStringBuffer OStringBuffer;
1114}
1115#undef RTL_STRING_CONST_FUNCTION
1116#endif
1117
1118#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1119using ::rtl::OStringBuffer;
1120#endif
1121
1122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.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_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_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:715
RTL_STR_MAX_VALUEOFINT32
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:631
rtl_str_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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_str_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_str_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
rtl_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl_str_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl_string_newFromLiteral
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:696
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_str_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl_str_getLength
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
stringutils.hxx
string.hxx
strbuf.h
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_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_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_stringbuffer_insert
SAL_DLLPUBLIC void rtl_stringbuffer_insert(rtl_String **This, sal_Int32 *capacity, sal_Int32 offset, const char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
rtl_stringbuffer_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_stringbuffer_newFromStr_WithLength(rtl_String **newStr, const char *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
rtl
Definition: bootstrap.hxx:34
rtl::OStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:70
rtl::OStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:355
rtl::OStringBuffer::OStringBuffer
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:76
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:703
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:966
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:1077
rtl::OStringBuffer::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:832
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:162
rtl::OStringBuffer::append
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:686
rtl::OStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:435
rtl::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:755
rtl::OStringBuffer::append
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:526
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:150
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:1036
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:381
rtl::OStringBuffer::append
OStringBuffer & append(const char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:583
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:921
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:843
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:191
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:738
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:660
rtl::OStringBuffer::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:490
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:396
rtl::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1054
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:1013
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:943
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:342
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:412
rtl::OStringBuffer::toString
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:511
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:803
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:560
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:102
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:543
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:872
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:721
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:89
rtl::OStringBuffer::append
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:549
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:641
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:776
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const 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:218
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:171
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:896
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:826
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:368
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:990
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:180
rtl::OString::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:602
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:576
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:136
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:139
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.hxx:163
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:191
rtl::libreoffice_internal::Enable
Definition: stringutils.hxx:371