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
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  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 >
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 >
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 >
192  : pData(NULL)
193  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
194  {
195  assert(
198  &pData,
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  {
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
301  operator =(T & literal) {
302  assert(
304  sal_Int32 const n
306  if (n >= nCapacity) {
307  ensureCapacity(n + 16); //TODO: check for overflow
308  }
309  std::memcpy(
310  pData->buffer,
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 
343  {
344  rtl_string_release( pData );
345  }
346 
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 
512  {
513  return OString(pData->buffer, pData->length);
514  }
515 
527  {
528  return append( str.getStr(), str.getLength() );
529  }
530 
542  template< typename T >
544  {
545  return append( str, rtl_str_getLength( str ) );
546  }
547 
548  template< typename T >
550  {
551  return append( str, rtl_str_getLength( str ) );
552  }
553 
559  template< typename T >
561  {
562  RTL_STRING_CONST_FUNCTION
563  assert(
565  return append(
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 
642  {
644  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
645  }
646 
661  {
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,
673  append( T* ) SAL_DELETED_FUNCTION;
675 
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 
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 >
827  {
828  return insert( offset, str, rtl_str_getLength( str ) );
829  }
830 
831  template< typename T >
833  {
834  return insert( offset, str, rtl_str_getLength( str ) );
835  }
836 
842  template< typename T >
844  {
845  RTL_STRING_CONST_FUNCTION
846  assert(
848  return insert(
849  offset,
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  {
899  return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
900  }
901 
921  OStringBuffer & insert(sal_Int32 offset, bool b)
922  {
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 
1078  rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1079  {
1080  *pInternalData = &pData;
1081  *pInternalCapacity = &nCapacity;
1082  }
1083 
1084 private:
1088  rtl_String * pData;
1089 
1093  sal_Int32 nCapacity;
1094 };
1095 
1096 #if defined LIBO_INTERNAL_ONLY
1097 template<> 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
1111 namespace rtl
1112 {
1113 typedef rtlunittest::OStringBuffer OStringBuffer;
1114 }
1115 #undef RTL_STRING_CONST_FUNCTION
1116 #endif
1117 
1118 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1119 using ::rtl::OStringBuffer;
1120 #endif
1121 
1122 /* 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:872
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
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:355
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:660
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:943
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
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
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1054
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1077
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
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:686
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
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:435
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:381
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:738
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:921
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:526
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
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:641
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
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:1036
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:396
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:1013
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:342
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
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:412
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:755
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:511
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
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:490
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:549
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
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
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
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:966
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:832
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:803
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
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:171
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:368
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:180
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:602
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:576
Definition: stringutils.hxx:136
Definition: stringutils.hxx:139
Definition: stringutils.hxx:371