LibreOffice
LibreOffice 7.5 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 #include <limits>
31 
32 #include "rtl/strbuf.h"
33 #include "rtl/string.hxx"
34 #include "rtl/stringutils.hxx"
35 
36 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
37 #include "rtl/stringconcat.hxx"
38 #include <string_view>
39 #include <type_traits>
40 #endif
41 
42 #ifdef RTL_STRING_UNITTEST
43 extern bool rtl_string_unittest_const_literal;
44 extern bool rtl_string_unittest_const_literal_function;
45 #endif
46 
47 // The unittest uses slightly different code to help check that the proper
48 // calls are made. The class is put into a different namespace to make
49 // sure the compiler generates a different (if generating also non-inline)
50 // copy of the function and does not merge them together. The class
51 // is "brought" into the proper rtl namespace by a typedef below.
52 #ifdef RTL_STRING_UNITTEST
53 #define rtl rtlunittest
54 #endif
55 
56 namespace rtl
57 {
58 
60 #ifdef RTL_STRING_UNITTEST
61 #undef rtl
62 // helper macro to make functions appear more readable
63 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
64 #else
65 #define RTL_STRING_CONST_FUNCTION
66 #endif
67 
72 {
73 public:
79  : pData(NULL)
80  , nCapacity( 16 )
81  {
82  rtl_string_new_WithLength( &pData, nCapacity );
83  }
84 
91  OStringBuffer( const OStringBuffer & value )
92  : pData(NULL)
93  , nCapacity( value.nCapacity )
94  {
95  rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
96  }
97 
104  explicit OStringBuffer(sal_Int32 length)
105  : pData(NULL)
106  , nCapacity( length )
107  {
108  rtl_string_new_WithLength( &pData, length );
109  }
110 #if defined LIBO_INTERNAL_ONLY
111  template<typename T>
112  explicit OStringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
113  : OStringBuffer(static_cast<sal_Int32>(length))
114  {
115  assert(
116  length >= 0
117  && static_cast<std::make_unsigned_t<T>>(length)
118  <= static_cast<std::make_unsigned_t<sal_Int32>>(
119  std::numeric_limits<sal_Int32>::max()));
120  }
121  // avoid (obvious) bugs
122  explicit OStringBuffer(bool) = delete;
123  explicit OStringBuffer(char) = delete;
124  explicit OStringBuffer(wchar_t) = delete;
125 #if defined __cpp_char8_t
126  explicit OStringBuffer(char8_t) = delete;
127 #endif
128  explicit OStringBuffer(char16_t) = delete;
129  explicit OStringBuffer(char32_t) = delete;
130 #endif
131 
142 #if defined LIBO_INTERNAL_ONLY
143  OStringBuffer(std::string_view sv)
144  : pData(nullptr)
145  , nCapacity( sv.length() + 16 )
146  {
147  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
148  throw std::bad_alloc();
149  }
150  rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
151  }
152 #else
153  OStringBuffer(const OString& value)
154  : pData(NULL)
155  , nCapacity( value.getLength() + 16 )
156  {
157  rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
158  }
159 #endif
160 
165  template< typename T >
167  : pData(NULL)
168  {
169  sal_Int32 length = rtl_str_getLength( value );
170  nCapacity = length + 16;
171  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
172  }
173 
174  template< typename T >
176  : pData(NULL)
177  {
178  sal_Int32 length = rtl_str_getLength( value );
179  nCapacity = length + 16;
180  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
181  }
182 
183 #if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
184  template< typename T >
186  : pData(NULL)
187  {
188  sal_Int32 length = rtl_str_getLength( value );
189  nCapacity = length + 16;
190  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
191  }
192 #endif
193 
205  template< typename T >
207  : pData(NULL)
208  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
209  {
210  assert(
213  &pData,
216 #ifdef RTL_STRING_UNITTEST
217  rtl_string_unittest_const_literal = true;
218 #endif
219  }
220 
233  OStringBuffer(const char * value, sal_Int32 length)
234  : pData(NULL)
235  , nCapacity( length + 16 )
236  {
237  rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
238  }
239 
240 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
241 
245  template< typename T1, typename T2 >
246  OStringBuffer( OStringConcat< T1, T2 >&& c )
247  {
248  const sal_Int32 l = c.length();
249  nCapacity = l + 16;
250  pData = rtl_string_alloc( nCapacity );
251  char* end = c.addData( pData->buffer );
252  *end = '\0';
253  pData->length = l;
254  }
255 
260  template< typename T, std::size_t N >
261  OStringBuffer( StringNumberBase< char, T, N >&& n )
262  : OStringBuffer( n.buf, n.length)
263  {}
264 #endif
265 
266 #if defined LIBO_INTERNAL_ONLY
267  operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
268 #endif
269 
272  OStringBuffer& operator = ( const OStringBuffer& value )
273  {
274  if (this != &value)
275  {
277  value.nCapacity,
278  value.pData);
279  nCapacity = value.nCapacity;
280  }
281  return *this;
282  }
283 
288 #if defined LIBO_INTERNAL_ONLY
289  OStringBuffer & operator =(std::string_view string) {
290  sal_Int32 n = string.length();
291  if (n >= nCapacity) {
292  ensureCapacity(n + 16); //TODO: check for overflow
293  }
294  std::memcpy(pData->buffer, string.data(), n);
295  pData->buffer[n] = '\0';
296  pData->length = n;
297  return *this;
298  }
299 #else
300  OStringBuffer & operator =(OString const & string) {
301  sal_Int32 n = string.getLength();
302  if (n >= nCapacity) {
303  ensureCapacity(n + 16); //TODO: check for overflow
304  }
305  std::memcpy(pData->buffer, string.pData->buffer, n + 1);
306  pData->length = n;
307  return *this;
308  }
309 #endif
310 
315  template<typename T>
316  typename
318  operator =(T & literal) {
319  assert(
321  sal_Int32 const n
323  if (n >= nCapacity) {
324  ensureCapacity(n + 16); //TODO: check for overflow
325  }
326  std::memcpy(
327  pData->buffer,
329  n + 1);
330  pData->length = n;
331  return *this;
332  }
333 
334 #if defined LIBO_INTERNAL_ONLY
335 
336  template<typename T1, typename T2>
337  OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
338  sal_Int32 const n = concat.length();
339  if (n >= nCapacity) {
340  ensureCapacity(n + 16); //TODO: check for overflow
341  }
342  *concat.addData(pData->buffer) = 0;
343  pData->length = n;
344  return *this;
345  }
346 
348  template<typename T, std::size_t N>
349  OStringBuffer & operator =(StringNumberBase<char, T, N> && n)
350  {
351  *this = OStringBuffer( std::move ( n ));
352  return *this;
353  }
354 #endif
355 
360  {
361  rtl_string_release( pData );
362  }
363 
373  {
374  OString aRet( pData );
375  rtl_string_new(&pData);
376  nCapacity = 0;
377  return aRet;
378  }
379 
385  sal_Int32 getLength() const
386  {
387  return pData->length;
388  }
389 
398  bool isEmpty() const
399  {
400  return pData->length == 0;
401  }
402 
413  sal_Int32 getCapacity() const
414  {
415  return nCapacity;
416  }
417 
429  void ensureCapacity(sal_Int32 minimumCapacity)
430  {
431  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
432  }
433 
452  void setLength(sal_Int32 newLength)
453  {
454  assert(newLength >= 0);
455  // Avoid modifications if pData points to const empty string:
456  if( newLength != pData->length )
457  {
458  if( newLength > nCapacity )
459  rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
460  else
461  pData->buffer[newLength] = '\0';
462  pData->length = newLength;
463  }
464  }
465 
479  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
480  char charAt( sal_Int32 index )
481  {
482  assert(index >= 0 && index < pData->length);
483  return pData->buffer[ index ];
484  }
485 
496  SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
497  OStringBuffer & setCharAt(sal_Int32 index, char ch)
498  {
499  assert(index >= 0 && index < pData->length);
500  pData->buffer[ index ] = ch;
501  return *this;
502  }
503 
507  const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
508 
518  char & operator [](sal_Int32 index)
519  {
520  assert(index >= 0 && index < pData->length);
521  return pData->buffer[index];
522  }
523 
529  {
530  return OString(pData->buffer, pData->length);
531  }
532 
533 #if !defined LIBO_INTERNAL_ONLY
534 
545  {
546  return append( str.getStr(), str.getLength() );
547  }
548 #endif
549 
561  template< typename T >
563  {
564  return append( str, rtl_str_getLength( str ) );
565  }
566 
567  template< typename T >
569  {
570  return append( str, rtl_str_getLength( str ) );
571  }
572 
578  template< typename T >
580  {
581  RTL_STRING_CONST_FUNCTION
582  assert(
584  return append(
587  }
588 
602  OStringBuffer & append( const char * str, sal_Int32 len)
603  {
604  assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
605  rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
606  return *this;
607  }
608 
609 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
610 
614  template< typename T1, typename T2 >
615  OStringBuffer& append( OStringConcat< T1, T2 >&& c )
616  {
617  sal_Int32 l = c.length();
618  if( l == 0 )
619  return *this;
620  l += pData->length;
621  rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
622  char* end = c.addData( pData->buffer + pData->length );
623  *end = '\0';
624  pData->length = l;
625  return *this;
626  }
627 
632  template< typename T, std::size_t N >
633  OStringBuffer& append( StringNumberBase< char, T, N >&& c )
634  {
635  return append( c.buf, c.length );
636  }
637 
642  OStringBuffer& append( std::string_view s )
643  {
644  return append( s.data(), s.size() );
645  }
646 
647 #endif
648 
661  {
663  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
664  }
665 
680  {
682  return append( sz, rtl_str_valueOfBoolean( sz, b ) );
683  }
684 
686  // Pointer can be automatically converted to bool, which is unwanted here.
687  // Explicitly delete all pointer append() overloads to prevent this
688  // (except for char* overload, which is handled elsewhere).
689  template< typename T >
690  typename libreoffice_internal::Enable< void,
692  append( T* ) SAL_DELETED_FUNCTION;
694 
706  {
707  return append( &c, 1 );
708  }
709 
722  OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
723  {
724  char sz[RTL_STR_MAX_VALUEOFINT32];
725  return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
726  }
727 
740  OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
741  {
742  char sz[RTL_STR_MAX_VALUEOFINT64];
743  return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
744  }
745 
758  {
759  char sz[RTL_STR_MAX_VALUEOFFLOAT];
760  return append( sz, rtl_str_valueOfFloat( sz, f ) );
761  }
762 
774  OStringBuffer & append(double d)
775  {
776  char sz[RTL_STR_MAX_VALUEOFDOUBLE];
777  return append( sz, rtl_str_valueOfDouble( sz, d ) );
778  }
779 
795  char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
796  sal_Int32 n = getLength();
797  rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
798  return pData->buffer + n;
799  }
800 
816 #if defined LIBO_INTERNAL_ONLY
817  OStringBuffer & insert(sal_Int32 offset, std::string_view str)
818  {
819  return insert( offset, str.data(), str.length() );
820  }
821 #else
822  OStringBuffer & insert(sal_Int32 offset, const OString & str)
823  {
824  return insert( offset, str.getStr(), str.getLength() );
825  }
826 #endif
827 
845  template< typename T >
847  {
848  return insert( offset, str, rtl_str_getLength( str ) );
849  }
850 
851  template< typename T >
853  {
854  return insert( offset, str, rtl_str_getLength( str ) );
855  }
856 
862  template< typename T >
864  {
865  RTL_STRING_CONST_FUNCTION
866  assert(
868  return insert(
869  offset,
872  }
873 
892  OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
893  {
894  assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
895  rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
896  return *this;
897  }
898 
916  OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
917  {
919  return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
920  }
921 
941  OStringBuffer & insert(sal_Int32 offset, bool b)
942  {
944  return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
945  }
946 
963  OStringBuffer & insert(sal_Int32 offset, char c)
964  {
965  return insert( offset, &c, 1 );
966  }
967 
986  OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
987  {
988  char sz[RTL_STR_MAX_VALUEOFINT32];
989  return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
990  }
991 
1010  OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
1011  {
1012  char sz[RTL_STR_MAX_VALUEOFINT64];
1013  return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
1014  }
1015 
1033  OStringBuffer insert(sal_Int32 offset, float f)
1034  {
1035  char sz[RTL_STR_MAX_VALUEOFFLOAT];
1036  return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
1037  }
1038 
1056  OStringBuffer & insert(sal_Int32 offset, double d)
1057  {
1058  char sz[RTL_STR_MAX_VALUEOFDOUBLE];
1059  return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
1060  }
1061 
1074  OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1075  {
1076  rtl_stringbuffer_remove( &pData, start, len );
1077  return *this;
1078  }
1079 
1098  rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1099  {
1100  *pInternalData = &pData;
1101  *pInternalCapacity = &nCapacity;
1102  }
1103 
1104 private:
1108  rtl_String * pData;
1109 
1113  sal_Int32 nCapacity;
1114 };
1115 
1116 #if defined LIBO_INTERNAL_ONLY
1117 template<> struct ToStringHelper<OStringBuffer> {
1118  static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1119 
1120  char * operator()(char * buffer, OStringBuffer const & s) const SAL_RETURNS_NONNULL
1121  { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1122 };
1123 #endif
1124 
1125 }
1126 
1127 #ifdef RTL_STRING_UNITTEST
1128 namespace rtl
1129 {
1130 typedef rtlunittest::OStringBuffer OStringBuffer;
1131 }
1132 #undef RTL_STRING_CONST_FUNCTION
1133 #endif
1134 
1135 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1136 using ::rtl::OStringBuffer;
1137 #endif
1138 
1139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:822
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:637
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:986
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:941
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:452
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:631
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:660
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:696
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:663
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:544
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:507
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:359
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.
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:71
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:679
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:104
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:206
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:795
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.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:1033
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:153
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
Definition: stringutils.hxx:140
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:474
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
OStringBuffer & append(const char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:602
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:233
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer &>::Type append(T &str)
Definition: strbuf.hxx:568
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:846
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:413
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: stringutils.hxx:374
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:715
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:722
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:385
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:429
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:892
unsigned char sal_Bool
Definition: types.h:38
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
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 ...
Definition: strbuf.hxx:863
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:528
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:78
Definition: bootstrap.hxx:33
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.
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer &>::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:852
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:215
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:757
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:1056
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:175
libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer &>::Type append(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: strbuf.hxx:579
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:916
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
Definition: stringutils.hxx:142
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 sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
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:562
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:963
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.
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:1010
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:91
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 & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:774
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:398
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:372
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.
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:166
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:740
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.
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1097
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:705