20 #ifndef INCLUDED_RTL_STRBUF_HXX 21 #define INCLUDED_RTL_STRBUF_HXX 32 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 36 #ifdef RTL_STRING_UNITTEST 37 extern bool rtl_string_unittest_const_literal;
38 extern bool rtl_string_unittest_const_literal_function;
46 #ifdef RTL_STRING_UNITTEST 47 #define rtl rtlunittest 54 #ifdef RTL_STRING_UNITTEST 57 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true; 59 #define RTL_STRING_CONST_FUNCTION 87 , nCapacity( value.nCapacity )
100 , nCapacity( length )
104 #if __cplusplus >= 201103L 109 #if SAL_TYPES_SIZEOFLONG == 4 111 explicit OStringBuffer(
long length)
112 : OStringBuffer(static_cast<int>(length))
115 explicit OStringBuffer(
unsigned long length)
116 : OStringBuffer(static_cast<int>(length))
121 explicit OStringBuffer(
char) =
delete;
137 , nCapacity( value.getLength() + 16 )
146 template<
typename T >
151 nCapacity = length + 16;
155 template<
typename T >
160 nCapacity = length + 16;
175 template<
typename T >
178 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
186 #ifdef RTL_STRING_UNITTEST 187 rtl_string_unittest_const_literal =
true;
205 , nCapacity( length + 16 )
210 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 215 template<
typename T1,
typename T2 >
218 const sal_Int32 l = c.length();
221 char* end = c.addData( pData->buffer );
236 nCapacity = value.nCapacity;
247 if (n >= nCapacity) {
248 ensureCapacity(n + 16);
250 std::memcpy(pData->buffer,
string.pData->buffer, n + 1);
262 operator =(T & literal) {
267 if (n >= nCapacity) {
268 ensureCapacity(n + 16);
278 #if defined LIBO_INTERNAL_ONLY 280 template<
typename T1,
typename T2>
281 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
282 sal_Int32
const n = concat.length();
283 if (n >= nCapacity) {
284 ensureCapacity(n + 16);
286 *concat.addData(pData->buffer) = 0;
323 return pData->length;
336 return pData->length == 0;
390 assert(newLength >= 0);
392 if( newLength != pData->length )
394 if( newLength > nCapacity )
397 pData->buffer[newLength] =
'\0';
398 pData->length = newLength;
418 assert(index >= 0 && index < pData->length);
419 return pData->buffer[ index ];
435 assert(index >= 0 && index < pData->length);
436 pData->buffer[ index ] = ch;
456 assert(index >= 0 && index < pData->length);
457 return pData->buffer[index];
466 return OString(pData->buffer, pData->length);
495 template<
typename T >
501 template<
typename T >
512 template<
typename T >
515 RTL_STRING_CONST_FUNCTION
519 &pData, &nCapacity, getLength(),
540 assert( len == 0 || str != NULL );
545 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 550 template<
typename T1,
typename T2 >
553 sal_Int32 l = c.length();
558 char* end = c.addData( pData->buffer + pData->length );
605 template<
typename T >
623 return append( &c, 1 );
712 sal_Int32 n = getLength();
714 return pData->buffer + n;
754 template<
typename T >
760 template<
typename T >
771 template<
typename T >
774 RTL_STRING_CONST_FUNCTION
778 &pData, &nCapacity, offset,
804 assert( len == 0 || str != NULL );
875 return insert( offset, &c, 1 );
1008 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1010 *pInternalData = &pData;
1011 *pInternalCapacity = &nCapacity;
1023 sal_Int32 nCapacity;
1028 #ifdef RTL_STRING_UNITTEST 1031 typedef rtlunittest::OStringBuffer OStringBuffer;
1033 #undef RTL_STRING_CONST_FUNCTION 1036 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 1037 using ::rtl::OStringBuffer;
1040 #endif // INCLUDED_RTL_STRBUF_HXX 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:513
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:732
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:755
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
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:802
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.
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:405
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:690
Definition: stringutils.hxx:123
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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:896
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:349
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:135
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
Definition: bootstrap.hxx:29
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:147
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:396
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:920
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.
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:465
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:966
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:98
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.
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:156
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:576
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:464
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:479
Definition: stringutils.hxx:146
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:656
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.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
sal_uInt16 sal_Unicode
Definition: types.h:141
unsigned char sal_Bool
Definition: types.h:38
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:761
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:431
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:308
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:711
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:826
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:638
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, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:873
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
Definition: stringutils.hxx:299
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:496
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:772
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 & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:595
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:85
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1007
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:538
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:97
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.
OStringBuffer & append(sal_Char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:621
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:176
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
char sal_Char
A legacy synonym for char.
Definition: types.h:120
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:673
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:334
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:295
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:851
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:943
Definition: stringutils.hxx:105
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 sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:502
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:65
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:72
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:984
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:321
Definition: stringutils.hxx:103
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:203
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 ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:365
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:443
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:388