LibreOffice
LibreOffice 5.1 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 <string.h>
27 
28 #include <rtl/ustrbuf.h>
29 #include <rtl/ustring.hxx>
30 #include <rtl/stringutils.hxx>
31 #include <sal/types.h>
32 
33 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
34 #include <rtl/stringconcat.hxx>
35 #endif
36 
37 // The unittest uses slightly different code to help check that the proper
38 // calls are made. The class is put into a different namespace to make
39 // sure the compiler generates a different (if generating also non-inline)
40 // copy of the function and does not merge them together. The class
41 // is "brought" into the proper rtl namespace by a typedef below.
42 #ifdef RTL_STRING_UNITTEST
43 #define rtl rtlunittest
44 #endif
45 
46 namespace rtl
47 {
48 
49 #ifdef RTL_STRING_UNITTEST
50 #undef rtl
51 #endif
52 
56 {
57 public:
63  : pData(NULL)
64  , nCapacity( 16 )
65  {
66  rtl_uString_new_WithLength( &pData, nCapacity );
67  }
68 
75  OUStringBuffer( const OUStringBuffer & value )
76  : pData(NULL)
77  , nCapacity( value.nCapacity )
78  {
79  rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
80  }
81 
88  explicit OUStringBuffer(int length)
89  : pData(NULL)
90  , nCapacity( length )
91  {
92  rtl_uString_new_WithLength( &pData, length );
93  }
94 #if __cplusplus >= 201103L
95  explicit OUStringBuffer(unsigned int length)
96  : OUStringBuffer(static_cast<int>(length))
97  {
98  }
99 #if SAL_TYPES_SIZEOFLONG == 4
100  // additional overloads for sal_Int32 sal_uInt32
101  explicit OUStringBuffer(long length)
102  : OUStringBuffer(static_cast<int>(length))
103  {
104  }
105  explicit OUStringBuffer(unsigned long length)
106  : OUStringBuffer(static_cast<int>(length))
107  {
108  }
109 #endif
110  // avoid obvious bugs
111  explicit OUStringBuffer(char) = delete;
112  explicit OUStringBuffer(sal_Unicode) = delete;
113 #endif
114 
125  OUStringBuffer(const OUString& value)
126  : pData(NULL)
127  , nCapacity( value.getLength() + 16 )
128  {
129  rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
130  }
131 
132  template< typename T >
134  : pData(NULL)
135  , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
136  {
137  assert(
140  &pData,
143 #ifdef RTL_STRING_UNITTEST
144  rtl_string_unittest_const_literal = true;
145 #endif
146  }
147 
148 #ifdef RTL_STRING_UNITTEST
149 
153  template< typename T >
155  {
156  pData = 0;
157  nCapacity = 10;
158  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
159  rtl_string_unittest_invalid_conversion = true;
160  }
165  template< typename T >
166  OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
167  {
168  pData = 0;
169  nCapacity = 10;
170  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
171  rtl_string_unittest_invalid_conversion = true;
172  }
173 #endif
174 
175 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
176 
180  template< typename T1, typename T2 >
181  OUStringBuffer( const OUStringConcat< T1, T2 >& c )
182  {
183  const sal_Int32 l = c.length();
184  nCapacity = l + 16;
185  pData = rtl_uString_alloc( nCapacity );
186  sal_Unicode* end = c.addData( pData->buffer );
187  *end = '\0';
188  pData->length = l;
189  // TODO realloc in case pData->>length is noticeably smaller than l ?
190  }
191 #endif
192 
194  OUStringBuffer& operator = ( const OUStringBuffer& value )
195  {
196  if (this != &value)
197  {
199  value.nCapacity,
200  value.pData);
201  nCapacity = value.nCapacity;
202  }
203  return *this;
204  }
205 
210  {
211  rtl_uString_release( pData );
212  }
213 
223  {
224  return OUString(
225  rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
226  SAL_NO_ACQUIRE );
227  }
228 
234  sal_Int32 getLength() const
235  {
236  return pData->length;
237  }
238 
247  bool isEmpty() const
248  {
249  return pData->length == 0;
250  }
251 
262  sal_Int32 getCapacity() const
263  {
264  return nCapacity;
265  }
266 
278  void ensureCapacity(sal_Int32 minimumCapacity)
279  {
280  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
281  }
282 
301  void setLength(sal_Int32 newLength)
302  {
303  assert(newLength >= 0);
304  // Avoid modifications if pData points to const empty string:
305  if( newLength != pData->length )
306  {
307  if( newLength > nCapacity )
308  rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
309  else
310  pData->buffer[newLength] = 0;
311  pData->length = newLength;
312  }
313  }
314 
328  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
329  sal_Unicode charAt( sal_Int32 index ) const
330  {
331  assert(index >= 0 && index < pData->length);
332  return pData->buffer[ index ];
333  }
334 
345  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
346  OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
347  {
348  assert(index >= 0 && index < pData->length);
349  pData->buffer[ index ] = ch;
350  return *this;
351  }
352 
356  const sal_Unicode* getStr() const { return pData->buffer; }
357 
367  sal_Unicode & operator [](sal_Int32 index)
368  {
369  assert(index >= 0 && index < pData->length);
370  return pData->buffer[index];
371  }
372 
382  const sal_Unicode & operator [](sal_Int32 index) const
383  {
384  assert(index >= 0 && index < pData->length);
385  return pData->buffer[index];
386  }
387 
392  const OUString toString() const
393  {
394  return OUString(pData->buffer, pData->length);
395  }
396 
408  {
409  return append( str.getStr(), str.getLength() );
410  }
411 
425  {
426  if(!str.isEmpty())
427  {
428  append( str.getStr(), str.getLength() );
429  }
430  return *this;
431  }
432 
445  {
446  return append( str, rtl_ustr_getLength( str ) );
447  }
448 
462  OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
463  {
464  assert( len == 0 || str != 0 ); // cannot assert that in rtl_uStringbuffer_insert
465  rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
466  return *this;
467  }
468 
474  template< typename T >
476  {
477  assert(
480  &pData, &nCapacity, getLength(),
483  return *this;
484  }
485 
486 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
487 
491  template< typename T1, typename T2 >
492  OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
493  {
494  sal_Int32 l = c.length();
495  if( l == 0 )
496  return *this;
497  l += pData->length;
498  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, l );
499  sal_Unicode* end = c.addData( pData->buffer + pData->length );
500  *end = '\0';
501  pData->length = l;
502  return *this;
503  }
504 #endif
505 
523  {
524  return appendAscii( str, rtl_str_getLength( str ) );
525  }
526 
545  OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
546  {
547  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
548  return *this;
549  }
550 
565  {
567  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
568  }
569 
571  // Pointer can be automatically converted to bool, which is unwanted here.
572  // Explicitly delete all pointer append() overloads to prevent this
573  // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
574  template< typename T >
575  typename libreoffice_internal::Enable< void,
577  append( T* ) SAL_DELETED_FUNCTION;
579 
580  // This overload is needed because OUString has a ctor from rtl_uString*, but
581  // the bool overload above would be preferred to the conversion.
585  OUStringBuffer & append(rtl_uString* str)
586  {
587  return append( OUString( str ));
588  }
589 
602  {
604  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
605  }
606 
620  {
621  assert(static_cast< unsigned char >(c) <= 0x7F);
622  return append(sal_Unicode(c));
623  }
624 
636  {
637  return append( &c, 1 );
638  }
639 
652  OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
653  {
655  return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
656  }
657 
670  OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
671  {
673  return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
674  }
675 
688  {
690  return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
691  }
692 
704  OUStringBuffer & append(double d)
705  {
707  return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
708  }
709 
723  OUStringBuffer & appendUtf32(sal_uInt32 c) {
724  return insertUtf32(getLength(), c);
725  }
726 
742  sal_Unicode * appendUninitialized(sal_Int32 length) {
743  sal_Int32 n = getLength();
744  rtl_uStringbuffer_insert(&pData, &nCapacity, n, 0, length);
745  return pData->buffer + n;
746  }
747 
763  OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
764  {
765  return insert( offset, str.getStr(), str.getLength() );
766  }
767 
785  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
786  {
787  return insert( offset, str, rtl_ustr_getLength( str ) );
788  }
789 
808  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
809  {
810  assert( len == 0 || str != 0 ); // cannot assert that in rtl_uStringbuffer_insert
811  rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
812  return *this;
813  }
814 
820  template< typename T >
822  {
823  assert(
826  &pData, &nCapacity, offset,
829  return *this;
830  }
831 
849  OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
850  {
852  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
853  }
854 
874  OUStringBuffer & insert(sal_Int32 offset, bool b)
875  {
877  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
878  }
879 
898  OUStringBuffer & insert(sal_Int32 offset, char c)
899  {
900  sal_Unicode u = c;
901  return insert( offset, &u, 1 );
902  }
903 
920  OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
921  {
922  return insert( offset, &c, 1 );
923  }
924 
944  OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
945  {
947  return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
948  }
949 
969  OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
970  {
972  return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
973  }
974 
993  OUStringBuffer insert(sal_Int32 offset, float f)
994  {
996  return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
997  }
998 
1017  OUStringBuffer & insert(sal_Int32 offset, double d)
1018  {
1020  return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
1021  }
1022 
1038  OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1039  rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1040  return *this;
1041  }
1042 
1055  OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1056  {
1057  rtl_uStringbuffer_remove( &pData, start, len );
1058  return *this;
1059  }
1060 
1071  OUStringBuffer & truncate( sal_Int32 start = 0 )
1072  {
1073  rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1074  return *this;
1075  }
1076 
1088  {
1089  sal_Int32 index = 0;
1090  while((index = indexOf(oldChar, index)) >= 0)
1091  {
1092  pData->buffer[ index ] = newChar;
1093  }
1094  return *this;
1095  }
1096 
1112  inline void accessInternals(rtl_uString *** pInternalData,
1113  sal_Int32 ** pInternalCapacity)
1114  {
1115  *pInternalData = &pData;
1116  *pInternalCapacity = &nCapacity;
1117  }
1118 
1119 
1135  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1136  {
1137  assert( fromIndex >= 0 && fromIndex <= pData->length );
1138  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1139  return (ret < 0 ? ret : ret+fromIndex);
1140  }
1141 
1153  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1154  {
1155  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1156  }
1157 
1172  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1173  {
1174  assert( fromIndex >= 0 && fromIndex <= pData->length );
1175  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1176  }
1177 
1195  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1196  {
1197  assert( fromIndex >= 0 && fromIndex <= pData->length );
1198  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1199  str.pData->buffer, str.pData->length );
1200  return (ret < 0 ? ret : ret+fromIndex);
1201  }
1202 
1209  template< typename T >
1210  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1211  {
1212  assert(
1214  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1215  pData->buffer + fromIndex, pData->length - fromIndex,
1218  return n < 0 ? n : n + fromIndex;
1219  }
1220 
1238  sal_Int32 lastIndexOf( const OUString & str ) const
1239  {
1240  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1241  str.pData->buffer, str.pData->length );
1242  }
1243 
1263  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1264  {
1265  assert( fromIndex >= 0 && fromIndex <= pData->length );
1266  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1267  str.pData->buffer, str.pData->length );
1268  }
1269 
1275  template< typename T >
1277  {
1278  assert(
1281  pData->buffer, pData->length,
1284  }
1285 
1295  sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1296  {
1297  sal_Int32 index;
1298  for(index = 0; index < getLength() ; index++)
1299  {
1300  if(pData->buffer[ index ] != c)
1301  {
1302  break;
1303  }
1304  }
1305  if(index)
1306  {
1307  remove(0, index);
1308  }
1309  return index;
1310  }
1311 
1321  sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1322  {
1323  sal_Int32 result = getLength();
1324  sal_Int32 index;
1325  for(index = getLength(); index > 0 ; index--)
1326  {
1327  if(pData->buffer[ index - 1 ] != c)
1328  {
1329  break;
1330  }
1331  }
1332  if(index < getLength())
1333  {
1334  truncate(index);
1335  }
1336  return result - getLength();
1337  }
1347  sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1348  {
1349  return stripStart(c) + stripEnd(c);
1350  }
1362  OUStringBuffer copy( sal_Int32 beginIndex ) const
1363  {
1364  return copy( beginIndex, getLength() - beginIndex );
1365  }
1366 
1380  OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1381  {
1382  assert(beginIndex >= 0 && beginIndex <= getLength());
1383  assert(count >= 0 && count <= getLength() - beginIndex);
1384  rtl_uString *pNew = 0;
1385  rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1386  return OUStringBuffer( pNew, count + 16 );
1387  }
1388 
1389 private:
1390  OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1391  {
1392  pData = value;
1393  nCapacity = capacity;
1394  }
1395 
1399  rtl_uString * pData;
1400 
1404  sal_Int32 nCapacity;
1405 };
1406 
1407 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1408 
1411 template<>
1412 struct ToStringHelper< OUStringBuffer >
1413  {
1414  static int length( const OUStringBuffer& s ) { return s.getLength(); }
1415  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1416  static const bool allowOStringConcat = false;
1417  static const bool allowOUStringConcat = true;
1418  };
1419 #endif
1420 
1421 }
1422 
1423 #ifdef RTL_STRING_UNITTEST
1424 namespace rtl
1425 {
1426 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1427 }
1428 #endif
1429 
1430 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1431 using ::rtl::OUStringBuffer;
1432 #endif
1433 
1434 #endif // INCLUDED_RTL_USTRBUF_HXX
1435 
1436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
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:1210
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:944
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:849
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:821
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1321
~OUStringBuffer()
Release the string data.
Definition: ustrbuf.hxx:209
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 void rtl_uStringbuffer_remove(rtl_uString **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
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:742
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:262
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
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:475
OUStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: ustrbuf.hxx:88
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition: ustrbuf.hxx:1038
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
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...
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:404
const sal_Unicode * getStr() const
Return a null terminated unicode character array.
Definition: ustrbuf.hxx:356
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:1263
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:763
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: ustrbuf.hxx:687
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.
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition: ustrbuf.hxx:1071
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:1003
OUStringBuffer & appendAscii(const sal_Char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:522
char sal_Char
A legacy synonym for char.
Definition: types.h:130
Definition: stringutils.hxx:116
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:652
OUStringBuffer(const OUStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: ustrbuf.hxx:75
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: ustrbuf.hxx:704
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:545
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:234
unsigned char sal_Bool
Definition: types.h:48
OUStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: ustrbuf.hxx:670
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.
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:1153
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of 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:1172
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:601
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:898
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1112
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.
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1362
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:619
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
OUStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: ustrbuf.hxx:62
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:1238
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:1195
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:723
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:504
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
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.
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition: ustrbuf.hxx:424
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1295
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:301
definition of a no acquire enum for ctors
Definition: types.h:382
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.
OUStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: ustrbuf.hxx:133
OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: ustrbuf.hxx:222
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...
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.
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: ustrbuf.hxx:278
OUStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: ustrbuf.hxx:874
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:920
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:462
sal_uInt16 sal_Unicode
Definition: types.h:152
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.
Definition: stringutils.hxx:244
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:1135
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:247
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 & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition: ustrbuf.hxx:1087
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:55
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:808
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:564
Definition: stringutils.hxx:118
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:495
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:1276
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:392
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1347
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:785
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1380
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:444
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_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:482
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_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.
Definition: bootstrap.hxx:24
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:104
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:993
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:1017
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 & append(const OUString &str)
Appends the string to this string buffer.
Definition: ustrbuf.hxx:407
OUStringBuffer(const OUString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: ustrbuf.hxx:125
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:969
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:635
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()