LibreOffice
LibreOffice 5.0 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 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, void >::size - 1 + 16 )
136  {
137  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
139 #ifdef RTL_STRING_UNITTEST
140  rtl_string_unittest_const_literal = true;
141 #endif
142  }
143 
144 #ifdef RTL_STRING_UNITTEST
145 
149  template< typename T >
151  {
152  pData = 0;
153  nCapacity = 10;
154  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
155  rtl_string_unittest_invalid_conversion = true;
156  }
161  template< typename T >
162  OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
163  {
164  pData = 0;
165  nCapacity = 10;
166  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
167  rtl_string_unittest_invalid_conversion = true;
168  }
169 #endif
170 
171 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
172 
176  template< typename T1, typename T2 >
177  OUStringBuffer( const OUStringConcat< T1, T2 >& c )
178  {
179  const sal_Int32 l = c.length();
180  nCapacity = l + 16;
181  pData = rtl_uString_alloc( nCapacity );
182  sal_Unicode* end = c.addData( pData->buffer );
183  *end = '\0';
184  pData->length = end - pData->buffer;
185  // TODO realloc in case pData->>length is noticeably smaller than l ?
186  }
187 #endif
188 
190  OUStringBuffer& operator = ( const OUStringBuffer& value )
191  {
192  if (this != &value)
193  {
195  value.nCapacity,
196  value.pData);
197  nCapacity = value.nCapacity;
198  }
199  return *this;
200  }
201 
206  {
207  rtl_uString_release( pData );
208  }
209 
219  {
220  return OUString(
221  rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
222  SAL_NO_ACQUIRE );
223  }
224 
230  sal_Int32 getLength() const
231  {
232  return pData->length;
233  }
234 
243  bool isEmpty() const
244  {
245  return pData->length == 0;
246  }
247 
258  sal_Int32 getCapacity() const
259  {
260  return nCapacity;
261  }
262 
274  void ensureCapacity(sal_Int32 minimumCapacity)
275  {
276  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
277  }
278 
297  void setLength(sal_Int32 newLength)
298  {
299  assert(newLength >= 0);
300  // Avoid modifications if pData points to const empty string:
301  if( newLength != pData->length )
302  {
303  if( newLength > nCapacity )
304  rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
305  else
306  pData->buffer[newLength] = 0;
307  pData->length = newLength;
308  }
309  }
310 
324  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
325  sal_Unicode charAt( sal_Int32 index ) const
326  {
327  assert(index >= 0 && index < pData->length);
328  return pData->buffer[ index ];
329  }
330 
341  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
342  OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
343  {
344  assert(index >= 0 && index < pData->length);
345  pData->buffer[ index ] = ch;
346  return *this;
347  }
348 
352  const sal_Unicode* getStr() const { return pData->buffer; }
353 
363  sal_Unicode & operator [](sal_Int32 index)
364  {
365  assert(index >= 0 && index < pData->length);
366  return pData->buffer[index];
367  }
368 
378  const sal_Unicode & operator [](sal_Int32 index) const
379  {
380  assert(index >= 0 && index < pData->length);
381  return pData->buffer[index];
382  }
383 
388  const OUString toString() const
389  {
390  return OUString(pData->buffer, pData->length);
391  }
392 
404  {
405  return append( str.getStr(), str.getLength() );
406  }
407 
421  {
422  if(!str.isEmpty())
423  {
424  append( str.getStr(), str.getLength() );
425  }
426  return *this;
427  }
428 
441  {
442  return append( str, rtl_ustr_getLength( str ) );
443  }
444 
458  OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
459  {
460  assert( len == 0 || str != 0 ); // cannot assert that in rtl_uStringbuffer_insert
461  rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
462  return *this;
463  }
464 
470  template< typename T >
472  {
473  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
474  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
476  return *this;
477  }
478 
479 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
480 
484  template< typename T1, typename T2 >
485  OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
486  {
487  const int l = c.length();
488  if( l == 0 )
489  return *this;
490  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
491  sal_Unicode* end = c.addData( pData->buffer + pData->length );
492  *end = '\0';
493  pData->length = end - pData->buffer;
494  return *this;
495  }
496 #endif
497 
515  {
516  return appendAscii( str, rtl_str_getLength( str ) );
517  }
518 
537  OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
538  {
539  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
540  return *this;
541  }
542 
557  {
559  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
560  }
561 
563  // Pointer can be automatically converted to bool, which is unwanted here.
564  // Explicitly delete all pointer append() overloads to prevent this
565  // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
566  template< typename T >
567  typename libreoffice_internal::Enable< void,
569  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 preferred 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  sal_Unicode * appendUninitialized(sal_Int32 length) {
735  sal_Int32 n = getLength();
736  rtl_uStringbuffer_insert(&pData, &nCapacity, n, 0, length);
737  return pData->buffer + n;
738  }
739 
755  OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
756  {
757  return insert( offset, str.getStr(), str.getLength() );
758  }
759 
777  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
778  {
779  return insert( offset, str, rtl_ustr_getLength( str ) );
780  }
781 
800  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
801  {
802  assert( len == 0 || str != 0 ); // cannot assert that in rtl_uStringbuffer_insert
803  rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
804  return *this;
805  }
806 
812  template< typename T >
814  {
815  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
816  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
818  return *this;
819  }
820 
838  OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
839  {
841  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
842  }
843 
863  OUStringBuffer & insert(sal_Int32 offset, bool b)
864  {
866  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
867  }
868 
887  OUStringBuffer & insert(sal_Int32 offset, char c)
888  {
889  sal_Unicode u = c;
890  return insert( offset, &u, 1 );
891  }
892 
909  OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
910  {
911  return insert( offset, &c, 1 );
912  }
913 
933  OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
934  {
936  return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
937  }
938 
958  OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
959  {
961  return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
962  }
963 
982  OUStringBuffer insert(sal_Int32 offset, float f)
983  {
985  return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
986  }
987 
1006  OUStringBuffer & insert(sal_Int32 offset, double d)
1007  {
1009  return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
1010  }
1011 
1027  OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1028  rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1029  return *this;
1030  }
1031 
1044  OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1045  {
1046  rtl_uStringbuffer_remove( &pData, start, len );
1047  return *this;
1048  }
1049 
1060  OUStringBuffer & truncate( sal_Int32 start = 0 )
1061  {
1062  rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1063  return *this;
1064  }
1065 
1077  {
1078  sal_Int32 index = 0;
1079  while((index = indexOf(oldChar, index)) >= 0)
1080  {
1081  pData->buffer[ index ] = newChar;
1082  }
1083  return *this;
1084  }
1085 
1101  inline void accessInternals(rtl_uString *** pInternalData,
1102  sal_Int32 ** pInternalCapacity)
1103  {
1104  *pInternalData = &pData;
1105  *pInternalCapacity = &nCapacity;
1106  }
1107 
1108 
1124  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1125  {
1126  assert( fromIndex >= 0 && fromIndex <= pData->length );
1127  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1128  return (ret < 0 ? ret : ret+fromIndex);
1129  }
1130 
1142  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1143  {
1144  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1145  }
1146 
1161  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1162  {
1163  assert( fromIndex >= 0 && fromIndex <= pData->length );
1164  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1165  }
1166 
1184  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1185  {
1186  assert( fromIndex >= 0 && fromIndex <= pData->length );
1187  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1188  str.pData->buffer, str.pData->length );
1189  return (ret < 0 ? ret : ret+fromIndex);
1190  }
1191 
1198  template< typename T >
1199  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1200  {
1201  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1202  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1203  pData->buffer + fromIndex, pData->length - fromIndex, literal,
1205  return ret < 0 ? ret : ret + fromIndex;
1206  }
1207 
1225  sal_Int32 lastIndexOf( const OUString & str ) const
1226  {
1227  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1228  str.pData->buffer, str.pData->length );
1229  }
1230 
1250  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1251  {
1252  assert( fromIndex >= 0 && fromIndex <= pData->length );
1253  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1254  str.pData->buffer, str.pData->length );
1255  }
1256 
1262  template< typename T >
1264  {
1265  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1267  pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
1268  }
1269 
1279  sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1280  {
1281  sal_Int32 index;
1282  for(index = 0; index < getLength() ; index++)
1283  {
1284  if(pData->buffer[ index ] != c)
1285  {
1286  break;
1287  }
1288  }
1289  if(index)
1290  {
1291  remove(0, index);
1292  }
1293  return index;
1294  }
1295 
1305  sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1306  {
1307  sal_Int32 result = getLength();
1308  sal_Int32 index;
1309  for(index = getLength(); index > 0 ; index--)
1310  {
1311  if(pData->buffer[ index - 1 ] != c)
1312  {
1313  break;
1314  }
1315  }
1316  if(index < getLength())
1317  {
1318  truncate(index);
1319  }
1320  return result - getLength();
1321  }
1331  sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1332  {
1333  return stripStart(c) + stripEnd(c);
1334  }
1346  OUStringBuffer copy( sal_Int32 beginIndex ) const
1347  {
1348  return copy( beginIndex, getLength() - beginIndex );
1349  }
1350 
1364  OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1365  {
1366  assert(beginIndex >= 0 && beginIndex <= getLength());
1367  assert(count >= 0 && count <= getLength() - beginIndex);
1368  rtl_uString *pNew = 0;
1369  rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1370  return OUStringBuffer( pNew, count + 16 );
1371  }
1372 
1373 private:
1374  OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1375  {
1376  pData = value;
1377  nCapacity = capacity;
1378  }
1379 
1383  rtl_uString * pData;
1384 
1388  sal_Int32 nCapacity;
1389 };
1390 
1391 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1392 
1395 template<>
1396 struct ToStringHelper< OUStringBuffer >
1397  {
1398  static int length( const OUStringBuffer& s ) { return s.getLength(); }
1399  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1400  static const bool allowOStringConcat = false;
1401  static const bool allowOUStringConcat = true;
1402  };
1403 #endif
1404 
1405 }
1406 
1407 #ifdef RTL_STRING_UNITTEST
1408 namespace rtl
1409 {
1410 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1411 }
1412 #endif
1413 
1414 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1415 using ::rtl::OUStringBuffer;
1416 #endif
1417 
1418 #endif // INCLUDED_RTL_USTRBUF_HXX
1419 
1420 /* 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:1199
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:933
OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:838
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:813
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1305
~OUStringBuffer()
Release the string data.
Definition: ustrbuf.hxx:205
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:734
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:258
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:471
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:1027
#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:352
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:1250
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:755
#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:679
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:1060
#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:514
char sal_Char
A legacy synonym for char.
Definition: types.h:130
Definition: stringutils.hxx:58
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
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:696
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:537
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:230
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:662
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:1142
#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:1161
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:593
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:887
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1101
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:1346
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:611
#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:1225
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:1184
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:715
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:487
#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:420
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1279
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:297
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:218
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:274
OUStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: ustrbuf.hxx:863
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:909
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:458
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:161
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:1124
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:243
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:1076
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:800
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:556
Definition: stringutils.hxx:60
#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:1263
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:388
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1331
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:777
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1364
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:440
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:465
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.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:115
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:982
OUStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:1006
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:403
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:958
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:627
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()