20 #ifndef _RTL_STRBUF_HXX_
21 #define _RTL_STRBUF_HXX_
32 #ifdef RTL_FAST_STRING
43 #ifdef RTL_STRING_UNITTEST
44 #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
118 , nCapacity( value.nCapacity )
131 , nCapacity( length )
148 , nCapacity( value.getLength() + 16 )
157 #ifdef HAVE_SFINAE_ANONYMOUS_BROKEN // see the OString ctors
162 nCapacity = length + 16;
166 template<
typename T >
171 nCapacity = length + 16;
175 template<
typename T >
180 nCapacity = length + 16;
195 template<
typename T >
198 , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
202 #ifdef RTL_STRING_UNITTEST
203 rtl_string_unittest_const_literal =
true;
206 #endif // HAVE_SFINAE_ANONYMOUS_BROKEN
222 , nCapacity( length + 16 )
227 #ifdef RTL_FAST_STRING
228 template<
typename T1,
typename T2 >
231 const sal_Int32 l = c.length();
232 rtl_String* buffer = NULL;
235 char* end = c.addData( buffer->buffer );
237 buffer->length = end - buffer->buffer;
251 nCapacity = value.nCapacity;
285 sal_Int32 getLength()
const
287 return pData->length;
300 sal_Int32 getCapacity()
const
316 void ensureCapacity(sal_Int32 minimumCapacity)
339 void setLength(sal_Int32 newLength)
341 assert(newLength >= 0);
343 if( newLength != pData->length )
345 if( newLength > nCapacity )
348 pData->buffer[newLength] =
'\0';
349 pData->length = newLength;
369 assert(index >= 0 && index < pData->length);
370 return pData->buffer[ index ];
386 assert(index >= 0 && index < pData->length);
387 pData->buffer[ index ] = ch;
405 sal_Char & operator [](sal_Int32 index) {
return pData->buffer[index]; }
413 return OString(pData->buffer, pData->length);
442 #ifdef HAVE_SFINAE_ANONYMOUS_BROKEN
448 template<
typename T >
454 template<
typename T >
465 template<
typename T >
524 return append( &c, 1 );
632 #ifdef HAVE_SFINAE_ANONYMOUS_BROKEN
638 template<
typename T >
644 template<
typename T >
655 template<
typename T >
731 return insert( offset, &c, 1 );
751 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
774 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
856 #ifdef RTL_FAST_STRING
858 struct ToStringHelper< OStringBuffer >
860 static int length(
const OStringBuffer& s ) {
return s.getLength(); }
861 static char* addData(
char* buffer,
const OStringBuffer& s ) {
return addDataHelper( buffer, s.getStr(), s.getLength()); }
862 static const bool allowOStringConcat =
true;
863 static const bool allowOUStringConcat =
false;
870 #ifdef RTL_STRING_UNITTEST
873 typedef rtlunittest::OStringBuffer OStringBuffer;
875 #undef RTL_STRING_CONST_FUNCTION
879 using ::rtl::OStringBuffer;