LibreOffice LibreOffice 4.2 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ustrbuf.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #ifndef INCLUDED_RTL_USTRBUF_HXX
21 #define INCLUDED_RTL_USTRBUF_HXX
22
23 #include <sal/config.h>
24
25 #include <cassert>
26 #include <string.h>
27
28 #include <osl/diagnose.h>
29 #include <rtl/ustrbuf.h>
30 #include <rtl/ustring.hxx>
31 #include <rtl/stringutils.hxx>
32 #include <sal/types.h>
33
34 #ifdef RTL_FAST_STRING
35 #include <rtl/stringconcat.hxx>
36 #endif
37
38 // The unittest uses slightly different code to help check that the proper
39 // calls are made. The class is put into a different namespace to make
40 // sure the compiler generates a different (if generating also non-inline)
41 // copy of the function and does not merge them together. The class
42 // is "brought" into the proper rtl namespace by a typedef below.
43 #ifdef RTL_STRING_UNITTEST
44 #define rtl rtlunittest
45 #endif
46
47 namespace rtl
48 {
49
50 #ifdef RTL_STRING_UNITTEST
51 #undef rtl
52 #endif
53
92 class SAL_WARN_UNUSED OUStringBuffer
93 {
94 public:
99 OUStringBuffer()
100 : pData(NULL)
101 , nCapacity( 16 )
102 {
103 rtl_uString_new_WithLength( &pData, nCapacity );
104 }
105
112 OUStringBuffer( const OUStringBuffer & value )
113 : pData(NULL)
114 , nCapacity( value.nCapacity )
115 {
116 rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
117 }
118
125 explicit OUStringBuffer(int length)
126 : pData(NULL)
127 , nCapacity( length )
128 {
129 rtl_uString_new_WithLength( &pData, length );
130 }
131
142 OUStringBuffer(const OUString& value)
143 : pData(NULL)
144 , nCapacity( value.getLength() + 16 )
145 {
146 rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
147 }
148
149 template< typename T >
150 OUStringBuffer( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() )
151 : pData(NULL)
152 , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
153 {
154 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
155 rtl_uString_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
156 #ifdef RTL_STRING_UNITTEST
157 rtl_string_unittest_const_literal = true;
158 #endif
159 }
160
161 #ifdef RTL_STRING_UNITTEST
162
166 template< typename T >
167 OUStringBuffer( T&, typename internal::ExceptConstCharArrayDetector< T >::Type = internal::Dummy() )
168 {
169 pData = 0;
170 nCapacity = 10;
171 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
172 rtl_string_unittest_invalid_conversion = true;
173 }
178 template< typename T >
179 OUStringBuffer( const T&, typename internal::ExceptCharArrayDetector< T >::Type = internal::Dummy() )
180 {
181 pData = 0;
182 nCapacity = 10;
183 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
184 rtl_string_unittest_invalid_conversion = true;
185 }
186 #endif
187
188 #ifdef RTL_FAST_STRING
189
193 template< typename T1, typename T2 >
194 OUStringBuffer( const OUStringConcat< T1, T2 >& c )
195 {
196 const sal_Int32 l = c.length();
197 nCapacity = l + 16;
198 pData = rtl_uString_alloc( nCapacity );
199 sal_Unicode* end = c.addData( pData->buffer );
200 *end = '\0';
201 pData->length = end - pData->buffer;
202 // TODO realloc in case pData->>length is noticeably smaller than l ?
203 }
204 #endif
205
207 OUStringBuffer& operator = ( const OUStringBuffer& value )
208 {
209 if (this != &value)
210 {
211 rtl_uStringbuffer_newFromStringBuffer(&pData,
212 value.nCapacity,
213 value.pData);
214 nCapacity = value.nCapacity;
215 }
216 return *this;
217 }
218
222 ~OUStringBuffer()
223 {
224 rtl_uString_release( pData );
225 }
226
235 OUString makeStringAndClear()
236 {
237 return OUString(
238 rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
239 SAL_NO_ACQUIRE );
240 }
241
247 sal_Int32 getLength() const
248 {
249 return pData->length;
250 }
251
260 bool isEmpty() const SAL_THROW(())
261 {
262 return pData->length == 0;
263 }
264
275 sal_Int32 getCapacity() const
276 {
277 return nCapacity;
278 }
279
291 void ensureCapacity(sal_Int32 minimumCapacity)
292 {
293 rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
294 }
295
314 void setLength(sal_Int32 newLength)
315 {
316 assert(newLength >= 0);
317 // Avoid modifications if pData points to const empty string:
318 if( newLength != pData->length )
319 {
320 if( newLength > nCapacity )
321 rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
322 else
323 pData->buffer[newLength] = 0;
324 pData->length = newLength;
325 }
326 }
327
341 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
342 sal_Unicode charAt( sal_Int32 index ) const
343 {
344 assert(index >= 0 && index < pData->length);
345 return pData->buffer[ index ];
346 }
347
358 SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
359 OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
360 {
361 assert(index >= 0 && index < pData->length);
362 pData->buffer[ index ] = ch;
363 return *this;
364 }
365
369 const sal_Unicode* getStr() const { return pData->buffer; }
370
380 sal_Unicode & operator [](sal_Int32 index)
381 {
382 assert(index >= 0 && index < pData->length);
383 return pData->buffer[index];
384 }
385
395 const sal_Unicode & operator [](sal_Int32 index) const
396 {
397 assert(index >= 0 && index < pData->length);
398 return pData->buffer[index];
399 }
400
405 const OUString toString() const
406 {
407 return OUString(pData->buffer, pData->length);
408 }
409
420 OUStringBuffer & append(const OUString &str)
421 {
422 return append( str.getStr(), str.getLength() );
423 }
424
437 OUStringBuffer & append(const OUStringBuffer &str)
438 {
439 if(!str.isEmpty())
440 {
441 append( str.getStr(), str.getLength() );
442 }
443 return *this;
444 }
445
457 OUStringBuffer & append( const sal_Unicode * str )
458 {
459 return append( str, rtl_ustr_getLength( str ) );
460 }
461
475 OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
476 {
477 // insert behind the last character
478 rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
479 return *this;
480 }
481
487 template< typename T >
488 typename internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type append( T& literal )
489 {
490 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
491 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
492 internal::ConstCharArrayDetector< T, void >::size - 1 );
493 return *this;
494 }
495
496 #ifdef RTL_FAST_STRING
497
501 template< typename T1, typename T2 >
502 OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
503 {
504 const int l = c.length();
505 if( l == 0 )
506 return *this;
507 rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
508 sal_Unicode* end = c.addData( pData->buffer + pData->length );
509 *end = '\0';
510 pData->length = end - pData->buffer;
511 return *this;
512 }
513 #endif
514
531 OUStringBuffer & appendAscii( const sal_Char * str )
532 {
533 return appendAscii( str, rtl_str_getLength( str ) );
534 }
535
554 OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
555 {
556 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
557 return *this;
558 }
559
573 OUStringBuffer & append(bool b)
574 {
575 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
576 return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
577 }
578
579 // Pointer can be automatically converted to bool, which is unwanted here.
580 // Explicitly delete all pointer append() overloads to prevent this
581 // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
582 template< typename T >
583 typename internal::Enable< void,
584 !internal::CharPtrDetector< T* >::ok && !internal::SalUnicodePtrDetector< T* >::ok >::Type
585 append( T* ) SAL_DELETED_FUNCTION;
586
587 // This overload is needed because OUString has a ctor from rtl_uString*, but
588 // the bool overload above would be prefered to the conversion.
592 OUStringBuffer & append(rtl_uString* str)
593 {
594 return append( OUString( str ));
595 }
596
608 OUStringBuffer & append(sal_Bool b)
609 {
610 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
611 return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
612 }
613
626 OUStringBuffer & append(char c)
627 {
628 assert(static_cast< unsigned char >(c) <= 0x7F);
629 return append(sal_Unicode(c));
630 }
631
642 OUStringBuffer & append(sal_Unicode c)
643 {
644 return append( &c, 1 );
645 }
646
659 OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
660 {
661 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
662 return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
663 }
664
677 OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
678 {
679 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
680 return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
681 }
682
694 OUStringBuffer & append(float f)
695 {
696 sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
697 return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
698 }
699
711 OUStringBuffer & append(double d)
712 {
713 sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
714 return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
715 }
716
730 OUStringBuffer & appendUtf32(sal_uInt32 c) {
731 return insertUtf32(getLength(), c);
732 }
733
749 OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
750 {
751 return insert( offset, str.getStr(), str.getLength() );
752 }
753
771 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
772 {
773 return insert( offset, str, rtl_ustr_getLength( str ) );
774 }
775
794 OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
795 {
796 // insert behind the last character
797 rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
798 return *this;
799 }
800
806 template< typename T >
807 typename internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
808 {
809 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
810 rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
811 internal::ConstCharArrayDetector< T, void >::size - 1 );
812 return *this;
813 }
814
832 OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
833 {
834 sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
835 return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
836 }
837
856 OUStringBuffer & insert(sal_Int32 offset, char c)
857 {
858 sal_Unicode u = c;
859 return insert( offset, &u, 1 );
860 }
861
878 OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
879 {
880 return insert( offset, &c, 1 );
881 }
882
902 OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
903 {
904 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
905 return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
906 }
907
927 OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
928 {
929 sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
930 return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
931 }
932
951 OUStringBuffer insert(sal_Int32 offset, float f)
952 {
953 sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
954 return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
955 }
956
975 OUStringBuffer & insert(sal_Int32 offset, double d)
976 {
977 sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
978 return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
979 }
980
996 OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
997 rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
998 return *this;
999 }
1000
1013 OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1014 {
1015 rtl_uStringbuffer_remove( &pData, start, len );
1016 return *this;
1017 }
1018
1029 OUStringBuffer & truncate( sal_Int32 start = 0 )
1030 {
1031 rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1032 return *this;
1033 }
1034
1045 OUStringBuffer& replace( sal_Unicode oldChar, sal_Unicode newChar )
1046 {
1047 sal_Int32 index = 0;
1048 while((index = indexOf(oldChar, index)) >= 0)
1049 {
1050 pData->buffer[ index ] = newChar;
1051 }
1052 return *this;
1053 }
1054
1070 inline void accessInternals(rtl_uString *** pInternalData,
1071 sal_Int32 ** pInternalCapacity)
1072 {
1073 *pInternalData = &pData;
1074 *pInternalCapacity = &nCapacity;
1075 }
1076
1077
1093 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1094 {
1095 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1096 return (ret < 0 ? ret : ret+fromIndex);
1097 }
1098
1110 sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
1111 {
1112 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1113 }
1114
1129 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
1130 {
1131 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1132 }
1133
1151 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1152 {
1153 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1154 str.pData->buffer, str.pData->length );
1155 return (ret < 0 ? ret : ret+fromIndex);
1156 }
1157
1164 template< typename T >
1165 typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1166 {
1167 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
1168 sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1169 pData->buffer + fromIndex, pData->length - fromIndex, literal,
1170 internal::ConstCharArrayDetector< T, void >::size - 1);
1171 return ret < 0 ? ret : ret + fromIndex;
1172 }
1173
1191 sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
1192 {
1193 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1194 str.pData->buffer, str.pData->length );
1195 }
1196
1216 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
1217 {
1218 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1219 str.pData->buffer, str.pData->length );
1220 }
1221
1227 template< typename T >
1228 typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const SAL_THROW(())
1229 {
1230 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
1231 return rtl_ustr_lastIndexOfAscii_WithLength(
1232 pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
1233 }
1234
1244 sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1245 {
1246 sal_Int32 index;
1247 for(index = 0; index < getLength() ; index++)
1248 {
1249 if(pData->buffer[ index ] != c)
1250 {
1251 break;
1252 }
1253 }
1254 if(index)
1255 {
1256 remove(0, index);
1257 }
1258 return index;
1259 }
1260
1270 sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1271 {
1272 sal_Int32 result = getLength();
1273 sal_Int32 index;
1274 for(index = getLength(); index > 0 ; index--)
1275 {
1276 if(pData->buffer[ index - 1 ] != c)
1277 {
1278 break;
1279 }
1280 }
1281 if(index < getLength())
1282 {
1283 truncate(index);
1284 }
1285 return result - getLength();
1286 }
1296 sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1297 {
1298 return stripStart(c) + stripEnd(c);
1299 }
1311 OUStringBuffer copy( sal_Int32 beginIndex ) const SAL_THROW(())
1312 {
1313 assert(beginIndex >= 0 && beginIndex <= getLength());
1314 return copy( beginIndex, getLength() - beginIndex );
1315 }
1316
1330 OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
1331 {
1332 assert(beginIndex >= 0 && beginIndex <= getLength());
1333 assert(count >= 0 && count <= getLength() - beginIndex);
1334 rtl_uString *pNew = 0;
1335 rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1336 return OUStringBuffer( pNew, count + 16 );
1337 }
1338
1339 #ifdef LIBO_INTERNAL_ONLY
1340 // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
1341 // even two buffers. It's intentional it returns OUString, just like the operator+ would in the fast variant.
1342 #ifndef RTL_FAST_STRING
1343
1347 friend OUString operator+( const OUStringBuffer& str1, const OUStringBuffer& str2 ) SAL_THROW(())
1348 {
1349 return OUString( str1.pData ).concat( str2.pData );
1350 }
1351 #endif
1352 #endif
1353
1354 private:
1355 OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1356 {
1357 pData = value;
1358 nCapacity = capacity;
1359 }
1360
1364 rtl_uString * pData;
1365
1369 sal_Int32 nCapacity;
1370 };
1371
1372 #ifdef RTL_FAST_STRING
1373
1376 template<>
1377 struct ToStringHelper< OUStringBuffer >
1378 {
1379 static int length( const OUStringBuffer& s ) { return s.getLength(); }
1380 static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1381 static const bool allowOStringConcat = false;
1382 static const bool allowOUStringConcat = true;
1383 };
1384 #endif
1385
1386 }
1387
1388 #ifdef RTL_STRING_UNITTEST
1389 namespace rtl
1390 {
1391 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1392 }
1393 #endif
1394
1395 #ifdef RTL_USING
1396 using ::rtl::OUStringBuffer;
1397 #endif
1398
1399 #endif // INCLUDED_RTL_USTRBUF_HXX
1400
1401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl_ustr_indexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
rtl::OUStringBuffer::truncate
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition: ustrbuf.hxx:1029
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:608
rtl_uString_new_WithLength
SAL_DLLPUBLIC void rtl_uString_new_WithLength(rtl_uString **newStr, sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_ustr_lastIndexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: ustrbuf.hxx:99
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix=10)
Inserts the string representation of the long argument into this string buffer.
Definition: ustrbuf.hxx:927
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const sal_Unicode *str)
Inserts the string representation of the char array argument into this string buffer.
Definition: ustrbuf.hxx:771
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustrbuf.hxx:1110
rtl::OUString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:386
RTL_USTR_MAX_VALUEOFDOUBLE
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition: ustrbuf.hxx:437
rtl::OUStringBuffer::stripStart
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1244
rtl_uStringbuffer_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_uStringbuffer_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
rtl_uStringbuffer_ensureCapacity
SAL_DLLPUBLIC void rtl_uStringbuffer_ensureCapacity(rtl_uString **This, sal_Int32 *capacity, sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: ustrbuf.hxx:125
rtl_ustr_indexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
rtl::OUStringBuffer::makeStringAndClear
OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: ustrbuf.hxx:235
rtl::OUStringBuffer::append
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition: ustrbuf.hxx:420
rtl::internal::Dummy
Definition: stringutils.hxx:67
rtl::OUStringBuffer::append
internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type append(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustrbuf.hxx:488
rtl_ustr_lastIndexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: ustrbuf.hxx:1216
rtl_ustr_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_ustr_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
stringconcat.hxx
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:136
diagnose.h
types.h
rtl::OUString::concat
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:1495
rtl_uStringbuffer_insertUtf32
SAL_DLLPUBLIC void rtl_uStringbuffer_insertUtf32(rtl_uString **pThis, sal_Int32 *capacity, sal_Int32 offset, sal_uInt32 c) SAL_THROW_EXTERN_C()
Inserts a single UTF-32 character into this string buffer.
rtl::OUStringBuffer::replace
OUStringBuffer & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition: ustrbuf.hxx:1045
rtl_ustr_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:832
RTL_USTR_MAX_VALUEOFFLOAT
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
rtl::OUStringBuffer::stripEnd
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1270
rtl::OUStringBuffer::insertUtf32
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition: ustrbuf.hxx:996
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:398
RTL_USTR_MAX_VALUEOFBOOLEAN
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:591
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:479
rtl::OUStringBuffer::toString
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:405
rtl::OUStringBuffer::append
OUStringBuffer & append(const sal_Unicode *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:475
rtl::OUStringBuffer::append
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: ustrbuf.hxx:694
rtl_uString_newFromLiteral
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: ustrbuf.hxx:1129
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1330
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const sal_Char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:531
rtl_uStringbuffer_insert
SAL_DLLPUBLIC void rtl_uStringbuffer_insert(rtl_uString **This, sal_Int32 *capacity, sal_Int32 offset, const sal_Unicode *str, sal_Int32 len)
Inserts the string representation of the str array argument into this string buffer.
rtl_ustr_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:856
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition: ustrbuf.hxx:659
rtl_uStringbuffer_insert_ascii
SAL_DLLPUBLIC void rtl_uStringbuffer_insert_ascii(rtl_uString **This, sal_Int32 *capacity, sal_Int32 offset, const sal_Char *str, sal_Int32 len)
Inserts the 8-Bit ASCII string representation of the str array argument into this string buffer...
rtl::OUStringBuffer::append
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: ustrbuf.hxx:711
rtl_ustr_lastIndexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
rtl::OUStringBuffer::append
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:457
rtl_uStringbuffer_newFromStringBuffer
SAL_DLLPUBLIC sal_Int32 rtl_uStringbuffer_newFromStringBuffer(rtl_uString **newStr, sal_Int32 capacity, rtl_uString *oldStr)
Allocates a new String that contains the same sequence of characters as the string argument...
rtl::OUStringBuffer::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustrbuf.hxx:1191
rtl::internal::Enable
Definition: stringutils.hxx:170
rtl::OUStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:247
rtl::internal::SalUnicodePtrDetector
Definition: stringutils.hxx:151
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const sal_Unicode *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: ustrbuf.hxx:794
rtl_ustr_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl::OUStringBuffer::append
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:573
rtl::OUStringBuffer::insert
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:951
rtl_uString_release
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
RTL_USTR_MAX_VALUEOFINT32
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
rtl_uString_alloc
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(const OUString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: ustrbuf.hxx:142
rtl::OUStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:314
rtl_uStringBuffer_makeStringAndClear
SAL_DLLPUBLIC rtl_uString * rtl_uStringBuffer_makeStringAndClear(rtl_uString **ppThis, sal_Int32 *nCapacity)
Returns an immutable rtl_uString object, while clearing the string buffer.
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:376
rtl::OUStringBuffer::accessInternals
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1070
rtl::OUStringBuffer::copy
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1311
rtl_uStringbuffer_remove
SAL_DLLPUBLIC void rtl_uStringbuffer_remove(rtl_uString **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
rtl::OUStringBuffer::insert
internal::ConstCharArrayDetector< T, OUStringBuffer & >::Type insert(sal_Int32 offset, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustrbuf.hxx:807
config.h
rtl::OUStringBuffer::append
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:626
rtl::internal::ConstCharArrayDetector
Definition: stringutils.hxx:110
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
Definition: ustrbuf.hxx:150
rtl::OUStringBuffer::insert
OUStringBuffer & 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: ustrbuf.hxx:902
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
rtl::OUStringBuffer::indexOf
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustrbuf.hxx:1151
rtl::OUStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:92
rtl::OUStringBuffer::indexOf
internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustrbuf.hxx:1165
rtl::OUStringBuffer::appendUtf32
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:730
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:975
rtl::internal::CharPtrDetector
Definition: stringutils.hxx:69
rtl::OUStringBuffer::getStr
const sal_Unicode * getStr() const
Return a null terminated unicode character array.
Definition: ustrbuf.hxx:369
RTL_USTR_MAX_VALUEOFINT64
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:1003
rtl_ustr_getLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:642
string.h
sal_Char
char sal_Char
Definition: types.h:124
rtl::OUStringBuffer::OUStringBuffer
OUStringBuffer(const OUStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: ustrbuf.hxx:112
rtl::OUStringBuffer::appendAscii
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:554
rtl::OUStringBuffer::ensureCapacity
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: ustrbuf.hxx:291
rtl_str_getLength
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
rtl_ustr_indexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:878
rtl::OUStringBuffer::strip
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1296
ustrbuf.h
stringutils.hxx
rtl::OUStringBuffer::~OUStringBuffer
~OUStringBuffer()
Release the string data.
Definition: ustrbuf.hxx:222
rtl::OUStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:275
rtl::OUStringBuffer::append
OUStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: ustrbuf.hxx:677
rtl::OUStringBuffer::indexOf
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: ustrbuf.hxx:1093
rtl::OUStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:260
rtl::OUStringBuffer::lastIndexOf
internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustrbuf.hxx:1228
rtl::OUString::getStr
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:408
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358
ustring.hxx
rtl::OUStringBuffer::insert
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:749