LibreOffice
LibreOffice 4.4 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 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 
92 {
93 public:
99  : pData(NULL)
100  , nCapacity( 16 )
101  {
102  rtl_uString_new_WithLength( &pData, nCapacity );
103  }
104 
112  : pData(NULL)
113  , nCapacity( value.nCapacity )
114  {
115  rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
116  }
117 
124  explicit OUStringBuffer(int length)
125  : pData(NULL)
126  , nCapacity( length )
127  {
128  rtl_uString_new_WithLength( &pData, length );
129  }
130 
141  OUStringBuffer(const OUString& value)
142  : pData(NULL)
143  , nCapacity( value.getLength() + 16 )
144  {
145  rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
146  }
147 
148  template< typename T >
150  : pData(NULL)
151  , nCapacity( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
152  {
153  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
155 #ifdef RTL_STRING_UNITTEST
156  rtl_string_unittest_const_literal = true;
157 #endif
158  }
159 
160 #ifdef RTL_STRING_UNITTEST
161 
165  template< typename T >
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  }
177  template< typename T >
178  OUStringBuffer( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
179  {
180  pData = 0;
181  nCapacity = 10;
182  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
183  rtl_string_unittest_invalid_conversion = true;
184  }
185 #endif
186 
187 #ifdef RTL_FAST_STRING
188 
192  template< typename T1, typename T2 >
193  OUStringBuffer( const OUStringConcat< T1, T2 >& c )
194  {
195  const sal_Int32 l = c.length();
196  nCapacity = l + 16;
197  pData = rtl_uString_alloc( nCapacity );
198  sal_Unicode* end = c.addData( pData->buffer );
199  *end = '\0';
200  pData->length = end - pData->buffer;
201  // TODO realloc in case pData->>length is noticeably smaller than l ?
202  }
203 #endif
204 
206  OUStringBuffer& operator = ( const OUStringBuffer& value )
207  {
208  if (this != &value)
209  {
211  value.nCapacity,
212  value.pData);
213  nCapacity = value.nCapacity;
214  }
215  return *this;
216  }
217 
222  {
223  rtl_uString_release( pData );
224  }
225 
235  {
236  return OUString(
237  rtl_uStringBuffer_makeStringAndClear( &pData, &nCapacity ),
238  SAL_NO_ACQUIRE );
239  }
240 
246  sal_Int32 getLength() const
247  {
248  return pData->length;
249  }
250 
259  bool isEmpty() const
260  {
261  return pData->length == 0;
262  }
263 
274  sal_Int32 getCapacity() const
275  {
276  return nCapacity;
277  }
278 
290  void ensureCapacity(sal_Int32 minimumCapacity)
291  {
292  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
293  }
294 
313  void setLength(sal_Int32 newLength)
314  {
315  assert(newLength >= 0);
316  // Avoid modifications if pData points to const empty string:
317  if( newLength != pData->length )
318  {
319  if( newLength > nCapacity )
320  rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
321  else
322  pData->buffer[newLength] = 0;
323  pData->length = newLength;
324  }
325  }
326 
340  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
341  sal_Unicode charAt( sal_Int32 index ) const
342  {
343  assert(index >= 0 && index < pData->length);
344  return pData->buffer[ index ];
345  }
346 
357  SAL_DEPRECATED("use rtl::OUStringBuffer::operator [] instead")
358  OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
359  {
360  assert(index >= 0 && index < pData->length);
361  pData->buffer[ index ] = ch;
362  return *this;
363  }
364 
368  const sal_Unicode* getStr() const { return pData->buffer; }
369 
379  sal_Unicode & operator [](sal_Int32 index)
380  {
381  assert(index >= 0 && index < pData->length);
382  return pData->buffer[index];
383  }
384 
394  const sal_Unicode & operator [](sal_Int32 index) const
395  {
396  assert(index >= 0 && index < pData->length);
397  return pData->buffer[index];
398  }
399 
404  const OUString toString() const
405  {
406  return OUString(pData->buffer, pData->length);
407  }
408 
420  {
421  return append( str.getStr(), str.getLength() );
422  }
423 
437  {
438  if(!str.isEmpty())
439  {
440  append( str.getStr(), str.getLength() );
441  }
442  return *this;
443  }
444 
457  {
458  return append( str, rtl_ustr_getLength( str ) );
459  }
460 
474  OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
475  {
476  assert( len >= 0 );
477  assert( len == 0 || str != 0 );
478  rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
479  return *this;
480  }
481 
487  template< typename T >
489  {
490  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
491  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), literal,
493  return *this;
494  }
495 
496 #ifdef RTL_FAST_STRING
497 
501  template< typename T1, typename T2 >
502  OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
503  {
504  const int l = c.length();
505  if( l == 0 )
506  return *this;
507  rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
508  sal_Unicode* end = c.addData( pData->buffer + pData->length );
509  *end = '\0';
510  pData->length = end - pData->buffer;
511  return *this;
512  }
513 #endif
514 
532  {
533  return appendAscii( str, rtl_str_getLength( str ) );
534  }
535 
554  OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
555  {
556  assert( len >= 0 );
557  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
558  return *this;
559  }
560 
575  {
577  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
578  }
579 
581  // Pointer can be automatically converted to bool, which is unwanted here.
582  // Explicitly delete all pointer append() overloads to prevent this
583  // (except for char* and sal_Unicode* overloads, which are handled elsewhere).
584  template< typename T >
585  typename libreoffice_internal::Enable< void,
587  append( T* ) SAL_DELETED_FUNCTION;
589 
590  // This overload is needed because OUString has a ctor from rtl_uString*, but
591  // the bool overload above would be preferred to the conversion.
595  OUStringBuffer & append(rtl_uString* str)
596  {
597  return append( OUString( str ));
598  }
599 
612  {
614  return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
615  }
616 
630  {
631  assert(static_cast< unsigned char >(c) <= 0x7F);
632  return append(sal_Unicode(c));
633  }
634 
646  {
647  return append( &c, 1 );
648  }
649 
662  OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
663  {
665  return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
666  }
667 
680  OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
681  {
683  return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
684  }
685 
698  {
700  return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
701  }
702 
714  OUStringBuffer & append(double d)
715  {
717  return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
718  }
719 
733  OUStringBuffer & appendUtf32(sal_uInt32 c) {
734  return insertUtf32(getLength(), c);
735  }
736 
752  sal_Unicode * appendUninitialized(sal_Int32 length) {
753  assert(length >= 0);
754  sal_Int32 n = getLength();
755  rtl_uStringbuffer_insert(&pData, &nCapacity, n, 0, length);
756  return pData->buffer + n;
757  }
758 
774  OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
775  {
776  return insert( offset, str.getStr(), str.getLength() );
777  }
778 
796  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
797  {
798  return insert( offset, str, rtl_ustr_getLength( str ) );
799  }
800 
819  OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
820  {
821  assert( offset >= 0 && offset <= pData->length );
822  assert( len >= 0 );
823  assert( len == 0 || str != 0 );
824  rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
825  return *this;
826  }
827 
833  template< typename T >
835  {
836  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
837  rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal,
839  return *this;
840  }
841 
859  OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
860  {
862  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
863  }
864 
884  OUStringBuffer & insert(sal_Int32 offset, bool b)
885  {
887  return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
888  }
889 
908  OUStringBuffer & insert(sal_Int32 offset, char c)
909  {
910  sal_Unicode u = c;
911  return insert( offset, &u, 1 );
912  }
913 
930  OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
931  {
932  return insert( offset, &c, 1 );
933  }
934 
954  OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
955  {
957  return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
958  }
959 
979  OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
980  {
982  return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
983  }
984 
1003  OUStringBuffer insert(sal_Int32 offset, float f)
1004  {
1006  return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
1007  }
1008 
1027  OUStringBuffer & insert(sal_Int32 offset, double d)
1028  {
1030  return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
1031  }
1032 
1048  OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
1049  rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
1050  return *this;
1051  }
1052 
1065  OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1066  {
1067  assert( start >= 0 && start <= pData->length );
1068  assert( len >= 0 );
1069  rtl_uStringbuffer_remove( &pData, start, len );
1070  return *this;
1071  }
1072 
1083  OUStringBuffer & truncate( sal_Int32 start = 0 )
1084  {
1085  assert( start >= 0 && start <= pData->length );
1086  rtl_uStringbuffer_remove( &pData, start, getLength() - start );
1087  return *this;
1088  }
1089 
1101  {
1102  sal_Int32 index = 0;
1103  while((index = indexOf(oldChar, index)) >= 0)
1104  {
1105  pData->buffer[ index ] = newChar;
1106  }
1107  return *this;
1108  }
1109 
1125  inline void accessInternals(rtl_uString *** pInternalData,
1126  sal_Int32 ** pInternalCapacity)
1127  {
1128  *pInternalData = &pData;
1129  *pInternalCapacity = &nCapacity;
1130  }
1131 
1132 
1148  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1149  {
1150  assert( fromIndex >= 0 && fromIndex <= pData->length );
1151  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1152  return (ret < 0 ? ret : ret+fromIndex);
1153  }
1154 
1166  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1167  {
1168  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1169  }
1170 
1185  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1186  {
1187  assert( fromIndex >= 0 && fromIndex <= pData->length );
1188  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1189  }
1190 
1208  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1209  {
1210  assert( fromIndex >= 0 && fromIndex <= pData->length );
1211  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1212  str.pData->buffer, str.pData->length );
1213  return (ret < 0 ? ret : ret+fromIndex);
1214  }
1215 
1222  template< typename T >
1223  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1224  {
1225  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1226  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1227  pData->buffer + fromIndex, pData->length - fromIndex, literal,
1229  return ret < 0 ? ret : ret + fromIndex;
1230  }
1231 
1249  sal_Int32 lastIndexOf( const OUString & str ) const
1250  {
1251  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1252  str.pData->buffer, str.pData->length );
1253  }
1254 
1274  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1275  {
1276  assert( fromIndex >= 0 && fromIndex <= pData->length );
1277  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1278  str.pData->buffer, str.pData->length );
1279  }
1280 
1286  template< typename T >
1288  {
1289  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1291  pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
1292  }
1293 
1303  sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
1304  {
1305  sal_Int32 index;
1306  for(index = 0; index < getLength() ; index++)
1307  {
1308  if(pData->buffer[ index ] != c)
1309  {
1310  break;
1311  }
1312  }
1313  if(index)
1314  {
1315  remove(0, index);
1316  }
1317  return index;
1318  }
1319 
1329  sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
1330  {
1331  sal_Int32 result = getLength();
1332  sal_Int32 index;
1333  for(index = getLength(); index > 0 ; index--)
1334  {
1335  if(pData->buffer[ index - 1 ] != c)
1336  {
1337  break;
1338  }
1339  }
1340  if(index < getLength())
1341  {
1342  truncate(index);
1343  }
1344  return result - getLength();
1345  }
1355  sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
1356  {
1357  return stripStart(c) + stripEnd(c);
1358  }
1370  OUStringBuffer copy( sal_Int32 beginIndex ) const
1371  {
1372  assert(beginIndex >= 0 && beginIndex <= getLength());
1373  return copy( beginIndex, getLength() - beginIndex );
1374  }
1375 
1389  OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const
1390  {
1391  assert(beginIndex >= 0 && beginIndex <= getLength());
1392  assert(count >= 0 && count <= getLength() - beginIndex);
1393  rtl_uString *pNew = 0;
1394  rtl_uStringbuffer_newFromStr_WithLength( &pNew, getStr() + beginIndex, count );
1395  return OUStringBuffer( pNew, count + 16 );
1396  }
1397 
1398 #ifdef LIBO_INTERNAL_ONLY
1399  // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
1400  // even two buffers. It's intentional it returns OUString, just like the operator+ would in the fast variant.
1401 #ifndef RTL_FAST_STRING
1402 
1406  friend OUString operator+( const OUStringBuffer& str1, const OUStringBuffer& str2 )
1407  {
1408  return OUString( str1.pData ).concat( str2.pData );
1409  }
1410 #endif
1411 #endif
1412 
1413 private:
1414  OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
1415  {
1416  pData = value;
1417  nCapacity = capacity;
1418  }
1419 
1423  rtl_uString * pData;
1424 
1428  sal_Int32 nCapacity;
1429 };
1430 
1431 #ifdef RTL_FAST_STRING
1432 
1435 template<>
1436 struct ToStringHelper< OUStringBuffer >
1437  {
1438  static int length( const OUStringBuffer& s ) { return s.getLength(); }
1439  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringBuffer& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1440  static const bool allowOStringConcat = false;
1441  static const bool allowOUStringConcat = true;
1442  };
1443 #endif
1444 
1445 }
1446 
1447 #ifdef RTL_STRING_UNITTEST
1448 namespace rtl
1449 {
1450 typedef rtlunittest::OUStringBuffer OUStringBuffer;
1451 }
1452 #endif
1453 
1454 #ifdef RTL_USING
1455 using ::rtl::OUStringBuffer;
1456 #endif
1457 
1458 #endif // INCLUDED_RTL_USTRBUF_HXX
1459 
1460 /* 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:141
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: ustrbuf.hxx:313
definition of a no acquire enum for ctors
Definition: types.h:372
unsigned char sal_Bool
Definition: types.h:48
OUStringBuffer copy(sal_Int32 beginIndex) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1370
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_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.
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:416
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:394
OUStringBuffer copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string buffer that is a substring of this string.
Definition: ustrbuf.hxx:1389
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:488
OUStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:908
OUStringBuffer & appendUtf32(sal_uInt32 c)
Appends a single UTF-32 character to this string buffer.
Definition: ustrbuf.hxx:733
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
OUStringBuffer & append(const sal_Unicode *str)
Appends the string representation of the char array argument to this string buffer.
Definition: ustrbuf.hxx:456
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 & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer. ...
Definition: ustrbuf.hxx:1027
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustrbuf.hxx:1249
const sal_Unicode * getStr() const
Return a null terminated unicode character array.
Definition: ustrbuf.hxx:368
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.
Definition: stringutils.hxx:68
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: ustrbuf.hxx:246
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
OUStringBuffer & append(sal_Unicode c)
Appends the string representation of the char argument to this string buffer.
Definition: ustrbuf.hxx:645
OUStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: ustrbuf.hxx:574
OUStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: ustrbuf.hxx:1003
OUStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: ustrbuf.hxx:149
OUStringBuffer(const OUStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: ustrbuf.hxx:111
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:1501
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:1287
sal_Int32 strip(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the both end of the buffer.
Definition: ustrbuf.hxx:1355
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:752
Definition: bootstrap.hxx:24
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const sal_Char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
void accessInternals(rtl_uString ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OUStringBuffer, for effective manipulation.
Definition: ustrbuf.hxx:1125
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:1148
bool isEmpty() const
Checks if a string buffer is empty.
Definition: ustrbuf.hxx:259
OUStringBuffer & append(char c)
Appends the string representation of the ASCII char argument to this string buffer.
Definition: ustrbuf.hxx:629
OUStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: ustrbuf.hxx:884
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:1223
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:954
OUStringBuffer & insert(sal_Int32 offset, const OUString &str)
Inserts the string into this string buffer.
Definition: ustrbuf.hxx:774
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:1208
char sal_Char
A legacy synonym for char.
Definition: types.h:130
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_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()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters...
Definition: ustrbuf.hxx:98
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:394
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 & insert(sal_Int32 offset, const sal_Unicode *str)
Inserts the string representation of the char array argument into this string buffer.
Definition: ustrbuf.hxx:796
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
OUStringBuffer & appendAscii(const sal_Char *str, sal_Int32 len)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:554
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: ustrbuf.hxx:290
OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
Inserts the string representation of the char argument into this string buffer.
Definition: ustrbuf.hxx:930
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()
Release the string data.
Definition: ustrbuf.hxx:221
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_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: ustrbuf.hxx:274
OUStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: ustrbuf.hxx:680
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...
OUString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: ustrbuf.hxx:234
OUStringBuffer & append(const OUString &str)
Appends the string to this string buffer.
Definition: ustrbuf.hxx:419
Definition: stringutils.hxx:171
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:1274
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
OUStringBuffer & truncate(sal_Int32 start=0)
Removes the tail of a string buffer start at the indicate position.
Definition: ustrbuf.hxx:1083
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
OUStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: ustrbuf.hxx:611
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:81
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.
OUStringBuffer & replace(sal_Unicode oldChar, sal_Unicode newChar)
Replace all occurrences of oldChar in this string buffer with newChar.
Definition: ustrbuf.hxx:1100
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, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: ustrbuf.hxx:859
Definition: stringutils.hxx:70
sal_Int32 stripEnd(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the end of the buffer.
Definition: ustrbuf.hxx:1329
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:979
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:1003
SAL_DLLPUBLIC rtl_uString * rtl_uStringBuffer_makeStringAndClear(rtl_uString **ppThis, sal_Int32 *nCapacity)
Returns an immutable rtl_uString object, while clearing the string buffer.
OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c)
Inserts a single UTF-32 character into this string buffer.
Definition: ustrbuf.hxx:1048
SAL_DLLPUBLIC void rtl_uString_new_WithLength(rtl_uString **newStr, sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
sal_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:1166
sal_uInt16 sal_Unicode
Definition: types.h:152
OUStringBuffer & append(const OUStringBuffer &str)
Appends the content of a stringbuffer to this string buffer.
Definition: ustrbuf.hxx:436
const OUString toString() const
Return a OUString instance reflecting the current content of this OUStringBuffer. ...
Definition: ustrbuf.hxx:404
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:474
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:834
sal_Int32 stripStart(sal_Unicode c=(sal_Unicode)' ')
Strip the given character from the start of the buffer.
Definition: ustrbuf.hxx:1303
OUStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: ustrbuf.hxx:697
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:1185
OUStringBuffer & appendAscii(const sal_Char *str)
Appends a 8-Bit ASCII character string to this string buffer.
Definition: ustrbuf.hxx:531
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
OUStringBuffer & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition: ustrbuf.hxx:662
OUStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: ustrbuf.hxx:124
OUStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: ustrbuf.hxx:714
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:91
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
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:819
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:588
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:475
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915