AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
4 #pragma once
5 
6 #include "sal/config.h"
7 
8 #include <cassert>
9 #include <cstring>
10 #include <limits>
11 
12 #include "rtl/strbuf.h"
13 #include "rtl/string.hxx"
14 #include "rtl/stringutils.hxx"
15 
16 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
17 #include "rtl/stringconcat.hxx"
18 #include <string_view>
19 #include <type_traits>
20 #endif
21 
22 #ifdef RTL_STRING_UNITTEST
23 extern bool rtl_string_unittest_const_literal;
24 extern bool rtl_string_unittest_const_literal_function;
25 #endif
26 
27 // The unittest uses slightly different code to help check that the proper
28 // calls are made. The class is put into a different namespace to make
29 // sure the compiler generates a different (if generating also non-inline)
30 // copy of the function and does not merge them together. The class
31 // is "brought" into the proper rtl namespace by a typedef below.
32 #ifdef RTL_STRING_UNITTEST
33 #define rtl rtlunittest
34 #endif
35 
36 namespace rtl
37 {
38 
40 #ifdef RTL_STRING_UNITTEST
41 #undef rtl
42 // helper macro to make functions appear more readable
43 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
44 #else
45 #define RTL_STRING_CONST_FUNCTION
46 #endif
47 
52 {
53 public:
59  : pData(NULL)
60  , nCapacity( 16 )
61  {
62  rtl_string_new_WithLength( &pData, nCapacity );
63  }
64 
71  OStringBuffer( const OStringBuffer & value )
72  : pData(NULL)
73  , nCapacity( value.nCapacity )
74  {
76  }
77 
84  explicit OStringBuffer(sal_Int32 length)
85  : pData(NULL)
86  , nCapacity( length )
87  {
88  rtl_string_new_WithLength( &pData, length );
89  }
90 #if defined LIBO_INTERNAL_ONLY
91  template<typename T>
92  explicit OStringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
93  : OStringBuffer(static_cast<sal_Int32>(length))
94  {
95  assert(
96  length >= 0
97  && static_cast<std::make_unsigned_t<T>>(length)
98  <= static_cast<std::make_unsigned_t<sal_Int32>>(
99  std::numeric_limits<sal_Int32>::max()));
100  }
101  // avoid (obvious) bugs
102  explicit OStringBuffer(bool) = delete;
103  explicit OStringBuffer(char) = delete;
104  explicit OStringBuffer(wchar_t) = delete;
105 #if defined __cpp_char8_t
106  explicit OStringBuffer(char8_t) = delete;
107 #endif
108  explicit OStringBuffer(char16_t) = delete;
109  explicit OStringBuffer(char32_t) = delete;
110 #endif
111 
122 #if defined LIBO_INTERNAL_ONLY
123  OStringBuffer(std::string_view sv)
124  : pData(nullptr)
125  , nCapacity( sv.length() + 16 )
126  {
127  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
128  throw std::bad_alloc();
129  }
130  rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
131  }
132 #else
133  OStringBuffer(const OString& value)
134  : pData(NULL)
135  , nCapacity( value.getLength() + 16 )
136  {
137  rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
138  }
139 #endif
140 
145  template< typename T >
147  : pData(NULL)
148  {
149  sal_Int32 length = rtl_str_getLength( value );
150  nCapacity = length + 16;
151  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
152  }
153 
154  template< typename T >
156  : pData(NULL)
157  {
158  sal_Int32 length = rtl_str_getLength( value );
159  nCapacity = length + 16;
160  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
161  }
162 
163 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
164  template< typename T >
166  : pData(NULL)
167  {
168  sal_Int32 length = rtl_str_getLength( value );
169  nCapacity = length + 16;
170  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
171  }
172 #endif
173 
185  template< typename T >
186  OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
187  : pData(NULL)
188  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
189  {
190  assert(
193  &pData,
196 #ifdef RTL_STRING_UNITTEST
197  rtl_string_unittest_const_literal = true;
198 #endif
199  }
200 
213  OStringBuffer(const char * value, sal_Int32 length)
214  : pData(NULL)
215  , nCapacity( length + 16 )
216  {
217  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
218  }
219 
220 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
221 
225  template< typename T1, typename T2 >
226  OStringBuffer( OStringConcat< T1, T2 >&& c )
227  {
228  const sal_Int32 l = c.length();
229  nCapacity = l + 16;
230  pData = rtl_string_alloc( nCapacity );
231  char* end = c.addData( pData->buffer );
232  *end = '\0';
233  pData->length = l;
234  }
235 
240  template< typename T, std::size_t N >
241  OStringBuffer( StringNumberBase< char, T, N >&& n )
242  : OStringBuffer( n.buf, n.length)
243  {}
244 #endif
245 
246 #if defined LIBO_INTERNAL_ONLY
247  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
248 #endif
249 
252  OStringBuffer& operator = ( const OStringBuffer& value )
253  {
254  if (this != &value)
255  {
257  value.nCapacity,
258  value.pData);
259  nCapacity = value.nCapacity;
260  }
261  return *this;
262  }
263 
268 #if defined LIBO_INTERNAL_ONLY
269  OStringBuffer & operator =(std::string_view string) {
270  sal_Int32 n = string.length();
271  if (n >= nCapacity) {
272  ensureCapacity(n + 16); //TODO: check for overflow
273  }
274  std::memcpy(pData->buffer, string.data(), n);
275  pData->buffer[n] = '\0';
276  pData->length = n;
277  return *this;
278  }
279 #else
280  OStringBuffer & operator =(OString const & string) {
281  sal_Int32 n = string.getLength();
282  if (n >= nCapacity) {
283  ensureCapacity(n + 16); //TODO: check for overflow
284  }
285  std::memcpy(pData->buffer, string.pData->buffer, n + 1);
286  pData->length = n;
287  return *this;
288  }
289 #endif
290 
295  template<typename T>
296  typename
298  operator =(T & literal) {
299  assert(
301  sal_Int32 const n
303  if (n >= nCapacity) {
304  ensureCapacity(n + 16); //TODO: check for overflow
305  }
306  std::memcpy(
307  pData->buffer,
309  n + 1);
310  pData->length = n;
311  return *this;
312  }
313 
314 #if defined LIBO_INTERNAL_ONLY
315 
316  template<typename T1, typename T2>
317  OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
318  sal_Int32 const n = concat.length();
319  if (n >= nCapacity) {
320  ensureCapacity(n + 16); //TODO: check for overflow
321  }
322  *concat.addData(pData->buffer) = 0;
323  pData->length = n;
324  return *this;
325  }
326 
328  template<typename T, std::size_t N>
329  OStringBuffer & operator =(StringNumberBase<char, T, N> && n)
330  {
331  *this = OStringBuffer( std::move ( n ));
332  return *this;
333  }
334 #endif
335 
340  {
341  rtl_string_release( pData );
342  }
343 
353  {
354  OString aRet( pData );
355  rtl_string_new(&pData);
356  nCapacity = 0;
357  return aRet;
358  }
359 
365  sal_Int32 getLength() const
366  {
367  return pData->length;
368  }
369 
378  bool isEmpty() const
379  {
380  return pData->length == 0;
381  }
382 
393  sal_Int32 getCapacity() const
394  {
395  return nCapacity;
396  }
397 
409  void ensureCapacity(sal_Int32 minimumCapacity)
410  {
411  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
412  }
413 
432  void setLength(sal_Int32 newLength)
433  {
434  assert(newLength >= 0);
435  // Avoid modifications if pData points to const empty string:
436  if( newLength != pData->length )
437  {
438  if( newLength > nCapacity )
439  rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
440  else
441  pData->buffer[newLength] = '\0';
442  pData->length = newLength;
443  }
444  }
445 
459  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
460  char charAt( sal_Int32 index )
461  {
462  assert(index >= 0 && index < pData->length);
463  return pData->buffer[ index ];
464  }
465 
476  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
477  OStringBuffer & setCharAt(sal_Int32 index, char ch)
478  {
479  assert(index >= 0 && index < pData->length);
480  pData->buffer[ index ] = ch;
481  return *this;
482  }
483 
487  const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
488 
498  char & operator [](sal_Int32 index)
499  {
500  assert(index >= 0 && index < pData->length);
501  return pData->buffer[index];
502  }
503 
509  {
510  return OString(pData->buffer, pData->length);
511  }
512 
513 #if !defined LIBO_INTERNAL_ONLY
514 
525  {
526  return append( str.getStr(), str.getLength() );
527  }
528 #endif
529 
541  template< typename T >
543  {
544  return append( str, rtl_str_getLength( str ) );
545  }
546 
547  template< typename T >
549  {
550  return append( str, rtl_str_getLength( str ) );
551  }
552 
558  template< typename T >
560  {
561  RTL_STRING_CONST_FUNCTION
562  assert(
564  return append(
567  }
568 
582  OStringBuffer & append( const char * str, sal_Int32 len)
583  {
584  assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
585  rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
586  return *this;
587  }
588 
589 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
590 
594  template< typename T1, typename T2 >
595  OStringBuffer& append( OStringConcat< T1, T2 >&& c )
596  {
597  sal_Int32 l = c.length();
598  if( l == 0 )
599  return *this;
600  l += pData->length;
601  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
602  char* end = c.addData( pData->buffer + pData->length );
603  *end = '\0';
604  pData->length = l;
605  return *this;
606  }
607 
612  template< typename T, std::size_t N >
613  OStringBuffer& append( StringNumberBase< char, T, N >&& c )
614  {
615  return append( c.buf, c.length );
616  }
617 
622  OStringBuffer& append( std::string_view s )
623  {
624  return append( s.data(), s.size() );
625  }
626 
627 #endif
628 
641  {
643  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
644  }
645 
660  {
662  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
663  }
664 
666  // Pointer can be automatically converted to bool, which is unwanted here.
667  // Explicitly delete all pointer append() overloads to prevent this
668  // (except for char* overload, which is handled elsewhere).
669  template< typename T >
670  typename libreoffice_internal::Enable< void,
672  append( T* ) SAL_DELETED_FUNCTION;
674 
685  OStringBuffer & append(char c)
686  {
687  return append( &c, 1 );
688  }
689 
702  OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
703  {
704  char sz[RTL_STR_MAX_VALUEOFINT32];
705  return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
706  }
707 
720  OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
721  {
722  char sz[RTL_STR_MAX_VALUEOFINT64];
723  return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
724  }
725 
738  {
739  char sz[RTL_STR_MAX_VALUEOFFLOAT];
740  return append( sz, rtl_str_valueOfFloat( sz, f ) );
741  }
742 
754  OStringBuffer & append(double d)
755  {
756  char sz[RTL_STR_MAX_VALUEOFDOUBLE];
757  return append( sz, rtl_str_valueOfDouble( sz, d ) );
758  }
759 
775  char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
776  sal_Int32 n = getLength();
777  rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
778  return pData->buffer + n;
779  }
780 
796 #if defined LIBO_INTERNAL_ONLY
797  OStringBuffer & insert(sal_Int32 offset, std::string_view str)
798  {
799  return insert( offset, str.data(), str.length() );
800  }
801 #else
802  OStringBuffer & insert(sal_Int32 offset, const OString & str)
803  {
804  return insert( offset, str.getStr(), str.getLength() );
805  }
806 #endif
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  char * operator()(char * buffer, OStringBuffer const & s) const SAL_RETURNS_NONNULL
1101  { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1102 };
1103 #endif
1104 
1105 }
1106 
1107 #ifdef RTL_STRING_UNITTEST
1108 namespace rtl
1109 {
1110 typedef rtlunittest::OStringBuffer OStringBuffer;
1111 }
1112 #undef RTL_STRING_CONST_FUNCTION
1113 #endif
1114 
1115 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1116 using ::rtl::OStringBuffer;
1117 #endif
1118 
1119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:611
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:943
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:378
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:640
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:921
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:1013
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:365
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:548
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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
unsigned char sal_Bool
Definition: types.h:18
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:51
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:832
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:409
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:1036
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:737
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:634
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:432
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.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:644
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
Definition: stringutils.hxx:374
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.
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:213
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.
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
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:618
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:196
rtl_stringbuffer_newFromStr_WithLength & pData
Definition: strbuf.hxx:151
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:508
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
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:352
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:695
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:775
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...
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED(&quot;Don&#39;t use, it&#39;s evil.&quot;) void doit(int nPara);.
Definition: types.h:454
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:569
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:524
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OStringBuffer & append(const char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:582
Definition: stringutils.hxx:142
OStringBuffer(sal_Int32 length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:84
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:264
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:676
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:754
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:542
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:487
nCapacity
Definition: strbuf.hxx:150
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:58
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
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
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:559
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:339
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:659
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.
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:720
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:393
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:133
Definition: stringutils.hxx:140
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:802
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.
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:71
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
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.
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 & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition: strbuf.hxx:702
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
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.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358