20 #ifndef INCLUDED_RTL_STRBUF_HXX
21 #define INCLUDED_RTL_STRBUF_HXX
33 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
42 #ifdef RTL_STRING_UNITTEST
43 #define rtl rtlunittest
50 #ifdef RTL_STRING_UNITTEST
53 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
55 #define RTL_STRING_CONST_FUNCTION
83 , nCapacity( value.nCapacity )
100 #if __cplusplus >= 201103L
105 #if SAL_TYPES_SIZEOFLONG == 4
107 explicit OStringBuffer(
long length)
108 : OStringBuffer(static_cast<int>(length))
111 explicit OStringBuffer(
unsigned long length)
112 : OStringBuffer(static_cast<int>(length))
117 explicit OStringBuffer(
char) =
delete;
133 , nCapacity( value.getLength() + 16 )
142 template<
typename T >
147 nCapacity = length + 16;
151 template<
typename T >
156 nCapacity = length + 16;
171 template<
typename T >
174 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
182 #ifdef RTL_STRING_UNITTEST
183 rtl_string_unittest_const_literal =
true;
201 , nCapacity( length + 16 )
206 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
211 template<
typename T1,
typename T2 >
214 const sal_Int32 l = c.length();
217 char* end = c.addData( pData->buffer );
243 if (n >= nCapacity) {
244 ensureCapacity(n + 16);
246 std::memcpy(pData->buffer,
string.pData->buffer, n + 1);
258 operator =(T & literal) {
263 if (n >= nCapacity) {
264 ensureCapacity(n + 16);
274 #if defined LIBO_INTERNAL_ONLY
276 template<
typename T1,
typename T2>
277 OStringBuffer & operator =(OStringConcat<T1, T2>
const & concat) {
278 sal_Int32
const n = concat.length();
279 if (n >= nCapacity) {
280 ensureCapacity(n + 16);
282 *concat.addData(pData->buffer) = 0;
319 return pData->length;
332 return pData->length == 0;
386 assert(newLength >= 0);
388 if( newLength != pData->length )
390 if( newLength > nCapacity )
393 pData->buffer[newLength] =
'\0';
394 pData->length = newLength;
414 assert(index >= 0 && index < pData->length);
415 return pData->buffer[ index ];
431 assert(index >= 0 && index < pData->length);
432 pData->buffer[ index ] = ch;
452 assert(index >= 0 && index < pData->length);
453 return pData->buffer[index];
462 return OString(pData->buffer, pData->length);
491 template<
typename T >
497 template<
typename T >
508 template<
typename T >
511 RTL_STRING_CONST_FUNCTION
515 &pData, &nCapacity, getLength(),
536 assert( len == 0 || str != NULL );
541 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
546 template<
typename T1,
typename T2 >
549 sal_Int32 l = c.length();
554 char* end = c.addData( pData->buffer + pData->length );
601 template<
typename T >
619 return append( &c, 1 );
708 sal_Int32 n = getLength();
710 return pData->buffer + n;
750 template<
typename T >
756 template<
typename T >
767 template<
typename T >
770 RTL_STRING_CONST_FUNCTION
774 &pData, &nCapacity, offset,
800 assert( len == 0 || str != NULL );
871 return insert( offset, &c, 1 );
1000 #ifdef RTL_STRING_UNITTEST
1003 typedef rtlunittest::OStringBuffer OStringBuffer;
1005 #undef RTL_STRING_CONST_FUNCTION
1008 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1009 using ::rtl::OStringBuffer;
1012 #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:916
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:475
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:94
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:330
#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:492
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:798
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:498
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:460
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:131
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:410
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:624
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:751
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:291
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:534
Definition: stringutils.hxx:267
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:869
Definition: stringutils.hxx:158
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:822
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:68
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:384
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:361
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:591
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:430
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:81
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:199
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:117
nCapacity
Definition: strbuf.hxx:147
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:439
sal_uInt16 sal_Unicode
Definition: types.h:155
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:728
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:669
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:61
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:892
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:572
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:757
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:509
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:939
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:847
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:509
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:404
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:304
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
Definition: stringutils.hxx:135
Definition: stringutils.hxx:115
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:652
OStringBuffer & append(double d)
Appends the string representation of the double 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:634
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:768
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:345
#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:317
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:707
rtl_stringbuffer_newFromStr_WithLength & pData
Definition: strbuf.hxx:148
#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:90
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:962