LibreOffice
LibreOffice 4.1 SDK C/C++ API Reference
 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 _RTL_USTRBUF_HXX_
21 #define _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 
93 {
94 public:
100  : pData(NULL)
101  , nCapacity( 16 )
102  {
103  rtl_uString_new_WithLength( &pData, nCapacity );
104  }
105 
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 >
151  : pData(NULL)
152  , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
153  {
154  assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
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 >
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  {
212  value.nCapacity,
213  value.pData);
214  nCapacity = value.nCapacity;
215  }
216  return *this;
217  }
218 
223  {
224  rtl_uString_release( pData );
225  }
226 
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 
390  const OUString toString() const
391  {
392  return OUString(pData->buffer, pData->length);
393  }
394 
406  {
407  return append( str.getStr(), str.getLength() );
408  }
409 
423  {
424  if(str.getLength() > 0)
425  {
426  append( str.getStr(), str.getLength() );
427  }
428  return *this;
429  }
430 
443  {
444  return append( str, rtl_ustr_getLength( str ) );
445  }
446 
460  OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
461  {
462  // insert behind the last character
463  rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
464  return *this;
465  }
466 
472  template< typename T >
474  {
475  assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
476  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
478  return *this;
479  }
480 
481 #ifdef RTL_FAST_STRING
482 
486  template< typename T1, typename T2 >
487  OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
488  {
489  const int l = c.length();
490  if( l == 0 )
491  return *this;
492  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
493  sal_Unicode* end = c.addData( pData->buffer + pData->length );
494  *end = '\0';
495  pData->length = end - pData->buffer;
496  return *this;
497  }
498 #endif
499 
517  {
518  return appendAscii( str, rtl_str_getLength( str ) );
519  }
520 
539  OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
540  {
541  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
542  return *this;
543  }
544 
559  {
561  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
562  }
563 
564  // Pointer can be automatically converted to bool, which is unwanted here.
565  // Explicitly delete all pointer append() overloads to prevent this
566  // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
567  template< typename T >
568  typename internal::Enable< void,
570  append( T* ) SAL_DELETED_FUNCTION;
571 
572  // This overload is needed because OUString has a ctor from rtl_uString*, but
573  // the bool overload above would be prefered to the conversion.
577  OUStringBuffer & append(rtl_uString* str)
578  {
579  return append( OUString( str ));
580  }
581 
594  {
596  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
597  }
598 
612  {
613  assert(static_cast< unsigned char >(c) <= 0x7F);
614  return append(sal_Unicode(c));
615  }
616 
628  {
629  return append( &c, 1 );
630  }
631 
644  OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
645  {
647  return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
648  }
649 
662  OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
663  {
665  return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
666  }
667 
680  {
682  return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
683  }
684 
696  OUStringBuffer & append(double d)
697  {
699  return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
700  }
701 
715  OUStringBuffer & appendUtf32(sal_uInt32 c) {
716  return insertUtf32(getLength(), c);
717  }
718 
734  OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
735  {
736  return insert( offset, str.getStr(), str.getLength() );
737  }
738 
756  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
757  {
758  return insert( offset, str, rtl_ustr_getLength( str ) );
759  }
760 
779  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
780  {
781  // insert behind the last character
782  rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
783  return *this;
784  }
785 
791  template< typename T >
793  {
794  assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
795  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
797  return *this;
798  }
799 
817  OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
818  {
820  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
821  }
822 
841  OUStringBuffer & insert(sal_Int32 offset, char c)
842  {
843  sal_Unicode u = c;
844  return insert( offset, &u, 1 );
845  }
846 
863  OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
864  {
865  return insert( offset, &c, 1 );
866  }
867 
887  OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
888  {
890  return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
891  }
892 
912  OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
913  {
915  return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
916  }
917 
936  OUStringBuffer insert(sal_Int32 offset, float f)
937  {
939  return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
940  }
941 
960  OUStringBuffer & insert(sal_Int32 offset, double d)
961  {
963  return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
964  }
965 
981  OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
982  rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
983  return *this;
984  }
985 
998  OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
999  {
1000  rtl_uStringbuffer_remove( &pData, start, len );
1001  return *this;
1002  }
1003 
1014  OUStringBuffer & truncate( sal_Int32 start = 0 )
1015  {
1016  rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1017  return *this;
1018  }
1019 
1031  {
1032  sal_Int32 index = 0;
1033  while((index = indexOf(oldChar, index)) >= 0)
1034  {
1035  pData->buffer[ index ] = newChar;
1036  }
1037  return *this;
1038  }
1039 
1055  inline void accessInternals(rtl_uString *** pInternalData,
1056  sal_Int32 ** pInternalCapacity)
1057  {
1058  *pInternalData = &pData;
1059  *pInternalCapacity = &nCapacity;
1060  }
1061 
1062 
1078  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1079  {
1080  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1081  return (ret < 0 ? ret : ret+fromIndex);
1082  }
1083 
1095  sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
1096  {
1097  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1098  }
1099 
1114  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
1115  {
1116  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1117  }
1118 
1136  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1137  {
1138  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1139  str.pData->buffer, str.pData->length );
1140  return (ret < 0 ? ret : ret+fromIndex);
1141  }
1142 
1149  template< typename T >
1150  typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
1151  {
1152  assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
1153  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1154  pData->buffer + fromIndex, pData->length - fromIndex, literal,
1156  return ret < 0 ? ret : ret + fromIndex;
1157  }
1158 
1176  sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
1177  {
1178  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1179  str.pData->buffer, str.pData->length );
1180  }
1181 
1201  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
1202  {
1203  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1204  str.pData->buffer, str.pData->length );
1205  }
1206 
1212  template< typename T >
1214  {
1215  assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
1217  pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
1218  }
1219 
1229  sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1230  {
1231  sal_Int32 index;
1232  for(index = 0; index < getLength() ; index++)
1233  {
1234  if(pData->buffer[ index ] != c)
1235  {
1236  break;
1237  }
1238  }
1239  if(index)
1240  {
1241  remove(0, index);
1242  }
1243  return index;
1244  }
1245 
1255  sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1256  {
1257  sal_Int32 result = getLength();
1258  sal_Int32 index;
1259  for(index = getLength(); index > 0 ; index--)
1260  {
1261  if(pData->buffer[ index - 1 ] != c)
1262  {
1263  break;
1264  }
1265  }
1266  if(index < getLength())
1267  {
1268  truncate(index);
1269  }
1270  return result - getLength();
1271  }
1281  sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1282  {
1283  return stripStart(c) + stripEnd(c);
1284  }
1296  OUStringBuffer copy( sal_Int32 beginIndex ) const SAL_THROW(())
1297  {
1298  assert(beginIndex >= 0 && beginIndex <= getLength());
1299  return copy( beginIndex, getLength() - beginIndex );
1300  }
1301 
1315  OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
1316  {
1317  assert(beginIndex >= 0 && beginIndex <= getLength());
1318  assert(count >= 0 && count <= getLength() - beginIndex);
1319  rtl_uString *pNew = 0;
1320  rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1321  return OUStringBuffer( pNew, count + 16 );
1322  }
1323 
1324 #ifdef LIBO_INTERNAL_ONLY
1325  // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
1326  // even two buffers. It's intentional it returns OUString, just like the operator+ would in the fast variant.
1327 #ifndef RTL_FAST_STRING
1328 
1332  friend OUString operator+( const OUStringBuffer& str1, const OUStringBuffer& str2 ) SAL_THROW(())
1333  {
1334  return OUString( str1.pData ).concat( str2.pData );
1335  }
1336 #endif
1337 #endif
1338 
1339 private:
1340  OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1341  {
1342  pData = value;
1343  nCapacity = capacity;
1344  }
1345 
1349  rtl_uString * pData;
1350 
1354  sal_Int32 nCapacity;
1355 };
1356 
1357 #ifdef RTL_FAST_STRING
1358 
1361 template<>
1362 struct ToStringHelper< OUStringBuffer >
1363  {
1364  static int length( const OUStringBuffer& s ) { return s.getLength(); }
1365  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1366  static const bool allowOStringConcat = false;
1367  static const bool allowOUStringConcat = true;
1368  };
1369 #endif
1370 
1371 }
1372 
1373 #ifdef RTL_STRING_UNITTEST
1374 namespace rtl
1375 {
1376 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1377 }
1378 #endif
1379 
1380 #ifdef RTL_USING
1381 using ::rtl::OUStringBuffer;
1382 #endif
1383 
1384 #endif /* _RTL_USTRBUF_HXX_ */
1385 
1386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
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.
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition: ustrbuf.hxx:1014
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:593
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.
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.
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: ustrbuf.hxx:99
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:87
char sal_Char
Definition: types.h:122
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:912
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:756
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_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.
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:1095
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:408
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition: ustrbuf.hxx:422
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1229
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:356
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:561
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
OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: ustrbuf.hxx:235
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition: ustrbuf.hxx:405
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
Definition: stringutils.hxx:67
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:473
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.
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:1201
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.
OUStringBuffer & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition: ustrbuf.hxx:1030
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:817
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1255
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition: ustrbuf.hxx:981
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
definition of a no acquire enum for ctors
Definition: types.h:374
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:390
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:460
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: ustrbuf.hxx:679
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:1114
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1315
OUStringBuffer & appendAscii(const sal_Char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:516
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:841
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.
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:644
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: ustrbuf.hxx:696
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:442
sal_uInt16 sal_Unicode
Definition: types.h:134
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:1176
Definition: stringutils.hxx:170
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...
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:247
Definition: stringutils.hxx:151
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...
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:779
SAL_DLLPUBLIC void rtl_uStringbuffer_remove(rtl_uString **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:558
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:1003
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:936
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.
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
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:314
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:477
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1055
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1296
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:792
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:611
Definition: stringutils.hxx:110
OUStringBuffer(T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
Definition: ustrbuf.hxx:150
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:887
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:1136
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.
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:92
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:1150
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:715
unsigned char sal_Bool
Definition: types.h:37
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:960
Definition: stringutils.hxx:69
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
const sal_Unicode * getStr() const
Return a null terminated unicode character array.
Definition: ustrbuf.hxx:369
SAL_DLLPUBLIC rtl_uString * rtl_uStringBuffer_makeStringAndClear(rtl_uString **ppThis, sal_Int32 *nCapacity)
Returns an immutable rtl_uString object, while clearing the string buffer.
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:627
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.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
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
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:539
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: ustrbuf.hxx:291
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:863
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1281
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.
~OUStringBuffer()
Release the string data.
Definition: ustrbuf.hxx:222
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:275
OUStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: ustrbuf.hxx:662
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:1078
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:260
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:1213
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:430
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.
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:734