LibreOffice: rtl/strbuf.hxx Source File

LibreOffice LibreOffice 26.2 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(libreoffice_internal::IsValidStrLen(length));
116 }
117 // avoid (obvious) bugs
118 explicit OStringBuffer(bool) = delete;
119 explicit OStringBuffer(char) = delete;
120 explicit OStringBuffer(wchar_t) = delete;
121#if !(defined _MSC_VER && _MSC_VER >= 1930 && _MSC_VER <= 1939 && defined _MANAGED)
122 explicit OStringBuffer(char8_t) = delete;
123#endif
124 explicit OStringBuffer(char16_t) = delete;
125 explicit OStringBuffer(char32_t) = delete;
126#endif
127
138#if defined LIBO_INTERNAL_ONLY
139 OStringBuffer(std::string_view sv)
140 : pData(nullptr)
141 , nCapacity(libreoffice_internal::ThrowIfInvalidStrLen(sv.length(), 16) + 16)
142 {
143 rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
144 }
145#else
146 OStringBuffer(const OString& value)
147 : pData(NULL)
148 , nCapacity( value.getLength() + 16 )
149 {
150 rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
151 }
152#endif
153
158 template< typename T >
159 OStringBuffer( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
160 : pData(NULL)
161 {
162 sal_Int32 length = rtl_str_getLength( value );
163 nCapacity = length + 16;
164 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
165 }
166
167 template< typename T >
168 OStringBuffer( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
169 : pData(NULL)
170 {
171 sal_Int32 length = rtl_str_getLength( value );
172 nCapacity = length + 16;
173 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
174 }
175
176#if __cplusplus > 202002L // C++23 P2266R3 "Simpler implicit move"
177 template< typename T >
178 OStringBuffer( T&& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
179 : pData(NULL)
180 {
181 sal_Int32 length = rtl_str_getLength( value );
182 nCapacity = length + 16;
183 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
184 }
185#endif
186
198 template< typename T >
199 OStringBuffer( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy())
200 : pData(NULL)
201 , nCapacity( libreoffice_internal::ConstCharArrayDetector<T>::length + 16 )
202 {
203 assert(
204 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
205 rtl_string_newFromLiteral(
206 &pData,
207 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
208 libreoffice_internal::ConstCharArrayDetector<T>::length, 16);
209#ifdef RTL_STRING_UNITTEST
210 rtl_string_unittest_const_literal = true;
211#endif
212 }
213
226 OStringBuffer(const char * value, sal_Int32 length)
227 : pData(NULL)
228 , nCapacity( length + 16 )
229 {
230 rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
231 }
232
233#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
238 template< typename T1, typename T2 >
239 OStringBuffer( OStringConcat< T1, T2 >&& c )
240 {
241 const sal_Int32 l = c.length();
242 nCapacity = l + 16;
243 pData = rtl_string_alloc( nCapacity );
244 char* end = c.addData( pData->buffer );
245 *end = '\0';
246 pData->length = l;
247 }
248
253 template< std::size_t N >
254 OStringBuffer( OStringNumber< N >&& n )
255 : OStringBuffer( n.buf, n.length)
256 {}
257#endif
258
259#if defined LIBO_INTERNAL_ONLY
260 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
261#endif
262
265 OStringBuffer& operator = ( const OStringBuffer& value )
266 {
267 if (this != &value)
268 {
269 rtl_stringbuffer_newFromStringBuffer(&pData,
270 value.nCapacity,
271 value.pData);
272 nCapacity = value.nCapacity;
273 }
274 return *this;
275 }
276
281#if defined LIBO_INTERNAL_ONLY
282 OStringBuffer & operator =(std::string_view string) {
283 sal_Int32 n = string.length();
284 if (n >= nCapacity) {
285 ensureCapacity(n + 16); //TODO: check for overflow
286 }
287 std::memcpy(pData->buffer, string.data(), n);
288 pData->buffer[n] = '\0';
289 pData->length = n;
290 return *this;
291 }
292#else
293 OStringBuffer & operator =(OString const & string) {
294 sal_Int32 n = string.getLength();
295 if (n >= nCapacity) {
296 ensureCapacity(n + 16); //TODO: check for overflow
297 }
298 std::memcpy(pData->buffer, string.pData->buffer, n + 1);
299 pData->length = n;
300 return *this;
301 }
302#endif
303
308 template<typename T>
309 typename
310 libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
311 operator =(T & literal) {
312 assert(
313 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
314 sal_Int32 const n
315 = libreoffice_internal::ConstCharArrayDetector<T>::length;
316 if (n >= nCapacity) {
317 ensureCapacity(n + 16); //TODO: check for overflow
318 }
319 std::memcpy(
320 pData->buffer,
321 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
322 n + 1);
323 pData->length = n;
324 return *this;
325 }
326
327#if defined LIBO_INTERNAL_ONLY
329 template<typename T1, typename T2>
330 OStringBuffer & operator =(OStringConcat<T1, T2> && concat) {
331 sal_Int32 const n = concat.length();
332 if (n >= nCapacity) {
333 ensureCapacity(n + 16); //TODO: check for overflow
334 }
335 *concat.addData(pData->buffer) = 0;
336 pData->length = n;
337 return *this;
338 }
339
341 template<std::size_t N>
342 OStringBuffer & operator =(OStringNumber<N> && n)
343 {
344 return operator =(std::string_view(n));
345 }
346#endif
347
351 ~OStringBuffer()
352 {
353 rtl_string_release( pData );
354 }
355
364 SAL_WARN_UNUSED_RESULT OString makeStringAndClear()
365 {
366 OString aRet( pData );
367 rtl_string_new(&pData);
368 nCapacity = 0;
369 return aRet;
370 }
371
377 sal_Int32 getLength() const
378 {
379 return pData->length;
380 }
381
390 bool isEmpty() const
391 {
392 return pData->length == 0;
393 }
394
405 sal_Int32 getCapacity() const
406 {
407 return nCapacity;
408 }
409
421 void ensureCapacity(sal_Int32 minimumCapacity)
422 {
423 rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
424 }
425
444 void setLength(sal_Int32 newLength)
445 {
446 assert(newLength >= 0);
447 // Avoid modifications if pData points to const empty string:
448 if( newLength != pData->length )
449 {
450 if( newLength > nCapacity )
451 rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
452 else
453 pData->buffer[newLength] = '\0';
454 pData->length = newLength;
455 }
456 }
457
471 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
472 char charAt( sal_Int32 index )
473 {
474 assert(index >= 0 && index < pData->length);
475 return pData->buffer[ index ];
476 }
477
488 SAL_DEPRECATED("use rtl::OStringBuffer::operator [] instead")
489 OStringBuffer & setCharAt(sal_Int32 index, char ch)
490 {
491 assert(index >= 0 && index < pData->length);
492 pData->buffer[ index ] = ch;
493 return *this;
494 }
495
499 const char* getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
500
510 char & operator [](sal_Int32 index)
511 {
512 assert(index >= 0 && index < pData->length);
513 return pData->buffer[index];
514 }
515
520 OString toString() const
521 {
522 return OString(pData->buffer, pData->length);
523 }
524
525#if !defined LIBO_INTERNAL_ONLY
536 OStringBuffer & append(const OString &str)
537 {
538 return insert(getLength(), str);
539 }
540#endif
541
553 template< typename T >
554 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type append( const T& str )
555 {
556 return insert(getLength(), str);
557 }
558
559 template< typename T >
560 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type append( T& str )
561 {
562 return insert(getLength(), str);
563 }
564
570 template< typename T >
571 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type append( T& literal )
572 {
573 return insert(getLength(), literal);
574 }
575
589 OStringBuffer & append( const char * str, sal_Int32 len)
590 {
591 return insert(getLength(), str, len);
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 c.addData(appendUninitialized(l));
605 return *this;
606 }
607
612 OStringBuffer& append( std::string_view s )
613 {
614 return insert(getLength(), s);
615 }
616
617#endif
618
630 OStringBuffer & append(sal_Bool b)
631 {
632 return insert(getLength(), b);
633 }
634
648 OStringBuffer & append(bool b)
649 {
650 return insert(getLength(), b);
651 }
652
654 // Pointer can be automatically converted to bool, which is unwanted here.
655 // Explicitly delete all pointer append() overloads to prevent this
656 // (except for char* overload, which is handled elsewhere).
657 template< typename T >
658 typename libreoffice_internal::Enable< void,
659 !libreoffice_internal::CharPtrDetector< T* >::ok >::Type
660 append( T* ) SAL_DELETED_FUNCTION;
662
673 OStringBuffer & append(char c)
674 {
675 return insert(getLength(), c);
676 }
677
690 OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
691 {
692 return insert(getLength(), i, radix);
693 }
694
707 OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
708 {
709 return insert(getLength(), l, radix);
710 }
711
723 OStringBuffer & append(float f)
724 {
725 return insert(getLength(), f);
726 }
727
739 OStringBuffer & append(double d)
740 {
741 return insert(getLength(), d);
742 }
743
759 char * appendUninitialized(sal_Int32 length) SAL_RETURNS_NONNULL {
760 sal_Int32 n = getLength();
761 rtl_stringbuffer_insert(&pData, &nCapacity, n, NULL, length);
762 return pData->buffer + n;
763 }
764
780#if defined LIBO_INTERNAL_ONLY
781 OStringBuffer & insert(sal_Int32 offset, std::string_view str)
782 {
783 return insert( offset, str.data(), str.length() );
784 }
785#else
786 OStringBuffer & insert(sal_Int32 offset, const OString & str)
787 {
788 return insert( offset, str.getStr(), str.getLength() );
789 }
790#endif
791
809 template< typename T >
810 typename libreoffice_internal::CharPtrDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, const T& str )
811 {
812 return insert( offset, str, rtl_str_getLength( str ) );
813 }
814
815 template< typename T >
816 typename libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& str )
817 {
818 return insert( offset, str, rtl_str_getLength( str ) );
819 }
820
826 template< typename T >
827 typename libreoffice_internal::ConstCharArrayDetector< T, OStringBuffer& >::Type insert( sal_Int32 offset, T& literal )
828 {
829 RTL_STRING_CONST_FUNCTION
830 assert(
831 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
832 return insert(
833 offset,
834 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
835 libreoffice_internal::ConstCharArrayDetector<T>::length);
836 }
837
856 OStringBuffer & insert( sal_Int32 offset, const char * str, sal_Int32 len)
857 {
858 assert( len == 0 || str != NULL ); // cannot assert that in rtl_stringbuffer_insert
859 rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
860 return *this;
861 }
862
880 OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
881 {
882 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
883 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
884 }
885
905 OStringBuffer & insert(sal_Int32 offset, bool b)
906 {
907 char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
908 return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
909 }
910
927 OStringBuffer & insert(sal_Int32 offset, char c)
928 {
929 return insert( offset, &c, 1 );
930 }
931
950 OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
951 {
952 char sz[RTL_STR_MAX_VALUEOFINT32];
953 return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
954 }
955
974 OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
975 {
976 char sz[RTL_STR_MAX_VALUEOFINT64];
977 return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
978 }
979
997 OStringBuffer & insert(sal_Int32 offset, float f)
998 {
999 // Same as rtl::str::valueOfFP, used for rtl_str_valueOfFloat
1000 rtl_math_doubleToString(&pData, &nCapacity, offset, f, rtl_math_StringFormat_G,
1001 RTL_STR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1002 NULL, 0, true);
1003 return *this;
1004 }
1005
1023 OStringBuffer & insert(sal_Int32 offset, double d)
1024 {
1025 // Same as rtl::str::valueOfFP, used for rtl_str_valueOfDouble
1026 rtl_math_doubleToString(&pData, &nCapacity, offset, d, rtl_math_StringFormat_G,
1027 RTL_STR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
1028 NULL, 0, true);
1029 return *this;
1030 }
1031
1044 OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
1045 {
1046 rtl_stringbuffer_remove( &pData, start, len );
1047 return *this;
1048 }
1049
1067 void accessInternals(
1068 rtl_String *** pInternalData, sal_Int32 ** pInternalCapacity)
1069 {
1070 *pInternalData = &pData;
1071 *pInternalCapacity = &nCapacity;
1072 }
1073
1074private:
1078 rtl_String * pData;
1079
1083 sal_Int32 nCapacity;
1084};
1085
1086#if defined LIBO_INTERNAL_ONLY
1087template<> struct ToStringHelper<OStringBuffer> {
1088 static std::size_t length(OStringBuffer const & s) { return s.getLength(); }
1089
1090 char * operator()(char * buffer, OStringBuffer const & s) const SAL_RETURNS_NONNULL
1091 { return addDataHelper(buffer, s.getStr(), s.getLength()); }
1092};
1093#endif
1094
1095}
1096
1097#ifdef RTL_STRING_UNITTEST
1098namespace rtl
1099{
1100typedef rtlunittest::OStringBuffer OStringBuffer;
1101}
1102#undef RTL_STRING_CONST_FUNCTION
1103#endif
1104
1105#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1106using ::rtl::OStringBuffer;
1107#endif
1108
1109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
SAL_N_ELEMENTS
#define SAL_N_ELEMENTS(arr)
Definition macros.h:51
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition types.h:492
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:396
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 used.
Definition types.h:288
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
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_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_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.
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_math_StringFormat_G
@ rtl_math_StringFormat_G
Like sprintf() G, 'F' or 'E' format is used depending on which one is more compact.
Definition math.h:53
rtl_math_doubleToString
SAL_DLLPUBLIC void rtl_math_doubleToString(rtl_String **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, char cDecSeparator, sal_Int32 const *pGroups, char cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
string.hxx
stringutils.hxx
rtl
Definition bootstrap.hxx:34
rtl::libreoffice_internal
Definition stringutils.hxx:119
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:364
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:690
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:950
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:1067
rtl::OStringBuffer::insert
libreoffice_internal::NonConstCharArrayDetector< T, OStringBuffer & >::Type insert(sal_Int32 offset, T &str)
Definition strbuf.hxx:816
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:159
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:997
rtl::OStringBuffer::append
OStringBuffer & append(char c)
Appends the string representation of the char argument to this string buffer.
Definition strbuf.hxx:673
rtl::OStringBuffer::charAt
char charAt(sal_Int32 index)
Returns the character at a specific index in this string buffer.
Definition strbuf.hxx:472
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:444
rtl::OStringBuffer::append
OStringBuffer & append(double d)
Appends the string representation of the double argument to this string buffer.
Definition strbuf.hxx:739
rtl::OStringBuffer::setCharAt
OStringBuffer & setCharAt(sal_Int32 index, char ch)
The character at the specified index of this string buffer is set to ch.
Definition strbuf.hxx:489
rtl::OStringBuffer::append
OStringBuffer & append(const OString &str)
Appends the string to this string buffer.
Definition strbuf.hxx:536
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:146
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:1023
rtl::OStringBuffer::isEmpty
bool isEmpty() const
Checks if a string buffer is empty.
Definition strbuf.hxx:390
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:589
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:905
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:827
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:199
rtl::OStringBuffer::append
OStringBuffer & append(float f)
Appends the string representation of the float argument to this string buffer.
Definition strbuf.hxx:723
rtl::OStringBuffer::append
OStringBuffer & append(bool b)
Appends the string representation of the bool argument to the string buffer.
Definition strbuf.hxx:648
rtl::OStringBuffer::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Return a null terminated character array.
Definition strbuf.hxx:499
rtl::OStringBuffer::getCapacity
sal_Int32 getCapacity() const
Returns the current capacity of the String buffer.
Definition strbuf.hxx:405
rtl::OStringBuffer::remove
OStringBuffer & remove(sal_Int32 start, sal_Int32 len)
Removes the characters in a substring of this sequence.
Definition strbuf.hxx:1044
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:927
rtl::OStringBuffer::~OStringBuffer
~OStringBuffer()
Release the string data.
Definition strbuf.hxx:351
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:421
rtl::OStringBuffer::toString
OString toString() const
Return an OString instance reflecting the current content of this OStringBuffer.
Definition strbuf.hxx:520
rtl::OStringBuffer::insert
OStringBuffer & insert(sal_Int32 offset, const OString &str)
Inserts the string into this string buffer.
Definition strbuf.hxx:786
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:571
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:554
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:856
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:707
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:560
rtl::OStringBuffer::append
OStringBuffer & append(sal_Bool b)
Appends the string representation of the sal_Bool argument to the string buffer.
Definition strbuf.hxx:630
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:759
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:226
rtl::OStringBuffer::OStringBuffer
OStringBuffer(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition strbuf.hxx:168
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:880
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:810
rtl::OStringBuffer::getLength
sal_Int32 getLength() const
Returns the length (character count) of this string buffer.
Definition strbuf.hxx:377
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:974
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition string.hxx:193
rtl::OString::getStr
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition string.hxx:697
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition string.hxx:671
rtl::libreoffice_internal::Dummy
Definition stringutils.hxx:178
rtl::libreoffice_internal::CharPtrDetector
Definition stringutils.hxx:181
rtl::libreoffice_internal::CharPtrDetector::ok
static const bool ok
Definition stringutils.hxx:182
rtl::libreoffice_internal::NonConstCharArrayDetector
Definition stringutils.hxx:205
rtl::libreoffice_internal::ConstCharArrayDetector
Definition stringutils.hxx:233
rtl::libreoffice_internal::Enable
Definition stringutils.hxx:397