20 #ifndef INCLUDED_RTL_STRBUF_HXX 21 #define INCLUDED_RTL_STRBUF_HXX 33 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 37 #ifdef RTL_STRING_UNITTEST 38 extern bool rtl_string_unittest_const_literal;
39 extern bool rtl_string_unittest_const_literal_function;
47 #ifdef RTL_STRING_UNITTEST 48 #define rtl rtlunittest 55 #ifdef RTL_STRING_UNITTEST 58 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true; 60 #define RTL_STRING_CONST_FUNCTION 88 , nCapacity( value.nCapacity )
101 , nCapacity( length )
105 #if __cplusplus >= 201103L 110 #if SAL_TYPES_SIZEOFLONG == 4 138 , nCapacity( value.getLength() + 16 )
147 template<
typename T >
152 nCapacity = length + 16;
156 template<
typename T >
161 nCapacity = length + 16;
176 template<
typename T >
179 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
187 #ifdef RTL_STRING_UNITTEST 188 rtl_string_unittest_const_literal =
true;
206 , nCapacity( length + 16 )
211 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 216 template<
typename T1,
typename T2 >
219 const sal_Int32 l = c.length();
222 char* end = c.addData( pData->buffer );
237 nCapacity = value.nCapacity;
248 if (n >= nCapacity) {
249 ensureCapacity(n + 16);
251 std::memcpy(pData->buffer,
string.pData->buffer, n + 1);
263 operator =(T & literal) {
268 if (n >= nCapacity) {
269 ensureCapacity(n + 16);
279 #if defined LIBO_INTERNAL_ONLY 281 template<
typename T1,
typename T2>
282 OStringBuffer & operator =(OStringConcat<T1, T2>
const & concat) {
283 sal_Int32
const n = concat.length();
284 if (n >= nCapacity) {
285 ensureCapacity(n + 16);
287 *concat.addData(pData->buffer) = 0;
324 return pData->length;
337 return pData->length == 0;
391 assert(newLength >= 0);
393 if( newLength != pData->length )
395 if( newLength > nCapacity )
398 pData->buffer[newLength] =
'\0';
399 pData->length = newLength;
419 assert(index >= 0 && index < pData->length);
420 return pData->buffer[ index ];
436 assert(index >= 0 && index < pData->length);
437 pData->buffer[ index ] = ch;
457 assert(index >= 0 && index < pData->length);
458 return pData->buffer[index];
467 return OString(pData->buffer, pData->length);
496 template<
typename T >
502 template<
typename T >
513 template<
typename T >
516 RTL_STRING_CONST_FUNCTION
520 &pData, &nCapacity, getLength(),
541 assert( len == 0 || str != NULL );
546 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 551 template<
typename T1,
typename T2 >
554 sal_Int32 l = c.length();
559 char* end = c.addData( pData->buffer + pData->length );
606 template<
typename T >
624 return append( &c, 1 );
713 sal_Int32 n = getLength();
715 return pData->buffer + n;
755 template<
typename T >
761 template<
typename T >
772 template<
typename T >
775 RTL_STRING_CONST_FUNCTION
779 &pData, &nCapacity, offset,
805 assert( len == 0 || str != NULL );
876 return insert( offset, &c, 1 );
1009 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1011 *pInternalData = &pData;
1012 *pInternalCapacity = &nCapacity;
1024 sal_Int32 nCapacity;
1029 #ifdef RTL_STRING_UNITTEST 1034 #undef RTL_STRING_CONST_FUNCTION 1037 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 1038 using ::rtl::OStringBuffer;
1041 #endif // INCLUDED_RTL_STRBUF_HXX 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:897
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:157
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:967
Definition: stringutils.hxx:135
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:514
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
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.
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:204
Definition: stringutils.hxx:158
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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:773
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1008
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:639
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer &>::Type append(T &str)
Definition: strbuf.hxx:503
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.
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:350
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:392
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:435
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:136
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:309
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 & 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:803
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:577
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:99
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:874
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:480
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:483
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:598
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.
Definition: stringutils.hxx:267
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:944
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:444
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:177
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:148
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:497
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:366
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:95
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:142
unsigned char sal_Bool
Definition: types.h:39
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:465
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:733
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:335
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:389
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:539
Definition: stringutils.hxx:117
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:827
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.
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:712
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:657
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:691
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:596
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:674
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:296
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:66
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:622
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:307
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:86
char sal_Char
A legacy synonym for char.
Definition: types.h:121
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer &>::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:762
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 & 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:921
Definition: stringutils.hxx:115
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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 insert(sal_Int32 offset, const T &str)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:756
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:409
Definition: bootstrap.hxx:29
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:322
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:852
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()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:73