LibreOffice
LibreOffice 5.2 SDK C/C++ API Reference
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 <cstddef>
27 #include <string.h>
28 
29 #include <rtl/ustrbuf.h>
30 #include <rtl/ustring.hxx>
31 #include <rtl/stringutils.hxx>
32 #include <sal/types.h>
33 
34 #ifdef LIBO_INTERNAL_ONLY // "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 
57 {
58 public:
64  : pData(NULL)
65  , nCapacity( 16 )
66  {
67  rtl_uString_new_WithLength( &pData, nCapacity );
68  }
69 
76  OUStringBuffer( const OUStringBuffer & value )
77  : pData(NULL)
78  , nCapacity( value.nCapacity )
79  {
80  rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
81  }
82 
89  explicit OUStringBuffer(int length)
90  : pData(NULL)
91  , nCapacity( length )
92  {
93  rtl_uString_new_WithLength( &pData, length );
94  }
95 #if __cplusplus >= 201103L
96  explicit OUStringBuffer(unsigned int length)
97  : OUStringBuffer(static_cast<int>(length))
98  {
99  }
100 #if SAL_TYPES_SIZEOFLONG == 4
101  // additional overloads for sal_Int32 sal_uInt32
102  explicit OUStringBuffer(long length)
103  : OUStringBuffer(static_cast<int>(length))
104  {
105  }
106  explicit OUStringBuffer(unsigned long length)
107  : OUStringBuffer(static_cast<int>(length))
108  {
109  }
110 #endif
111  // avoid obvious bugs
112  explicit OUStringBuffer(char) = delete;
113  explicit OUStringBuffer(sal_Unicode) = delete;
114 #endif
115 
126  OUStringBuffer(const OUString& value)
127  : pData(NULL)
128  , nCapacity( value.getLength() + 16 )
129  {
130  rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
131  }
132 
133  template< typename T >
135  : pData(NULL)
136  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
137  {
138  assert(
141  &pData,
144 #ifdef RTL_STRING_UNITTEST
145  rtl_string_unittest_const_literal = true;
146 #endif
147  }
148 
149 #ifdef RTL_STRING_UNITTEST
150 
154  template< typename T >
156  {
157  pData = NULL;
158  nCapacity = 10;
159  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
160  rtl_string_unittest_invalid_conversion = true;
161  }
166  template< typename T >
168  {
169  pData = NULL;
170  nCapacity = 10;
171  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
172  rtl_string_unittest_invalid_conversion = true;
173  }
174 #endif
175 
176 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
177 
181  template< typename T1, typename T2 >
182  OUStringBuffer( const OUStringConcat< T1, T2 >& c )
183  {
184  const sal_Int32 l = c.length();
185  nCapacity = l + 16;
186  pData = rtl_uString_alloc( nCapacity );
187  sal_Unicode* end = c.addData( pData->buffer );
188  *end = '\0';
189  pData->length = l;
190  // TODO realloc in case pData->>length is noticeably smaller than l ?
191  }
192 #endif
193 
195  OUStringBuffer& operator = ( const OUStringBuffer& value )
196  {
197  if (this != &value)
198  {
200  value.nCapacity,
201  value.pData);
202  nCapacity = value.nCapacity;
203  }
204  return *this;
205  }
206 
211  {
212  rtl_uString_release( pData );
213  }
214 
224  {
225  return OUString(
226  rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
227  SAL_NO_ACQUIRE );
228  }
229 
235  sal_Int32 getLength() const
236  {
237  return pData->length;
238  }
239 
248  bool isEmpty() const
249  {
250  return pData->length == 0;
251  }
252 
263  sal_Int32 getCapacity() const
264  {
265  return nCapacity;
266  }
267 
279  void ensureCapacity(sal_Int32 minimumCapacity)
280  {
281  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
282  }
283 
302  void setLength(sal_Int32 newLength)
303  {
304  assert(newLength >= 0);
305  // Avoid modifications if pData points to const empty string:
306  if( newLength != pData->length )
307  {
308  if( newLength > nCapacity )
309  rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
310  else
311  pData->buffer[newLength] = 0;
312  pData->length = newLength;
313  }
314  }
315 
329  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
330  sal_Unicode charAt( sal_Int32 index ) const
331  {
332  assert(index >= 0 && index < pData->length);
333  return pData->buffer[ index ];
334  }
335 
346  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
347  OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
348  {
349  assert(index >= 0 && index < pData->length);
350  pData->buffer[ index ] = ch;
351  return *this;
352  }
353 
357  const sal_Unicode* getStr() const { return pData->buffer; }
358 
368  sal_Unicode & operator [](sal_Int32 index)
369  {
370  assert(index >= 0 && index < pData->length);
371  return pData->buffer[index];
372  }
373 
383  const sal_Unicode & operator [](sal_Int32 index) const
384  {
385  assert(index >= 0 && index < pData->length);
386  return pData->buffer[index];
387  }
388 
393  const OUString toString() const
394  {
395  return OUString(pData->buffer, pData->length);
396  }
397 
409  {
410  return append( str.getStr(), str.getLength() );
411  }
412 
426  {
427  if(!str.isEmpty())
428  {
429  append( str.getStr(), str.getLength() );
430  }
431  return *this;
432  }
433 
446  {
447  return append( str, rtl_ustr_getLength( str ) );
448  }
449 
463  OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
464  {
465  assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
466  rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
467  return *this;
468  }
469 
475  template< typename T >
477  {
478  assert(
481  &pData, &nCapacity, getLength(),
484  return *this;
485  }
486 
487 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
488 
492  template< typename T1, typename T2 >
493  OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
494  {
495  sal_Int32 l = c.length();
496  if( l == 0 )
497  return *this;
498  l += pData->length;
499  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, l );
500  sal_Unicode* end = c.addData( pData->buffer + pData->length );
501  *end = '\0';
502  pData->length = l;
503  return *this;
504  }
505 #endif
506 
524  {
525  return appendAscii( str, rtl_str_getLength( str ) );
526  }
527 
546  OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
547  {
548  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
549  return *this;
550  }
551 
566  {
568  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
569  }
570 
572  // Pointer can be automatically converted to bool, which is unwanted here.
573  // Explicitly delete all pointer append() overloads to prevent this
574  // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
575  template< typename T >
576  typename libreoffice_internal::Enable< void,
578  append( T* ) SAL_DELETED_FUNCTION;
580 
581  // This overload is needed because OUString has a ctor from rtl_uString*, but
582  // the bool overload above would be preferred to the conversion.
586  OUStringBuffer & append(rtl_uString* str)
587  {
588  return append( OUString( str ));
589  }
590 
603  {
605  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
606  }
607 
621  {
622  assert(static_cast< unsigned char >(c) <= 0x7F);
623  return append(sal_Unicode(c));
624  }
625 
637  {
638  return append( &c, 1 );
639  }
640 
641 #if LIBO_INTERNAL_ONLY && \
642  (!defined SAL_W32 || defined __MINGW32__ || defined __clang__)
643  // cf. sal/types.h sal_Unicode
644  void append(sal_uInt16) = delete;
645 #endif
646 
659  OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
660  {
662  return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
663  }
664 
677  OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
678  {
680  return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
681  }
682 
695  {
697  return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
698  }
699 
711  OUStringBuffer & append(double d)
712  {
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  sal_Unicode * appendUninitialized(sal_Int32 length) {
750  sal_Int32 n = getLength();
751  rtl_uStringbuffer_insert(&pData, &nCapacity, n, NULL, length);
752  return pData->buffer + n;
753  }
754 
770  OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
771  {
772  return insert( offset, str.getStr(), str.getLength() );
773  }
774 
792  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
793  {
794  return insert( offset, str, rtl_ustr_getLength( str ) );
795  }
796 
815  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
816  {
817  assert( len == 0 || str != NULL ); // cannot assert that in rtl_uStringbuffer_insert
818  rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
819  return *this;
820  }
821 
827  template< typename T >
829  {
830  assert(
833  &pData, &nCapacity, offset,
836  return *this;
837  }
838 
856  OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
857  {
859  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
860  }
861 
881  OUStringBuffer & insert(sal_Int32 offset, bool b)
882  {
884  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
885  }
886 
905  OUStringBuffer & insert(sal_Int32 offset, char c)
906  {
907  sal_Unicode u = c;
908  return insert( offset, &u, 1 );
909  }
910 
927  OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
928  {
929  return insert( offset, &c, 1 );
930  }
931 
951  OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
952  {
954  return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
955  }
956 
976  OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
977  {
979  return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
980  }
981 
1000  OUStringBuffer insert(sal_Int32 offset, float f)
1001  {
1003  return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
1004  }
1005 
1024  OUStringBuffer & insert(sal_Int32 offset, double d)
1025  {
1027  return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
1028  }
1029 
1045  OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1046  rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1047  return *this;
1048  }
1049 
1062  OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1063  {
1064  rtl_uStringbuffer_remove( &pData, start, len );
1065  return *this;
1066  }
1067 
1078  OUStringBuffer & truncate( sal_Int32 start = 0 )
1079  {
1080  rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1081  return *this;
1082  }
1083 
1095  {
1096  sal_Int32 index = 0;
1097  while((index = indexOf(oldChar, index)) >= 0)
1098  {
1099  pData->buffer[ index ] = newChar;
1100  }
1101  return *this;
1102  }
1103 
1119  inline void accessInternals(rtl_uString *** pInternalData,
1120  sal_Int32 ** pInternalCapacity)
1121  {
1122  *pInternalData = &pData;
1123  *pInternalCapacity = &nCapacity;
1124  }
1125 
1126 
1142  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1143  {
1144  assert( fromIndex >= 0 && fromIndex <= pData->length );
1145  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1146  return (ret < 0 ? ret : ret+fromIndex);
1147  }
1148 
1160  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1161  {
1162  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1163  }
1164 
1179  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1180  {
1181  assert( fromIndex >= 0 && fromIndex <= pData->length );
1182  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1183  }
1184 
1202  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1203  {
1204  assert( fromIndex >= 0 && fromIndex <= pData->length );
1205  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1206  str.pData->buffer, str.pData->length );
1207  return (ret < 0 ? ret : ret+fromIndex);
1208  }
1209 
1216  template< typename T >
1217  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1218  {
1219  assert(
1221  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1222  pData->buffer + fromIndex, pData->length - fromIndex,
1225  return n < 0 ? n : n + fromIndex;
1226  }
1227 
1245  sal_Int32 lastIndexOf( const OUString & str ) const
1246  {
1247  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1248  str.pData->buffer, str.pData->length );
1249  }
1250 
1270  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1271  {
1272  assert( fromIndex >= 0 && fromIndex <= pData->length );
1273  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1274  str.pData->buffer, str.pData->length );
1275  }
1276 
1282  template< typename T >
1284  {
1285  assert(
1288  pData->buffer, pData->length,
1291  }
1292 
1302  sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1303  {
1304  sal_Int32 index;
1305  for(index = 0; index < getLength() ; index++)
1306  {
1307  if(pData->buffer[ index ] != c)
1308  {
1309  break;
1310  }
1311  }
1312  if(index)
1313  {
1314  remove(0, index);
1315  }
1316  return index;
1317  }
1318 
1328  sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1329  {
1330  sal_Int32 result = getLength();
1331  sal_Int32 index;
1332  for(index = getLength(); index > 0 ; index--)
1333  {
1334  if(pData->buffer[ index - 1 ] != c)
1335  {
1336  break;
1337  }
1338  }
1339  if(index < getLength())
1340  {
1341  truncate(index);
1342  }
1343  return result - getLength();
1344  }
1354  sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1355  {
1356  return stripStart(c) + stripEnd(c);
1357  }
1369  OUStringBuffer copy( sal_Int32 beginIndex ) const
1370  {
1371  return copy( beginIndex, getLength() - beginIndex );
1372  }
1373 
1387  OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1388  {
1389  assert(beginIndex >= 0 && beginIndex <= getLength());
1390  assert(count >= 0 && count <= getLength() - beginIndex);
1391  rtl_uString *pNew = NULL;
1392  rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1393  return OUStringBuffer( pNew, count + 16 );
1394  }
1395 
1396 private:
1397  OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1398  {
1399  pData = value;
1400  nCapacity = capacity;
1401  }
1402 
1406  rtl_uString * pData;
1407 
1411  sal_Int32 nCapacity;
1412 };
1413 
1414 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1415 
1418 template<>
1419 struct ToStringHelper< OUStringBuffer >
1420  {
1421  static int length( const OUStringBuffer& s ) { return s.getLength(); }
1422  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1423  static const bool allowOStringConcat = false;
1424  static const bool allowOUStringConcat = true;
1425  };
1426 #endif
1427 
1428 }
1429 
1430 #ifdef RTL_STRING_UNITTEST
1431 namespace rtl
1432 {
1433 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1434 }
1435 #endif
1436 
1437 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1438 using ::rtl::OUStringBuffer;
1439 #endif
1440 
1441 #endif // INCLUDED_RTL_USTRBUF_HXX
1442 
1443 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUStringBuffer(const OUString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: ustrbuf.hxx:126
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:302
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1369
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:564
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:542
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1387
char sal_Char
A legacy synonym for char.
Definition: types.h:130
libreoffice_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:476
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:905
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:730
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...
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:445
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:1024
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
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:1245
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
const sal_Unicode * getStr() const
Return a null terminated unicode character array.
Definition: ustrbuf.hxx:357
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:235
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:636
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_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.
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:565
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:1000
OUStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: ustrbuf.hxx:134
OUStringBuffer(const OUStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: ustrbuf.hxx:76
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.
Definition: stringutils.hxx:245
libreoffice_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:1283
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1354
sal_Unicode * appendUninitialized(sal_Int32 length)
Unsafe way to make space for a fixed amount of characters to be appended into this OUStringBuffer...
Definition: ustrbuf.hxx:749
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1119
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:1142
OUStringBuffer & append(rtl_uString *str)
Definition: ustrbuf.hxx:586
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:248
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.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:620
OUStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: ustrbuf.hxx:881
libreoffice_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:1217
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:951
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:770
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:1202
unsigned char sal_Bool
Definition: types.h:48
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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.
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: ustrbuf.hxx:63
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
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:792
Definition: stringutils.hxx:119
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:546
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: ustrbuf.hxx:279
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:927
sal_uInt16 sal_Unicode
Definition: types.h:155
~OUStringBuffer()
Release the string data.
Definition: ustrbuf.hxx:210
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:263
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
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...
OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: ustrbuf.hxx:223
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition: ustrbuf.hxx:408
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.
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:1270
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 & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition: ustrbuf.hxx:1078
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:602
Definition: bootstrap.hxx:29
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
definition of a no acquire enum for ctors
Definition: types.h:388
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.
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:509
OUStringBuffer & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition: ustrbuf.hxx:1094
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:856
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1328
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:976
SAL_DLLPUBLIC void rtl_uStringbuffer_remove(rtl_uString **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition: ustrbuf.hxx:1045
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:1160
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition: ustrbuf.hxx:425
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:393
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:463
Definition: stringutils.hxx:117
libreoffice_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:828
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1302
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.
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: ustrbuf.hxx:694
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.
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:1179
OUStringBuffer & appendAscii(const sal_Char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:523
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
OUStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: ustrbuf.hxx:89
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: ustrbuf.hxx:711
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.
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:56
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.
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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:815
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:1003
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.
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.