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 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 );
232 nCapacity = value.nCapacity;
268 return pData->length;
281 return pData->length == 0;
335 assert(newLength >= 0);
337 if( newLength != pData->length )
339 if( newLength > nCapacity )
342 pData->buffer[newLength] =
'\0';
343 pData->length = newLength;
363 assert(index >= 0 && index < pData->length);
364 return pData->buffer[ index ];
380 assert(index >= 0 && index < pData->length);
381 pData->buffer[ index ] = ch;
401 assert(index >= 0 && index < pData->length);
402 return pData->buffer[index];
411 return OString(pData->buffer, pData->length);
440 template<
typename T >
446 template<
typename T >
457 template<
typename T >
460 RTL_STRING_CONST_FUNCTION
464 &pData, &nCapacity, getLength(),
485 assert( len == 0 || str != NULL );
490 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 495 template<
typename T1,
typename T2 >
498 sal_Int32 l = c.length();
503 char* end = c.addData( pData->buffer + pData->length );
550 template<
typename T >
568 return append( &c, 1 );
657 sal_Int32 n = getLength();
659 return pData->buffer + n;
699 template<
typename T >
705 template<
typename T >
716 template<
typename T >
719 RTL_STRING_CONST_FUNCTION
723 &pData, &nCapacity, offset,
749 assert( len == 0 || str != NULL );
820 return insert( offset, &c, 1 );
947 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 952 struct ToStringHelper< OStringBuffer >
954 static int length(
const OStringBuffer& s ) {
return s.
getLength(); }
955 static char* addData(
char* buffer,
const OStringBuffer& s ) {
return addDataHelper( buffer, s.
getStr(), s.
getLength()); }
956 static const bool allowOStringConcat =
true;
957 static const bool allowOUStringConcat =
false;
964 #ifdef RTL_STRING_UNITTEST 969 #undef RTL_STRING_CONST_FUNCTION 972 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST 973 using ::rtl::OStringBuffer;
976 #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:865
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:424
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:172
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:279
#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:441
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:747
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:447
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:409
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:700
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:240
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:483
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:152
Definition: stringutils.hxx:245
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:818
Definition: stringutils.hxx:160
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:771
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:333
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:310
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:540
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:119
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:388
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:677
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:618
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:841
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:521
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:706
Definition: bootstrap.hxx:29
OStringBuffer & append(sal_Char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:566
#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:888
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:796
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:458
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:253
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
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:143
Definition: stringutils.hxx:137
Definition: stringutils.hxx:117
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:601
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:635
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:583
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:717
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:294
#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:266
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:656
#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:911