20 #ifndef INCLUDED_RTL_STRBUF_HXX
21 #define INCLUDED_RTL_STRBUF_HXX
32 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
41 #ifdef RTL_STRING_UNITTEST
42 #define rtl rtlunittest
49 #ifdef RTL_STRING_UNITTEST
52 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
54 #define RTL_STRING_CONST_FUNCTION
82 , nCapacity( value.nCapacity )
99 #if __cplusplus >= 201103L
104 #if SAL_TYPES_SIZEOFLONG == 4
106 explicit OStringBuffer(
long length)
107 : OStringBuffer(static_cast<int>(length))
110 explicit OStringBuffer(
unsigned long length)
111 : OStringBuffer(static_cast<int>(length))
116 explicit OStringBuffer(
char) =
delete;
132 , nCapacity( value.getLength() + 16 )
141 template<
typename T >
146 nCapacity = length + 16;
150 template<
typename T >
155 nCapacity = length + 16;
170 template<
typename T >
173 , nCapacity( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
177 #ifdef RTL_STRING_UNITTEST
178 rtl_string_unittest_const_literal =
true;
196 , nCapacity( length + 16 )
201 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
206 template<
typename T1,
typename T2 >
209 const sal_Int32 l = c.length();
212 char* end = c.addData( pData->buffer );
214 pData->length = end - pData->buffer;
263 return pData->length;
276 return pData->length == 0;
330 assert(newLength >= 0);
332 if( newLength != pData->length )
334 if( newLength > nCapacity )
337 pData->buffer[newLength] =
'\0';
338 pData->length = newLength;
358 assert(index >= 0 && index < pData->length);
359 return pData->buffer[ index ];
375 assert(index >= 0 && index < pData->length);
376 pData->buffer[ index ] = ch;
396 assert(index >= 0 && index < pData->length);
397 return pData->buffer[index];
406 return OString(pData->buffer, pData->length);
435 template<
typename T >
441 template<
typename T >
452 template<
typename T >
455 RTL_STRING_CONST_FUNCTION
476 assert( len == 0 || str != 0 );
481 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
486 template<
typename T1,
typename T2 >
489 const int l = c.length();
493 char* end = c.addData( pData->buffer + pData->length );
495 pData->length = end - pData->buffer;
540 template<
typename T >
558 return append( &c, 1 );
647 sal_Int32 n = getLength();
649 return pData->buffer + n;
689 template<
typename T >
695 template<
typename T >
706 template<
typename T >
709 RTL_STRING_CONST_FUNCTION
735 assert( len == 0 || str != 0 );
806 return insert( offset, &c, 1 );
933 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
938 struct ToStringHelper< OStringBuffer >
940 static int length(
const OStringBuffer& s ) {
return s.getLength(); }
941 static char* addData(
char* buffer,
const OStringBuffer& s ) {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
942 static const bool allowOStringConcat =
true;
943 static const bool allowOUStringConcat =
false;
950 #ifdef RTL_STRING_UNITTEST
953 typedef rtlunittest::OStringBuffer OStringBuffer;
955 #undef RTL_STRING_CONST_FUNCTION
958 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
959 using ::rtl::OStringBuffer;
962 #endif // INCLUDED_RTL_STRBUF_HXX
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
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:851
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:419
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:93
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.
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:274
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
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:436
char sal_Char
A legacy synonym for char.
Definition: types.h:130
OStringBuffer & insert(sal_Int32 offset, const sal_Char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:733
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:442
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:404
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:130
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:404
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_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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:690
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:235
OStringBuffer & append(const sal_Char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:474
Definition: stringutils.hxx:161
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:804
Definition: stringutils.hxx:101
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:757
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:67
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:328
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:305
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:530
SAL_DLLPUBLIC void rtl_stringbuffer_newFromStr_WithLength(rtl_String **newStr, const sal_Char *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
unsigned char sal_Bool
Definition: types.h:48
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:362
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:80
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
OStringBuffer(const sal_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:194
SAL_DLLPUBLIC void rtl_stringbuffer_insert(rtl_String **This, sal_Int32 *capacity, sal_Int32 offset, const sal_Char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: stringutils.hxx:60
nCapacity
Definition: strbuf.hxx:146
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:383
sal_uInt16 sal_Unicode
Definition: types.h:152
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:667
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:608
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:60
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:827
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:511
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:696
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:495
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:874
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:782
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:453
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:336
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(sal_Char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:248
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
Definition: stringutils.hxx:78
Definition: stringutils.hxx:58
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:591
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:625
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:573
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.
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:707
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:289
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:261
char * appendUninitialized(sal_Int32 length)
Unsafe way to make space for a fixed amount of characters to be appended into this OStringBuffer...
Definition: strbuf.hxx:646
rtl_stringbuffer_newFromStr_WithLength & pData
Definition: strbuf.hxx:147
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:88
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:897