LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 7.4 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#include <limits>
31
32#include "rtl/strbuf.h"
33#include "rtl/string.hxx"
34#include "rtl/stringutils.hxx"
35
36#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
37#include "rtl/stringconcat.hxx"
38#include <string_view>
39#include <type_traits>
40#endif
41
42#ifdef RTL_STRING_UNITTEST
43extern bool rtl_string_unittest_const_literal;
44extern bool rtl_string_unittest_const_literal_function;
45#endif
46
47// The unittest uses slightly different code to help check that the proper
48// calls are made. The class is put into a different namespace to make
49// sure the compiler generates a different (if generating also non-inline)
50// copy of the function and does not merge them together. The class
51// is "brought" into the proper rtl namespace by a typedef below.
52#ifdef RTL_STRING_UNITTEST
53#define rtl rtlunittest
54#endif
55
56namespace rtl
57{
58
60#ifdef RTL_STRING_UNITTEST
61#undef rtl
62// helper macro to make functions appear more readable
63#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
64#else
65#define RTL_STRING_CONST_FUNCTION
66#endif
68
71 class SAL_WARN_UNUSED OStringBuffer
72{
73public:
78 OStringBuffer()
79 : pData(NULL)
80 , nCapacity( 16 )
81 {
82 rtl_string_new_WithLength( &pData, nCapacity );
83 }
84
91 OStringBuffer( const OStringBuffer & value )
92 : pData(NULL)
93 , nCapacity( value.nCapacity )
94 {
95 rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
96 }
97
104 explicit OStringBuffer(sal_Int32 length)
105 : pData(NULL)
106 , nCapacity( length )
107 {
108 rtl_string_new_WithLength( &pData, length );
109 }
110#if defined LIBO_INTERNAL_ONLY
111 template<typename T>
112 explicit OStringBuffer(T length, std::enable_if_t<std::is_integral_v<T>, int> = 0)
113 : OStringBuffer(static_cast<sal_Int32>(length))
114 {
115 assert(
116 length >= 0
117 && static_cast<std::make_unsigned_t<T>>(length)
118 <= static_cast<std::make_unsigned_t<sal_Int32>>(
119 std::numeric_limits<sal_Int32>::max()));
120 }
121 // avoid (obvious) bugs
122 explicit OStringBuffer(bool) = delete;
123 explicit OStringBuffer(char) = delete;
124 explicit OStringBuffer(wchar_t) = delete;
125#if defined __cpp_char8_t
126 explicit OStringBuffer(char8_t) = delete;
127#endif
128 explicit OStringBuffer(char16_t) = delete;
129 explicit OStringBuffer(char32_t) = delete;
130#endif
131
142#if defined LIBO_INTERNAL_ONLY
143 OStringBuffer(std::string_view sv)
144 : pData(nullptr)
145 , nCapacity( sv.length() + 16 )
146 {
147 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
148 throw std::bad_alloc();
149 }
150 rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
151 }
152#else
153 OStringBuffer(const OString& value)
154 : pData(NULL)
155 , nCapacity( value.getLength() + 16 )
156 {
157 rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
158 }
159#endif
160
165 template< typename T >
166 OStringBuffer( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
167 : pData(NULL)
168 {
169 sal_Int32 length = rtl_str_getLength( value );
170 nCapacity = length + 16;
171 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
172 }
173
174 template< typename T >
175 OStringBuffer( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
176 : pData(NULL)
177 {
178 sal_Int32 length = rtl_str_getLength( value );
179 nCapacity = length + 16;
180 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
181 }
182
194 template< typename T >
195 OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
196 : pData(NULL)
197 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
198 {
199 assert(
200 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
201 rtl_string_newFromLiteral(
202 &pData,
203 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
204 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
205#ifdef RTL_STRING_UNITTEST
206 rtl_string_unittest_const_literal = true;
207#endif
208 }
209
222 OStringBuffer(const char * value, sal_Int32 length)
223 : pData(NULL)
224 , nCapacity( length + 16 )
225 {
226 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
227 }
228
229#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
234 template< typename T1, typename T2 >
235 OStringBuffer( OStringConcat< T1, T2 >&& c )
236 {
237 const sal_Int32 l = c.length();
238 nCapacity = l + 16;
239 pData = rtl_string_alloc( nCapacity );
240 char* end = c.addData( pData->buffer );
241 *end = '\0';
242 pData->length = l;
243 }
244
249 template< typename T >
250 OStringBuffer( OStringNumber< T >&& n )
251 : OStringBuffer( OString( n ))
252 {}
253#endif
254
255#if defined LIBO_INTERNAL_ONLY
256 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
257#endif
258
261 OStringBuffer& operator = ( const OStringBuffer& value )
262 {
263 if (this != &value)
264 {
265 rtl_stringbuffer_newFromStringBuffer(&pData,
266 value.nCapacity,
267 value.pData);
268 nCapacity = value.nCapacity;
269 }
270 return *this;
271 }
272
277#if defined LIBO_INTERNAL_ONLY
278 OStringBuffer & operator =(std::string_view string) {
279 sal_Int32 n = string.length();
280 if (n >= nCapacity) {
281 ensureCapacity(n + 16); //TODO: check for overflow
282 }
283 std::memcpy(pData->buffer, string.data(), n);
284 pData->buffer[n] = '\0';
285 pData->length = n;
286 return *this;
287 }
288#else
289 OStringBuffer & operator =(OString const & string) {
290 sal_Int32 n = string.getLength();
291 if (n >= nCapacity) {
292 ensureCapacity(n + 16); //TODO: check for overflow
293 }
294 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
295 pData->length = n;
296 return *this;
297 }
298#endif
299
304 template<typename T>
305 typename
306 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
307 operator =(T & literal) {
308 assert(
309 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
310 sal_Int32 const n
311 = libreoffice_internal::ConstCharArrayDetector<T>::length;
312 if (n >= nCapacity) {
313 ensureCapacity(n + 16); //TODO: check for overflow
314 }
315 std::memcpy(
316 pData->buffer,
317 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
318 n + 1);
319 pData->length = n;
320 return *this;
321 }
322
323#if defined LIBO_INTERNAL_ONLY
325 template<typename T1, typename T2>
326 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
327 sal_Int32 const n = concat.length();
328 if (n >= nCapacity) {
329 ensureCapacity(n + 16); //TODO: check for overflow
330 }
331 *concat.addData(pData->buffer) = 0;
332 pData->length = n;
333 return *this;
334 }
335
337 template<typename T>
338 OStringBuffer & operator =(OStringNumber<T> && n)
339 {
340 *this = OStringBuffer( std::move ( n ));
341 return *this;
342 }
343#endif
344
348 ~OStringBuffer()
349 {
350 rtl_string_release( pData );
351 }
352
361 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
362 {
363 OString aRet( pData );
364 rtl_string_new(&pData);
365 nCapacity = 0;
366 return aRet;
367 }
368
374 sal_Int32 getLength() const
375 {
376 return pData->length;
377 }
378
387 bool isEmpty() const
388 {
389 return pData->length == 0;
390 }
391
402 sal_Int32 getCapacity() const
403 {
404 return nCapacity;
405 }
406
418 void ensureCapacity(sal_Int32 minimumCapacity)
419 {
420 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
421 }
422
441 void setLength(sal_Int32 newLength)
442 {
443 assert(newLength >= 0);
444 // Avoid modifications if pData points to const empty string:
445 if( newLength != pData->length )
446 {
447 if( newLength > nCapacity )
448 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
449 else
450 pData->buffer[newLength] = '\0';
451 pData->length = newLength;
452 }
453 }
454
468 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
469 char charAt( sal_Int32 index )
470 {
471 assert(index >= 0 && index < pData->length);
472 return pData->buffer[ index ];
473 }
474
485 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
486 OStringBuffer & setCharAt(sal_Int32 index, char ch)
487 {
488 assert(index >= 0 && index < pData->length);
489 pData->buffer[ index ] = ch;
490 return *this;
491 }
492
496 const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
497
507 char & operator [](sal_Int32 index)
508 {
509 assert(index >= 0 && index < pData->length);
510 return pData->buffer[index];
511 }
512
517 OString toString() const
518 {
519 return OString(pData->buffer, pData->length);
520 }
521
522#if !defined LIBO_INTERNAL_ONLY
533 OStringBuffer & append(const OString &str)
534 {
535 return append( str.getStr(), str.getLength() );
536 }
537#endif
538
550 template< typename T >
551 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
552 {
553 return append( str, rtl_str_getLength( str ) );
554 }
555
556 template< typename T >
557 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
558 {
559 return append( str, rtl_str_getLength( str ) );
560 }
561
567 template< typename T >
568 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
569 {
570 RTL_STRING_CONST_FUNCTION
571 assert(
572 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
573 return append(
574 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
575 libreoffice_internal::ConstCharArrayDetector<T>::length);
576 }
577
591 OStringBuffer & append( const char * str, sal_Int32 len)
592 {
593 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
594 rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
595 return *this;
596 }
597
598#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
603 template< typename T1, typename T2 >
604 OStringBuffer& append( OStringConcat< T1, T2 >&& c )
605 {
606 sal_Int32 l = c.length();
607 if( l == 0 )
608 return *this;
609 l += pData->length;
610 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
611 char* end = c.addData( pData->buffer + pData->length );
612 *end = '\0';
613 pData->length = l;
614 return *this;
615 }
616
621 template< typename T >
622 OStringBuffer& append( OStringNumber< T >&& c )
623 {
624 return append( c.buf, c.length );
625 }
626
631 OStringBuffer& append( std::string_view s )
632 {
633 return append( s.data(), s.size() );
634 }
635
636#endif
637
649 OStringBuffer & append(sal_Bool b)
650 {
651 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
652 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
653 }
654
668 OStringBuffer & append(bool b)
669 {
670 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
671 return append( sz, rtl_str_valueOfBoolean( sz, b ) );
672 }
673
675 // Pointer can be automatically converted to bool, which is unwanted here.
676 // Explicitly delete all pointer append() overloads to prevent this
677 // (except for char* overload, which is handled elsewhere).
678 template< typename T >
679 typename libreoffice_internal::Enable< void,
680 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
681 append( T* ) SAL_DELETED_FUNCTION;
683
694 OStringBuffer & append(char c)
695 {
696 return append( &c, 1 );
697 }
698
711 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
712 {
713 char sz[RTL_STR_MAX_VALUEOFINT32];
714 return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
715 }
716
729 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
730 {
731 char sz[RTL_STR_MAX_VALUEOFINT64];
732 return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
733 }
734
746 OStringBuffer & append(float f)
747 {
748 char sz[RTL_STR_MAX_VALUEOFFLOAT];
749 return append( sz, rtl_str_valueOfFloat( sz, f ) );
750 }
751
763 OStringBuffer & append(double d)
764 {
765 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
766 return append( sz, rtl_str_valueOfDouble( sz, d ) );
767 }
768
784 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
785 sal_Int32 n = getLength();
786 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
787 return pData->buffer + n;
788 }
789
805#if defined LIBO_INTERNAL_ONLY
806 OStringBuffer & insert(sal_Int32 offset, std::string_view str)
807 {
808 return insert( offset, str.data(), str.length() );
809 }
810#else
811 OStringBuffer & insert(sal_Int32 offset, const OString & str)
812 {
813 return insert( offset, str.getStr(), str.getLength() );
814 }
815#endif
816
834 template< typename T >
835 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
836 {
837 return insert( offset, str, rtl_str_getLength( str ) );
838 }
839
840 template< typename T >
841 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
842 {
843 return insert( offset, str, rtl_str_getLength( str ) );
844 }
845
851 template< typename T >
852 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
853 {
854 RTL_STRING_CONST_FUNCTION
855 assert(
856 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
857 return insert(
858 offset,
859 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
860 libreoffice_internal::ConstCharArrayDetector<T>::length);
861 }
862
881 OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
882 {
883 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
884 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
885 return *this;
886 }
887
905 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
906 {
907 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
908 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
909 }
910
930 OStringBuffer & insert(sal_Int32 offset, bool b)
931 {
932 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
933 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
934 }
935
952 OStringBuffer & insert(sal_Int32 offset, char c)
953 {
954 return insert( offset, &c, 1 );
955 }
956
975 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
976 {
977 char sz[RTL_STR_MAX_VALUEOFINT32];
978 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
979 }
980
999 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
1000 {
1001 char sz[RTL_STR_MAX_VALUEOFINT64];
1002 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
1003 }
1004
1022 OStringBuffer insert(sal_Int32 offset, float f)
1023 {
1024 char sz[RTL_STR_MAX_VALUEOFFLOAT];
1025 return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
1026 }
1027
1045 OStringBuffer & insert(sal_Int32 offset, double d)
1046 {
1047 char sz[RTL_STR_MAX_VALUEOFDOUBLE];
1048 return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
1049 }
1050
1063 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1064 {
1065 rtl_stringbuffer_remove( &pData, start, len );
1066 return *this;
1067 }
1068
1086 void accessInternals(
1087 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1088 {
1089 *pInternalData = &pData;
1090 *pInternalCapacity = &nCapacity;
1091 }
1092
1093private:
1097 rtl_String * pData;
1098
1102 sal_Int32 nCapacity;
1103};
1104
1105#if defined LIBO_INTERNAL_ONLY
1106template<> struct ToStringHelper<OStringBuffer> {
1107 static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1108
1109 static char * addData(char * buffer, OStringBuffer const & s) SAL_RETURNS_NONNULL
1110 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1111
1112 static constexpr bool allowOStringConcat = true;
1113 static constexpr bool allowOUStringConcat = false;
1114};
1115#endif
1116
1117}
1118
1119#ifdef RTL_STRING_UNITTEST
1120namespace rtl
1121{
1122typedef rtlunittest::OStringBuffer OStringBuffer;
1123}
1124#undef RTL_STRING_CONST_FUNCTION
1125#endif
1126
1127#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1128using ::rtl::OStringBuffer;
1129#endif
1130
1131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
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_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
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.
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
stringutils.hxx
rtl
Definition: bootstrap.hxx:34
rtl::OStringBuffer
A string buffer implements a mutable sequence of characters.
Definition: strbuf.hxx:72
rtl::OStringBuffer::makeStringAndClear
SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
Fill the string data in the new string and clear the buffer.
Definition: strbuf.hxx:361
rtl::OStringBuffer::OStringBuffer
OStringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
Definition: strbuf.hxx:78
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:711
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:975
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:1086
rtl::OStringBuffer::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition: strbuf.hxx:841
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:166
rtl::OStringBuffer::append
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition: strbuf.hxx:694
rtl::OStringBuffer::OStringBuffer
OStringBuffer(sal_Int32 length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length a...
Definition: strbuf.hxx:104
rtl::OStringBuffer::setLength
void setLength(sal_Int32 newLength)
Sets the length of this String buffer.
Definition: strbuf.hxx:441
rtl::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition: strbuf.hxx:763
rtl::OStringBuffer::append
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition: strbuf.hxx:533
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:153
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:1045
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition: strbuf.hxx:387
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:591
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:930
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:852
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:195
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition: strbuf.hxx:746
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition: strbuf.hxx:668
rtl::OStringBuffer::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition: strbuf.hxx:496
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition: strbuf.hxx:402
rtl::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition: strbuf.hxx:1063
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:1022
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:952
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition: strbuf.hxx:348
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:418
rtl::OStringBuffer::toString
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition: strbuf.hxx:517
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition: strbuf.hxx:811
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:568
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:551
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:881
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:729
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:91
rtl::OStringBuffer::append
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type append(T &str)
Definition: strbuf.hxx:557
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition: strbuf.hxx:649
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:784
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:222
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: strbuf.hxx:175
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:905
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:835
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition: strbuf.hxx:374
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:999
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:180
rtl::OString::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:602
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:576
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:140
rtl::libreoffice_internal::CharPtrDetector
Definition: stringutils.hxx:143
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition: stringutils.hxx:167
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:195
rtl::libreoffice_internal::Enable
Definition: stringutils.hxx:375