LibreOffice: rtl/string.hxx Source File

LibreOffice LibreOffice 7.3 SDK C/C++ API Reference

string.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#ifndef INCLUDED_RTL_STRING_HXX
25#define INCLUDED_RTL_STRING_HXX
26
27#include "sal/config.h"
28
29#include <cassert>
30#include <cstddef>
31#include <cstdlib>
32#include <limits>
33#include <new>
34#include <ostream>
35#include <utility>
36#include <string.h>
37
38#if defined LIBO_INTERNAL_ONLY
39#include <string_view>
40#include <type_traits>
41#endif
42
43#include "rtl/textenc.h"
44#include "rtl/string.h"
45#include "rtl/stringutils.hxx"
46
47#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
48#include "config_global.h"
49#include "rtl/stringconcat.hxx"
50#endif
51
52#ifdef RTL_STRING_UNITTEST
53extern bool rtl_string_unittest_const_literal;
54extern bool rtl_string_unittest_const_literal_function;
55#endif
56
57// The unittest uses slightly different code to help check that the proper
58// calls are made. The class is put into a different namespace to make
59// sure the compiler generates a different (if generating also non-inline)
60// copy of the function and does not merge them together. The class
61// is "brought" into the proper rtl namespace by a typedef below.
62#ifdef RTL_STRING_UNITTEST
63#define rtl rtlunittest
64#endif
65
66namespace rtl
67{
68
70#ifdef RTL_STRING_UNITTEST
71#undef rtl
72// helper macro to make functions appear more readable
73#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
74#else
75#define RTL_STRING_CONST_FUNCTION
76#endif
78
79#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
86template<std::size_t N> class SAL_WARN_UNUSED OStringLiteral {
87 static_assert(N != 0);
88 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
89 friend class OString;
90
91public:
92#if HAVE_CPP_CONSTEVAL
93 consteval
94#else
95 constexpr
96#endif
97 OStringLiteral(char const (&literal)[N]) {
98 assertLayout();
99 assert(literal[N - 1] == '\0');
100 //TODO: Use C++20 constexpr std::copy_n (P0202R3):
101 for (std::size_t i = 0; i != N; ++i) {
102 more.buffer[i] = literal[i];
103 }
104 }
105
106#if defined __cpp_char8_t
107#if HAVE_CPP_CONSTEVAL
108 consteval
109#else
110 constexpr
111#endif
112 explicit OStringLiteral(char8_t const (&literal)[N]) {
113 assertLayout();
114 assert(literal[N - 1] == '\0');
115 //TODO: Use C++20 constexpr std::copy_n (P0202R3):
116 for (std::size_t i = 0; i != N; ++i) {
117 more.buffer[i] = literal[i];
118 }
119 }
120#endif
121
122 constexpr sal_Int32 getLength() const { return more.length; }
123
124 constexpr char const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
125
126 constexpr operator std::string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
127
128private:
129 static constexpr void assertLayout() {
130 // These static_asserts verifying the layout compatibility with rtl_String cannot be class
131 // member declarations, as offsetof requires a complete type, so defer them to here:
132 static_assert(std::is_standard_layout_v<OStringLiteral>);
133 static_assert(offsetof(OStringLiteral, str.refCount) == offsetof(OStringLiteral, more.refCount));
134 static_assert(offsetof(OStringLiteral, str.length) == offsetof(OStringLiteral, more.length));
135 static_assert(offsetof(OStringLiteral, str.buffer) == offsetof(OStringLiteral, more.buffer));
136 }
137
138 union {
139 rtl_String str;
140 struct {
141 oslInterlockedCount refCount;
142 sal_Int32 length;
143 char buffer[N];
144 } more =
145 {
146 0x40000000, // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
147 N - 1,
148 {} //TODO: drop initialization for C++20 (P1331R2)
149 };
150 };
151};
152#endif
153
154/* ======================================================================= */
155
180 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
181{
182public:
184 rtl_String * pData;
186
190 OString()
191 {
192 pData = NULL;
193 rtl_string_new( &pData );
194 }
195
201 OString( const OString & str )
202 {
203 pData = str.pData;
204 rtl_string_acquire( pData );
205 }
206
207#if defined LIBO_INTERNAL_ONLY
214 OString( OString && str ) noexcept
215 {
216 pData = str.pData;
217 str.pData = nullptr;
218 rtl_string_new( &str.pData );
219 }
220#endif
221
227 OString( rtl_String * str )
228 {
229 pData = str;
230 rtl_string_acquire( pData );
231 }
232
240 OString( rtl_String * str, __sal_NoAcquire )
241 {
242 pData = str;
243 }
244
250 explicit OString( char value )
251 : pData (NULL)
252 {
253 rtl_string_newFromStr_WithLength( &pData, &value, 1 );
254 }
255
256#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
257 // Catch inadvertent conversions to the above ctor (e.g., from sal_[u]Int8, aka [un]signed
258 // char):
259 OString(int) = delete;
260#endif
261
270 template< typename T >
271 OString( const T& value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
272 {
273 pData = NULL;
274 rtl_string_newFromStr( &pData, value );
275 }
276
277 template< typename T >
278 OString( T& value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
279 {
280 pData = NULL;
281 rtl_string_newFromStr( &pData, value );
282 }
283
294 template< typename T >
295 OString( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
296 {
297 assert(
298 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
299 pData = NULL;
300 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
301 rtl_string_new(&pData);
302 } else {
303 rtl_string_newFromLiteral(
304 &pData,
305 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
306 literal),
307 libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
308 }
309#ifdef RTL_STRING_UNITTEST
310 rtl_string_unittest_const_literal = true;
311#endif
312 }
313
322 OString( const char * value, sal_Int32 length )
323 {
324 pData = NULL;
325 rtl_string_newFromStr_WithLength( &pData, value, length );
326 }
327
328#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
330
335 template<std::size_t N> constexpr OString(OStringLiteral<N> const & literal):
336 pData(const_cast<rtl_String *>(&literal.str)) {}
337 template<std::size_t N> OString(OStringLiteral<N> &&) = delete;
339#endif
340
341#if defined LIBO_INTERNAL_ONLY
342 explicit OString(std::string_view sv) {
343 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
344 throw std::bad_alloc();
345 }
346 pData = nullptr;
347 rtl_string_newFromStr_WithLength(&pData, sv.data(), sv.size());
348 }
349#endif
350
365 OString( const sal_Unicode * value, sal_Int32 length,
366 rtl_TextEncoding encoding,
367 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
368 {
369 pData = NULL;
370 rtl_uString2String( &pData, value, length, encoding, convertFlags );
371 if (pData == NULL) {
372 throw std::bad_alloc();
373 }
374 }
375
376#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
381 template< typename T1, typename T2 >
382 OString( OStringConcat< T1, T2 >&& c )
383 {
384 const sal_Int32 l = c.length();
385 pData = rtl_string_alloc( l );
386 if (l != 0)
387 {
388 char* end = c.addData( pData->buffer );
389 pData->length = l;
390 *end = '\0';
391 }
392 }
393
398 template< typename T >
399 OString( OStringNumber< T >&& n )
400 : OString( n.buf, n.length )
401 {}
402#endif
403
404#ifdef LIBO_INTERNAL_ONLY
405 OString(std::nullptr_t) = delete;
406#endif
407
411 ~OString()
412 {
413 rtl_string_release( pData );
414 }
415
421 OString & operator=( const OString & str )
422 {
423 rtl_string_assign( &pData, str.pData );
424 return *this;
425 }
426
427#if defined LIBO_INTERNAL_ONLY
434 OString & operator=( OString && str ) noexcept
435 {
436 rtl_string_release( pData );
437 pData = str.pData;
438 str.pData = nullptr;
439 rtl_string_new( &str.pData );
440 return *this;
441 }
442#endif
443
449 template< typename T >
450 typename libreoffice_internal::ConstCharArrayDetector< T, OString& >::Type operator=( T& literal )
451 {
452 RTL_STRING_CONST_FUNCTION
453 assert(
454 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
455 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
456 rtl_string_new(&pData);
457 } else {
458 rtl_string_newFromLiteral(
459 &pData,
460 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
461 literal),
462 libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
463 }
464 return *this;
465 }
466
472 OString & operator+=( const OString & str )
473#if defined LIBO_INTERNAL_ONLY
474 &
475#endif
476 {
477 rtl_string_newConcat( &pData, pData, str.pData );
478 return *this;
479 }
480#if defined LIBO_INTERNAL_ONLY
481 void operator+=(OString const &) && = delete;
482#endif
483
484#if defined LIBO_INTERNAL_ONLY
485 template<typename T> typename libreoffice_internal::CharPtrDetector<T, OString &>::Type
486 operator +=(T const & value) & { return operator +=(std::string_view(value)); }
487 template<typename T> typename libreoffice_internal::CharPtrDetector<T, OString &>::Type
488 operator +=(T const &) && = delete;
489
490 template<typename T>
491 typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type
492 operator +=(T & value) & { return operator +=(std::string_view(value)); }
493 template<typename T>
494 typename libreoffice_internal::NonConstCharArrayDetector<T, OString &>::Type operator +=(T &) &&
495 = delete;
496
497 template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
498 operator +=(T & literal) & {
499 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
500 return operator +=(
501 std::string_view(
502 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
503 libreoffice_internal::ConstCharArrayDetector<T>::length));
504 }
505 template<typename T> typename libreoffice_internal::ConstCharArrayDetector<T, OString &>::Type
506 operator +=(T &) && = delete;
507
508 template<std::size_t N> OString & operator +=(OStringLiteral<N> const & literal) &
509 { return operator +=(std::string_view(literal.getStr(), literal.getLength())); }
510 template<std::size_t N> void operator +=(OStringLiteral<N> const &) && = delete;
511
512 OString & operator +=(std::string_view sv) & {
513 if (sv.empty()) {
514 return *this;
515 }
516 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max() - pData->length)) {
517 throw std::bad_alloc();
518 }
519 auto const l = pData->length + sv.size();
520 rtl_string_ensureCapacity(&pData, l);
521 *addDataHelper(pData->buffer + pData->length, sv.data(), sv.size()) = '\0';
522 pData->length = l;
523 return *this;
524 }
525 void operator +=(std::string_view) && = delete;
526#endif
527
528#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
533 template< typename T1, typename T2 >
534 OString& operator+=( OStringConcat< T1, T2 >&& c ) & {
535 sal_Int32 l = c.length();
536 if( l == 0 )
537 return *this;
538 l += pData->length;
539 rtl_string_ensureCapacity( &pData, l );
540 char* end = c.addData( pData->buffer + pData->length );
541 *end = '\0';
542 pData->length = l;
543 return *this;
544 }
545 template<typename T1, typename T2> void operator +=(
546 OStringConcat<T1, T2> &&) && = delete;
547
552 template< typename T >
553 OString& operator+=( OStringNumber< T >&& n ) & {
554 return operator +=(std::string_view(n.buf, n.length));
555 }
556 template<typename T> void operator +=(
557 OStringNumber<T> &&) && = delete;
558#endif
559
564 void clear()
565 {
566 rtl_string_new( &pData );
567 }
568
577 sal_Int32 getLength() const { return pData->length; }
578
587 bool isEmpty() const
588 {
589 return pData->length == 0;
590 }
591
603 const char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
604
614 char operator [](sal_Int32 index) const {
615 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
616 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
617 return getStr()[index];
618 }
619
632 sal_Int32 compareTo( const OString & str ) const
633 {
634 return rtl_str_compare_WithLength( pData->buffer, pData->length,
635 str.pData->buffer, str.pData->length );
636 }
637
651 sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
652 {
653 return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
654 rObj.pData->buffer, rObj.pData->length, maxLength );
655 }
656
669 sal_Int32 reverseCompareTo( const OString & str ) const
670 {
671 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
672 str.pData->buffer, str.pData->length );
673 }
674
686 bool equals( const OString & str ) const
687 {
688 if ( pData->length != str.pData->length )
689 return false;
690 if ( pData == str.pData )
691 return true;
692 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
693 str.pData->buffer, str.pData->length ) == 0;
694 }
695
711 bool equalsL( const char* value, sal_Int32 length ) const
712 {
713 if ( pData->length != length )
714 return false;
715
716 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
717 value, length ) == 0;
718 }
719
734#if defined LIBO_INTERNAL_ONLY
735 bool equalsIgnoreAsciiCase( std::string_view str ) const
736 {
737 if ( sal_uInt32(pData->length) != str.size() )
738 return false;
739 if ( pData->buffer == str.data() )
740 return true;
741 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
742 str.data(), str.size() ) == 0;
743 }
744#else
745 bool equalsIgnoreAsciiCase( const OString & str ) const
746 {
747 if ( pData->length != str.pData->length )
748 return false;
749 if ( pData == str.pData )
750 return true;
751 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
752 str.pData->buffer, str.pData->length ) == 0;
753 }
754#endif
755
777 template< typename T >
778 typename libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase( const T& asciiStr ) const
779 {
780 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
781 }
782
783 template< typename T >
784 typename libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& asciiStr ) const
785 {
786 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
787 }
788
794 template< typename T >
795 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const
796 {
797 RTL_STRING_CONST_FUNCTION
798 assert(
799 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
800 return
801 (pData->length
802 == libreoffice_internal::ConstCharArrayDetector<T>::length)
803 && (rtl_str_compareIgnoreAsciiCase_WithLength(
804 pData->buffer, pData->length,
805 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
806 literal),
807 libreoffice_internal::ConstCharArrayDetector<T>::length)
808 == 0);
809 }
810
830 bool equalsIgnoreAsciiCaseL( const char * asciiStr, sal_Int32 asciiStrLength ) const
831 {
832 if ( pData->length != asciiStrLength )
833 return false;
834
835 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
836 asciiStr, asciiStrLength ) == 0;
837 }
838
854#if defined LIBO_INTERNAL_ONLY
855 bool match( std::string_view str, sal_Int32 fromIndex = 0 ) const
856 {
857 return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
858 str.data(), str.size(), str.size() ) == 0;
859 }
860#else
861 bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
862 {
863 return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
864 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
865 }
866#endif
867
873 template< typename T >
874 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
875 {
876 RTL_STRING_CONST_FUNCTION
877 assert(
878 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
879 return
880 rtl_str_shortenedCompare_WithLength(
881 pData->buffer + fromIndex, pData->length - fromIndex,
882 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
883 literal),
884 libreoffice_internal::ConstCharArrayDetector<T>::length,
885 libreoffice_internal::ConstCharArrayDetector<T>::length)
886 == 0;
887 }
888
905 bool matchL(
906 char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
907 const
908 {
909 return rtl_str_shortenedCompare_WithLength(
910 pData->buffer + fromIndex, pData->length - fromIndex,
911 str, strLength, strLength) == 0;
912 }
913
914 // This overload is left undefined, to detect calls of matchL that
915 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
916 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
917 // platforms):
918#if SAL_TYPES_SIZEOFLONG == 8
919 void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
920#endif
921
940#if defined LIBO_INTERNAL_ONLY
941 bool matchIgnoreAsciiCase( std::string_view str, sal_Int32 fromIndex = 0 ) const
942 {
943 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
944 str.data(), str.size(),
945 str.size() ) == 0;
946 }
947#else
948 bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
949 {
950 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
951 str.pData->buffer, str.pData->length,
952 str.pData->length ) == 0;
953 }
954#endif
960 template< typename T >
961 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
962 {
963 RTL_STRING_CONST_FUNCTION
964 assert(
965 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
966 return
967 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
968 pData->buffer+fromIndex, pData->length-fromIndex,
969 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
970 literal),
971 libreoffice_internal::ConstCharArrayDetector<T>::length,
972 libreoffice_internal::ConstCharArrayDetector<T>::length)
973 == 0;
974 }
975
990#if defined LIBO_INTERNAL_ONLY
991 bool startsWith(std::string_view str, OString * rest = NULL) const {
992 bool b = match(str);
993 if (b && rest != NULL) {
994 *rest = copy(str.size());
995 }
996 return b;
997 }
998#else
999 bool startsWith(OString const & str, OString * rest = NULL) const {
1000 bool b = match(str);
1001 if (b && rest != NULL) {
1002 *rest = copy(str.getLength());
1003 }
1004 return b;
1005 }
1006#endif
1007
1013 template< typename T >
1014 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(
1015 T & literal, OString * rest = NULL) const
1016 {
1017 RTL_STRING_CONST_FUNCTION
1018 bool b = match(literal, 0);
1019 if (b && rest != NULL) {
1020 *rest = copy(
1021 libreoffice_internal::ConstCharArrayDetector<T>::length);
1022 }
1023 return b;
1024 }
1025
1045#if defined LIBO_INTERNAL_ONLY
1046 bool startsWithIgnoreAsciiCase(std::string_view str, OString * rest = NULL)
1047 const
1048 {
1049 bool b = matchIgnoreAsciiCase(str);
1050 if (b && rest != NULL) {
1051 *rest = copy(str.size());
1052 }
1053 return b;
1054 }
1055#else
1056 bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
1057 const
1058 {
1059 bool b = matchIgnoreAsciiCase(str);
1060 if (b && rest != NULL) {
1061 *rest = copy(str.getLength());
1062 }
1063 return b;
1064 }
1065#endif
1066
1072 template< typename T >
1073 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
1074 startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
1075 {
1076 RTL_STRING_CONST_FUNCTION
1077 assert(
1078 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1079 bool b = matchIgnoreAsciiCase(literal);
1080 if (b && rest != NULL) {
1081 *rest = copy(
1082 libreoffice_internal::ConstCharArrayDetector<T>::length);
1083 }
1084 return b;
1085 }
1086
1101#if defined LIBO_INTERNAL_ONLY
1102 bool endsWith(std::string_view str, OString * rest = NULL) const {
1103 bool b = str.size() <= sal_uInt32(getLength())
1104 && match(str, getLength() - str.size());
1105 if (b && rest != NULL) {
1106 *rest = copy(0, getLength() - str.size());
1107 }
1108 return b;
1109 }
1110#else
1111 bool endsWith(OString const & str, OString * rest = NULL) const {
1112 bool b = str.getLength() <= getLength()
1113 && match(str, getLength() - str.getLength());
1114 if (b && rest != NULL) {
1115 *rest = copy(0, getLength() - str.getLength());
1116 }
1117 return b;
1118 }
1119#endif
1120
1126 template< typename T >
1127 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(
1128 T & literal, OString * rest = NULL) const
1129 {
1130 RTL_STRING_CONST_FUNCTION
1131 assert(
1132 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1133 bool b
1134 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1135 <= sal_uInt32(getLength()))
1136 && match(
1137 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1138 literal),
1139 (getLength()
1140 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1141 if (b && rest != NULL) {
1142 *rest = copy(
1143 0,
1144 (getLength()
1145 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1146 }
1147 return b;
1148 }
1149
1163 bool endsWithL(char const * str, sal_Int32 strLength) const {
1164 return strLength <= getLength()
1165 && matchL(str, strLength, getLength() - strLength);
1166 }
1167
1168 friend bool operator == ( const OString& rStr1, const OString& rStr2 )
1169 { return rStr1.equals(rStr2); }
1170 friend bool operator != ( const OString& rStr1, const OString& rStr2 )
1171 { return !(operator == ( rStr1, rStr2 )); }
1172 friend bool operator < ( const OString& rStr1, const OString& rStr2 )
1173 { return rStr1.compareTo( rStr2 ) < 0; }
1174 friend bool operator > ( const OString& rStr1, const OString& rStr2 )
1175 { return rStr1.compareTo( rStr2 ) > 0; }
1176 friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
1177 { return rStr1.compareTo( rStr2 ) <= 0; }
1178 friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
1179 { return rStr1.compareTo( rStr2 ) >= 0; }
1180
1181 template< typename T >
1182 friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
1183 {
1184 return rStr1.compareTo( value ) == 0;
1185 }
1186
1187 template< typename T >
1188 friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr1, T& value )
1189 {
1190 return rStr1.compareTo( value ) == 0;
1191 }
1192
1193 template< typename T >
1194 friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
1195 {
1196 return rStr2.compareTo( value ) == 0;
1197 }
1198
1199 template< typename T >
1200 friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==( T& value, const OString& rStr2 )
1201 {
1202 return rStr2.compareTo( value ) == 0;
1203 }
1204
1210 template< typename T >
1211 friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr, T& literal )
1212 {
1213 RTL_STRING_CONST_FUNCTION
1214 assert(
1215 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1216 return
1217 (rStr.getLength()
1218 == libreoffice_internal::ConstCharArrayDetector<T>::length)
1219 && (rtl_str_compare_WithLength(
1220 rStr.pData->buffer, rStr.pData->length,
1221 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1222 literal),
1223 libreoffice_internal::ConstCharArrayDetector<T>::length)
1224 == 0);
1225 }
1226
1232 template< typename T >
1233 friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OString& rStr )
1234 {
1235 RTL_STRING_CONST_FUNCTION
1236 assert(
1237 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1238 return
1239 (rStr.getLength()
1240 == libreoffice_internal::ConstCharArrayDetector<T>::length)
1241 && (rtl_str_compare_WithLength(
1242 rStr.pData->buffer, rStr.pData->length,
1243 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1244 literal),
1245 libreoffice_internal::ConstCharArrayDetector<T>::length)
1246 == 0);
1247 }
1248
1249 template< typename T >
1250 friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1251 {
1252 return !(operator == ( rStr1, value ));
1253 }
1254
1255 template< typename T >
1256 friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr1, T& value )
1257 {
1258 return !(operator == ( rStr1, value ));
1259 }
1260
1261 template< typename T >
1262 friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1263 {
1264 return !(operator == ( value, rStr2 ));
1265 }
1266
1267 template< typename T >
1268 friend typename libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=( T& value, const OString& rStr2 )
1269 {
1270 return !(operator == ( value, rStr2 ));
1271 }
1272
1278 template< typename T >
1279 friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr, T& literal )
1280 {
1281 return !( rStr == literal );
1282 }
1283
1289 template< typename T >
1290 friend typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OString& rStr )
1291 {
1292 return !( literal == rStr );
1293 }
1294
1302 sal_Int32 hashCode() const
1303 {
1304 return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1305 }
1306
1320 sal_Int32 indexOf( char ch, sal_Int32 fromIndex = 0 ) const
1321 {
1322 sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1323 return (ret < 0 ? ret : ret+fromIndex);
1324 }
1325
1335 sal_Int32 lastIndexOf( char ch ) const
1336 {
1337 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1338 }
1339
1352 sal_Int32 lastIndexOf( char ch, sal_Int32 fromIndex ) const
1353 {
1354 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1355 }
1356
1372#if defined LIBO_INTERNAL_ONLY
1373 sal_Int32 indexOf( std::string_view str, sal_Int32 fromIndex = 0 ) const
1374 {
1375 sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1376 str.data(), str.size() );
1377 return (ret < 0 ? ret : ret+fromIndex);
1378 }
1379#else
1380 sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1381 {
1382 sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1383 str.pData->buffer, str.pData->length );
1384 return (ret < 0 ? ret : ret+fromIndex);
1385 }
1386#endif
1392 template< typename T >
1393 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1394 {
1395 RTL_STRING_CONST_FUNCTION
1396 assert(
1397 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1398 sal_Int32 n = rtl_str_indexOfStr_WithLength(
1399 pData->buffer + fromIndex, pData->length - fromIndex,
1400 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1401 libreoffice_internal::ConstCharArrayDetector<T>::length);
1402 return n < 0 ? n : n + fromIndex;
1403 }
1404
1423 sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1424 const
1425 {
1426 sal_Int32 n = rtl_str_indexOfStr_WithLength(
1427 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1428 return n < 0 ? n : n + fromIndex;
1429 }
1430
1431 // This overload is left undefined, to detect calls of indexOfL that
1432 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1433 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1434 // platforms):
1435#if SAL_TYPES_SIZEOFLONG == 8
1436 void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1437#endif
1438
1454#if defined LIBO_INTERNAL_ONLY
1455 sal_Int32 lastIndexOf( std::string_view str ) const
1456 {
1457 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1458 str.data(), str.size() );
1459 }
1460#else
1461 sal_Int32 lastIndexOf( const OString & str ) const
1462 {
1463 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1464 str.pData->buffer, str.pData->length );
1465 }
1466#endif
1467
1485#if defined LIBO_INTERNAL_ONLY
1486 sal_Int32 lastIndexOf( std::string_view str, sal_Int32 fromIndex ) const
1487 {
1488 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1489 str.data(), str.size() );
1490 }
1491#else
1492 sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1493 {
1494 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1495 str.pData->buffer, str.pData->length );
1496 }
1497#endif
1498
1509 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1510 {
1511 return copy(beginIndex, getLength() - beginIndex);
1512 }
1513
1526 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1527 {
1528 rtl_String *pNew = NULL;
1529 rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1530 return OString( pNew, SAL_NO_ACQUIRE );
1531 }
1532
1533#if defined LIBO_INTERNAL_ONLY
1544 SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex ) const
1545 {
1546 assert(beginIndex >= 0);
1547 assert(beginIndex <= getLength());
1548 return subView(beginIndex, getLength() - beginIndex);
1549 }
1550
1563 SAL_WARN_UNUSED_RESULT std::string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
1564 {
1565 assert(beginIndex >= 0);
1566 assert(count >= 0);
1567 assert(beginIndex <= getLength());
1568 assert(count <= getLength() - beginIndex);
1569 return std::string_view(*this).substr(beginIndex, count);
1570 }
1571#endif
1572
1573#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1582 SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const
1583 {
1584 rtl_String* pNew = NULL;
1585 rtl_string_newConcat( &pNew, pData, str.pData );
1586 return OString( pNew, SAL_NO_ACQUIRE );
1587 }
1588#endif
1589
1590#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1591 friend OString operator+( const OString & str1, const OString & str2 )
1592 {
1593 return str1.concat( str2 );
1594 }
1595#endif
1596
1597// hide this from internal code to avoid ambiguous lookup error
1598#ifndef LIBO_INTERNAL_ONLY
1612 SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1613 {
1614 rtl_String* pNew = NULL;
1615 rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1616 return OString( pNew, SAL_NO_ACQUIRE );
1617 }
1618#endif
1619
1620#ifdef LIBO_INTERNAL_ONLY
1621 SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, std::string_view newStr ) const
1622 {
1623 rtl_String* pNew = NULL;
1624 rtl_string_newReplaceStrAt_WithLength ( &pNew, pData, index, count, newStr.data(), newStr.size() );
1625 return OString( pNew, SAL_NO_ACQUIRE );
1626 }
1627#endif
1628
1642 SAL_WARN_UNUSED_RESULT OString replace( char oldChar, char newChar ) const
1643 {
1644 rtl_String* pNew = NULL;
1645 rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1646 return OString( pNew, SAL_NO_ACQUIRE );
1647 }
1648
1667 SAL_WARN_UNUSED_RESULT OString replaceFirst(
1668 OString const & from, OString const & to, sal_Int32 * index = NULL) const
1669 {
1670 rtl_String * s = NULL;
1671 sal_Int32 i = 0;
1672 rtl_string_newReplaceFirst(
1673 &s, pData, from.pData->buffer, from.pData->length,
1674 to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1675 return OString(s, SAL_NO_ACQUIRE);
1676 }
1677
1691 SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1692 rtl_String * s = NULL;
1693 rtl_string_newReplaceAll(
1694 &s, pData, from.pData->buffer, from.pData->length,
1695 to.pData->buffer, to.pData->length);
1696 return OString(s, SAL_NO_ACQUIRE);
1697 }
1698
1709 SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const
1710 {
1711 rtl_String* pNew = NULL;
1712 rtl_string_newToAsciiLowerCase( &pNew, pData );
1713 return OString( pNew, SAL_NO_ACQUIRE );
1714 }
1715
1726 SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const
1727 {
1728 rtl_String* pNew = NULL;
1729 rtl_string_newToAsciiUpperCase( &pNew, pData );
1730 return OString( pNew, SAL_NO_ACQUIRE );
1731 }
1732
1744 SAL_WARN_UNUSED_RESULT OString trim() const
1745 {
1746 rtl_String* pNew = NULL;
1747 rtl_string_newTrim( &pNew, pData );
1748 return OString( pNew, SAL_NO_ACQUIRE );
1749 }
1750
1775 OString getToken( sal_Int32 token, char cTok, sal_Int32& index ) const
1776 {
1777 rtl_String * pNew = NULL;
1778 index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1779 return OString( pNew, SAL_NO_ACQUIRE );
1780 }
1781
1795 OString getToken(sal_Int32 count, char separator) const {
1796 sal_Int32 n = 0;
1797 return getToken(count, separator, n);
1798 }
1799
1808 bool toBoolean() const
1809 {
1810 return rtl_str_toBoolean( pData->buffer );
1811 }
1812
1819 char toChar() const
1820 {
1821 return pData->buffer[0];
1822 }
1823
1834 sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1835 {
1836 return rtl_str_toInt32( pData->buffer, radix );
1837 }
1838
1851 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1852 {
1853 return rtl_str_toUInt32( pData->buffer, radix );
1854 }
1855
1866 sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1867 {
1868 return rtl_str_toInt64( pData->buffer, radix );
1869 }
1870
1883 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1884 {
1885 return rtl_str_toUInt64( pData->buffer, radix );
1886 }
1887
1896 float toFloat() const
1897 {
1898 return rtl_str_toFloat( pData->buffer );
1899 }
1900
1909 double toDouble() const
1910 {
1911 return rtl_str_toDouble( pData->buffer );
1912 }
1913
1914#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1915
1916 static OStringNumber< int > number( int i, sal_Int16 radix = 10 )
1917 {
1918 return OStringNumber< int >( i, radix );
1919 }
1920 static OStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
1921 {
1922 return OStringNumber< long long >( ll, radix );
1923 }
1924 static OStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
1925 {
1926 return OStringNumber< unsigned long long >( ll, radix );
1927 }
1928 static OStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
1929 {
1930 return number( static_cast< unsigned long long >( i ), radix );
1931 }
1932 static OStringNumber< long long > number( long i, sal_Int16 radix = 10)
1933 {
1934 return number( static_cast< long long >( i ), radix );
1935 }
1936 static OStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
1937 {
1938 return number( static_cast< unsigned long long >( i ), radix );
1939 }
1940 static OStringNumber< float > number( float f )
1941 {
1942 return OStringNumber< float >( f );
1943 }
1944 static OStringNumber< double > number( double d )
1945 {
1946 return OStringNumber< double >( d );
1947 }
1948#else
1959 static OString number( int i, sal_Int16 radix = 10 )
1960 {
1961 char aBuf[RTL_STR_MAX_VALUEOFINT32];
1962 return OString(aBuf, rtl_str_valueOfInt32(aBuf, i, radix));
1963 }
1966 static OString number( unsigned int i, sal_Int16 radix = 10 )
1967 {
1968 return number( static_cast< unsigned long long >( i ), radix );
1969 }
1972 static OString number( long i, sal_Int16 radix = 10 )
1973 {
1974 return number( static_cast< long long >( i ), radix );
1975 }
1978 static OString number( unsigned long i, sal_Int16 radix = 10 )
1979 {
1980 return number( static_cast< unsigned long long >( i ), radix );
1981 }
1984 static OString number( long long ll, sal_Int16 radix = 10 )
1985 {
1986 char aBuf[RTL_STR_MAX_VALUEOFINT64];
1987 return OString(aBuf, rtl_str_valueOfInt64(aBuf, ll, radix));
1988 }
1991 static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1992 {
1993 char aBuf[RTL_STR_MAX_VALUEOFUINT64];
1994 return OString(aBuf, rtl_str_valueOfUInt64(aBuf, ll, radix));
1995 }
1996
2006 static OString number( float f )
2007 {
2008 char aBuf[RTL_STR_MAX_VALUEOFFLOAT];
2009 return OString(aBuf, rtl_str_valueOfFloat(aBuf, f));
2010 }
2011
2021 static OString number( double d )
2022 {
2023 char aBuf[RTL_STR_MAX_VALUEOFDOUBLE];
2024 return OString(aBuf, rtl_str_valueOfDouble(aBuf, d));
2025 }
2026#endif
2027
2039 SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
2040 {
2041 return boolean(b);
2042 }
2043
2055 static OString boolean( bool b )
2056 {
2057 char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
2058 return OString(aBuf, rtl_str_valueOfBoolean(aBuf, b));
2059 }
2060
2068 SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( char c )
2069 {
2070 return OString( &c, 1 );
2071 }
2072
2083 SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2084 {
2085 return number( i, radix );
2086 }
2087
2098 SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2099 {
2100 return number( ll, radix );
2101 }
2102
2112 SAL_DEPRECATED("use number()") static OString valueOf( float f )
2113 {
2114 return number(f);
2115 }
2116
2126 SAL_DEPRECATED("use number()") static OString valueOf( double d )
2127 {
2128 return number(d);
2129 }
2130
2131#if defined LIBO_INTERNAL_ONLY
2132 operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
2133#endif
2134
2135#if defined LIBO_INTERNAL_ONLY
2136 // A wrapper for the first expression in an
2137 //
2138 // OString::Concat(e1) + e2 + ...
2139 //
2140 // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
2141 // classes (so something like
2142 //
2143 // OString s = "a" + (b ? std::string_view("c") : std::string_view("dd"));
2144 //
2145 // would not compile):
2146 template<typename T> [[nodiscard]] static
2147 typename std::enable_if_t<
2148 ToStringHelper<T>::allowOStringConcat, OStringConcat<OStringConcatMarker, T>>
2149 Concat(T const & value) { return OStringConcat<OStringConcatMarker, T>({}, value); }
2150
2151 // This overload is needed so that an argument of type 'char const[N]' ends up as
2152 // 'OStringConcat<rtl::OStringConcatMarker, char const[N]>' rather than as
2153 // 'OStringConcat<rtl::OStringConcatMarker, char[N]>':
2154 template<typename T, std::size_t N> [[nodiscard]] static
2155 typename std::enable_if_t<
2156 ToStringHelper<T[N]>::allowOStringConcat, OStringConcat<OStringConcatMarker, T[N]>>
2157 Concat(T (& value)[N]) { return OStringConcat<OStringConcatMarker, T[N]>({}, value); }
2158#endif
2159};
2160
2161#if defined LIBO_INTERNAL_ONLY
2162inline bool operator ==(OString const & lhs, OStringConcatenation const & rhs)
2163{ return lhs == std::string_view(rhs); }
2164inline bool operator !=(OString const & lhs, OStringConcatenation const & rhs)
2165{ return lhs != std::string_view(rhs); }
2166inline bool operator ==(OStringConcatenation const & lhs, OString const & rhs)
2167{ return std::string_view(lhs) == rhs; }
2168inline bool operator !=(OStringConcatenation const & lhs, OString const & rhs)
2169{ return std::string_view(lhs) != rhs; }
2170#endif
2171
2172/* ======================================================================= */
2173
2174#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2175
2179template<>
2180struct ToStringHelper< OString >
2181 {
2182 static std::size_t length( const OString& s ) { return s.getLength(); }
2183 static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2184 static const bool allowOStringConcat = true;
2185 static const bool allowOUStringConcat = false;
2186 };
2187
2191template<std::size_t N>
2192struct ToStringHelper< OStringLiteral<N> >
2193 {
2194 static constexpr std::size_t length( const OStringLiteral<N>& str ) { return str.getLength(); }
2195 static char* addData( char* buffer, const OStringLiteral<N>& str ) { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
2196 static const bool allowOStringConcat = true;
2197 static const bool allowOUStringConcat = false;
2198 };
2199
2203template< typename charT, typename traits, typename T1, typename T2 >
2204inline std::basic_ostream<charT, traits> & operator <<(
2205 std::basic_ostream<charT, traits> & stream, OStringConcat< T1, T2 >&& concat)
2206{
2207 return stream << OString( std::move(concat) );
2208}
2209#endif
2210
2211
2217 struct OStringHash
2218{
2228 size_t operator()( const OString& rString ) const
2229 { return static_cast<size_t>(rString.hashCode()); }
2230};
2231
2233 struct CStringEqual
2234{
2235 bool operator()( const char* p1, const char* p2) const
2236 { return rtl_str_compare(p1, p2) == 0; }
2237};
2238
2240 struct CStringHash
2241{
2242 size_t operator()(const char* p) const
2243 { return rtl_str_hashCode(p); }
2244};
2245
2246/* ======================================================================= */
2247
2254template< typename charT, typename traits > std::basic_ostream<charT, traits> &
2255 operator <<(
2256 std::basic_ostream<charT, traits> & stream, OString const & rString)
2257{
2258 return stream << rString.getStr();
2259 // best effort; potentially loses data due to embedded null characters
2260}
2261
2262} /* Namespace */
2263
2264#ifdef RTL_STRING_UNITTEST
2265namespace rtl
2266{
2267typedef rtlunittest::OString OString;
2268}
2269#undef RTL_STRING_CONST_FUNCTION
2270#endif
2271
2272#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2273using ::rtl::OString;
2274using ::rtl::OStringChar;
2275using ::rtl::OStringConcatenation;
2276using ::rtl::OStringHash;
2277using ::rtl::OStringLiteral;
2278#endif
2279
2281
2286#if defined LIBO_INTERNAL_ONLY
2287namespace std {
2288
2289template<>
2290struct hash<::rtl::OString>
2291{
2292 std::size_t operator()(::rtl::OString const & s) const
2293 { return std::size_t(s.hashCode()); }
2294};
2295
2296}
2297
2298#endif
2300
2301#endif // INCLUDED_RTL_STRING_HXX
2302
2303/* 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_NoAcquire
__sal_NoAcquire
Definition: types.h:353
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:356
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
string.h
rtl_str_toDouble
SAL_DLLPUBLIC double rtl_str_toDouble(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
rtl_str_compare
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
rtl_str_hashCode_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
rtl_string_newReplaceStrAt
SAL_DLLPUBLIC void rtl_string_newReplaceStrAt(rtl_String **newStr, rtl_String *str, sal_Int32 idx, sal_Int32 count, rtl_String *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
rtl_str_toBoolean
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
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_acquire
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
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_string_newConcat
SAL_DLLPUBLIC void rtl_string_newConcat(rtl_String **newStr, rtl_String *left, rtl_String *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
rtl_str_toUInt32
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
rtl_str_compareIgnoreAsciiCase
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const char *first, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl_string_assign
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
rtl_str_lastIndexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
rtl_string_newReplaceAll
SAL_DLLPUBLIC void rtl_string_newReplaceAll(rtl_String **newStr, rtl_String *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
rtl_str_reverseCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
rtl_str_toUInt64
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
rtl_string_getToken
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
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_newReplaceFirst
SAL_DLLPUBLIC void rtl_string_newReplaceFirst(rtl_String **newStr, rtl_String *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
rtl_string_newFromStr
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
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_str_shortenedCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
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_shortenedCompareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
rtl_str_indexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
rtl_uString2String
SAL_DLLPUBLIC void rtl_uString2String(rtl_String **newStr, const sal_Unicode *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new byte string by converting a Unicode string, using a specific text encoding.
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.
OUSTRING_TO_OSTRING_CVTFLAGS
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1358
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_str_hashCode
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
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_MAX_VALUEOFUINT64
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:677
rtl_string_newToAsciiLowerCase
SAL_DLLPUBLIC void rtl_string_newToAsciiLowerCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string.
rtl_string_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
rtl_string_newTrim
SAL_DLLPUBLIC void rtl_string_newTrim(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
rtl_str_toInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:654
rtl_string_ensureCapacity
SAL_DLLPUBLIC void rtl_string_ensureCapacity(rtl_String **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
rtl_string_newFromSubString
SAL_DLLPUBLIC void rtl_string_newFromSubString(rtl_String **newStr, const rtl_String *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
rtl_str_indexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const char *str, sal_Int32 len, const char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
rtl_str_valueOfUInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
rtl_string_newToAsciiUpperCase
SAL_DLLPUBLIC void rtl_string_newToAsciiUpperCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string.
rtl_str_toFloat
SAL_DLLPUBLIC float rtl_str_toFloat(const char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
rtl_string_newReplace
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, char oldChar, char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string.
rtl_str_toInt64
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
rtl_str_compareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl_str_compare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const char *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
rtl_str_lastIndexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const char *str, sal_Int32 len, char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
stringutils.hxx
textenc.h
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
oslInterlockedCount
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
salhelper::operator<
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
salhelper::operator>
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
salhelper::operator==
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
rtl
Definition: bootstrap.hxx:34
rtl::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros,...
Definition: string.hxx:2255
com::sun::star::uno::operator!=
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:668
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:181
rtl::OString::concat
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1582
rtl::OString::OString
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:295
rtl::OString::OString
OString(const sal_Unicode *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
New string from a Unicode character buffer array.
Definition: string.hxx:365
rtl::OString::endsWith
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1127
rtl::OString::number
static OString number(unsigned long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1978
rtl::OString::startsWith
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:999
rtl::OString::operator==
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1211
rtl::OString::startsWith
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1014
rtl::OString::operator==
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1233
rtl::OString::indexOf
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1393
rtl::OString::OString
OString(const char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:322
rtl::OString::number
static OString number(unsigned long long ll, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1991
rtl::OString::number
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1959
rtl::OString::toUInt64
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1883
rtl::OString::indexOfL
sal_Int32 indexOfL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring,...
Definition: string.hxx:1423
rtl::OString::operator=
libreoffice_internal::ConstCharArrayDetector< T, OString & >::Type operator=(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:450
rtl::OString::compareTo
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:632
rtl::OString::operator+=
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:472
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:795
rtl::OString::toAsciiUpperCase
SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: string.hxx:1726
rtl::OString::startsWithIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1074
rtl::OString::operator!=
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1290
rtl::OString::toChar
char toChar() const
Returns the first character from this string.
Definition: string.hxx:1819
rtl::OString::toBoolean
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1808
rtl::OString::operator+
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1591
rtl::OString::copy
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1509
rtl::OString::operator!=
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1256
rtl::OString::OString
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:227
rtl::OString::startsWithIgnoreAsciiCase
bool startsWithIgnoreAsciiCase(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: string.hxx:1056
rtl::OString::number
static OString number(long long ll, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1984
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1461
rtl::OString::clear
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:564
rtl::OString::replaceFirst
SAL_WARN_UNUSED_RESULT OString replaceFirst(OString const &from, OString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: string.hxx:1667
rtl::OString::getToken
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1795
rtl::OString::number
static OString number(unsigned int i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1966
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::operator=
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:421
rtl::OString::matchIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:961
rtl::OString::compareTo
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:651
rtl::OString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:587
rtl::OString::operator==
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:1200
rtl::OString::OString
OString(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a character buffer array.
Definition: string.hxx:271
rtl::OString::getToken
OString getToken(sal_Int32 token, char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1775
rtl::OString::reverseCompareTo
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:669
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: string.hxx:1492
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(char ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1335
rtl::OString::copy
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1526
rtl::OString::operator!=
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1250
rtl::OString::replace
SAL_WARN_UNUSED_RESULT OString replace(char oldChar, char newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
Definition: string.hxx:1642
rtl::OString::hashCode
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1302
rtl::OString::boolean
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:2055
rtl::OString::matchL
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:905
rtl::OString::equalsL
bool equalsL(const char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:711
rtl::OString::trim
SAL_WARN_UNUSED_RESULT OString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: string.hxx:1744
rtl::OString::OString
OString(const OString &str)
New string from OString.
Definition: string.hxx:201
rtl::OString::replaceAll
SAL_WARN_UNUSED_RESULT OString replaceAll(OString const &from, OString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: string.hxx:1691
rtl::OString::endsWithL
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:1163
rtl::OString::toAsciiLowerCase
SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: string.hxx:1709
rtl::OString::match
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:861
rtl::OString::toFloat
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1896
rtl::OString::OString
OString()
New string containing no characters.
Definition: string.hxx:190
rtl::OString::match
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:874
rtl::OString::operator==
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:1194
rtl::OString::OString
OString(char value)
New string from a single character.
Definition: string.hxx:250
rtl::OString::number
static OString number(long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1972
rtl::OString::equalsIgnoreAsciiCase
bool equalsIgnoreAsciiCase(const OString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:745
rtl::OString::toInt64
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1866
rtl::OString::indexOf
sal_Int32 indexOf(const OString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring,...
Definition: string.hxx:1380
rtl::OString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1834
rtl::OString::~OString
~OString()
Release the string data.
Definition: string.hxx:411
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:784
rtl::OString::operator!=
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1279
rtl::OString::equalsIgnoreAsciiCase
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:778
rtl::OString::indexOf
sal_Int32 indexOf(char ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character,...
Definition: string.hxx:1320
rtl::OString::replaceAt
SAL_WARN_UNUSED_RESULT OString replaceAt(sal_Int32 index, sal_Int32 count, const OString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: string.hxx:1612
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:577
rtl::OString::toDouble
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1909
rtl::OString::number
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:2021
rtl::OString::endsWith
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:1111
rtl::OString::equals
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:686
rtl::OString::operator==
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:1188
rtl::OString::OString
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:240
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(char ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: string.hxx:1352
rtl::OString::OString
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:278
rtl::OString::operator==
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:1182
rtl::OString::toUInt32
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1851
rtl::OString::number
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:2006
rtl::OString::operator!=
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1262
rtl::OString::equalsIgnoreAsciiCaseL
bool equalsIgnoreAsciiCaseL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: string.hxx:830
rtl::OString::matchIgnoreAsciiCase
bool matchIgnoreAsciiCase(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: string.hxx:948
rtl::OString::operator!=
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1268
rtl::OStringHash
A helper to use OStrings with hash maps.
Definition: string.hxx:2218
rtl::OStringHash::operator()
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:2228
rtl::CStringEqual
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2234
rtl::CStringEqual::operator()
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:2235
rtl::CStringHash
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:2241
rtl::CStringHash::operator()
size_t operator()(const char *p) const
Definition: string.hxx:2242
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