1*9eab2a37SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9eab2a37SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9eab2a37SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9eab2a37SAndrew Rist * distributed with this work for additional information 6*9eab2a37SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9eab2a37SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9eab2a37SAndrew Rist * "License"); you may not use this file except in compliance 9*9eab2a37SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9eab2a37SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9eab2a37SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9eab2a37SAndrew Rist * software distributed under the License is distributed on an 15*9eab2a37SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9eab2a37SAndrew Rist * KIND, either express or implied. See the License for the 17*9eab2a37SAndrew Rist * specific language governing permissions and limitations 18*9eab2a37SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9eab2a37SAndrew Rist *************************************************************/ 21*9eab2a37SAndrew Rist 22*9eab2a37SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _RTL_STRING_H_ 25cdf0e10cSrcweir #define _RTL_STRING_H_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <osl/interlck.h> 29cdf0e10cSrcweir #include <rtl/textcvt.h> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifdef __cplusplus 32cdf0e10cSrcweir extern "C" { 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir /* ======================================================================= */ 36cdf0e10cSrcweir 37cdf0e10cSrcweir /** Return the length of a string. 38cdf0e10cSrcweir 39cdf0e10cSrcweir The length is equal to the number of 8-bit characters in the string, 40cdf0e10cSrcweir without the terminating NUL character. 41cdf0e10cSrcweir 42cdf0e10cSrcweir @param str 43cdf0e10cSrcweir a null-terminated string. 44cdf0e10cSrcweir 45cdf0e10cSrcweir @return 46cdf0e10cSrcweir the length of the sequence of characters represented by this string, 47cdf0e10cSrcweir excluding the terminating NUL character. 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_getLength( const sal_Char * str ) SAL_THROW_EXTERN_C(); 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** Compare two strings. 52cdf0e10cSrcweir 53cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 54cdf0e10cSrcweir strings and returns a value indicating their relationship. This function 55cdf0e10cSrcweir cannot be used for language-specific sorting. Both strings must be 56cdf0e10cSrcweir null-terminated. 57cdf0e10cSrcweir 58cdf0e10cSrcweir @param first 59cdf0e10cSrcweir the first null-terminated string to be compared. 60cdf0e10cSrcweir 61cdf0e10cSrcweir @param second 62cdf0e10cSrcweir the second null-terminated string which is compared with the first one. 63cdf0e10cSrcweir 64cdf0e10cSrcweir @return 65cdf0e10cSrcweir 0 if both strings are equal, a value less than 0 if the first string is 66cdf0e10cSrcweir less than the second string, and a value greater than 0 if the first 67cdf0e10cSrcweir string is greater than the second string. 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_compare( const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir /** Compare two strings. 72cdf0e10cSrcweir 73cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 74cdf0e10cSrcweir strings and returns a value indicating their relationship. This function 75cdf0e10cSrcweir cannot be used for language-specific sorting. 76cdf0e10cSrcweir 77cdf0e10cSrcweir @param first 78cdf0e10cSrcweir the first string to be compared. Need not be null-terminated, but must be 79cdf0e10cSrcweir at least as long as the specified firstLen. 80cdf0e10cSrcweir 81cdf0e10cSrcweir @param firstLen 82cdf0e10cSrcweir the length of the first string. 83cdf0e10cSrcweir 84cdf0e10cSrcweir @param second 85cdf0e10cSrcweir the second string which is compared with the first one. Need not be 86cdf0e10cSrcweir null-terminated, but must be at least as long as the specified secondLen. 87cdf0e10cSrcweir 88cdf0e10cSrcweir @param secondLen 89cdf0e10cSrcweir the length of the second string. 90cdf0e10cSrcweir 91cdf0e10cSrcweir @return 92cdf0e10cSrcweir 0 if both strings are equal, a value less than 0 if the first string is 93cdf0e10cSrcweir less than the second string, and a value greater than 0 if the first 94cdf0e10cSrcweir string is greater than the second string. 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_compare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir /** Compare two strings with a maximum count of characters. 99cdf0e10cSrcweir 100cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 101cdf0e10cSrcweir strings and returns a value indicating their relationship. This function 102cdf0e10cSrcweir cannot be used for language-specific sorting. 103cdf0e10cSrcweir 104cdf0e10cSrcweir @param first 105cdf0e10cSrcweir the first string to be compared. Need not be null-terminated, but must be 106cdf0e10cSrcweir at least as long as the specified firstLen. 107cdf0e10cSrcweir 108cdf0e10cSrcweir @param firstLen 109cdf0e10cSrcweir the length of the first string. 110cdf0e10cSrcweir 111cdf0e10cSrcweir @param second 112cdf0e10cSrcweir the second string which is compared with the first one. Need not be 113cdf0e10cSrcweir null-terminated, but must be at least as long as the specified secondLen. 114cdf0e10cSrcweir 115cdf0e10cSrcweir @param secondLen 116cdf0e10cSrcweir the length of the second string. 117cdf0e10cSrcweir 118cdf0e10cSrcweir @param shortenedLen 119cdf0e10cSrcweir the maximum number of characters to compare. This length can be greater 120cdf0e10cSrcweir or smaller than the lengths of the two strings. 121cdf0e10cSrcweir 122cdf0e10cSrcweir @return 123cdf0e10cSrcweir 0 if both substrings are equal, a value less than 0 if the first substring 124cdf0e10cSrcweir is less than the second substring, and a value greater than 0 if the first 125cdf0e10cSrcweir substring is greater than the second substring. 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir sal_Int32 SAL_CALL 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(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** Compare two strings from back to front. 130cdf0e10cSrcweir 131cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 132cdf0e10cSrcweir strings and returns a value indicating their relationship. This function 133cdf0e10cSrcweir cannot be used for language-specific sorting. 134cdf0e10cSrcweir 135cdf0e10cSrcweir @param first 136cdf0e10cSrcweir the first string to be compared. Need not be null-terminated, but must be 137cdf0e10cSrcweir at least as long as the specified firstLen. 138cdf0e10cSrcweir 139cdf0e10cSrcweir @param firstLen 140cdf0e10cSrcweir the length of the first string. 141cdf0e10cSrcweir 142cdf0e10cSrcweir @param second 143cdf0e10cSrcweir the second string which is compared with the first one. Need not be 144cdf0e10cSrcweir null-terminated, but must be at least as long as the specified secondLen. 145cdf0e10cSrcweir 146cdf0e10cSrcweir @param secondLen 147cdf0e10cSrcweir the length of the second string. 148cdf0e10cSrcweir 149cdf0e10cSrcweir @return 150cdf0e10cSrcweir 0 if both strings are equal, a value less than 0 if the first string 151cdf0e10cSrcweir compares less than the second string, and a value greater than 0 if the 152cdf0e10cSrcweir first string compares greater than the second string. 153cdf0e10cSrcweir */ 154cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir /** Compare two strings, ignoring the case of ASCII characters. 157cdf0e10cSrcweir 158cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 159cdf0e10cSrcweir strings and returns a value indicating their relationship. Character 160cdf0e10cSrcweir values between 65 and 90 (ASCII A--Z) are interpreted as values between 97 161cdf0e10cSrcweir and 122 (ASCII a--z). This function cannot be used for language-specific 162cdf0e10cSrcweir sorting. Both strings must be null-terminated. 163cdf0e10cSrcweir 164cdf0e10cSrcweir @param first 165cdf0e10cSrcweir the first null-terminated string to be compared. 166cdf0e10cSrcweir 167cdf0e10cSrcweir @param second 168cdf0e10cSrcweir the second null-terminated string which is compared with the first one. 169cdf0e10cSrcweir 170cdf0e10cSrcweir @return 171cdf0e10cSrcweir 0 if both strings are equal, a value less than 0 if the first string is 172cdf0e10cSrcweir less than the second string, and a value greater than 0 if the first 173cdf0e10cSrcweir string is greater than the second string. 174cdf0e10cSrcweir */ 175cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase( const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C(); 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** Compare two strings, ignoring the case of ASCII characters. 178cdf0e10cSrcweir 179cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 180cdf0e10cSrcweir strings and returns a value indicating their relationship. Character 181cdf0e10cSrcweir values between 65 and 90 (ASCII A--Z) are interpreted as values between 97 182cdf0e10cSrcweir and 122 (ASCII a--z). This function cannot be used for language-specific 183cdf0e10cSrcweir sorting. 184cdf0e10cSrcweir 185cdf0e10cSrcweir @param first 186cdf0e10cSrcweir the first string to be compared. Need not be null-terminated, but must be 187cdf0e10cSrcweir at least as long as the specified firstLen. 188cdf0e10cSrcweir 189cdf0e10cSrcweir @param firstLen 190cdf0e10cSrcweir the length of the first string. 191cdf0e10cSrcweir 192cdf0e10cSrcweir @param second 193cdf0e10cSrcweir the second string which is compared with the first one. Need not be 194cdf0e10cSrcweir null-terminated, but must be at least as long as the specified secondLen. 195cdf0e10cSrcweir 196cdf0e10cSrcweir @param secondLen 197cdf0e10cSrcweir the length of the second string. 198cdf0e10cSrcweir 199cdf0e10cSrcweir @return 200cdf0e10cSrcweir 0 if both strings are equal, a value less than 0 if the first string is 201cdf0e10cSrcweir less than the second string, and a value greater than 0 if the first 202cdf0e10cSrcweir string is greater than the second string. 203cdf0e10cSrcweir */ 204cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir /** Compare two strings with a maximum count of characters, ignoring the case 207cdf0e10cSrcweir of ASCII characters. 208cdf0e10cSrcweir 209cdf0e10cSrcweir The comparison is based on the numeric value of each character in the 210cdf0e10cSrcweir strings and returns a value indicating their relationship. Character 211cdf0e10cSrcweir values between 65 and 90 (ASCII A--Z) are interpreted as values between 97 212cdf0e10cSrcweir and 122 (ASCII a--z). This function cannot be used for language-specific 213cdf0e10cSrcweir sorting. 214cdf0e10cSrcweir 215cdf0e10cSrcweir @param first 216cdf0e10cSrcweir the first string to be compared. Need not be null-terminated, but must be 217cdf0e10cSrcweir at least as long as the specified firstLen. 218cdf0e10cSrcweir 219cdf0e10cSrcweir @param firstLen 220cdf0e10cSrcweir the length of the first string. 221cdf0e10cSrcweir 222cdf0e10cSrcweir @param second 223cdf0e10cSrcweir the second string which is compared with the first one. Need not be 224cdf0e10cSrcweir null-terminated, but must be at least as long as the specified secondLen. 225cdf0e10cSrcweir 226cdf0e10cSrcweir @param secondLen 227cdf0e10cSrcweir the length of the second string. 228cdf0e10cSrcweir 229cdf0e10cSrcweir @param shortenedLen 230cdf0e10cSrcweir the maximum number of characters to compare. This length can be greater 231cdf0e10cSrcweir or smaller than the lengths of the two strings. 232cdf0e10cSrcweir 233cdf0e10cSrcweir @return 234cdf0e10cSrcweir 0 if both substrings are equal, a value less than 0 if the first substring 235cdf0e10cSrcweir is less than the second substring, and a value greater than 0 if the first 236cdf0e10cSrcweir substring is greater than the second substring. 237cdf0e10cSrcweir */ 238cdf0e10cSrcweir sal_Int32 SAL_CALL 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(); 239cdf0e10cSrcweir 240cdf0e10cSrcweir /** Return a hash code for a string. 241cdf0e10cSrcweir 242cdf0e10cSrcweir It is not allowed to store the hash code persistently, because later 243cdf0e10cSrcweir versions could return other hash codes. The string must be 244cdf0e10cSrcweir null-terminated. 245cdf0e10cSrcweir 246cdf0e10cSrcweir @param str 247cdf0e10cSrcweir a null-terminated string. 248cdf0e10cSrcweir 249cdf0e10cSrcweir @return 250cdf0e10cSrcweir a hash code for the given string. 251cdf0e10cSrcweir */ 252cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_hashCode( const sal_Char * str ) SAL_THROW_EXTERN_C(); 253cdf0e10cSrcweir 254cdf0e10cSrcweir /** Return a hash code for a string. 255cdf0e10cSrcweir 256cdf0e10cSrcweir It is not allowed to store the hash code persistently, because later 257cdf0e10cSrcweir versions could return other hash codes. 258cdf0e10cSrcweir 259cdf0e10cSrcweir @param str 260cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 261cdf0e10cSrcweir the specified len. 262cdf0e10cSrcweir 263cdf0e10cSrcweir @param len 264cdf0e10cSrcweir the length of the string. 265cdf0e10cSrcweir 266cdf0e10cSrcweir @return 267cdf0e10cSrcweir a hash code for the given string. 268cdf0e10cSrcweir */ 269cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_hashCode_WithLength( const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); 270cdf0e10cSrcweir 271cdf0e10cSrcweir /** Search for the first occurrence of a character within a string. 272cdf0e10cSrcweir 273cdf0e10cSrcweir The string must be null-terminated. 274cdf0e10cSrcweir 275cdf0e10cSrcweir @param str 276cdf0e10cSrcweir a null-terminated string. 277cdf0e10cSrcweir 278cdf0e10cSrcweir @param ch 279cdf0e10cSrcweir the character to be searched for. 280cdf0e10cSrcweir 281cdf0e10cSrcweir @return 282cdf0e10cSrcweir the index (starting at 0) of the first occurrence of the character in the 283cdf0e10cSrcweir string, or -1 if the character does not occur. 284cdf0e10cSrcweir */ 285cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_indexOfChar( const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C(); 286cdf0e10cSrcweir 287cdf0e10cSrcweir /** Search for the first occurrence of a character within a string. 288cdf0e10cSrcweir 289cdf0e10cSrcweir @param str 290cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 291cdf0e10cSrcweir the specified len. 292cdf0e10cSrcweir 293cdf0e10cSrcweir @param len 294cdf0e10cSrcweir the length of the string. 295cdf0e10cSrcweir 296cdf0e10cSrcweir @param ch 297cdf0e10cSrcweir the character to be searched for. 298cdf0e10cSrcweir 299cdf0e10cSrcweir @return 300cdf0e10cSrcweir the index (starting at 0) of the first occurrence of the character in the 301cdf0e10cSrcweir string, or -1 if the character does not occur. 302cdf0e10cSrcweir */ 303cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C(); 304cdf0e10cSrcweir 305cdf0e10cSrcweir /** Search for the last occurrence of a character within a string. 306cdf0e10cSrcweir 307cdf0e10cSrcweir The string must be null-terminated. 308cdf0e10cSrcweir 309cdf0e10cSrcweir @param str 310cdf0e10cSrcweir a null-terminated string. 311cdf0e10cSrcweir 312cdf0e10cSrcweir @param ch 313cdf0e10cSrcweir the character to be searched for. 314cdf0e10cSrcweir 315cdf0e10cSrcweir @return 316cdf0e10cSrcweir the index (starting at 0) of the last occurrence of the character in the 317cdf0e10cSrcweir string, or -1 if the character does not occur. The returned value is 318cdf0e10cSrcweir always smaller than the string length. 319cdf0e10cSrcweir */ 320cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_lastIndexOfChar( const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir /** Search for the last occurrence of a character within a string. 323cdf0e10cSrcweir 324cdf0e10cSrcweir @param str 325cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 326cdf0e10cSrcweir the specified len. 327cdf0e10cSrcweir 328cdf0e10cSrcweir @param len 329cdf0e10cSrcweir the length of the string. 330cdf0e10cSrcweir 331cdf0e10cSrcweir @param ch 332cdf0e10cSrcweir the character to be searched for. 333cdf0e10cSrcweir 334cdf0e10cSrcweir @return 335cdf0e10cSrcweir the index (starting at 0) of the last occurrence of the character in the 336cdf0e10cSrcweir string, or -1 if the character does not occur. The returned value is 337cdf0e10cSrcweir always smaller than the string length. 338cdf0e10cSrcweir */ 339cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C(); 340cdf0e10cSrcweir 341cdf0e10cSrcweir /** Search for the first occurrence of a substring within a string. 342cdf0e10cSrcweir 343cdf0e10cSrcweir If subStr is empty, or both str and subStr are empty, -1 is returned. 344cdf0e10cSrcweir Both strings must be null-terminated. 345cdf0e10cSrcweir 346cdf0e10cSrcweir @param str 347cdf0e10cSrcweir a null-terminated string. 348cdf0e10cSrcweir 349cdf0e10cSrcweir @param subStr 350cdf0e10cSrcweir the null-terminated substring to be searched for. 351cdf0e10cSrcweir 352cdf0e10cSrcweir @return 353cdf0e10cSrcweir the index (starting at 0) of the first character of the first occurrence 354cdf0e10cSrcweir of the substring within the string, or -1 if the substring does not occur. 355cdf0e10cSrcweir */ 356cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_indexOfStr( const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C(); 357cdf0e10cSrcweir 358cdf0e10cSrcweir /** Search for the first occurrence of a substring within a string. 359cdf0e10cSrcweir 360cdf0e10cSrcweir If subStr is empty, or both str and subStr are empty, -1 is returned. 361cdf0e10cSrcweir 362cdf0e10cSrcweir @param str 363cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 364cdf0e10cSrcweir the specified len. 365cdf0e10cSrcweir 366cdf0e10cSrcweir @param len 367cdf0e10cSrcweir the length of the string. 368cdf0e10cSrcweir 369cdf0e10cSrcweir @param subStr 370cdf0e10cSrcweir the substring to be searched for. Need not be null-terminated, but must 371cdf0e10cSrcweir be at least as long as the specified subLen. 372cdf0e10cSrcweir 373cdf0e10cSrcweir @param subLen 374cdf0e10cSrcweir the length of the substring. 375cdf0e10cSrcweir 376cdf0e10cSrcweir @return 377cdf0e10cSrcweir the index (starting at 0) of the first character of the first occurrence 378cdf0e10cSrcweir of the substring within the string, or -1 if the substring does not occur. 379cdf0e10cSrcweir */ 380cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C(); 381cdf0e10cSrcweir 382cdf0e10cSrcweir /** Search for the last occurrence of a substring within a string. 383cdf0e10cSrcweir 384cdf0e10cSrcweir If subStr is empty, or both str and subStr are empty, -1 is returned. 385cdf0e10cSrcweir Both strings must be null-terminated. 386cdf0e10cSrcweir 387cdf0e10cSrcweir @param str 388cdf0e10cSrcweir a null-terminated string. 389cdf0e10cSrcweir 390cdf0e10cSrcweir @param subStr 391cdf0e10cSrcweir the null-terminated substring to be searched for. 392cdf0e10cSrcweir 393cdf0e10cSrcweir @return 394cdf0e10cSrcweir the index (starting at 0) of the first character of the last occurrence 395cdf0e10cSrcweir of the substring within the string, or -1 if the substring does not occur. 396cdf0e10cSrcweir */ 397cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_lastIndexOfStr( const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C(); 398cdf0e10cSrcweir 399cdf0e10cSrcweir /** Search for the last occurrence of a substring within a string. 400cdf0e10cSrcweir 401cdf0e10cSrcweir If subStr is empty, or both str and subStr are empty, -1 is returned. 402cdf0e10cSrcweir 403cdf0e10cSrcweir @param str 404cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 405cdf0e10cSrcweir the specified len. 406cdf0e10cSrcweir 407cdf0e10cSrcweir @param len 408cdf0e10cSrcweir the length of the string. 409cdf0e10cSrcweir 410cdf0e10cSrcweir @param subStr 411cdf0e10cSrcweir the substring to be searched for. Need not be null-terminated, but must 412cdf0e10cSrcweir be at least as long as the specified subLen. 413cdf0e10cSrcweir 414cdf0e10cSrcweir @param subLen 415cdf0e10cSrcweir the length of the substring. 416cdf0e10cSrcweir 417cdf0e10cSrcweir @return 418cdf0e10cSrcweir the index (starting at 0) of the first character of the first occurrence 419cdf0e10cSrcweir of the substring within the string, or -1 if the substring does not occur. 420cdf0e10cSrcweir */ 421cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C(); 422cdf0e10cSrcweir 423cdf0e10cSrcweir /** Replace all occurrences of a single character within a string. 424cdf0e10cSrcweir 425cdf0e10cSrcweir If oldChar does not occur within str, then the string is not modified. 426cdf0e10cSrcweir The string must be null-terminated. 427cdf0e10cSrcweir 428cdf0e10cSrcweir @param str 429cdf0e10cSrcweir a null-terminated string. 430cdf0e10cSrcweir 431cdf0e10cSrcweir @param oldChar 432cdf0e10cSrcweir the old character. 433cdf0e10cSrcweir 434cdf0e10cSrcweir @param newChar 435cdf0e10cSrcweir the new character. 436cdf0e10cSrcweir */ 437cdf0e10cSrcweir void SAL_CALL rtl_str_replaceChar( sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C(); 438cdf0e10cSrcweir 439cdf0e10cSrcweir /** Replace all occurrences of a single character within a string. 440cdf0e10cSrcweir 441cdf0e10cSrcweir If oldChar does not occur within str, then the string is not modified. 442cdf0e10cSrcweir 443cdf0e10cSrcweir @param str 444cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 445cdf0e10cSrcweir the specified len. 446cdf0e10cSrcweir 447cdf0e10cSrcweir @param len 448cdf0e10cSrcweir the length of the string. 449cdf0e10cSrcweir 450cdf0e10cSrcweir @param oldChar 451cdf0e10cSrcweir the old character. 452cdf0e10cSrcweir 453cdf0e10cSrcweir @param newChar 454cdf0e10cSrcweir the new character. 455cdf0e10cSrcweir */ 456cdf0e10cSrcweir void SAL_CALL rtl_str_replaceChar_WithLength( sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C(); 457cdf0e10cSrcweir 458cdf0e10cSrcweir /** Convert all ASCII uppercase letters to lowercase within a string. 459cdf0e10cSrcweir 460cdf0e10cSrcweir The characters with values between 65 and 90 (ASCII A--Z) are replaced 461cdf0e10cSrcweir with values between 97 and 122 (ASCII a--z). The string must be 462cdf0e10cSrcweir null-terminated. 463cdf0e10cSrcweir 464cdf0e10cSrcweir @param str 465cdf0e10cSrcweir a null-terminated string. 466cdf0e10cSrcweir */ 467cdf0e10cSrcweir void SAL_CALL rtl_str_toAsciiLowerCase( sal_Char * str ) SAL_THROW_EXTERN_C(); 468cdf0e10cSrcweir 469cdf0e10cSrcweir /** Convert all ASCII uppercase letters to lowercase within a string. 470cdf0e10cSrcweir 471cdf0e10cSrcweir The characters with values between 65 and 90 (ASCII A--Z) are replaced 472cdf0e10cSrcweir with values between 97 and 122 (ASCII a--z). 473cdf0e10cSrcweir 474cdf0e10cSrcweir @param str 475cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 476cdf0e10cSrcweir the specified len. 477cdf0e10cSrcweir 478cdf0e10cSrcweir @param len 479cdf0e10cSrcweir the length of the string. 480cdf0e10cSrcweir */ 481cdf0e10cSrcweir void SAL_CALL rtl_str_toAsciiLowerCase_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); 482cdf0e10cSrcweir 483cdf0e10cSrcweir /** Convert all ASCII lowercase letters to uppercase within a string. 484cdf0e10cSrcweir 485cdf0e10cSrcweir The characters with values between 97 and 122 (ASCII a--z) are replaced 486cdf0e10cSrcweir with values between 65 and 90 (ASCII A--Z). The string must be 487cdf0e10cSrcweir null-terminated. 488cdf0e10cSrcweir 489cdf0e10cSrcweir @param str 490cdf0e10cSrcweir a null-terminated string. 491cdf0e10cSrcweir */ 492cdf0e10cSrcweir void SAL_CALL rtl_str_toAsciiUpperCase( sal_Char * str ) SAL_THROW_EXTERN_C(); 493cdf0e10cSrcweir 494cdf0e10cSrcweir /** Convert all ASCII lowercase letters to uppercase within a string. 495cdf0e10cSrcweir 496cdf0e10cSrcweir The characters with values between 97 and 122 (ASCII a--z) are replaced 497cdf0e10cSrcweir with values between 65 and 90 (ASCII A--Z). 498cdf0e10cSrcweir 499cdf0e10cSrcweir @param str 500cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 501cdf0e10cSrcweir the specified len. 502cdf0e10cSrcweir 503cdf0e10cSrcweir @param len 504cdf0e10cSrcweir the length of the string. 505cdf0e10cSrcweir */ 506cdf0e10cSrcweir void SAL_CALL rtl_str_toAsciiUpperCase_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); 507cdf0e10cSrcweir 508cdf0e10cSrcweir /** Remove white space from both ends of a string. 509cdf0e10cSrcweir 510cdf0e10cSrcweir All characters with values less than or equal to 32 (the space character) 511cdf0e10cSrcweir are considered to be white space. This function cannot be used for 512cdf0e10cSrcweir language-specific operations. The string must be null-terminated. 513cdf0e10cSrcweir 514cdf0e10cSrcweir @param str 515cdf0e10cSrcweir a null-terminated string. 516cdf0e10cSrcweir 517cdf0e10cSrcweir @return 518cdf0e10cSrcweir the new length of the string. 519cdf0e10cSrcweir */ 520cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_trim( sal_Char * str ) SAL_THROW_EXTERN_C(); 521cdf0e10cSrcweir 522cdf0e10cSrcweir /** Remove white space from both ends of the string. 523cdf0e10cSrcweir 524cdf0e10cSrcweir All characters with values less than or equal to 32 (the space character) 525cdf0e10cSrcweir are considered to be white space. This function cannot be used for 526cdf0e10cSrcweir language-specific operations. The string must be null-terminated. 527cdf0e10cSrcweir 528cdf0e10cSrcweir @param str 529cdf0e10cSrcweir a string. Need not be null-terminated, but must be at least as long as 530cdf0e10cSrcweir the specified len. 531cdf0e10cSrcweir 532cdf0e10cSrcweir @param len 533cdf0e10cSrcweir the original length of the string. 534cdf0e10cSrcweir 535cdf0e10cSrcweir @return 536cdf0e10cSrcweir the new length of the string. 537cdf0e10cSrcweir */ 538cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_trim_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); 539cdf0e10cSrcweir 540cdf0e10cSrcweir /** Create the string representation of a boolean. 541cdf0e10cSrcweir 542cdf0e10cSrcweir If b is true, the buffer is filled with the string "true" and 5 is 543cdf0e10cSrcweir returned. If b is false, the buffer is filled with the string "false" and 544cdf0e10cSrcweir 6 is returned. This function cannot be used for language-specific 545cdf0e10cSrcweir operations. 546cdf0e10cSrcweir 547cdf0e10cSrcweir @param str 548cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 549cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFBOOLEAN define to create 550cdf0e10cSrcweir a buffer that is big enough. 551cdf0e10cSrcweir 552cdf0e10cSrcweir @param b 553cdf0e10cSrcweir a boolean value. 554cdf0e10cSrcweir 555cdf0e10cSrcweir @return 556cdf0e10cSrcweir the length of the string. 557cdf0e10cSrcweir */ 558cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfBoolean( sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C(); 559cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFBOOLEAN 6 560cdf0e10cSrcweir 561cdf0e10cSrcweir /** Create the string representation of a character. 562cdf0e10cSrcweir 563cdf0e10cSrcweir @param str 564cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 565cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFCHAR define to create a 566cdf0e10cSrcweir buffer that is big enough. 567cdf0e10cSrcweir 568cdf0e10cSrcweir @param ch 569cdf0e10cSrcweir a character value. 570cdf0e10cSrcweir 571cdf0e10cSrcweir @return 572cdf0e10cSrcweir the length of the string. 573cdf0e10cSrcweir */ 574cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfChar( sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C(); 575cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFCHAR 2 576cdf0e10cSrcweir 577cdf0e10cSrcweir /** Create the string representation of an integer. 578cdf0e10cSrcweir 579cdf0e10cSrcweir This function cannot be used for language-specific operations. 580cdf0e10cSrcweir 581cdf0e10cSrcweir @param str 582cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 583cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFINT32 define to create a 584cdf0e10cSrcweir buffer that is big enough. 585cdf0e10cSrcweir 586cdf0e10cSrcweir @param i 587cdf0e10cSrcweir an integer value. 588cdf0e10cSrcweir 589cdf0e10cSrcweir @param radix 590cdf0e10cSrcweir the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX 591cdf0e10cSrcweir (36), inclusive. 592cdf0e10cSrcweir 593cdf0e10cSrcweir @return 594cdf0e10cSrcweir the length of the string. 595cdf0e10cSrcweir */ 596cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfInt32( sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C(); 597cdf0e10cSrcweir #define RTL_STR_MIN_RADIX 2 598cdf0e10cSrcweir #define RTL_STR_MAX_RADIX 36 599cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFINT32 33 600cdf0e10cSrcweir 601cdf0e10cSrcweir /** Create the string representation of a long integer. 602cdf0e10cSrcweir 603cdf0e10cSrcweir This function cannot be used for language-specific operations. 604cdf0e10cSrcweir 605cdf0e10cSrcweir @param str 606cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 607cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFINT64 define to create a 608cdf0e10cSrcweir buffer that is big enough. 609cdf0e10cSrcweir 610cdf0e10cSrcweir @param l 611cdf0e10cSrcweir a long integer value. 612cdf0e10cSrcweir 613cdf0e10cSrcweir @param radix 614cdf0e10cSrcweir the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX 615cdf0e10cSrcweir (36), inclusive. 616cdf0e10cSrcweir 617cdf0e10cSrcweir @return 618cdf0e10cSrcweir the length of the string. 619cdf0e10cSrcweir */ 620cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfInt64( sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C(); 621cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFINT64 65 622cdf0e10cSrcweir 623cdf0e10cSrcweir /** Create the string representation of a float. 624cdf0e10cSrcweir 625cdf0e10cSrcweir This function cannot be used for language-specific conversion. 626cdf0e10cSrcweir 627cdf0e10cSrcweir @param str 628cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 629cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFFLOAT define to create a 630cdf0e10cSrcweir buffer that is big enough. 631cdf0e10cSrcweir 632cdf0e10cSrcweir @param f 633cdf0e10cSrcweir a float value. 634cdf0e10cSrcweir 635cdf0e10cSrcweir @return 636cdf0e10cSrcweir the length of the string. 637cdf0e10cSrcweir */ 638cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfFloat( sal_Char * str, float f ) SAL_THROW_EXTERN_C(); 639cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFFLOAT 15 640cdf0e10cSrcweir 641cdf0e10cSrcweir /** Create the string representation of a double. 642cdf0e10cSrcweir 643cdf0e10cSrcweir This function cannot be used for language-specific conversion. 644cdf0e10cSrcweir 645cdf0e10cSrcweir @param str 646cdf0e10cSrcweir a buffer that is big enough to hold the result and the terminating NUL 647cdf0e10cSrcweir character. You should use the RTL_STR_MAX_VALUEOFDOUBLE define to create 648cdf0e10cSrcweir a buffer that is big enough. 649cdf0e10cSrcweir 650cdf0e10cSrcweir @param d 651cdf0e10cSrcweir a double value. 652cdf0e10cSrcweir 653cdf0e10cSrcweir @return 654cdf0e10cSrcweir the length of the string. 655cdf0e10cSrcweir */ 656cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_valueOfDouble( sal_Char * str, double d ) SAL_THROW_EXTERN_C(); 657cdf0e10cSrcweir #define RTL_STR_MAX_VALUEOFDOUBLE 25 658cdf0e10cSrcweir 659cdf0e10cSrcweir /** Interpret a string as a boolean. 660cdf0e10cSrcweir 661cdf0e10cSrcweir This function cannot be used for language-specific conversion. The string 662cdf0e10cSrcweir must be null-terminated. 663cdf0e10cSrcweir 664cdf0e10cSrcweir @param str 665cdf0e10cSrcweir a null-terminated string. 666cdf0e10cSrcweir 667cdf0e10cSrcweir @return 668cdf0e10cSrcweir true if the string is "1" or "true" in any ASCII case, false otherwise. 669cdf0e10cSrcweir */ 670cdf0e10cSrcweir sal_Bool SAL_CALL rtl_str_toBoolean( const sal_Char * str ) SAL_THROW_EXTERN_C(); 671cdf0e10cSrcweir 672cdf0e10cSrcweir /** Interpret a string as an integer. 673cdf0e10cSrcweir 674cdf0e10cSrcweir This function cannot be used for language-specific conversion. The string 675cdf0e10cSrcweir must be null-terminated. 676cdf0e10cSrcweir 677cdf0e10cSrcweir @param str 678cdf0e10cSrcweir a null-terminated string. 679cdf0e10cSrcweir 680cdf0e10cSrcweir @param radix 681cdf0e10cSrcweir the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX 682cdf0e10cSrcweir (36), inclusive. 683cdf0e10cSrcweir 684cdf0e10cSrcweir @return 685cdf0e10cSrcweir the integer value represented by the string, or 0 if the string does not 686cdf0e10cSrcweir represent an integer. 687cdf0e10cSrcweir */ 688cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_str_toInt32( const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C(); 689cdf0e10cSrcweir 690cdf0e10cSrcweir /** Interpret a string as a long integer. 691cdf0e10cSrcweir 692cdf0e10cSrcweir This function cannot be used for language-specific conversion. The string 693cdf0e10cSrcweir must be null-terminated. 694cdf0e10cSrcweir 695cdf0e10cSrcweir @param str 696cdf0e10cSrcweir a null-terminated string. 697cdf0e10cSrcweir 698cdf0e10cSrcweir @param radix 699cdf0e10cSrcweir the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX 700cdf0e10cSrcweir (36), inclusive. 701cdf0e10cSrcweir 702cdf0e10cSrcweir @return 703cdf0e10cSrcweir the long integer value represented by the string, or 0 if the string does 704cdf0e10cSrcweir not represent a long integer. 705cdf0e10cSrcweir */ 706cdf0e10cSrcweir sal_Int64 SAL_CALL rtl_str_toInt64( const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C(); 707cdf0e10cSrcweir 708cdf0e10cSrcweir /** Interpret a string as a float. 709cdf0e10cSrcweir 710cdf0e10cSrcweir This function cannot be used for language-specific conversion. The string 711cdf0e10cSrcweir must be null-terminated. 712cdf0e10cSrcweir 713cdf0e10cSrcweir @param str 714cdf0e10cSrcweir a null-terminated string. 715cdf0e10cSrcweir 716cdf0e10cSrcweir @return 717cdf0e10cSrcweir the float value represented by the string, or 0.0 if the string does not 718cdf0e10cSrcweir represent a float. 719cdf0e10cSrcweir */ 720cdf0e10cSrcweir float SAL_CALL rtl_str_toFloat( const sal_Char * str ) SAL_THROW_EXTERN_C(); 721cdf0e10cSrcweir 722cdf0e10cSrcweir /** Interpret a string as a double. 723cdf0e10cSrcweir 724cdf0e10cSrcweir This function cannot be used for language-specific conversion. The string 725cdf0e10cSrcweir must be null-terminated. 726cdf0e10cSrcweir 727cdf0e10cSrcweir @param str 728cdf0e10cSrcweir a null-terminated string. 729cdf0e10cSrcweir 730cdf0e10cSrcweir @return 731cdf0e10cSrcweir the float value represented by the string, or 0.0 if the string does not 732cdf0e10cSrcweir represent a double. 733cdf0e10cSrcweir */ 734cdf0e10cSrcweir double SAL_CALL rtl_str_toDouble( const sal_Char * str ) SAL_THROW_EXTERN_C(); 735cdf0e10cSrcweir 736cdf0e10cSrcweir /* ======================================================================= */ 737cdf0e10cSrcweir 738cdf0e10cSrcweir #ifdef SAL_W32 739cdf0e10cSrcweir # pragma pack(push, 8) 740cdf0e10cSrcweir #elif defined(SAL_OS2) 741cdf0e10cSrcweir # pragma pack(push, 4) 742cdf0e10cSrcweir #endif 743cdf0e10cSrcweir 744cdf0e10cSrcweir /** The implementation of a byte string. 745cdf0e10cSrcweir 746cdf0e10cSrcweir @internal 747cdf0e10cSrcweir */ 748cdf0e10cSrcweir typedef struct _rtl_String 749cdf0e10cSrcweir { 750cdf0e10cSrcweir oslInterlockedCount refCount; /* opaque */ 751cdf0e10cSrcweir sal_Int32 length; 752cdf0e10cSrcweir sal_Char buffer[1]; 753cdf0e10cSrcweir } rtl_String; 754cdf0e10cSrcweir 755cdf0e10cSrcweir #if defined( SAL_W32) || defined(SAL_OS2) 756cdf0e10cSrcweir #pragma pack(pop) 757cdf0e10cSrcweir #endif 758cdf0e10cSrcweir 759cdf0e10cSrcweir /* ----------------------------------------------------------------------- */ 760cdf0e10cSrcweir 761cdf0e10cSrcweir /** Increment the reference count of a string. 762cdf0e10cSrcweir 763cdf0e10cSrcweir @param str 764cdf0e10cSrcweir a string. 765cdf0e10cSrcweir */ 766cdf0e10cSrcweir void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C(); 767cdf0e10cSrcweir 768cdf0e10cSrcweir /** Decrement the reference count of a string. 769cdf0e10cSrcweir 770cdf0e10cSrcweir If the count goes to zero than the string data is deleted. 771cdf0e10cSrcweir 772cdf0e10cSrcweir @param str 773cdf0e10cSrcweir a string. 774cdf0e10cSrcweir */ 775cdf0e10cSrcweir void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C(); 776cdf0e10cSrcweir 777cdf0e10cSrcweir /** Allocate a new string containing no characters. 778cdf0e10cSrcweir 779cdf0e10cSrcweir @param newStr 780cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 781cdf0e10cSrcweir string. 782cdf0e10cSrcweir */ 783cdf0e10cSrcweir void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C(); 784cdf0e10cSrcweir 785cdf0e10cSrcweir /** Allocate a new string containing space for a given number of characters. 786cdf0e10cSrcweir 787cdf0e10cSrcweir If len is greater than zero, the reference count of the new string will be 788cdf0e10cSrcweir 1. The values of all characters are set to 0 and the length of the string 789cdf0e10cSrcweir is 0. This function does not handle out-of-memory conditions. 790cdf0e10cSrcweir 791cdf0e10cSrcweir @param newStr 792cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 793cdf0e10cSrcweir string. 794cdf0e10cSrcweir 795cdf0e10cSrcweir @param len 796cdf0e10cSrcweir the number of characters. 797cdf0e10cSrcweir */ 798cdf0e10cSrcweir void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C(); 799cdf0e10cSrcweir 800cdf0e10cSrcweir /** Allocate a new string that contains a copy of another string. 801cdf0e10cSrcweir 802cdf0e10cSrcweir If the length of value is greater than zero, the reference count of the 803cdf0e10cSrcweir new string will be 1. This function does not handle out-of-memory 804cdf0e10cSrcweir conditions. 805cdf0e10cSrcweir 806cdf0e10cSrcweir @param newStr 807cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 808cdf0e10cSrcweir string. 809cdf0e10cSrcweir 810cdf0e10cSrcweir @param value 811cdf0e10cSrcweir a valid string. 812cdf0e10cSrcweir */ 813cdf0e10cSrcweir void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C(); 814cdf0e10cSrcweir 815cdf0e10cSrcweir /** Allocate a new string that contains a copy of a character array. 816cdf0e10cSrcweir 817cdf0e10cSrcweir If the length of value is greater than zero, the reference count of the 818cdf0e10cSrcweir new string will be 1. This function does not handle out-of-memory 819cdf0e10cSrcweir conditions. 820cdf0e10cSrcweir 821cdf0e10cSrcweir @param newStr 822cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 823cdf0e10cSrcweir string. 824cdf0e10cSrcweir 825cdf0e10cSrcweir @param value 826cdf0e10cSrcweir a null-terminated character array. 827cdf0e10cSrcweir */ 828cdf0e10cSrcweir void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C(); 829cdf0e10cSrcweir 830cdf0e10cSrcweir /** Allocate a new string that contains a copy of a character array. 831cdf0e10cSrcweir 832cdf0e10cSrcweir If the length of value is greater than zero, the reference count of the 833cdf0e10cSrcweir new string will be 1. This function does not handle out-of-memory 834cdf0e10cSrcweir conditions. 835cdf0e10cSrcweir 836cdf0e10cSrcweir @param newStr 837cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 838cdf0e10cSrcweir string. 839cdf0e10cSrcweir 840cdf0e10cSrcweir @param value 841cdf0e10cSrcweir a character array. Need not be null-terminated, but must be at least as 842cdf0e10cSrcweir long as the specified len. 843cdf0e10cSrcweir 844cdf0e10cSrcweir @param len 845cdf0e10cSrcweir the length of the character array. 846cdf0e10cSrcweir */ 847cdf0e10cSrcweir void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C(); 848cdf0e10cSrcweir 849cdf0e10cSrcweir /** Assign a new value to a string. 850cdf0e10cSrcweir 851cdf0e10cSrcweir First releases any value str might currently hold, then acquires 852cdf0e10cSrcweir rightValue. 853cdf0e10cSrcweir 854cdf0e10cSrcweir @param str 855cdf0e10cSrcweir pointer to the string. The pointed-to data must be null or a valid 856cdf0e10cSrcweir string. 857cdf0e10cSrcweir 858cdf0e10cSrcweir @param rightValue 859cdf0e10cSrcweir a valid string. 860cdf0e10cSrcweir */ 861cdf0e10cSrcweir void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C(); 862cdf0e10cSrcweir 863cdf0e10cSrcweir /** Return the length of a string. 864cdf0e10cSrcweir 865cdf0e10cSrcweir The length is equal to the number of characters in the string. 866cdf0e10cSrcweir 867cdf0e10cSrcweir @param str 868cdf0e10cSrcweir a valid string. 869cdf0e10cSrcweir 870cdf0e10cSrcweir @return 871cdf0e10cSrcweir the length of the string. 872cdf0e10cSrcweir */ 873cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C(); 874cdf0e10cSrcweir 875cdf0e10cSrcweir /** Return a pointer to the underlying character array of a string. 876cdf0e10cSrcweir 877cdf0e10cSrcweir @param str 878cdf0e10cSrcweir a valid string. 879cdf0e10cSrcweir 880cdf0e10cSrcweir @return 881cdf0e10cSrcweir a pointer to the null-terminated character array. 882cdf0e10cSrcweir */ 883cdf0e10cSrcweir sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C(); 884cdf0e10cSrcweir 885cdf0e10cSrcweir /** Create a new string that is the concatenation of two other strings. 886cdf0e10cSrcweir 887cdf0e10cSrcweir The new string does not necessarily have a reference count of 1 (in cases 888cdf0e10cSrcweir where one of the two other strings is empty), so it must not be modified 889cdf0e10cSrcweir without checking the reference count. This function does not handle 890cdf0e10cSrcweir out-of-memory conditions. 891cdf0e10cSrcweir 892cdf0e10cSrcweir @param newStr 893cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 894cdf0e10cSrcweir string. 895cdf0e10cSrcweir 896cdf0e10cSrcweir @param left 897cdf0e10cSrcweir a valid string. 898cdf0e10cSrcweir 899cdf0e10cSrcweir @param right 900cdf0e10cSrcweir a valid string. 901cdf0e10cSrcweir */ 902cdf0e10cSrcweir void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C(); 903cdf0e10cSrcweir 904cdf0e10cSrcweir /** Create a new string by replacing a substring of another string. 905cdf0e10cSrcweir 906cdf0e10cSrcweir The new string results from replacing a number of characters (count), 907cdf0e10cSrcweir starting at the specified position (index) in the original string (str), 908cdf0e10cSrcweir with some new substring (subStr). If subStr is null, than only a number 909cdf0e10cSrcweir of characters is deleted. 910cdf0e10cSrcweir 911cdf0e10cSrcweir The new string does not necessarily have a reference count of 1, so it 912cdf0e10cSrcweir must not be modified without checking the reference count. This function 913cdf0e10cSrcweir does not handle out-of-memory conditions. 914cdf0e10cSrcweir 915cdf0e10cSrcweir @param newStr 916cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 917cdf0e10cSrcweir string. 918cdf0e10cSrcweir 919cdf0e10cSrcweir @param str 920cdf0e10cSrcweir a valid string. 921cdf0e10cSrcweir 922cdf0e10cSrcweir @param index 923cdf0e10cSrcweir the index into str at which to start replacement. Must be between 0 and 924cdf0e10cSrcweir the length of str, inclusive. 925cdf0e10cSrcweir 926cdf0e10cSrcweir @param count 927cdf0e10cSrcweir the number of charcters to remove. Must not be negative, and the sum of 928cdf0e10cSrcweir index and count must not exceed the length of str. 929cdf0e10cSrcweir 930cdf0e10cSrcweir @param subStr 931cdf0e10cSrcweir either null or a valid string to be inserted. 932cdf0e10cSrcweir */ 933cdf0e10cSrcweir void SAL_CALL rtl_string_newReplaceStrAt( rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C(); 934cdf0e10cSrcweir 935cdf0e10cSrcweir /** Create a new string by replacing all occurrences of a single character 936cdf0e10cSrcweir within another string. 937cdf0e10cSrcweir 938cdf0e10cSrcweir The new string results from replacing all occurrences of oldChar in str 939cdf0e10cSrcweir with newChar. 940cdf0e10cSrcweir 941cdf0e10cSrcweir The new string does not necessarily have a reference count of 1 (in cases 942cdf0e10cSrcweir where oldChar does not occur in str), so it must not be modified without 943cdf0e10cSrcweir checking the reference count. This function does not handle out-of-memory 944cdf0e10cSrcweir conditions. 945cdf0e10cSrcweir 946cdf0e10cSrcweir @param newStr 947cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 948cdf0e10cSrcweir string. 949cdf0e10cSrcweir 950cdf0e10cSrcweir @param str 951cdf0e10cSrcweir a valid string. 952cdf0e10cSrcweir 953cdf0e10cSrcweir @param oldChar 954cdf0e10cSrcweir the old character. 955cdf0e10cSrcweir 956cdf0e10cSrcweir @param newChar 957cdf0e10cSrcweir the new character. 958cdf0e10cSrcweir */ 959cdf0e10cSrcweir void SAL_CALL rtl_string_newReplace( rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C(); 960cdf0e10cSrcweir 961cdf0e10cSrcweir /** Create a new string by converting all ASCII uppercase letters to lowercase 962cdf0e10cSrcweir within another string. 963cdf0e10cSrcweir 964cdf0e10cSrcweir The new string results from replacing all characters with values between 965cdf0e10cSrcweir 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z). 966cdf0e10cSrcweir 967cdf0e10cSrcweir This function cannot be used for language-specific conversion. The new 968cdf0e10cSrcweir string does not necessarily have a reference count of 1 (in cases where 969cdf0e10cSrcweir no characters need to be converted), so it must not be modified without 970cdf0e10cSrcweir checking the reference count. This function does not handle out-of-memory 971cdf0e10cSrcweir conditions. 972cdf0e10cSrcweir 973cdf0e10cSrcweir @param newStr 974cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 975cdf0e10cSrcweir string. 976cdf0e10cSrcweir 977cdf0e10cSrcweir @param str 978cdf0e10cSrcweir a valid string. 979cdf0e10cSrcweir */ 980cdf0e10cSrcweir void SAL_CALL rtl_string_newToAsciiLowerCase( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C(); 981cdf0e10cSrcweir 982cdf0e10cSrcweir /** Create a new string by converting all ASCII lowercase letters to uppercase 983cdf0e10cSrcweir within another string. 984cdf0e10cSrcweir 985cdf0e10cSrcweir The new string results from replacing all characters with values between 986cdf0e10cSrcweir 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z). 987cdf0e10cSrcweir 988cdf0e10cSrcweir This function cannot be used for language-specific conversion. The new 989cdf0e10cSrcweir string does not necessarily have a reference count of 1 (in cases where 990cdf0e10cSrcweir no characters need to be converted), so it must not be modified without 991cdf0e10cSrcweir checking the reference count. This function does not handle out-of-memory 992cdf0e10cSrcweir conditions. 993cdf0e10cSrcweir 994cdf0e10cSrcweir @param newStr 995cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 996cdf0e10cSrcweir string. 997cdf0e10cSrcweir 998cdf0e10cSrcweir @param str 999cdf0e10cSrcweir a valid string. 1000cdf0e10cSrcweir */ 1001cdf0e10cSrcweir void SAL_CALL rtl_string_newToAsciiUpperCase( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C(); 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir /** Create a new string by removing white space from both ends of another 1004cdf0e10cSrcweir string. 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir The new string results from removing all characters with values less than 1007cdf0e10cSrcweir or equal to 32 (the space character) form both ends of str. 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir This function cannot be used for language-specific conversion. The new 1010cdf0e10cSrcweir string does not necessarily have a reference count of 1 (in cases where 1011cdf0e10cSrcweir no characters need to be removed), so it must not be modified without 1012cdf0e10cSrcweir checking the reference count. This function does not handle out-of-memory 1013cdf0e10cSrcweir conditions. 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir @param newStr 1016cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 1017cdf0e10cSrcweir string. 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir @param str 1020cdf0e10cSrcweir a valid string. 1021cdf0e10cSrcweir */ 1022cdf0e10cSrcweir void SAL_CALL rtl_string_newTrim( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C(); 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir /** Create a new string by extracting a single token from another string. 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir Starting at index, the token's next token is searched for. If there is no 1027cdf0e10cSrcweir such token, the result is an empty string. Otherwise, all characters from 1028cdf0e10cSrcweir the start of that token and up to, but not including the next occurrence 1029cdf0e10cSrcweir of cTok make up the resulting token. The return value is the position of 1030cdf0e10cSrcweir the next token, or -1 if no more tokens follow. 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir Example code could look like 1033cdf0e10cSrcweir rtl_String * pToken = NULL; 1034cdf0e10cSrcweir sal_Int32 nIndex = 0; 1035cdf0e10cSrcweir do 1036cdf0e10cSrcweir { 1037cdf0e10cSrcweir ... 1038cdf0e10cSrcweir nIndex = rtl_string_getToken(&pToken, pStr, 0, ';', nIndex); 1039cdf0e10cSrcweir ... 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir while (nIndex >= 0); 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir The new string does not necessarily have a reference count of 1, so it 1044cdf0e10cSrcweir must not be modified without checking the reference count. This function 1045cdf0e10cSrcweir does not handle out-of-memory conditions. 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir @param newStr 1048cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 1049cdf0e10cSrcweir string. If either token or index is negative, an empty token is stored in 1050cdf0e10cSrcweir newStr (and -1 is returned). 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir @param str 1053cdf0e10cSrcweir a valid string. 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir @param token 1056cdf0e10cSrcweir the number of the token to return, starting at index. 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir @param cTok 1059cdf0e10cSrcweir the character that seperates the tokens. 1060cdf0e10cSrcweir 1061cdf0e10cSrcweir @param index 1062cdf0e10cSrcweir the position at which searching for the token starts. Must not be greater 1063cdf0e10cSrcweir than the length of str. 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir @return 1066cdf0e10cSrcweir the index of the next token, or -1 if no more tokens follow. 1067cdf0e10cSrcweir */ 1068cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_string_getToken( rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C(); 1069cdf0e10cSrcweir 1070cdf0e10cSrcweir /* ======================================================================= */ 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir /** Supply an ASCII string literal together with its length. 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir This macro can be used to compute (some of) the arguments in function calls 1075cdf0e10cSrcweir like rtl::OString(RTL_CONSTASCII_STRINGPARAM("foo")) or 1076cdf0e10cSrcweir rtl::OUString::equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("foo")). 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir @param constAsciiStr 1079cdf0e10cSrcweir must be an expression of type "(possibly cv-qualified reference to) array of 1080cdf0e10cSrcweir (possibly cv-qualified) char." Each element of the referenced array must 1081cdf0e10cSrcweir represent an ASCII value in the range 0x00--0x7F. The last element of the 1082cdf0e10cSrcweir referenced array is not considered part of the represented ASCII string, and 1083cdf0e10cSrcweir its value should be 0x00. Depending on where this macro is used, the nature 1084cdf0e10cSrcweir of the supplied expression might be further restricted. 1085cdf0e10cSrcweir */ 1086cdf0e10cSrcweir #define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, ((sal_Int32)sizeof(constAsciiStr)-1) 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir /** Supply the length of an ASCII string literal. 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir This macro can be used to compute arguments in function calls like 1091cdf0e10cSrcweir rtl::OUString::match(other, RTL_CONSTASCII_LENGTH("prefix")). 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir @param constAsciiStr 1094cdf0e10cSrcweir must be an expression of type "(possibly cv-qualified reference to) array of 1095cdf0e10cSrcweir (possibly cv-qualified) char." Each element of the referenced array must 1096cdf0e10cSrcweir represent an ASCII value in the range 0x00--0x7F. The last element of the 1097cdf0e10cSrcweir referenced array is not considered part of the represented ASCII string, and 1098cdf0e10cSrcweir its value should be 0x00. Depending on where this macro is used, the nature 1099cdf0e10cSrcweir of the supplied expression might be further restricted. 1100cdf0e10cSrcweir */ 1101cdf0e10cSrcweir #define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(sizeof(constAsciiStr)-1)) 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir /* ======================================================================= */ 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir /* predefined constants for String-Conversion */ 1106cdf0e10cSrcweir #define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\ 1107cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\ 1108cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\ 1109cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\ 1110cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE) 1111cdf0e10cSrcweir 1112cdf0e10cSrcweir /* ----------------------------------------------------------------------- */ 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir /** Create a new byte string by converting a Unicode string, using a specific 1115cdf0e10cSrcweir text encoding. 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir The lengths of the byte string and the Unicode string may differ (e.g., 1118cdf0e10cSrcweir for double-byte encodings, UTF-7, UTF-8). 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir If the length of the Unicode string is greater than zero, the reference 1121cdf0e10cSrcweir count of the new string will be 1. 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir If an out-of-memory condition occurs, newStr will point to a null pointer 1124cdf0e10cSrcweir upon return. 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir @param newStr 1127cdf0e10cSrcweir pointer to the new string. The pointed-to data must be null or a valid 1128cdf0e10cSrcweir string. 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir @param str 1131cdf0e10cSrcweir a Unicode character array. Need not be null-terminated, but must be at 1132cdf0e10cSrcweir least as long as the specified len. 1133cdf0e10cSrcweir 1134cdf0e10cSrcweir @param len 1135cdf0e10cSrcweir the length of the Unicode character array. 1136cdf0e10cSrcweir 1137cdf0e10cSrcweir @param encoding 1138cdf0e10cSrcweir the text encoding to use for conversion. 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir @param convertFlags 1141cdf0e10cSrcweir flags which control the conversion. Either use 1142cdf0e10cSrcweir OUSTRING_TO_OSTRING_CVTFLAGS, or see 1143cdf0e10cSrcweir <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more 1144cdf0e10cSrcweir details. 1145cdf0e10cSrcweir */ 1146cdf0e10cSrcweir void SAL_CALL rtl_uString2String( rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C(); 1147cdf0e10cSrcweir 1148cdf0e10cSrcweir /** 1149cdf0e10cSrcweir Converts a Unicode string to a byte string, signalling failure. 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir @param pTarget 1152cdf0e10cSrcweir An out parameter receiving the converted string. Must not be null itself, and 1153cdf0e10cSrcweir must contain either null or a pointer to a valid rtl_String; the contents are 1154cdf0e10cSrcweir not modified if conversion fails (rtl_convertUStringToString returns false). 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir @param pSource 1157cdf0e10cSrcweir The Unicode string. May only be null if nLength is zero. 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir @param nLength 1160cdf0e10cSrcweir The length of the Unicode string. Must be non-negative. 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir @param nEncoding 1163cdf0e10cSrcweir The text encoding to convert into. Must be an octet encoding (i.e., 1164cdf0e10cSrcweir rtl_isOctetTextEncoding(nEncoding) must return true). 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir @param nFlags 1167cdf0e10cSrcweir A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the conversion 1168cdf0e10cSrcweir (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH need not be 1169cdf0e10cSrcweir included, it is implicitly assumed. Typical uses are either 1170cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | 1171cdf0e10cSrcweir RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot be 1172cdf0e10cSrcweir converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS (make a 1173cdf0e10cSrcweir best efforts conversion). 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir @return 1176cdf0e10cSrcweir True if the conversion succeeded, false otherwise. 1177cdf0e10cSrcweir */ 1178cdf0e10cSrcweir sal_Bool SAL_CALL rtl_convertUStringToString(rtl_String ** pTarget, 1179cdf0e10cSrcweir sal_Unicode const * pSource, 1180cdf0e10cSrcweir sal_Int32 nLength, 1181cdf0e10cSrcweir rtl_TextEncoding nEncoding, 1182cdf0e10cSrcweir sal_uInt32 nFlags) 1183cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir #ifdef __cplusplus 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir #endif 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir #endif /* _RTL_STRING_H_ */ 1190