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>::length + 16 )
181 #ifdef RTL_STRING_UNITTEST
182 rtl_string_unittest_const_literal =
true;
200 , nCapacity( length + 16 )
205 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
210 template<
typename T1,
typename T2 >
213 const sal_Int32 l = c.length();
216 char* end = c.addData( pData->buffer );
231 nCapacity = value.nCapacity;
267 return pData->length;
280 return pData->length == 0;
334 assert(newLength >= 0);
336 if( newLength != pData->length )
338 if( newLength > nCapacity )
341 pData->buffer[newLength] =
'\0';
342 pData->length = newLength;
362 assert(index >= 0 && index < pData->length);
363 return pData->buffer[ index ];
379 assert(index >= 0 && index < pData->length);
380 pData->buffer[ index ] = ch;
400 assert(index >= 0 && index < pData->length);
401 return pData->buffer[index];
410 return OString(pData->buffer, pData->length);
439 template<
typename T >
445 template<
typename T >
456 template<
typename T >
459 RTL_STRING_CONST_FUNCTION
463 &pData, &nCapacity, getLength(),
484 assert( len == 0 || str != 0 );
489 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
494 template<
typename T1,
typename T2 >
497 sal_Int32 l = c.length();
502 char* end = c.addData( pData->buffer + pData->length );
549 template<
typename T >
567 return append( &c, 1 );
656 sal_Int32 n = getLength();
658 return pData->buffer + n;
698 template<
typename T >
704 template<
typename T >
715 template<
typename T >
718 RTL_STRING_CONST_FUNCTION
722 &pData, &nCapacity, offset,
748 assert( len == 0 || str != 0 );
819 return insert( offset, &c, 1 );
946 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
951 struct ToStringHelper< OStringBuffer >
953 static int length(
const OStringBuffer& s ) {
return s.getLength(); }
954 static char* addData(
char* buffer,
const OStringBuffer& s ) {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
955 static const bool allowOStringConcat =
true;
956 static const bool allowOUStringConcat =
false;
963 #ifdef RTL_STRING_UNITTEST
966 typedef rtlunittest::OStringBuffer OStringBuffer;
968 #undef RTL_STRING_CONST_FUNCTION
971 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
972 using ::rtl::OStringBuffer;
975 #endif // INCLUDED_RTL_STRBUF_HXX
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
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_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:278
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:910
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:770
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:746
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:293
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
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:309
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:404
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:265
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:539
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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:699
Definition: stringutils.hxx:136
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
char sal_Char
A legacy synonym for char.
Definition: types.h:130
Definition: stringutils.hxx:116
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:89
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:408
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
unsigned char sal_Bool
Definition: types.h:48
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:864
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:171
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:151
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:676
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:380
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:67
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 void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:239
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 & append(const sal_Char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:482
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:387
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:817
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:198
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:332
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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.
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:600
sal_uInt16 sal_Unicode
Definition: types.h:152
Definition: stringutils.hxx:244
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:705
Definition: stringutils.hxx:159
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_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
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.
OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:252
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:840
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:520
Definition: stringutils.hxx:118
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.
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:142
#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, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:795
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:457
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:634
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:617
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
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:655
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:582
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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:440
Definition: bootstrap.hxx:24
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:716
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:446
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
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:887
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:354
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:60
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:423
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.