LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 7.3 SDK C/C++ API Reference

Loading...
Searching...
No Matches
strbuf.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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#pragma once
25
26#include "sal/config.h"
27
28#include <cassert>
29#include <cstring>
30
31#include "rtl/strbuf.h"
32#include "rtl/string.hxx"
33#include "rtl/stringutils.hxx"
34
35#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
36#include "rtl/stringconcat.hxx"
37#include <string_view>
38#endif
39
40#ifdef RTL_STRING_UNITTEST
41extern bool rtl_string_unittest_const_literal;
42extern bool rtl_string_unittest_const_literal_function;
43#endif
44
45// The unittest uses slightly different code to help check that the proper
46// calls are made. The class is put into a different namespace to make
47// sure the compiler generates a different (if generating also non-inline)
48// copy of the function and does not merge them together. The class
49// is "brought" into the proper rtl namespace by a typedef below.
50#ifdef RTL_STRING_UNITTEST
51#define rtl rtlunittest
52#endif
53
54namespace rtl
55{
56
58#ifdef RTL_STRING_UNITTEST
59#undef rtl
60// helper macro to make functions appear more readable
61#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
62#else
63#define RTL_STRING_CONST_FUNCTION
64#endif
66
69 class SAL_WARN_UNUSED OStringBuffer
70{
71public:
76 OStringBuffer()
77 : pData(NULL)
78 , nCapacity( 16 )
79 {
80 rtl_string_new_WithLength( &pData, nCapacity );
81 }
82
89 OStringBuffer( const OStringBuffer & value )
90 : pData(NULL)
91 , nCapacity( value.nCapacity )
92 {
93 rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
94 }
95
102 explicit OStringBuffer(int length)
103 : pData(NULL)
104 , nCapacity( length )
105 {
106 rtl_string_new_WithLength( &pData, length );
107 }
108#if __cplusplus >= 201103L
109 explicit OStringBuffer(unsigned int length)
110 : OStringBuffer(static_cast<int>(length))
111 {
112 }
113#if SAL_TYPES_SIZEOFLONG == 4
114 // additional overloads for sal_Int32 sal_uInt32
115 explicit OStringBuffer(long length)
116 : OStringBuffer(static_cast<int>(length))
117 {
118 }
119 explicit OStringBuffer(unsigned long length)
120 : OStringBuffer(static_cast<int>(length))
121 {
122 }
123#endif
124 // avoid obvious bugs
125 explicit OStringBuffer(char) = delete;
126 explicit OStringBuffer(sal_Unicode) = delete;
127#endif
128
139#if defined LIBO_INTERNAL_ONLY
140 OStringBuffer(std::string_view sv)
141 : pData(nullptr)
142 , nCapacity( sv.length() + 16 )
143 {
144 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
145 throw std::bad_alloc();
146 }
147 rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
148 }
149#else
150 OStringBuffer(const OString& value)
151 : pData(NULL)
152 , nCapacity( value.getLength() + 16 )
153 {
154 rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
155 }
156#endif
157
162 template< typename T >
163 OStringBuffer( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
164 : pData(NULL)
165 {
166 sal_Int32 length = rtl_str_getLength( value );
167 nCapacity = length + 16;
168 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
169 }
170
171 template< typename T >
172 OStringBuffer( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
173 : pData(NULL)
174 {
175 sal_Int32 length = rtl_str_getLength( value );
176 nCapacity = length + 16;
177 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
178 }
179
191 template< typename T >
192 OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
193 : pData(NULL)
194 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
195 {
196 assert(
197 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
198 rtl_string_newFromLiteral(
199 &pData,
200 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
201 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
202#ifdef RTL_STRING_UNITTEST
203 rtl_string_unittest_const_literal = true;
204#endif
205 }
206
219 OStringBuffer(const char * value, sal_Int32 length)
220 : pData(NULL)
221 , nCapacity( length + 16 )
222 {
223 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
224 }
225
226#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
231 template< typename T1, typename T2 >
232 OStringBuffer( OStringConcat< T1, T2 >&& c )
233 {
234 const sal_Int32 l = c.length();
235 nCapacity = l + 16;
236 pData = rtl_string_alloc( nCapacity );
237 char* end = c.addData( pData->buffer );
238 *end = '\0';
239 pData->length = l;
240 }
241
246 template< typename T >
247 OStringBuffer( OStringNumber< T >&& n )
248 : OStringBuffer( OString( n ))
249 {}
250#endif
251
252#if defined LIBO_INTERNAL_ONLY
253 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
254#endif
255
258 OStringBuffer& operator = ( const OStringBuffer& value )
259 {
260 if (this != &value)
261 {
262 rtl_stringbuffer_newFromStringBuffer(&pData,
263 value.nCapacity,
264 value.pData);
265 nCapacity = value.nCapacity;
266 }
267 return *this;
268 }
269
274#if defined LIBO_INTERNAL_ONLY
275 OStringBuffer & operator =(std::string_view string) {
276 sal_Int32 n = string.length();
277 if (n >= nCapacity) {
278 ensureCapacity(n + 16); //TODO: check for overflow
279 }
280 std::memcpy(pData->buffer, string.data(), n + 1);
281 pData->length = n;
282 return *this;
283 }
284#else
285 OStringBuffer & operator =(OString const & string) {
286 sal_Int32 n = string.getLength();
287 if (n >= nCapacity) {
288 ensureCapacity(n + 16); //TODO: check for overflow
289 }
290 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
291 pData->length = n;
292 return *this;
293 }
294#endif
295
300 template<typename T>
301 typename
302 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
303 operator =(T & literal) {
304 assert(
305 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
306 sal_Int32 const n
307 = libreoffice_internal::ConstCharArrayDetector<T>::length;
308 if (n >= nCapacity) {
309 ensureCapacity(n + 16); //TODO: check for overflow
310 }
311 std::memcpy(
312 pData->buffer,
313 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
314 n + 1);
315 pData->length = n;
316 return *this;
317 }
318
319#if defined LIBO_INTERNAL_ONLY
321 template<typename T1, typename T2>
322 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
323 sal_Int32 const n = concat.length();
324 if (n >= nCapacity) {
325 ensureCapacity(n + 16); //TODO: check for overflow
326 }
327 *concat.addData(pData->buffer) = 0;
328 pData->length = n;
329 return *this;
330 }
331
333 template<typename T>
334 OStringBuffer & operator =(OStringNumber<T> && n)
335 {
336 *this = OStringBuffer( std::move ( n ));
337 return *this;
338 }
339#endif
340
344 ~OStringBuffer()
345 {
346 rtl_string_release( pData );
347 }
348
357 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
358 {
359 OString aRet( pData );
360 rtl_string_new(&pData);
361 nCapacity = 0;
362 return aRet;
363 }
364
370 sal_Int32 getLength() const
371 {
372 return pData->length;
373 }
374
383 bool isEmpty() const
384 {
385 return pData->length == 0;
386 }
387
398 sal_Int32 getCapacity() const
399 {
400 return nCapacity;
401 }
402
414 void ensureCapacity(sal_Int32 minimumCapacity)
415 {
416 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
417 }
418
437 void setLength(sal_Int32 newLength)
438 {
439 assert(newLength >= 0);
440 // Avoid modifications if pData points to const empty string:
441 if( newLength != pData->length )
442 {
443 if( newLength > nCapacity )
444 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
445 else
446 pData->buffer[newLength] = '\0';
447 pData->length = newLength;
448 }
449 }
450
464 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
465 char charAt( sal_Int32 index )
466 {
467 assert(index >= 0 && index < pData->length);
468 return pData->buffer[ index ];
469 }
470
481 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
482 OStringBuffer & setCharAt(sal_Int32 index, char ch)
483 {
484 assert(index >= 0 && index < pData->length);
485 pData->buffer[ index ] = ch;
486 return *this;
487 }
488
492 const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
493
503 char & operator [](sal_Int32 index)
504 {
505 assert(index >= 0 && index < pData->length);
506 return pData->buffer[index];
507 }
508
513 OString toString() const
514 {
515 return OString(pData->buffer, pData->length);
516 }
517
518#if !defined LIBO_INTERNAL_ONLY
529 OStringBuffer & append(const OString &str)
530 {
531 return append( str.getStr(), str.getLength() );
532 }
533#endif
534
546 template< typename T >
547 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
548 {
549 return append( str, rtl_str_getLength( str ) );
550 }
551
552 template< typename T >
553 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
554 {
555 return append( str, rtl_str_getLength( str ) );
556 }
557
563 template< typename T >
564 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
565 {
566 RTL_STRING_CONST_FUNCTION
567 assert(
568 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
569 return append(
570 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
571 libreoffice_internal::ConstCharArrayDetector<T>::length);
572 }
573
587 OStringBuffer & append( const char * str, sal_Int32 len)
588 {
589 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
590 rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
591 return *this;
592 }
593
594#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
599 template< typename T1, typename T2 >
600 OStringBuffer& append( OStringConcat< T1, T2 >&& c )
601 {
602 sal_Int32 l = c.length();
603 if( l == 0 )
604 return *this;
605 l += pData->length;
606 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
607 char* end = c.addData( pData->buffer + pData->length );
608 *end = '\0';
609 pData->length = l;
610 return *this;
611 }
612
617 template< typename T >
618 OStringBuffer& append( OStringNumber< T >&& c )
619 {
620 return append( c.buf, c.length );
621 }
622
627 OStringBuffer& append( std::string_view s )
628 {
629 return append( s.data(), s.size() );
630 }
631
632#endif
633
645 OStringBuffer & append(sal_Bool b)
646 {
647 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
648 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
649 }
650
664 OStringBuffer & append(bool b)
665 {
666 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
667 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
668 }
669
671 // Pointer can be automatically converted to bool, which is unwanted here.
672 // Explicitly delete all pointer append() overloads to prevent this
673 // (except for char* overload, which is handled elsewhere).
674 template< typename T >
675 typename libreoffice_internal::Enable< void,
676 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
677 append( T* ) SAL_DELETED_FUNCTION;
679
690 OStringBuffer & append(char c)
691 {
692 return append( &c, 1 );
693 }
694
707 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
708 {
709 char sz[RTL_STR_MAX_VALUEOFINT32];
710 return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
711 }
712
725 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
726 {
727 char sz[RTL_STR_MAX_VALUEOFINT64];
728 return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
729 }
730
742 OStringBuffer & append(float f)
743 {
744 char sz[RTL_STR_MAX_VALUEOFFLOAT];
745 return append( sz, rtl_str_valueOfFloat( sz, f ) );
746 }
747
759 OStringBuffer & append(double d)
760 {
761 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
762 return append( sz, rtl_str_valueOfDouble( sz, d ) );
763 }
764
780 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
781 sal_Int32 n = getLength();
782 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
783 return pData->buffer + n;
784 }
785
801#if defined LIBO_INTERNAL_ONLY
802 OStringBuffer & insert(sal_Int32 offset, std::string_view str)
803 {
804 return insert( offset, str.data(), str.length() );
805 }
806#else
807 OStringBuffer & insert(sal_Int32 offset, const OString & str)
808 {
809 return insert( offset, str.getStr(), str.getLength() );
810 }
811#endif
812
830 template< typename T >
831 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
832 {
833 return insert( offset, str, rtl_str_getLength( str ) );
834 }
835
836 template< typename T >
837 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
838 {
839 return insert( offset, str, rtl_str_getLength( str ) );
840 }
841
847 template< typename T >
848 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
849 {
850 RTL_STRING_CONST_FUNCTION
851 assert(
852 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
853 return insert(
854 offset,
855 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
856 libreoffice_internal::ConstCharArrayDetector<T>::length);
857 }
858
877 OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
878 {
879 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
880 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
881 return *this;
882 }
883
901 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
902 {
903 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
904 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
905 }
906
926 OStringBuffer & insert(sal_Int32 offset, bool b)
927 {
928 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
929 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
930 }
931
948 OStringBuffer & insert(sal_Int32 offset, char c)
949 {
950 return insert( offset, &c, 1 );
951 }
952
971 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
972 {
973 char sz[RTL_STR_MAX_VALUEOFINT32];
974 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
975 }
976
995 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
996 {
997 char sz[RTL_STR_MAX_VALUEOFINT64];
998 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
999 }
1000
1018 OStringBuffer insert(sal_Int32 offset, float f)
1019 {
1020 char sz[RTL_STR_MAX_VALUEOFFLOAT];
1021 return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
1022 }
1023
1041 OStringBuffer & insert(sal_Int32 offset, double d)
1042 {
1043 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
1044 return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
1045 }
1046
1059 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1060 {
1061 rtl_stringbuffer_remove( &pData, start, len );
1062 return *this;
1063 }
1064
1082 void accessInternals(
1083 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1084 {
1085 *pInternalData = &pData;
1086 *pInternalCapacity = &nCapacity;
1087 }
1088
1089private:
1093 rtl_String * pData;
1094
1098 sal_Int32 nCapacity;
1099};
1100
1101#if defined LIBO_INTERNAL_ONLY
1102template<> struct ToStringHelper<OStringBuffer> {
1103 static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1104
1105 static char * addData(char * buffer, OStringBuffer const & s) SAL_RETURNS_NONNULL
1106 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1107
1108 static constexpr bool allowOStringConcat = true;
1109 static constexpr bool allowOUStringConcat = false;
1110};
1111#endif
1112
1113}
1114
1115#ifdef RTL_STRING_UNITTEST
1116namespace rtl
1117{
1118typedef rtlunittest::OStringBuffer OStringBuffer;
1119}
1120#undef RTL_STRING_CONST_FUNCTION
1121#endif
1122
1123#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1124using ::rtl::OStringBuffer;
1125#endif
1126
1127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:474
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:123
SAL_WARN_UNUSED_RESULT
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
config.h
strbuf.h
rtl_stringbuffer_ensureCapacity
SAL_DLLPUBLIC void rtl_stringbuffer_ensureCapacity(rtl_String **This, sal_Int32 *capacity, sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
rtl_stringbuffer_newFromStringBuffer
SAL_DLLPUBLIC sal_Int32 rtl_stringbuffer_newFromStringBuffer(rtl_String **newStr, sal_Int32 capacity, rtl_String *oldStr)
Allocates a new String that contains the same sequence of characters as the string argument.
rtl_stringbuffer_remove
SAL_DLLPUBLIC void rtl_stringbuffer_remove(rtl_String **This, sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
rtl_stringbuffer_insert
SAL_DLLPUBLIC void rtl_stringbuffer_insert(rtl_String **This, sal_Int32 *capacity, sal_Int32 offset, const char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
rtl_stringbuffer_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_stringbuffer_newFromStr_WithLength(rtl_String **newStr, const char *value, sal_Int32 count)
Allocates a new String that contains characters from the character array argument.
stringutils.hxx
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:715
RTL_STR_MAX_VALUEOFINT32
#define RTL_STR_MAX_VALUEOFINT32
Definition: string.h:631
rtl_str_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
rtl_string_alloc
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_str_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_str_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
rtl_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl_str_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl_string_newFromLiteral
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:589
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:696
rtl_string_new_WithLength
SAL_DLLPUBLIC void rtl_string_new_WithLength(rtl_String **newStr, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_str_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt32(char *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl_str_getLength
SAL_DLLPUBLIC sal_Int32 rtl_str_getLength(const char *str) SAL_THROW_EXTERN_C()
Return the length of a string.
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
string.hxx
rtl
Definition: bootstrap.hxx:34
rtl::OStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:70
rtl::OStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:357
rtl::OStringBuffer::OStringBuffer
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:76
rtl::OStringBuffer::append
OStringBuffer & append(sal_Int32 i, sal_Int16 radix=10)
Appends the string representation of the sal_Int32 argument to this string buffer.
Definition: strbuf.hxx:707
rtl::OStringBuffer::insert
OStringBuffer & 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: strbuf.hxx:971
rtl::OStringBuffer::accessInternals
void accessInternals(rtl_String ***pInternalData, sal_Int32 **pInternalCapacity)
Allows access to the internal data of this OStringBuffer, for effective manipulation.
Definition: strbuf.hxx:1082
rtl::OStringBuffer::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:837
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:163
rtl::OStringBuffer::append
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:690
rtl::OStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:437
rtl::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:759
rtl::OStringBuffer::append
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:529
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const OString &value)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:150
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, double d)
Inserts the string representation of the double argument into this string buffer.
Definition: strbuf.hxx:1041
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:383
rtl::OStringBuffer::append
OStringBuffer & append(const char *str, sal_Int32 len)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:587
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, bool b)
Inserts the string representation of the bool argument into this string buffer.
Definition: strbuf.hxx:926
rtl::OStringBuffer::insert
libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:848
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Constructs a string buffer so that it represents the same sequence of characters as the string litera...
Definition: strbuf.hxx:192
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:742
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:664
rtl::OStringBuffer::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:492
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:398
rtl::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1059
rtl::OStringBuffer::insert
OStringBuffer insert(sal_Int32 offset, float f)
Inserts the string representation of the float argument into this string buffer.
Definition: strbuf.hxx:1018
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, char c)
Inserts the string representation of the char argument into this string buffer.
Definition: strbuf.hxx:948
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:344
rtl::OStringBuffer::ensureCapacity
void ensureCapacity(sal_Int32 minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
Definition: strbuf.hxx:414
rtl::OStringBuffer::toString
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:513
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:807
rtl::OStringBuffer::append
libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer & >::Type append(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: strbuf.hxx:564
rtl::OStringBuffer::OStringBuffer
OStringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:102
rtl::OStringBuffer::append
libreoffice_internal::CharPtrDetector< T, OStringBuffer & >::Type append(const T &str)
Appends the string representation of the char array argument to this string buffer.
Definition: strbuf.hxx:547
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const char *str, sal_Int32 len)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:877
rtl::OStringBuffer::append
OStringBuffer & append(sal_Int64 l, sal_Int16 radix=10)
Appends the string representation of the long argument to this string buffer.
Definition: strbuf.hxx:725
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const OStringBuffer &value)
Allocates a new string buffer that contains the same sequence of characters as the string buffer argu...
Definition: strbuf.hxx:89
rtl::OStringBuffer::append
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:553
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:645
rtl::OStringBuffer::appendUninitialized
char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL
Unsafe way to make space for a fixed amount of characters to be appended into this OStringBuffer.
Definition: strbuf.hxx:780
rtl::OStringBuffer::OStringBuffer
OStringBuffer(const char *value, sal_Int32 length)
Constructs a string buffer so that it represents the same sequence of characters as the string argume...
Definition: strbuf.hxx:219
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:172
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
Inserts the string representation of the sal_Bool argument into this string buffer.
Definition: strbuf.hxx:901
rtl::OStringBuffer::insert
libreoffice_internal::CharPtrDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, const T &str)
Inserts the string representation of the char array argument into this string buffer.
Definition: strbuf.hxx:831
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:370
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix=10)
Inserts the string representation of the long argument into this string buffer.
Definition: strbuf.hxx:995
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:181
rtl::OString::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:603
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:577
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:136
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:139
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.hxx:163
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:191
rtl::libreoffice_internal::Enable
Definition: stringutils.hxx:371