00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _RTL_STRING_H_
00021 #define _RTL_STRING_H_
00022
00023 #include "sal/config.h"
00024
00025 #include "osl/interlck.h"
00026 #include "rtl/textcvt.h"
00027 #include "sal/saldllapi.h"
00028 #include "sal/types.h"
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034
00035
00048 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_getLength(
00049 const sal_Char * str ) SAL_THROW_EXTERN_C();
00050
00069 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare(
00070 const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00071
00097 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare_WithLength(
00098 const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00099
00129 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_shortenedCompare_WithLength(
00130 const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00131
00157 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength(
00158 const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00159
00179 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase(
00180 const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00181
00209 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength(
00210 const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00211
00244 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
00245 const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00246
00259 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
00260 const sal_Char * str ) SAL_THROW_EXTERN_C();
00261
00277 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
00278 const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00279
00294 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar(
00295 const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
00296
00313 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength(
00314 const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
00315
00331 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar(
00332 const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
00333
00351 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength(
00352 const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
00353
00369 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr(
00370 const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
00371
00394 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength(
00395 const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00396
00412 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr(
00413 const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
00414
00437 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength(
00438 const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00439
00454 SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar(
00455 sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
00456
00474 SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar_WithLength(
00475 sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
00476
00486 SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiLowerCase(
00487 sal_Char * str ) SAL_THROW_EXTERN_C();
00488
00501 SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiLowerCase_WithLength(
00502 sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00503
00513 SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiUpperCase(
00514 sal_Char * str ) SAL_THROW_EXTERN_C();
00515
00528 SAL_DLLPUBLIC void SAL_CALL rtl_str_toAsciiUpperCase_WithLength(
00529 sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00530
00543 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim(
00544 sal_Char * str ) SAL_THROW_EXTERN_C();
00545
00562 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim_WithLength(
00563 sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00564
00583 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfBoolean(
00584 sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C();
00585 #define RTL_STR_MAX_VALUEOFBOOLEAN 6
00586
00600 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfChar(
00601 sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
00602 #define RTL_STR_MAX_VALUEOFCHAR 2
00603
00623 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt32(
00624 sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00625 #define RTL_STR_MIN_RADIX 2
00626 #define RTL_STR_MAX_RADIX 36
00627 #define RTL_STR_MAX_VALUEOFINT32 33
00628
00648 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt64(
00649 sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00650 #define RTL_STR_MAX_VALUEOFINT64 65
00651
00667 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfFloat(
00668 sal_Char * str, float f ) SAL_THROW_EXTERN_C();
00669 #define RTL_STR_MAX_VALUEOFFLOAT 15
00670
00686 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfDouble(
00687 sal_Char * str, double d ) SAL_THROW_EXTERN_C();
00688 #define RTL_STR_MAX_VALUEOFDOUBLE 25
00689
00701 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean(
00702 const sal_Char * str ) SAL_THROW_EXTERN_C();
00703
00720 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
00721 const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00722
00739 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_str_toInt64(
00740 const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00741
00754 SAL_DLLPUBLIC float SAL_CALL rtl_str_toFloat(
00755 const sal_Char * str ) SAL_THROW_EXTERN_C();
00756
00769 SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble(
00770 const sal_Char * str ) SAL_THROW_EXTERN_C();
00771
00772
00773
00774 #ifdef SAL_W32
00775 # pragma pack(push, 8)
00776 #endif
00777
00781 typedef struct _rtl_String
00782 {
00783 oslInterlockedCount refCount;
00784 sal_Int32 length;
00785 sal_Char buffer[1];
00786 } rtl_String;
00789 #if defined(SAL_W32)
00790 #pragma pack(pop)
00791 #endif
00792
00793
00794
00800 SAL_DLLPUBLIC void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C();
00801
00809 SAL_DLLPUBLIC void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C();
00810
00817 SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C();
00818
00832 SAL_DLLPUBLIC void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C();
00833
00847 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C();
00848
00862 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
00863
00881 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
00882
00896 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromSubString(
00897 rtl_String ** newStr, const rtl_String * from,
00898 sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
00899
00904 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromLiteral( rtl_String ** newStr, const sal_Char * value, sal_Int32 len, sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
00905
00918 SAL_DLLPUBLIC void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C();
00919
00930 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C();
00931
00940 SAL_DLLPUBLIC sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C();
00941
00959 SAL_DLLPUBLIC void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C();
00960
00990 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceStrAt(
00991 rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C();
00992
01017 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplace(
01018 rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
01019
01047 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceFirst(
01048 rtl_String ** newStr, rtl_String * str, char const * from,
01049 sal_Int32 fromLength, char const * to, sal_Int32 toLength,
01050 sal_Int32 * index) SAL_THROW_EXTERN_C();
01051
01075 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplaceAll(
01076 rtl_String ** newStr, rtl_String * str, char const * from,
01077 sal_Int32 fromLength, char const * to, sal_Int32 toLength)
01078 SAL_THROW_EXTERN_C();
01079
01099 SAL_DLLPUBLIC void SAL_CALL rtl_string_newToAsciiLowerCase(
01100 rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
01101
01121 SAL_DLLPUBLIC void SAL_CALL rtl_string_newToAsciiUpperCase(
01122 rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
01123
01143 SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
01144 rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
01145
01190 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
01191 rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
01192
01193
01194
01209
01210
01211
01212
01213
01214 #define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
01215 ((sal_Int32)SAL_N_ELEMENTS(constAsciiStr)-1)
01216
01230 #define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1))
01231
01232
01233
01234
01235 #define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
01236 RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
01237 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
01238 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\
01239 RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
01240
01241
01242
01275 SAL_DLLPUBLIC void SAL_CALL rtl_uString2String(
01276 rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
01277
01308 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertUStringToString(
01309 rtl_String ** pTarget,
01310 sal_Unicode const * pSource,
01311 sal_Int32 nLength,
01312 rtl_TextEncoding nEncoding,
01313 sal_uInt32 nFlags)
01314 SAL_THROW_EXTERN_C();
01315
01316 #ifdef __cplusplus
01317 }
01318 #endif
01319
01320 #endif
01321
01322