LibreOffice LibreOffice 4.3 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 INCLUDED_RTL_STRING_HXX
21 #define INCLUDED_RTL_STRING_HXX
22
23 #include <sal/config.h>
24
25 #include <cassert>
26 #include <new>
27 #include <ostream>
28 #include <string.h>
29
30 #include <osl/diagnose.h>
31 #include <rtl/textenc.h>
32 #include <rtl/string.h>
33 #include <rtl/stringutils.hxx>
34
35 #ifdef RTL_FAST_STRING
36 #include <rtl/stringconcat.hxx>
37 #endif
38
39 #include <sal/log.hxx>
40
41 // The unittest uses slightly different code to help check that the proper
42 // calls are made. The class is put into a different namespace to make
43 // sure the compiler generates a different (if generating also non-inline)
44 // copy of the function and does not merge them together. The class
45 // is "brought" into the proper rtl namespace by a typedef below.
46 #ifdef RTL_STRING_UNITTEST
47 #define rtl rtlunittest
48 #endif
49
50 namespace rtl
51 {
52
54 #ifdef RTL_STRING_UNITTEST
55 #undef rtl
56 // helper macro to make functions appear more readable
57 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
58 #else
59 #define RTL_STRING_CONST_FUNCTION
60 #endif
61
63 /* ======================================================================= */
64
89 class SAL_WARN_UNUSED OString
90 {
91 public:
93 rtl_String * pData;
95
99 OString() SAL_THROW(())
100 {
101 pData = 0;
102 rtl_string_new( &pData );
103 }
104
110 OString( const OString & str ) SAL_THROW(())
111 {
112 pData = str.pData;
113 rtl_string_acquire( pData );
114 }
115
121 OString( rtl_String * str ) SAL_THROW(())
122 {
123 pData = str;
124 rtl_string_acquire( pData );
125 }
126
134 inline OString( rtl_String * str, __sal_NoAcquire ) SAL_THROW(())
135 {
136 pData = str;
137 }
138
144 explicit OString( sal_Char value ) SAL_THROW(())
145 : pData (0)
146 {
147 rtl_string_newFromStr_WithLength( &pData, &value, 1 );
148 }
149
158 template< typename T >
159 OString( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
160 {
161 pData = 0;
162 rtl_string_newFromStr( &pData, value );
163 }
164
165 template< typename T >
166 OString( T& value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
167 {
168 pData = 0;
169 rtl_string_newFromStr( &pData, value );
170 }
171
182 template< typename T >
183 OString( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy() ) SAL_THROW(())
184 {
185 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
186 pData = 0;
187 if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
188 rtl_string_new( &pData );
189 else
190 rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
191 #ifdef RTL_STRING_UNITTEST
192 rtl_string_unittest_const_literal = true;
193 #endif
194 }
195
204 OString( const sal_Char * value, sal_Int32 length ) SAL_THROW(())
205 {
206 pData = 0;
207 rtl_string_newFromStr_WithLength( &pData, value, length );
208 }
209
224 OString( const sal_Unicode * value, sal_Int32 length,
225 rtl_TextEncoding encoding,
226 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
227 {
228 pData = 0;
229 rtl_uString2String( &pData, value, length, encoding, convertFlags );
230 if (pData == 0) {
231 throw std::bad_alloc();
232 }
233 }
234
235 #ifdef RTL_FAST_STRING
236
240 template< typename T1, typename T2 >
241 OString( const OStringConcat< T1, T2 >& c )
242 {
243 const sal_Int32 l = c.length();
244 pData = rtl_string_alloc( l );
245 if (l != 0)
246 {
247 char* end = c.addData( pData->buffer );
248 pData->length = end - pData->buffer;
249 *end = '\0';
250 }
251 }
252 #endif
253
257 ~OString() SAL_THROW(())
258 {
259 rtl_string_release( pData );
260 }
261
267 OString & operator=( const OString & str ) SAL_THROW(())
268 {
269 rtl_string_assign( &pData, str.pData );
270 return *this;
271 }
272
278 template< typename T >
279 typename internal::ConstCharArrayDetector< T, OString& >::Type operator=( T& literal ) SAL_THROW(())
280 {
281 RTL_STRING_CONST_FUNCTION
282 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
283 if( internal::ConstCharArrayDetector< T, void >::size - 1 == 0 ) // empty string
284 rtl_string_new( &pData );
285 else
286 rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 0 );
287 return *this;
288 }
289
295 OString & operator+=( const OString & str ) SAL_THROW(())
296 {
297 rtl_string_newConcat( &pData, pData, str.pData );
298 return *this;
299 }
300
301 #ifdef RTL_FAST_STRING
302
306 template< typename T1, typename T2 >
307 OString& operator+=( const OStringConcat< T1, T2 >& c )
308 {
309 const int l = c.length();
310 if( l == 0 )
311 return *this;
312 rtl_string_ensureCapacity( &pData, pData->length + l );
313 char* end = c.addData( pData->buffer + pData->length );
314 *end = '\0';
315 pData->length = end - pData->buffer;
316 return *this;
317 }
318 #endif
319
327 sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
328
337 bool isEmpty() const SAL_THROW(())
338 {
339 return pData->length == 0;
340 }
341
353 const sal_Char * getStr() const SAL_THROW(()) { return pData->buffer; }
354
364 sal_Char operator [](sal_Int32 index) const {
365 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
366 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
367 return getStr()[index];
368 }
369
382 sal_Int32 compareTo( const OString & str ) const SAL_THROW(())
383 {
384 return rtl_str_compare_WithLength( pData->buffer, pData->length,
385 str.pData->buffer, str.pData->length );
386 }
387
401 sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const SAL_THROW(())
402 {
403 return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
404 rObj.pData->buffer, rObj.pData->length, maxLength );
405 }
406
419 sal_Int32 reverseCompareTo( const OString & str ) const SAL_THROW(())
420 {
421 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
422 str.pData->buffer, str.pData->length );
423 }
424
436 bool equals( const OString & str ) const SAL_THROW(())
437 {
438 if ( pData->length != str.pData->length )
439 return false;
440 if ( pData == str.pData )
441 return true;
442 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
443 str.pData->buffer, str.pData->length ) == 0;
444 }
445
461 bool equalsL( const sal_Char* value, sal_Int32 length ) const SAL_THROW(())
462 {
463 if ( pData->length != length )
464 return false;
465
466 return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
467 value, length ) == 0;
468 }
469
484 bool equalsIgnoreAsciiCase( const OString & str ) const SAL_THROW(())
485 {
486 if ( pData->length != str.pData->length )
487 return false;
488 if ( pData == str.pData )
489 return true;
490 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
491 str.pData->buffer, str.pData->length ) == 0;
492 }
493
515 template< typename T >
516 typename internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase( const T& asciiStr ) const SAL_THROW(())
517 {
518 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
519 }
520
521 template< typename T >
522 typename internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& asciiStr ) const SAL_THROW(())
523 {
524 return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
525 }
526
532 template< typename T >
533 typename internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const SAL_THROW(())
534 {
535 RTL_STRING_CONST_FUNCTION
536 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
537 if ( pData->length != internal::ConstCharArrayDetector< T, void >::size - 1 )
538 return false;
539 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
540 literal, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
541 }
542
562 bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
563 {
564 if ( pData->length != asciiStrLength )
565 return false;
566
567 return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
568 asciiStr, asciiStrLength ) == 0;
569 }
570
586 bool match( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
587 {
588 return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
589 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
590 }
591
597 template< typename T >
598 typename internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
599 {
600 RTL_STRING_CONST_FUNCTION
601 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
602 return rtl_str_shortenedCompare_WithLength(
603 pData->buffer + fromIndex, pData->length - fromIndex,
604 literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1) == 0;
605 }
606
623 bool matchL(
624 char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
625 const
626 {
627 return rtl_str_shortenedCompare_WithLength(
628 pData->buffer + fromIndex, pData->length - fromIndex,
629 str, strLength, strLength) == 0;
630 }
631
632 // This overload is left undefined, to detect calls of matchL that
633 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
634 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
635 // platforms):
636 #if SAL_TYPES_SIZEOFLONG == 8
637 void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
638 #endif
639
658 bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
659 {
660 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
661 str.pData->buffer, str.pData->length,
662 str.pData->length ) == 0;
663 }
664
670 template< typename T >
671 typename internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
672 {
673 RTL_STRING_CONST_FUNCTION
674 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
675 return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
676 literal, internal::ConstCharArrayDetector< T, void >::size - 1, internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
677 }
678
693 bool startsWith(OString const & str, OString * rest = 0) const {
694 bool b = match(str, 0);
695 if (b && rest != 0) {
696 *rest = copy(str.getLength());
697 }
698 return b;
699 }
700
706 template< typename T >
707 typename internal::ConstCharArrayDetector< T, bool >::Type startsWith(
708 T & literal, OString * rest = 0) const
709 {
710 RTL_STRING_CONST_FUNCTION
711 bool b = match(literal, 0);
712 if (b && rest != 0) {
713 *rest = copy(internal::ConstCharArrayDetector< T, void >::size - 1);
714 }
715 return b;
716 }
717
732 bool endsWith(OString const & str, OString * rest = 0) const {
733 bool b = str.getLength() <= getLength()
734 && match(str, getLength() - str.getLength());
735 if (b && rest != 0) {
736 *rest = copy(0, getLength() - str.getLength());
737 }
738 return b;
739 }
740
746 template< typename T >
747 typename internal::ConstCharArrayDetector< T, bool >::Type endsWith(
748 T & literal, OString * rest = 0) const
749 {
750 RTL_STRING_CONST_FUNCTION
751 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
752 bool b = internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
753 && match(literal, getLength() - ( internal::ConstCharArrayDetector< T, void >::size - 1 ));
754 if (b && rest != 0) {
755 *rest = copy(
756 0,
757 (getLength()
758 - (internal::ConstCharArrayDetector< T, void >::size - 1)));
759 }
760 return b;
761 }
762
776 bool endsWithL(char const * str, sal_Int32 strLength) const {
777 return strLength <= getLength()
778 && matchL(str, strLength, getLength() - strLength);
779 }
780
781 friend bool operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
782 { return rStr1.equals(rStr2); }
783 friend bool operator != ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
784 { return !(operator == ( rStr1, rStr2 )); }
785 friend bool operator < ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
786 { return rStr1.compareTo( rStr2 ) < 0; }
787 friend bool operator > ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
788 { return rStr1.compareTo( rStr2 ) > 0; }
789 friend bool operator <= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
790 { return rStr1.compareTo( rStr2 ) <= 0; }
791 friend bool operator >= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
792 { return rStr1.compareTo( rStr2 ) >= 0; }
793
794 template< typename T >
795 friend typename internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value ) SAL_THROW(())
796 {
797 return rStr1.compareTo( value ) == 0;
798 }
799
800 template< typename T >
801 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr1, T& value ) SAL_THROW(())
802 {
803 return rStr1.compareTo( value ) == 0;
804 }
805
806 template< typename T >
807 friend typename internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 ) SAL_THROW(())
808 {
809 return rStr2.compareTo( value ) == 0;
810 }
811
812 template< typename T >
813 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator==( T& value, const OString& rStr2 ) SAL_THROW(())
814 {
815 return rStr2.compareTo( value ) == 0;
816 }
817
823 template< typename T >
824 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( const OString& rStr, T& literal ) SAL_THROW(())
825 {
826 RTL_STRING_CONST_FUNCTION
827 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
828 return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
829 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
830 internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
831 }
832
838 template< typename T >
839 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OString& rStr ) SAL_THROW(())
840 {
841 RTL_STRING_CONST_FUNCTION
842 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
843 return rStr.getLength() == internal::ConstCharArrayDetector< T, void >::size - 1
844 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal,
845 internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0;
846 }
847
848 template< typename T >
849 friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value ) SAL_THROW(())
850 {
851 return !(operator == ( rStr1, value ));
852 }
853
854 template< typename T >
855 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr1, T& value ) SAL_THROW(())
856 {
857 return !(operator == ( rStr1, value ));
858 }
859
860 template< typename T >
861 friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 ) SAL_THROW(())
862 {
863 return !(operator == ( value, rStr2 ));
864 }
865
866 template< typename T >
867 friend typename internal::NonConstCharArrayDetector< T, bool >::Type operator!=( T& value, const OString& rStr2 ) SAL_THROW(())
868 {
869 return !(operator == ( value, rStr2 ));
870 }
871
877 template< typename T >
878 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OString& rStr, T& literal ) SAL_THROW(())
879 {
880 return !( rStr == literal );
881 }
882
888 template< typename T >
889 friend typename internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OString& rStr ) SAL_THROW(())
890 {
891 return !( literal == rStr );
892 }
893
901 sal_Int32 hashCode() const SAL_THROW(())
902 {
903 return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
904 }
905
919 sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
920 {
921 sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
922 return (ret < 0 ? ret : ret+fromIndex);
923 }
924
934 sal_Int32 lastIndexOf( sal_Char ch ) const SAL_THROW(())
935 {
936 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
937 }
938
951 sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const SAL_THROW(())
952 {
953 return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
954 }
955
971 sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
972 {
973 sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
974 str.pData->buffer, str.pData->length );
975 return (ret < 0 ? ret : ret+fromIndex);
976 }
977
983 template< typename T >
984 typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
985 {
986 RTL_STRING_CONST_FUNCTION
987 assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
988 sal_Int32 n = rtl_str_indexOfStr_WithLength(
989 pData->buffer + fromIndex, pData->length - fromIndex, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
990 return n < 0 ? n : n + fromIndex;
991 }
992
1011 sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1012 const SAL_THROW(())
1013 {
1014 sal_Int32 n = rtl_str_indexOfStr_WithLength(
1015 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1016 return n < 0 ? n : n + fromIndex;
1017 }
1018
1019 // This overload is left undefined, to detect calls of indexOfL that
1020 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1021 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1022 // platforms):
1023 #if SAL_TYPES_SIZEOFLONG == 8
1024 void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1025 #endif
1026
1042 sal_Int32 lastIndexOf( const OString & str ) const SAL_THROW(())
1043 {
1044 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1045 str.pData->buffer, str.pData->length );
1046 }
1047
1065 sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const SAL_THROW(())
1066 {
1067 return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1068 str.pData->buffer, str.pData->length );
1069 }
1070
1081 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
1082 {
1083 rtl_String *pNew = 0;
1084 rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1085 return OString( pNew, SAL_NO_ACQUIRE );
1086 }
1087
1100 SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
1101 {
1102 rtl_String *pNew = 0;
1103 rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1104 return OString( pNew, SAL_NO_ACQUIRE );
1105 }
1106
1115 SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const SAL_THROW(())
1116 {
1117 rtl_String* pNew = 0;
1118 rtl_string_newConcat( &pNew, pData, str.pData );
1119 return OString( pNew, SAL_NO_ACQUIRE );
1120 }
1121
1122 #ifndef RTL_FAST_STRING
1123 friend OString operator+( const OString & str1, const OString & str2 ) SAL_THROW(())
1124 {
1125 return str1.concat( str2 );
1126 }
1127 #endif
1128
1142 SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
1143 {
1144 rtl_String* pNew = 0;
1145 rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1146 return OString( pNew, SAL_NO_ACQUIRE );
1147 }
1148
1162 SAL_WARN_UNUSED_RESULT OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
1163 {
1164 rtl_String* pNew = 0;
1165 rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1166 return OString( pNew, SAL_NO_ACQUIRE );
1167 }
1168
1187 SAL_WARN_UNUSED_RESULT OString replaceFirst(
1188 OString const & from, OString const & to, sal_Int32 * index = 0) const
1189 {
1190 rtl_String * s = 0;
1191 sal_Int32 i = 0;
1192 rtl_string_newReplaceFirst(
1193 &s, pData, from.pData->buffer, from.pData->length,
1194 to.pData->buffer, to.pData->length, index == 0 ? &i : index);
1195 return OString(s, SAL_NO_ACQUIRE);
1196 }
1197
1211 SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1212 rtl_String * s = 0;
1213 rtl_string_newReplaceAll(
1214 &s, pData, from.pData->buffer, from.pData->length,
1215 to.pData->buffer, to.pData->length);
1216 return OString(s, SAL_NO_ACQUIRE);
1217 }
1218
1229 SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const SAL_THROW(())
1230 {
1231 rtl_String* pNew = 0;
1232 rtl_string_newToAsciiLowerCase( &pNew, pData );
1233 return OString( pNew, SAL_NO_ACQUIRE );
1234 }
1235
1246 SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const SAL_THROW(())
1247 {
1248 rtl_String* pNew = 0;
1249 rtl_string_newToAsciiUpperCase( &pNew, pData );
1250 return OString( pNew, SAL_NO_ACQUIRE );
1251 }
1252
1264 SAL_WARN_UNUSED_RESULT OString trim() const SAL_THROW(())
1265 {
1266 rtl_String* pNew = 0;
1267 rtl_string_newTrim( &pNew, pData );
1268 return OString( pNew, SAL_NO_ACQUIRE );
1269 }
1270
1295 OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const SAL_THROW(())
1296 {
1297 rtl_String * pNew = 0;
1298 index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1299 return OString( pNew, SAL_NO_ACQUIRE );
1300 }
1301
1315 OString getToken(sal_Int32 count, char separator) const {
1316 sal_Int32 n = 0;
1317 return getToken(count, separator, n);
1318 }
1319
1328 bool toBoolean() const SAL_THROW(())
1329 {
1330 return rtl_str_toBoolean( pData->buffer );
1331 }
1332
1339 sal_Char toChar() const SAL_THROW(())
1340 {
1341 return pData->buffer[0];
1342 }
1343
1354 sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
1355 {
1356 return rtl_str_toInt32( pData->buffer, radix );
1357 }
1358
1371 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
1372 {
1373 return rtl_str_toUInt32( pData->buffer, radix );
1374 }
1375
1386 sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
1387 {
1388 return rtl_str_toInt64( pData->buffer, radix );
1389 }
1390
1403 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
1404 {
1405 return rtl_str_toUInt64( pData->buffer, radix );
1406 }
1407
1416 float toFloat() const SAL_THROW(())
1417 {
1418 return rtl_str_toFloat( pData->buffer );
1419 }
1420
1429 double toDouble() const SAL_THROW(())
1430 {
1431 return rtl_str_toDouble( pData->buffer );
1432 }
1433
1444 static OString number( int i, sal_Int16 radix = 10 )
1445 {
1446 return number( static_cast< long long >( i ), radix );
1447 }
1450 static OString number( unsigned int i, sal_Int16 radix = 10 )
1451 {
1452 return number( static_cast< unsigned long long >( i ), radix );
1453 }
1456 static OString number( long i, sal_Int16 radix = 10 )
1457 {
1458 return number( static_cast< long long >( i ), radix );
1459 }
1462 static OString number( unsigned long i, sal_Int16 radix = 10 )
1463 {
1464 return number( static_cast< unsigned long long >( i ), radix );
1465 }
1468 static OString number( long long ll, sal_Int16 radix = 10 )
1469 {
1470 sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64];
1471 rtl_String* pNewData = 0;
1472 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1473 return OString( pNewData, SAL_NO_ACQUIRE );
1474 }
1477 static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1478 {
1479 sal_Char aBuf[RTL_STR_MAX_VALUEOFUINT64];
1480 rtl_String* pNewData = 0;
1481 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1482 return OString( pNewData, SAL_NO_ACQUIRE );
1483 }
1484
1494 static OString number( float f )
1495 {
1496 sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT];
1497 rtl_String* pNewData = 0;
1498 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1499 return OString( pNewData, SAL_NO_ACQUIRE );
1500 }
1501
1511 static OString number( double d )
1512 {
1513 sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE];
1514 rtl_String* pNewData = 0;
1515 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1516 return OString( pNewData, SAL_NO_ACQUIRE );
1517 }
1518
1530 SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b ) SAL_THROW(())
1531 {
1532 return boolean(b);
1533 }
1534
1546 static OString boolean( bool b ) SAL_THROW(())
1547 {
1548 sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
1549 rtl_String* pNewData = 0;
1550 rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1551 return OString( pNewData, SAL_NO_ACQUIRE );
1552 }
1553
1561 SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c ) SAL_THROW(())
1562 {
1563 return OString( &c, 1 );
1564 }
1565
1576 SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
1577 {
1578 return number( i, radix );
1579 }
1580
1591 SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
1592 {
1593 return number( ll, radix );
1594 }
1595
1605 SAL_DEPRECATED("use number()") static OString valueOf( float f ) SAL_THROW(())
1606 {
1607 return number(f);
1608 }
1609
1619 SAL_DEPRECATED("use number()") static OString valueOf( double d ) SAL_THROW(())
1620 {
1621 return number(d);
1622 }
1623
1624 };
1625
1626 /* ======================================================================= */
1627
1628 #ifdef RTL_FAST_STRING
1629
1637 struct SAL_WARN_UNUSED OStringLiteral
1638 {
1639 template< int N >
1640 OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1641 int size;
1642 const char* data;
1643 };
1644
1648 template<>
1649 struct ToStringHelper< OString >
1650 {
1651 static int length( const OString& s ) { return s.getLength(); }
1652 static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1653 static const bool allowOStringConcat = true;
1654 static const bool allowOUStringConcat = false;
1655 };
1656
1660 template<>
1661 struct ToStringHelper< OStringLiteral >
1662 {
1663 static int length( const OStringLiteral& str ) { return str.size; }
1664 static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1665 static const bool allowOStringConcat = true;
1666 static const bool allowOUStringConcat = false;
1667 };
1668
1672 template< typename charT, typename traits, typename T1, typename T2 >
1673 inline std::basic_ostream<charT, traits> & operator <<(
1674 std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1675 {
1676 return stream << OString( concat );
1677 }
1678 #else
1679 // non-RTL_FAST_STRING needs this to compile
1681 typedef OString OStringLiteral;
1683 #endif
1684
1685
1691 struct OStringHash
1692 {
1702 size_t operator()( const OString& rString ) const
1703 { return (size_t)rString.hashCode(); }
1704 };
1705
1707 struct CStringEqual
1708 {
1709 bool operator()( const char* p1, const char* p2) const
1710 { return rtl_str_compare(p1, p2) == 0; }
1711 };
1712
1714 struct CStringHash
1715 {
1716 size_t operator()(const char* p) const
1717 { return rtl_str_hashCode(p); }
1718 };
1719
1720 /* ======================================================================= */
1721
1728 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1729 operator <<(
1730 std::basic_ostream<charT, traits> & stream, OString const & string)
1731 {
1732 return stream << string.getStr();
1733 // best effort; potentially loses data due to embedded null characters
1734 }
1735
1736 } /* Namespace */
1737
1738 #ifdef RTL_STRING_UNITTEST
1739 namespace rtl
1740 {
1741 typedef rtlunittest::OString OString;
1742 }
1743 #undef RTL_STRING_CONST_FUNCTION
1744 #endif
1745
1746 #ifdef RTL_USING
1747 using ::rtl::OString;
1748 using ::rtl::OStringHash;
1749 using ::rtl::OStringLiteral;
1750 #endif
1751
1752 #endif // INCLUDED_RTL_STRING_HXX
1753
1754 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OString::equals
bool equals(const OString &str) const SAL_THROW(())
Perform a comparison of two strings.
Definition: string.hxx:436
rtl::OString::hashCode
sal_Int32 hashCode() const SAL_THROW(())
Returns a hashcode for this string.
Definition: string.hxx:901
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.
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:491
com::sun::star::uno::operator!=
bool operator!=(const Any &rAny, const C &value) SAL_THROW(())
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:582
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:1477
rtl::OString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const SAL_THROW(())
Returns the int32 value from this string.
Definition: string.hxx:1354
log.hxx
rtl::OString::copy
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex, sal_Int32 count) const SAL_THROW(())
Returns a new string that is a substring of this string.
Definition: string.hxx:1100
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.
stringconcat.hxx
rtl::OString::OString
OString(T &value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy()) SAL_THROW(())
Definition: string.hxx:166
rtl::OString::trim
SAL_WARN_UNUSED_RESULT OString trim() const SAL_THROW(())
Returns a new string resulting from removing white space from both ends of the string.
Definition: string.hxx:1264
rtl::OStringHash::operator()
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1702
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.
string.h
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...
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::OString::getStr
const sal_Char * getStr() const SAL_THROW(())
Returns a pointer to the characters of this string.
Definition: string.hxx:353
rtl::OString::indexOf
internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:984
RTL_STR_MAX_VALUEOFFLOAT
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
salhelper::operator<
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:98
rtl::OString::equalsIgnoreAsciiCaseL
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const SAL_THROW(())
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:562
rtl::OString::OString
OString(const sal_Char *value, sal_Int32 length) SAL_THROW(())
New string from a character buffer array.
Definition: string.hxx:204
rtl::OString::operator+=
OString & operator+=(const OString &str) SAL_THROW(())
Append a string to this string.
Definition: string.hxx:295
rtl
Definition: bootstrap.hxx:24
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:1456
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str, sal_Int32 fromIndex) const SAL_THROW(())
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: string.hxx:1065
rtl::OString::OString
OString() SAL_THROW(())
New string containing no characters.
Definition: string.hxx:99
rtl::internal::Dummy
Definition: stringutils.hxx:67
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_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::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value) SAL_THROW(())
Definition: string.hxx:855
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::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:1211
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...
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:388
rtl::OString::isEmpty
bool isEmpty() const SAL_THROW(())
Checks if a string is empty.
Definition: string.hxx:337
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::operator==
friend internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value) SAL_THROW(())
Definition: string.hxx:795
rtl::OString::operator==
friend internal::ConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr, T &literal) SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:824
rtl::OString::toFloat
float toFloat() const SAL_THROW(())
Returns the float value from this string.
Definition: string.hxx:1416
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::toChar
sal_Char toChar() const SAL_THROW(())
Returns the first character from this string.
Definition: string.hxx:1339
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_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::number
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1511
rtl::OString::toUInt64
sal_uInt64 toUInt64(sal_Int16 radix=10) const SAL_THROW(())
Returns the uint64 value from this string.
Definition: string.hxx:1403
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_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(rtl_String *str) SAL_THROW(())
New string from OString data.
Definition: string.hxx:121
rtl::CStringEqual::operator()
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1709
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:224
rtl::OString::match
bool match(const OString &str, sal_Int32 fromIndex=0) const SAL_THROW(())
Match against a substring appearing in this string.
Definition: string.hxx:586
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:384
rtl::OString::indexOf
sal_Int32 indexOf(const OString &str, sal_Int32 fromIndex=0) const SAL_THROW(())
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: string.hxx:971
rtl::CStringEqual
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1707
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:1187
rtl::OString::copy
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const SAL_THROW(())
Returns a new string that is a substring of this string.
Definition: string.hxx:1081
diagnose.h
rtl::OString::getToken
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1315
rtl::OString::endsWith
internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:747
rtl::OString::OString
OString(const T &value, typename internal::CharPtrDetector< T, internal::Dummy >::Type=internal::Dummy()) SAL_THROW(())
New string from a character buffer array.
Definition: string.hxx:159
rtl::OString::startsWith
internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:707
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::toBoolean
bool toBoolean() const SAL_THROW(())
Returns the Boolean value from this string.
Definition: string.hxx:1328
rtl::OString::match
internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:598
rtl::OString::equalsL
bool equalsL(const sal_Char *value, sal_Int32 length) const SAL_THROW(())
Perform a comparison of two strings.
Definition: string.hxx:461
rtl::OString::operator!=
friend internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OString &rStr) SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:889
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::endsWith
bool endsWith(OString const &str, OString *rest=0) const
Check whether this string ends with a given substring.
Definition: string.hxx:732
rtl::OString::matchIgnoreAsciiCase
bool matchIgnoreAsciiCase(const OString &str, sal_Int32 fromIndex=0) const SAL_THROW(())
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: string.hxx:658
rtl::OString::toInt64
sal_Int64 toInt64(sal_Int16 radix=10) const SAL_THROW(())
Returns the int64 value from this string.
Definition: string.hxx:1386
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:307
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_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_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::OString::boolean
static OString boolean(bool b) SAL_THROW(())
Returns the string representation of the boolean argument.
Definition: string.hxx:1546
rtl::OString::equalsIgnoreAsciiCase
internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const SAL_THROW(())
Definition: string.hxx:522
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:128
rtl::OString::operator=
internal::ConstCharArrayDetector< T, OString & >::Type operator=(T &literal) SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:279
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(const OString &str) const SAL_THROW(())
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: string.hxx:1042
rtl::OString::operator=
OString & operator=(const OString &str) SAL_THROW(())
Assign a new string.
Definition: string.hxx:267
rtl::OString::operator!=
friend internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value) SAL_THROW(())
Definition: string.hxx:849
rtl::OString::equalsIgnoreAsciiCase
internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:533
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.
rtl::CStringHash::operator()
size_t operator()(const char *p) const
Definition: string.hxx:1716
rtl::OString::indexOf
sal_Int32 indexOf(sal_Char ch, sal_Int32 fromIndex=0) const SAL_THROW(())
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: string.hxx:919
RTL_STR_MAX_VALUEOFDOUBLE
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
salhelper::operator==
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:118
rtl::OString::concat
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const SAL_THROW(())
Concatenates the specified string to the end of this string.
Definition: string.hxx:1115
rtl::OString::number
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1494
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::operator==
friend internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OString &rStr) SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:839
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:1462
rtl::OString::getLength
sal_Int32 getLength() const SAL_THROW(())
Returns the length of this string.
Definition: string.hxx:327
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.
rtl::OString::getToken
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const SAL_THROW(())
Returns a token in the string.
Definition: string.hxx:1295
rtl_string_acquire
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
rtl::internal::NonConstCharArrayDetector
Definition: stringutils.hxx:87
RTL_STR_MAX_VALUEOFUINT64
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
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_string_release
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
rtl::OString::toAsciiLowerCase
SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const SAL_THROW(())
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: string.hxx:1229
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:89
rtl::internal::ConstCharArrayDetector
Definition: stringutils.hxx:110
rtl::OString::equalsIgnoreAsciiCase
internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const SAL_THROW(())
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:516
rtl::OString::operator!=
friend internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2) SAL_THROW(())
Definition: string.hxx:861
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:1450
SAL_THROW
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
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::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:671
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:1468
rtl::OString::OString
OString(const OString &str) SAL_THROW(())
New string from OString.
Definition: string.hxx:110
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.
salhelper::operator>
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:108
rtl::OString::reverseCompareTo
sal_Int32 reverseCompareTo(const OString &str) const SAL_THROW(())
Compares two strings in reverse order.
Definition: string.hxx:419
rtl::OString::operator!=
friend internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2) SAL_THROW(())
Definition: string.hxx:867
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
rtl::OString::endsWithL
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:776
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::compareTo
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const SAL_THROW(())
Compares two strings with an maximum count of characters.
Definition: string.hxx:401
rtl_str_toFloat
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
rtl::OString::OString
OString(rtl_String *str, __sal_NoAcquire) SAL_THROW(())
New string from OString data without acquiring it.
Definition: string.hxx:134
rtl::internal::CharPtrDetector
Definition: stringutils.hxx:69
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::OString::indexOfL
sal_Int32 indexOfL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const SAL_THROW(())
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: string.hxx:1011
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::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch) const SAL_THROW(())
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: string.hxx:934
rtl_str_toUInt32
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
config.h
rtl::OString::operator==
friend internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2) SAL_THROW(())
Definition: string.hxx:813
rtl::OString::toDouble
double toDouble() const SAL_THROW(())
Returns the double value from this string.
Definition: string.hxx:1429
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:1729
rtl::OString::lastIndexOf
sal_Int32 lastIndexOf(sal_Char ch, sal_Int32 fromIndex) const SAL_THROW(())
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: string.hxx:951
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...
OUSTRING_TO_OSTRING_CVTFLAGS
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324
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_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::~OString
~OString() SAL_THROW(())
Release the string data.
Definition: string.hxx:257
rtl::OString::startsWith
bool startsWith(OString const &str, OString *rest=0) const
Check whether this string starts with a given substring.
Definition: string.hxx:693
RTL_STR_MAX_VALUEOFBOOLEAN
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
rtl::OString::operator!=
friend internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr, T &literal) SAL_THROW(())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:878
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.
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:603
stringutils.hxx
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_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::number
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1444
rtl::OString::operator==
friend internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2) SAL_THROW(())
Definition: string.hxx:807
rtl::OString::operator+
friend OString operator+(const OString &str1, const OString &str2) SAL_THROW(())
Definition: string.hxx:1123
rtl::OString::toUInt32
sal_uInt32 toUInt32(sal_Int16 radix=10) const SAL_THROW(())
Returns the uint32 value from this string.
Definition: string.hxx:1371
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:150
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::OString::OString
OString(T &literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type=internal::Dummy()) SAL_THROW(())
New string from a string literal.
Definition: string.hxx:183
rtl::OStringHash
A helper to use OStrings with hash maps.
Definition: string.hxx:1691
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::replace
SAL_WARN_UNUSED_RESULT OString replace(sal_Char oldChar, sal_Char newChar) const SAL_THROW(())
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: string.hxx:1162
rtl::OString::replaceAt
SAL_WARN_UNUSED_RESULT OString replaceAt(sal_Int32 index, sal_Int32 count, const OString &newStr) const SAL_THROW(())
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: string.hxx:1142
rtl::OString::compareTo
sal_Int32 compareTo(const OString &str) const SAL_THROW(())
Compares two strings.
Definition: string.hxx:382
rtl::OString::toAsciiUpperCase
SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const SAL_THROW(())
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: string.hxx:1246
textenc.h
rtl::OString::operator==
friend internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value) SAL_THROW(())
Definition: string.hxx:801
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:623
rtl::OString::equalsIgnoreAsciiCase
bool equalsIgnoreAsciiCase(const OString &str) const SAL_THROW(())
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:484
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
rtl::OString::OString
OString(sal_Char value) SAL_THROW(())
New string from a single character.
Definition: string.hxx:144
rtl::CStringHash
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1714
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.
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...