LibreOffice LibreOffice 4.1 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #ifndef _RTL_STRING_HXX_
21 #define _RTL_STRING_HXX_
22
23 #include "sal/config.h"
24
25 #include <cassert>
26 #include <ostream>
27 #include <string.h>
28
29 #include <osl/diagnose.h>
30 #include <rtl/textenc.h>
31 #include <rtl/string.h>
32 #include <rtl/stringutils.hxx>
33
34 #ifdef RTL_FAST_STRING
35 #include <rtl/stringconcat.hxx>
36 #endif
37
38 #include "sal/log.hxx"
39
40 #if !defined EXCEPTIONS_OFF
41 #include <new>
42 #endif
43
44 // The unittest uses slightly different code to help check that the proper
45 // calls are made. The class is put into a different namespace to make
46 // sure the compiler generates a different (if generating also non-inline)
47 // copy of the function and does not merge them together. The class
48 // is "brought" into the proper rtl namespace by a typedef below.
49 #ifdef RTL_STRING_UNITTEST
50 #define rtl rtlunittest
51 #endif
52
53 namespace rtl
54 {
55
56 #ifdef RTL_STRING_UNITTEST
57 #undef rtl
58 // helper macro to make functions appear more readable
59 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
60 #else
61 #define RTL_STRING_CONST_FUNCTION
62 #endif
63
64 /* ======================================================================= */
65
90 class SAL_WARN_UNUSED OString
91 {
92 public:
94 rtl_String * pData;
96
97 private:
98 class DO_NOT_ACQUIRE;
99
100 OString( rtl_String * value, SAL_UNUSED_PARAMETER DO_NOT_ACQUIRE * )
101 {
102 pData = value;
103 }
104
105 public:
109 OString() SAL_THROW(())
110 {
111 pData = 0;
112 rtl_string_new( &pData );
113 }
114
120 OString( const OString & str ) SAL_THROW(())
121 {
122 pData = str.pData;
123 rtl_string_acquire( pData );
124 }
125
131 OString( rtl_String * str ) SAL_THROW(())
132 {
133 pData = str;
134 rtl_string_acquire( pData );
135 }
136
144 inline OString( rtl_String * str, __sal_NoAcquire ) SAL_THROW(())
145 {
146 pData = str;
147 }
148
154 explicit OString( sal_Char value ) SAL_THROW(())
155 : pData (0)
156 {
157 rtl_string_newFromStr_WithLength( &pData, &value, 1 );
158 }
159
168 template< typename T >
169 OString( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
170 {
171 pData = 0;
172 rtl_string_newFromStr( &pData, value );
173 }
174
175 template< typename T >
176 OString( T& value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
177 {
178 pData = 0;
179 rtl_string_newFromStr( &pData, value );
180 }
181
192 template< typename T >
193 OString( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
194 {
195 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
196 pData = 0;
197 if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
198 rtl_string_new( &pData );
199 else
200 rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
201 #ifdef RTL_STRING_UNITTEST
202 rtl_string_unittest_const_literal = true;
203 #endif
204 }
205
214 OString( const sal_Char * value, sal_Int32 length ) SAL_THROW(())
215 {
216 pData = 0;
217 rtl_string_newFromStr_WithLength( &pData, value, length );
218 }
219
234 OString( const sal_Unicode * value, sal_Int32 length,
235 rtl_TextEncoding encoding,
236 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
237 {
238 pData = 0;
239 rtl_uString2String( &pData, value, length, encoding, convertFlags );
240 if (pData == 0) {
241 #if defined EXCEPTIONS_OFF
242 abort();
243 #else
244 throw std::bad_alloc();
245 #endif
246 }
247 }
248
249 #ifdef RTL_FAST_STRING
250
254 template< typename T1, typename T2 >
255 OString( const OStringConcat< T1, T2 >& c )
256 {
257 const sal_Int32 l = c.length();
258 pData = rtl_string_alloc( l );
259 if (l != 0)
260 {
261 char* end = c.addData( pData->buffer );
262 pData->length = end - pData->buffer;
263 *end = '\0';
264 }
265 }
266 #endif
267
271 ~OString() SAL_THROW(())
272 {
273 rtl_string_release( pData );
274 }
275
281 OString & operator=( const OString & str ) SAL_THROW(())
282 {
283 rtl_string_assign( &pData, str.pData );
284 return *this;
285 }
286
292 template< typename T >
293 typename internal::ConstCharArrayDetector< T, OString& >::Type operator=( T& literal ) SAL_THROW(())
294 {
295 RTL_STRING_CONST_FUNCTION
296 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
297 if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
298 rtl_string_new( &pData );
299 else
300 rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
301 return *this;
302 }
303
309 OString & operator+=( const OString & str ) SAL_THROW(())
310 {
311 rtl_string_newConcat( &pData, pData, str.pData );
312 return *this;
313 }
314
315 #ifdef RTL_FAST_STRING
316
320 template< typename T1, typename T2 >
321 OString& operator+=( const OStringConcat< T1, T2 >& c )
322 {
323 const int l = c.length();
324 if( l == 0 )
325 return *this;
326 rtl_string_ensureCapacity( &pData, pData->length + l );
327 char* end = c.addData( pData->buffer + pData->length );
328 *end = '\0';
329 pData->length = end - pData->buffer;
330 return *this;
331 }
332 #endif
333
341 sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
342
351 bool isEmpty() const SAL_THROW(())
352 {
353 return pData->length == 0;
354 }
355
367 const sal_Char * getStr() const SAL_THROW(()) { return pData->buffer; }
368
378 sal_Char operator [](sal_Int32 index) const {
379 assert(index >= 0 && index <= getLength());
380 //TODO: should really check for < getLength(), but there is quite
381 // some clever code out there that violates this function's
382 // documented precondition and relies on s[s.getLength()] == 0 and
383 // that would need to be fixed first
384 return getStr()[index];
385 }
386
399 sal_Int32 compareTo( const OString & str ) const SAL_THROW(())
400 {
401 return rtl_str_compare_WithLength( pData->buffer, pData->length,
402 str.pData->buffer, str.pData->length );
403 }
404
418 sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const SAL_THROW(())
419 {
420 return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
421 rObj.pData->buffer, rObj.pData->length, maxLength );
422 }
423
436 sal_Int32 reverseCompareTo( const OString & str ) const SAL_THROW(())
437 {
438 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
439 str.pData->buffer, str.pData->length );
440 }
441
453 sal_Bool equals( const OString & str ) const SAL_THROW(())
454 {
455 if ( pData->length != str.pData->length )
456 return sal_False;
457 if ( pData == str.pData )
458 return sal_True;
459 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
460 str.pData->buffer, str.pData->length ) == 0;
461 }
462
478 sal_Bool equalsL( const sal_Char* value, sal_Int32 length ) const SAL_THROW(())
479 {
480 if ( pData->length != length )
481 return sal_False;
482
483 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
484 value, length ) == 0;
485 }
486
501 sal_Bool equalsIgnoreAsciiCase( const OString & str ) const SAL_THROW(())
502 {
503 if ( pData->length != str.pData->length )
504 return sal_False;
505 if ( pData == str.pData )
506 return sal_True;
507 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
508 str.pData->buffer, str.pData->length ) == 0;
509 }
510
532 template< typename T >
533 typename internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase( const T& asciiStr ) const SAL_THROW(())
534 {
535 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
536 }
537
538 template< typename T >
539 typename internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& asciiStr ) const SAL_THROW(())
540 {
541 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
542 }
543
549 template< typename T >
550 typename internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const SAL_THROW(())
551 {
552 RTL_STRING_CONST_FUNCTION
553 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
554 if ( pData->length != internal::ConstCharArrayDetector< T, void >::size - 1 )
555 return false;
556 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
557 literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
558 }
559
579 sal_Bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
580 {
581 if ( pData->length != asciiStrLength )
582 return sal_False;
583
584 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
585 asciiStr, asciiStrLength ) == 0;
586 }
587
603 sal_Bool match( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
604 {
605 return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
606 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
607 }
608
614 template< typename T >
615 typename internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
616 {
617 RTL_STRING_CONST_FUNCTION
618 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
619 return rtl_str_shortenedCompare_WithLength(
620 pData->buffer + fromIndex, pData->length - fromIndex,
621 literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1) == 0;
622 }
623
640 bool matchL(
641 char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
642 const
643 {
644 return rtl_str_shortenedCompare_WithLength(
645 pData->buffer + fromIndex, pData->length - fromIndex,
646 str, strLength, strLength) == 0;
647 }
648
649 // This overload is left undefined, to detect calls of matchL that
650 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
651 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
652 // platforms):
653 #if SAL_TYPES_SIZEOFLONG == 8
654 void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
655 #endif
656
675 sal_Bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
676 {
677 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
678 str.pData->buffer, str.pData->length,
679 str.pData->length ) == 0;
680 }
681
687 template< typename T >
688 typename internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
689 {
690 RTL_STRING_CONST_FUNCTION
691 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
692 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
693 literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
694 }
695
706 bool startsWith(OString const & str) const {
707 return match(str, 0);
708 }
709
715 template< typename T >
716 typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
717 {
718 RTL_STRING_CONST_FUNCTION
719 return match(literal, 0);
720 }
721
732 bool endsWith(OString const & str) const {
733 return str.getLength() <= getLength()
734 && match(str, getLength() - str.getLength());
735 }
736
742 template< typename T >
743 typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
744 {
745 RTL_STRING_CONST_FUNCTION
746 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
747 return internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
748 && match(literal, getLength() - ( internal::ConstCharArrayDetector< T, void >::size - 1 ));
749 }
750
764 bool endsWithL(char const * str, sal_Int32 strLength) const {
765 return strLength <= getLength()
766 && matchL(str, strLength, getLength() - strLength);
767 }
768
769 friend sal_Bool operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
770 { return rStr1.equals(rStr2); }
771 friend sal_Bool operator != ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
772 { return !(operator == ( rStr1, rStr2 )); }
773 friend sal_Bool operator < ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
774 { return rStr1.compareTo( rStr2 ) < 0; }
775 friend sal_Bool operator > ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
776 { return rStr1.compareTo( rStr2 ) > 0; }
777 friend sal_Bool operator <= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
778 { return rStr1.compareTo( rStr2 ) <= 0; }
779 friend sal_Bool operator >= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
780 { return rStr1.compareTo( rStr2 ) >= 0; }
781
782 template< typename T >
783 friend typename internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value ) SAL_THROW(())
784 {
785 return rStr1.compareTo( value ) == 0;
786 }
787
788 template< typename T >
789 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr1, T& value ) SAL_THROW(())
790 {
791 return rStr1.compareTo( value ) == 0;
792 }
793
794 template< typename T >
795 friend typename internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 ) SAL_THROW(())
796 {
797 return rStr2.compareTo( value ) == 0;
798 }
799
800 template< typename T >
801 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( T& value, const OString& rStr2 ) SAL_THROW(())
802 {
803 return rStr2.compareTo( value ) == 0;
804 }
805
811 template< typename T >
812 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr, T& literal ) SAL_THROW(())
813 {
814 RTL_STRING_CONST_FUNCTION
815 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
816 return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
817 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
818 internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
819 }
820
826 template< typename T >
827 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OString& rStr ) SAL_THROW(())
828 {
829 RTL_STRING_CONST_FUNCTION
830 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
831 return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
832 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
833 internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
834 }
835
836 template< typename T >
837 friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value ) SAL_THROW(())
838 {
839 return !(operator == ( rStr1, value ));
840 }
841
842 template< typename T >
843 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr1, T& value ) SAL_THROW(())
844 {
845 return !(operator == ( rStr1, value ));
846 }
847
848 template< typename T >
849 friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 ) SAL_THROW(())
850 {
851 return !(operator == ( value, rStr2 ));
852 }
853
854 template< typename T >
855 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( T& value, const OString& rStr2 ) SAL_THROW(())
856 {
857 return !(operator == ( value, rStr2 ));
858 }
859
865 template< typename T >
866 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr, T& literal ) SAL_THROW(())
867 {
868 return !( rStr == literal );
869 }
870
876 template< typename T >
877 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OString& rStr ) SAL_THROW(())
878 {
879 return !( literal == rStr );
880 }
881
889 sal_Int32 hashCode() const SAL_THROW(())
890 {
891 return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
892 }
893
907 sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
908 {
909 sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
910 return (ret < 0 ? ret : ret+fromIndex);
911 }
912
922 sal_Int32 lastIndexOf( sal_Char ch ) const SAL_THROW(())
923 {
924 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
925 }
926
939 sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const SAL_THROW(())
940 {
941 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
942 }
943
959 sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
960 {
961 sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
962 str.pData->buffer, str.pData->length );
963 return (ret < 0 ? ret : ret+fromIndex);
964 }
965
971 template< typename T >
972 typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
973 {
974 RTL_STRING_CONST_FUNCTION
975 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
976 sal_Int32 n = rtl_str_indexOfStr_WithLength(
977 pData->buffer + fromIndex, pData->length - fromIndex, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
978 return n < 0 ? n : n + fromIndex;
979 }
980
999 sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1000 const SAL_THROW(())
1001 {
1002 sal_Int32 n = rtl_str_indexOfStr_WithLength(
1003 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1004 return n < 0 ? n : n + fromIndex;
1005 }
1006
1007 // This overload is left undefined, to detect calls of indexOfL that
1008 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1009 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1010 // platforms):
1011 #if SAL_TYPES_SIZEOFLONG == 8
1012 void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1013 #endif
1014
1030 sal_Int32 lastIndexOf( const OString & str ) const SAL_THROW(())
1031 {
1032 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1033 str.pData->buffer, str.pData->length );
1034 }
1035
1053 sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const SAL_THROW(())
1054 {
1055 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1056 str.pData->buffer, str.pData->length );
1057 }
1058
1069 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
1070 {
1071 rtl_String *pNew = 0;
1072 rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1073 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1074 }
1075
1088 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
1089 {
1090 rtl_String *pNew = 0;
1091 rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1092 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1093 }
1094
1103 SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const SAL_THROW(())
1104 {
1105 rtl_String* pNew = 0;
1106 rtl_string_newConcat( &pNew, pData, str.pData );
1107 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1108 }
1109
1110 #ifndef RTL_FAST_STRING
1111 friend OString operator+( const OString & str1, const OString & str2 ) SAL_THROW(())
1112 {
1113 return str1.concat( str2 );
1114 }
1115 #endif
1116
1130 SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
1131 {
1132 rtl_String* pNew = 0;
1133 rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1134 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1135 }
1136
1150 SAL_WARN_UNUSED_RESULT OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
1151 {
1152 rtl_String* pNew = 0;
1153 rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1154 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1155 }
1156
1175 SAL_WARN_UNUSED_RESULT OString replaceFirst(
1176 OString const & from, OString const & to, sal_Int32 * index = 0) const
1177 {
1178 rtl_String * s = 0;
1179 sal_Int32 i = 0;
1180 rtl_string_newReplaceFirst(
1181 &s, pData, from.pData->buffer, from.pData->length,
1182 to.pData->buffer, to.pData->length, index == 0 ? &i : index);
1183 return OString(s, SAL_NO_ACQUIRE);
1184 }
1185
1199 SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1200 rtl_String * s = 0;
1201 rtl_string_newReplaceAll(
1202 &s, pData, from.pData->buffer, from.pData->length,
1203 to.pData->buffer, to.pData->length);
1204 return OString(s, SAL_NO_ACQUIRE);
1205 }
1206
1217 SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const SAL_THROW(())
1218 {
1219 rtl_String* pNew = 0;
1220 rtl_string_newToAsciiLowerCase( &pNew, pData );
1221 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1222 }
1223
1234 SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const SAL_THROW(())
1235 {
1236 rtl_String* pNew = 0;
1237 rtl_string_newToAsciiUpperCase( &pNew, pData );
1238 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1239 }
1240
1252 SAL_WARN_UNUSED_RESULT OString trim() const SAL_THROW(())
1253 {
1254 rtl_String* pNew = 0;
1255 rtl_string_newTrim( &pNew, pData );
1256 return OString( pNew, (DO_NOT_ACQUIRE*)0 );
1257 }
1258
1283 OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const SAL_THROW(())
1284 {
1285 rtl_String * pNew = 0;
1286 index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1287 return OString( pNew, (DO_NOT_ACQUIRE *)0 );
1288 }
1289
1303 OString getToken(sal_Int32 count, char separator) const {
1304 sal_Int32 n = 0;
1305 return getToken(count, separator, n);
1306 }
1307
1316 sal_Bool toBoolean() const SAL_THROW(())
1317 {
1318 return rtl_str_toBoolean( pData->buffer );
1319 }
1320
1327 sal_Char toChar() const SAL_THROW(())
1328 {
1329 return pData->buffer[0];
1330 }
1331
1341 sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
1342 {
1343 return rtl_str_toInt32( pData->buffer, radix );
1344 }
1345
1355 sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
1356 {
1357 return rtl_str_toInt64( pData->buffer, radix );
1358 }
1359
1372 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
1373 {
1374 return rtl_str_toUInt64( pData->buffer, radix );
1375 }
1376
1385 float toFloat() const SAL_THROW(())
1386 {
1387 return rtl_str_toFloat( pData->buffer );
1388 }
1389
1398 double toDouble() const SAL_THROW(())
1399 {
1400 return rtl_str_toDouble( pData->buffer );
1401 }
1402
1413 static OString number( int i, sal_Int16 radix = 10 )
1414 {
1415 return number( static_cast< long long >( i ), radix );
1416 }
1419 static OString number( unsigned int i, sal_Int16 radix = 10 )
1420 {
1421 return number( static_cast< unsigned long long >( i ), radix );
1422 }
1425 static OString number( long i, sal_Int16 radix = 10 )
1426 {
1427 return number( static_cast< long long >( i ), radix );
1428 }
1431 static OString number( unsigned long i, sal_Int16 radix = 10 )
1432 {
1433 return number( static_cast< unsigned long long >( i ), radix );
1434 }
1437 static OString number( long long ll, sal_Int16 radix = 10 )
1438 {
1439 sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64];
1440 rtl_String* pNewData = 0;
1441 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1442 return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
1443 }
1446 static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1447 {
1448 sal_Char aBuf[RTL_STR_MAX_VALUEOFUINT64];
1449 rtl_String* pNewData = 0;
1450 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1451 return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
1452 }
1453
1463 static OString number( float f )
1464 {
1465 sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT];
1466 rtl_String* pNewData = 0;
1467 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1468 return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
1469 }
1470
1480 static OString number( double d )
1481 {
1482 sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE];
1483 rtl_String* pNewData = 0;
1484 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1485 return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
1486 }
1487
1499 SAL_DEPRECATED_INTERNAL("use boolean()") static OString valueOf( sal_Bool b ) SAL_THROW(())
1500 {
1501 return boolean(b);
1502 }
1503
1515 static OString boolean( bool b ) SAL_THROW(())
1516 {
1517 sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
1518 rtl_String* pNewData = 0;
1519 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1520 return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
1521 }
1522
1530 SAL_DEPRECATED_INTERNAL("convert to OString or use directly") static OString valueOf( sal_Char c ) SAL_THROW(())
1531 {
1532 return OString( &c, 1 );
1533 }
1534
1545 SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
1546 {
1547 return number( i, radix );
1548 }
1549
1560 SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
1561 {
1562 return number( ll, radix );
1563 }
1564
1574 SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( float f ) SAL_THROW(())
1575 {
1576 return number(f);
1577 }
1578
1588 SAL_DEPRECATED_INTERNAL("use number()") static OString valueOf( double d ) SAL_THROW(())
1589 {
1590 return number(d);
1591 }
1592
1593 };
1594
1595 /* ======================================================================= */
1596
1597 #ifdef RTL_FAST_STRING
1598
1606 struct SAL_WARN_UNUSED OStringLiteral
1607 {
1608 template< int N >
1609 OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1610 int size;
1611 const char* data;
1612 };
1613
1617 template<>
1618 struct ToStringHelper< OString >
1619 {
1620 static int length( const OString& s ) { return s.getLength(); }
1621 static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1622 static const bool allowOStringConcat = true;
1623 static const bool allowOUStringConcat = false;
1624 };
1625
1629 template<>
1630 struct ToStringHelper< OStringLiteral >
1631 {
1632 static int length( const OStringLiteral& str ) { return str.size; }
1633 static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1634 static const bool allowOStringConcat = true;
1635 static const bool allowOUStringConcat = false;
1636 };
1637
1641 template< typename charT, typename traits, typename T1, typename T2 >
1642 inline std::basic_ostream<charT, traits> & operator <<(
1643 std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1644 {
1645 return stream << OString( concat );
1646 }
1647 #else
1648 // non-RTL_FAST_CODE needs this to compile
1649 typedef OString OStringLiteral;
1650 #endif
1651
1652
1658 struct OStringHash
1659 {
1669 size_t operator()( const OString& rString ) const
1670 { return (size_t)rString.hashCode(); }
1671 };
1672
1674 struct CStringEqual
1675 {
1676 bool operator()( const char* p1, const char* p2) const
1677 { return rtl_str_compare(p1, p2) == 0; }
1678 };
1679
1681 struct CStringHash
1682 {
1683 size_t operator()(const char* p) const
1684 { return rtl_str_hashCode(p); }
1685 };
1686
1687 /* ======================================================================= */
1688
1695 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1696 operator <<(
1697 std::basic_ostream<charT, traits> & stream, OString const & string)
1698 {
1699 return stream << string.getStr();
1700 // best effort; potentially loses data due to embedded null characters
1701 }
1702
1703 } /* Namespace */
1704
1705 #ifdef RTL_STRING_UNITTEST
1706 namespace rtl
1707 {
1708 typedef rtlunittest::OString OString;
1709 }
1710 #undef RTL_STRING_CONST_FUNCTION
1711 #endif
1712
1713 #ifdef RTL_USING
1714 using ::rtl::OString;
1715 using ::rtl::OStringHash;
1716 using ::rtl::OStringLiteral;
1717 #endif
1718
1719 #endif /* _RTL_STRING_HXX_ */
1720
1721 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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::OString::toUInt64
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1372
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: string.hxx:939
rtl::OString::OString
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:144
rtl::OString::equalsIgnoreAsciiCase
internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:539
rtl::OString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:351
rtl::OString::~OString
~OString()
Release the string data.
Definition: string.hxx:271
rtl::OString::reverseCompareTo
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:436
rtl::OString::operator=
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:281
rtl_string_newFromStr
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
com::sun::star::uno::operator!=
sal_Bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:558
rtl::OString::operator!=
friend internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:849
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:303
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::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &string)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1696
SAL_UNUSED_PARAMETER
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:540
sal_Char
char sal_Char
Definition: types.h:122
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::OString::operator!=
friend internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:837
sal_True
#define sal_True
Definition: types.h:39
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_string_getToken
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, sal_Char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
textenc.h
rtl::OString::operator!=
friend 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:877
rtl_str_toDouble
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
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:1234
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::OString::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: string.hxx:922
rtl_str_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl_str_toInt32
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
rtl_str_lastIndexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
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:1130
rtl::OString::match
sal_Bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:603
rtl_str_compareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl::OString::OString
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:214
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:356
rtl::OString::endsWith
internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:743
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:561
rtl::internal::NonConstCharArrayDetector
Definition: stringutils.hxx:87
rtl::OString::toDouble
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1398
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
rtl_str_reverseCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
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:640
salhelper::operator==
sal_Bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:118
rtl::OString::toBoolean
sal_Bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1316
rtl::OString::startsWith
bool startsWith(OString const &str) const
Check whether this string starts with a given substring.
Definition: string.hxx:706
rtl::OString::operator==
friend internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:795
rtl::OString::number
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1463
salhelper::operator>
sal_Bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:108
rtl::OString::operator==
friend internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:801
rtl_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
rtl::internal::Dummy
Definition: stringutils.hxx:67
rtl_str_toBoolean
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
rtl_str_valueOfUInt64
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(sal_Char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
rtl::OString::indexOf
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:972
rtl::OString::getToken
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1303
rtl::CStringHash::operator()
size_t operator()(const char *p) const
Definition: string.hxx:1683
rtl::OString::operator+=
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:309
rtl_str_indexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
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::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, starting at the specified index.
Definition: string.hxx:959
rtl::OString::hashCode
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:889
rtl::OString::replace
SAL_WARN_UNUSED_RESULT OString replace(sal_Char oldChar, sal_Char newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: string.hxx:1150
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::OString::OString
OString()
New string containing no characters.
Definition: string.hxx:109
diagnose.h
rtl::OString::OString
OString(const T &value, typename internal::CharPtrDetector< T, internal::Dummy >::Type=internal::Dummy())
New string from a character buffer array.
Definition: string.hxx:169
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, starting at the specified index.
Definition: string.hxx:999
rtl::OString::toChar
sal_Char toChar() const
Returns the first character from this string.
Definition: string.hxx:1327
rtl::CStringEqual::operator()
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1676
rtl::OString::OString
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:154
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_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl::OString::endsWithL
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:764
rtl_str_hashCode_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const sal_Char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
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:1419
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: string.hxx:1030
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:374
rtl::OString::matchIgnoreAsciiCase
sal_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:675
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
rtl::OString::OString
OString(T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
New string from a string literal.
Definition: string.hxx:193
rtl_string_new
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
log.hxx
rtl_str_compareIgnoreAsciiCase
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
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:1446
rtl_str_shortenedCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
rtl_str_lastIndexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
config.h
rtl::OString::operator=
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:293
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_acquire
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
string.h
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, searching backward starting before the specified index.
Definition: string.hxx:1053
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:134
rtl::OString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1341
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:1199
rtl::OString::operator==
friend internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:789
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:1431
rtl::OString::startsWith
internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:716
rtl::OString::equalsIgnoreAsciiCase
internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:533
rtl_str_toInt64
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
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:1252
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:1425
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
rtl::OString::getToken
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1283
rtl::OString::operator+
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1111
rtl_str_compare
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
rtl::OString::equalsIgnoreAsciiCase
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:550
rtl::OStringHash
A helper to use OStrings with hash maps.
Definition: string.hxx:1658
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:1437
rtl::OStringLiteral
OString OStringLiteral
Definition: string.hxx:1649
RTL_STR_MAX_VALUEOFUINT64
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:90
rtl::OString::number
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1413
rtl::OString::operator!=
friend 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:866
rtl::OString::endsWith
bool endsWith(OString const &str) const
Check whether this string ends with a given substring.
Definition: string.hxx:732
rtl::internal::ConstCharArrayDetector
Definition: stringutils.hxx:110
RTL_STRING_CONST_FUNCTION
#define RTL_STRING_CONST_FUNCTION
Definition: string.hxx:61
stringutils.hxx
rtl::OString::toInt64
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1355
OUSTRING_TO_OSTRING_CVTFLAGS
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1303
rtl::OString::OString
OString(const OString &str)
New string from OString.
Definition: string.hxx:120
rtl::CStringHash
Hashing functor for classic c-strings (i.e.
Definition: string.hxx:1681
rtl::OString::operator==
friend internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:783
rtl::OString::equalsIgnoreAsciiCaseL
sal_Bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:579
sal_Bool
unsigned char sal_Bool
Definition: types.h:37
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::OString::operator!=
friend internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:855
rtl::internal::CharPtrDetector
Definition: stringutils.hxx:69
rtl_string_newReplace
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, sal_Char oldChar, sal_Char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
rtl::OString::equals
sal_Bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:453
rtl::OString::replaceFirst
SAL_WARN_UNUSED_RESULT OString replaceFirst(OString const &from, OString const &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: string.hxx:1175
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_toFloat
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
rtl_string_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const sal_Char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
rtl_str_indexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
rtl::OString::equalsL
sal_Bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:478
rtl_str_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
rtl_string_newFromLiteral
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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:1088
SAL_DEPRECATED_INTERNAL
#define SAL_DEPRECATED_INTERNAL(message)
This macro is used to tag interfaces that are deprecated for both internal and external API users...
Definition: types.h:492
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:341
rtl::OString::indexOf
sal_Int32 indexOf(sal_Char ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: string.hxx:907
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:234
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
rtl::OString::match
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:615
rtl::OString::OString
OString(T &value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy())
Definition: string.hxx:176
sal_False
#define sal_False
Definition: types.h:38
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:418
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:1069
rtl::OString::OString
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:131
rtl::OString::compareTo
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:399
rtl::OString::operator!=
friend internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:843
rtl::OString::getStr
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:367
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::OString::equalsIgnoreAsciiCase
sal_Bool equalsIgnoreAsciiCase(const OString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:501
rtl::OString::number
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1480
rtl::OString::operator==
friend 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:827
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
stringconcat.hxx
rtl_str_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
rtl_str_toUInt64
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
rtl::OStringHash::operator()
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1669
rtl::OString::matchIgnoreAsciiCase
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:688
rtl::OString::boolean
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1515
rtl_str_hashCode
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const sal_Char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
rtl::CStringEqual
Equality functor for classic c-strings (i.e.
Definition: string.hxx:1674
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:370
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:1217
salhelper::operator<
sal_Bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:98
rtl::OString::operator==
friend 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:812
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:1103
rtl::OString::toFloat
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1385
rtl_str_compare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_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...