20 #ifndef INCLUDED_RTL_STRBUF_HXX
21 #define INCLUDED_RTL_STRBUF_HXX
32 #ifdef RTL_FAST_STRING
43 #ifdef RTL_STRING_UNITTEST
44 #define rtl rtlunittest
51 #ifdef RTL_STRING_UNITTEST
54 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
56 #define RTL_STRING_CONST_FUNCTION
120 , nCapacity( value.nCapacity )
133 , nCapacity( length )
150 , nCapacity( value.getLength() + 16 )
159 template<
typename T >
164 nCapacity = length + 16;
168 template<
typename T >
173 nCapacity = length + 16;
188 template<
typename T >
191 , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
195 #ifdef RTL_STRING_UNITTEST
196 rtl_string_unittest_const_literal =
true;
214 , nCapacity( length + 16 )
219 #ifdef RTL_FAST_STRING
224 template<
typename T1,
typename T2 >
227 const sal_Int32 l = c.length();
230 char* end = c.addData( pData->buffer );
232 pData->length = end - pData->buffer;
245 nCapacity = value.nCapacity;
281 return pData->length;
294 return pData->length == 0;
348 assert(newLength >= 0);
350 if( newLength != pData->length )
352 if( newLength > nCapacity )
355 pData->buffer[newLength] =
'\0';
356 pData->length = newLength;
376 assert(index >= 0 && index < pData->length);
377 return pData->buffer[ index ];
393 assert(index >= 0 && index < pData->length);
394 pData->buffer[ index ] = ch;
414 assert(index >= 0 && index < pData->length);
415 return pData->buffer[index];
424 return OString(pData->buffer, pData->length);
453 template<
typename T >
459 template<
typename T >
470 template<
typename T >
473 RTL_STRING_CONST_FUNCTION
499 #ifdef RTL_FAST_STRING
504 template<
typename T1,
typename T2 >
507 const int l = c.length();
511 char* end = c.addData( pData->buffer + pData->length );
513 pData->length = end - pData->buffer;
558 template<
typename T >
576 return append( &c, 1 );
686 template<
typename T >
692 template<
typename T >
703 template<
typename T >
706 RTL_STRING_CONST_FUNCTION
803 return insert( offset, &c, 1 );
918 #ifdef LIBO_INTERNAL_ONLY
921 #ifndef RTL_FAST_STRING
945 #ifdef RTL_FAST_STRING
950 struct ToStringHelper< OStringBuffer >
952 static int length(
const OStringBuffer& s ) {
return s.
getLength(); }
953 static char* addData(
char* buffer,
const OStringBuffer& s ) {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
954 static const bool allowOStringConcat =
true;
955 static const bool allowOUStringConcat =
false;
962 #ifdef RTL_STRING_UNITTEST
965 typedef rtlunittest::OStringBuffer OStringBuffer;
967 #undef RTL_STRING_CONST_FUNCTION
971 using ::rtl::OStringBuffer;
975 #endif // INCLUDED_RTL_STRBUF_HXX
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:643
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:491
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_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.
const sal_Char * getStr() const SAL_THROW(())
Returns a pointer to the characters of this string.
Definition: string.hxx:353
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:548
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:609
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
unsigned char sal_Bool
Definition: types.h:46
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:704
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:148
Definition: bootstrap.hxx:24
Definition: stringutils.hxx:67
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.
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 & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:664
OStringBuffer(const T &value, typename internal::CharPtrDetector< T, internal::Dummy >::Type=internal::Dummy())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:160
const OString toString() const
Return a OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:422
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:118
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:98
OStringBuffer & insert(sal_Int32 offset, sal_Char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:801
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OStringBuffer(T &value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
Definition: strbuf.hxx:169
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:492
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: strbuf.hxx:105
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:253
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:471
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 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:307
OStringBuffer(T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
Constructs a string buffer so that it represents the same sequence of characters as the string litera...
Definition: strbuf.hxx:189
char sal_Char
A legacy synonym for char.
Definition: types.h:128
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:730
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:591
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:323
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const SAL_THROW(())
Concatenates the specified string to the end of this string.
Definition: string.hxx:1115
const sal_Char * getStr() const
Return a null terminated character array.
Definition: strbuf.hxx:401
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:687
sal_Int32 getLength() const SAL_THROW(())
Returns the length of this string.
Definition: string.hxx:327
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:131
Definition: stringutils.hxx:87
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:754
Definition: stringutils.hxx:170
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:627
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:848
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:89
Definition: stringutils.hxx:110
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:693
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 & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:529
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:779
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:871
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:279
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:824
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...
Definition: stringutils.hxx:69
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_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: strbuf.hxx:894
bool isEmpty() const SAL_THROW(())
Checks if a string buffer is empty.
Definition: strbuf.hxx:292
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:626
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:437
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:603
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:346
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.
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:454
OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:266
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:212
internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:460
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650