LibreOffice
LibreOffice 7.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 /*
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
41 extern bool rtl_string_unittest_const_literal;
42 extern 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 
54 namespace 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 
70 {
71 public:
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  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 #else
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 #endif
157 
162  template< typename T >
164  : pData(NULL)
165  {
166  sal_Int32 length = rtl_str_getLength( value );
167  nCapacity = length + 16;
168  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
169  }
170 
171  template< typename T >
173  : pData(NULL)
174  {
175  sal_Int32 length = rtl_str_getLength( value );
176  nCapacity = length + 16;
177  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
178  }
179 
191  template< typename T >
193  : pData(NULL)
194  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
195  {
196  assert(
199  &pData,
202 #ifdef RTL_STRING_UNITTEST
203  rtl_string_unittest_const_literal = true;
204 #endif
205  }
206 
219  OStringBuffer(const char * value, sal_Int32 length)
220  : pData(NULL)
221  , nCapacity( length + 16 )
222  {
223  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
224  }
225 
226 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
231  template< typename T1, typename T2 >
232  OStringBuffer( OStringConcat< T1, T2 >&& c )
233  {
234  const sal_Int32 l = c.length();
235  nCapacity = l + 16;
236  pData = rtl_string_alloc( nCapacity );
237  char* end = c.addData( pData->buffer );
238  *end = '\0';
239  pData->length = l;
240  }
241 
246  template< typename T >
247  OStringBuffer( OStringNumber< T >&& n )
248  : OStringBuffer( OString( n ))
249  {}
250 #endif
251 
252 #if defined LIBO_INTERNAL_ONLY
253  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
254 #endif
255 
258  OStringBuffer& operator = ( const OStringBuffer& value )
259  {
260  if (this != &value)
261  {
263  value.nCapacity,
264  value.pData);
265  nCapacity = value.nCapacity;
266  }
267  return *this;
268  }
269 
274 #if defined LIBO_INTERNAL_ONLY
275  OStringBuffer & operator =(std::string_view string) {
276  sal_Int32 n = string.length();
277  if (n >= nCapacity) {
278  ensureCapacity(n + 16); //TODO: check for overflow
279  }
280  std::memcpy(pData->buffer, string.data(), n + 1);
281  pData->length = n;
282  return *this;
283  }
284 #else
285  OStringBuffer & operator =(OString const & string) {
286  sal_Int32 n = string.getLength();
287  if (n >= nCapacity) {
288  ensureCapacity(n + 16); //TODO: check for overflow
289  }
290  std::memcpy(pData->buffer, string.pData->buffer, n + 1);
291  pData->length = n;
292  return *this;
293  }
294 #endif
295 
300  template<typename T>
301  typename
303  operator =(T & literal) {
304  assert(
306  sal_Int32 const n
308  if (n >= nCapacity) {
309  ensureCapacity(n + 16); //TODO: check for overflow
310  }
311  std::memcpy(
312  pData->buffer,
314  n + 1);
315  pData->length = n;
316  return *this;
317  }
318 
319 #if defined LIBO_INTERNAL_ONLY
321  template<typename T1, typename T2>
322  OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
323  sal_Int32 const n = concat.length();
324  if (n >= nCapacity) {
325  ensureCapacity(n + 16); //TODO: check for overflow
326  }
327  *concat.addData(pData->buffer) = 0;
328  pData->length = n;
329  return *this;
330  }
331 
333  template<typename T>
334  OStringBuffer & operator =(OStringNumber<T> && n)
335  {
336  *this = OStringBuffer( std::move ( n ));
337  return *this;
338  }
339 #endif
340 
345  {
346  rtl_string_release( pData );
347  }
348 
358  {
359  OString aRet( pData );
360  rtl_string_new(&pData);
361  nCapacity = 0;
362  return aRet;
363  }
364 
370  sal_Int32 getLength() const
371  {
372  return pData->length;
373  }
374 
383  bool isEmpty() const
384  {
385  return pData->length == 0;
386  }
387 
398  sal_Int32 getCapacity() const
399  {
400  return nCapacity;
401  }
402 
414  void ensureCapacity(sal_Int32 minimumCapacity)
415  {
416  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
417  }
418 
437  void setLength(sal_Int32 newLength)
438  {
439  assert(newLength >= 0);
440  // Avoid modifications if pData points to const empty string:
441  if( newLength != pData->length )
442  {
443  if( newLength > nCapacity )
444  rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
445  else
446  pData->buffer[newLength] = '\0';
447  pData->length = newLength;
448  }
449  }
450 
464  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
465  char charAt( sal_Int32 index )
466  {
467  assert(index >= 0 && index < pData->length);
468  return pData->buffer[ index ];
469  }
470 
481  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
482  OStringBuffer & setCharAt(sal_Int32 index, char ch)
483  {
484  assert(index >= 0 && index < pData->length);
485  pData->buffer[ index ] = ch;
486  return *this;
487  }
488 
492  const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
493 
503  char & operator [](sal_Int32 index)
504  {
505  assert(index >= 0 && index < pData->length);
506  return pData->buffer[index];
507  }
508 
514  {
515  return OString(pData->buffer, pData->length);
516  }
517 
518 #if !defined LIBO_INTERNAL_ONLY
530  {
531  return append( str.getStr(), str.getLength() );
532  }
533 #endif
534 
546  template< typename T >
548  {
549  return append( str, rtl_str_getLength( str ) );
550  }
551 
552  template< typename T >
554  {
555  return append( str, rtl_str_getLength( str ) );
556  }
557 
563  template< typename T >
565  {
566  RTL_STRING_CONST_FUNCTION
567  assert(
569  return append(
572  }
573 
587  OStringBuffer & append( const char * str, sal_Int32 len)
588  {
589  assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
590  rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
591  return *this;
592  }
593 
594 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
599  template< typename T1, typename T2 >
600  OStringBuffer& append( OStringConcat< T1, T2 >&& c )
601  {
602  sal_Int32 l = c.length();
603  if( l == 0 )
604  return *this;
605  l += pData->length;
606  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
607  char* end = c.addData( pData->buffer + pData->length );
608  *end = '\0';
609  pData->length = l;
610  return *this;
611  }
612 
617  template< typename T >
618  OStringBuffer& append( OStringNumber< T >&& c )
619  {
620  return append( c.buf, c.length );
621  }
622 
627  OStringBuffer& append( std::string_view s )
628  {
629  return append( s.data(), s.size() );
630  }
631 
632 #endif
633 
646  {
648  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
649  }
650 
665  {
667  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
668  }
669 
671  // Pointer can be automatically converted to bool, which is unwanted here.
672  // Explicitly delete all pointer append() overloads to prevent this
673  // (except for char* overload, which is handled elsewhere).
674  template< typename T >
675  typename libreoffice_internal::Enable< void,
677  append( T* ) SAL_DELETED_FUNCTION;
679 
691  {
692  return append( &c, 1 );
693  }
694 
707  OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
708  {
709  char sz[RTL_STR_MAX_VALUEOFINT32];
710  return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
711  }
712 
725  OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
726  {
727  char sz[RTL_STR_MAX_VALUEOFINT64];
728  return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
729  }
730 
743  {
744  char sz[RTL_STR_MAX_VALUEOFFLOAT];
745  return append( sz, rtl_str_valueOfFloat( sz, f ) );
746  }
747 
759  OStringBuffer & append(double d)
760  {
761  char sz[RTL_STR_MAX_VALUEOFDOUBLE];
762  return append( sz, rtl_str_valueOfDouble( sz, d ) );
763  }
764 
780  char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
781  sal_Int32 n = getLength();
782  rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
783  return pData->buffer + n;
784  }
785 
801 #if defined LIBO_INTERNAL_ONLY
802  OStringBuffer & insert(sal_Int32 offset, std::string_view str)
803  {
804  return insert( offset, str.data(), str.length() );
805  }
806 #else
807  OStringBuffer & insert(sal_Int32 offset, const OString & str)
808  {
809  return insert( offset, str.getStr(), str.getLength() );
810  }
811 #endif
812 
830  template< typename T >
832  {
833  return insert( offset, str, rtl_str_getLength( str ) );
834  }
835 
836  template< typename T >
838  {
839  return insert( offset, str, rtl_str_getLength( str ) );
840  }
841 
847  template< typename T >
849  {
850  RTL_STRING_CONST_FUNCTION
851  assert(
853  return insert(
854  offset,
857  }
858 
877  OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
878  {
879  assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
880  rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
881  return *this;
882  }
883 
901  OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
902  {
904  return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
905  }
906 
926  OStringBuffer & insert(sal_Int32 offset, bool b)
927  {
929  return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
930  }
931 
948  OStringBuffer & insert(sal_Int32 offset, char c)
949  {
950  return insert( offset, &c, 1 );
951  }
952 
971  OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
972  {
973  char sz[RTL_STR_MAX_VALUEOFINT32];
974  return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
975  }
976 
995  OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
996  {
997  char sz[RTL_STR_MAX_VALUEOFINT64];
998  return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
999  }
1000 
1018  OStringBuffer insert(sal_Int32 offset, float f)
1019  {
1020  char sz[RTL_STR_MAX_VALUEOFFLOAT];
1021  return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
1022  }
1023 
1041  OStringBuffer & insert(sal_Int32 offset, double d)
1042  {
1043  char sz[RTL_STR_MAX_VALUEOFDOUBLE];
1044  return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
1045  }
1046 
1059  OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1060  {
1061  rtl_stringbuffer_remove( &pData, start, len );
1062  return *this;
1063  }
1064 
1083  rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1084  {
1085  *pInternalData = &pData;
1086  *pInternalCapacity = &nCapacity;
1087  }
1088 
1089 private:
1093  rtl_String * pData;
1094 
1098  sal_Int32 nCapacity;
1099 };
1100 
1101 #if defined LIBO_INTERNAL_ONLY
1102 template<> struct ToStringHelper<OStringBuffer> {
1103  static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1104 
1105  static char * addData(char * buffer, OStringBuffer const & s) SAL_RETURNS_NONNULL
1106  { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1107 
1108  static constexpr bool allowOStringConcat = true;
1109  static constexpr bool allowOUStringConcat = false;
1110 };
1111 #endif
1112 
1113 }
1114 
1115 #ifdef RTL_STRING_UNITTEST
1116 namespace rtl
1117 {
1118 typedef rtlunittest::OStringBuffer OStringBuffer;
1119 }
1120 #undef RTL_STRING_CONST_FUNCTION
1121 #endif
1122 
1123 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1124 using ::rtl::OStringBuffer;
1125 #endif
1126 
1127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:474
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
unsigned char sal_Bool
Definition: types.h:38
sal_uInt16 sal_Unicode
Definition: types.h:123
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
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_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_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
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.
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.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:715
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:631
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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_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.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:696
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.
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.
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
Definition: bootstrap.hxx:34
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:70
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:877
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:547
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:357
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:76
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:664
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:948
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:564
OStringBuffer & append(const char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:587
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1059
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1082
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:163
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:690
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:707
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:437
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
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:383
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:742
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:926
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:529
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:848
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:645
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:192
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:1041
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:398
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:1018
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:344
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:831
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:414
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:759
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:513
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:901
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
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:492
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:553
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:780
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:995
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:725
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
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:971
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:837
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:807
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:219
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:172
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:370
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:181
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:603
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:577
Definition: stringutils.hxx:136
Definition: stringutils.hxx:139
Definition: stringutils.hxx:371