UDK 3.2.7 C/C++ API Reference

rtl/ustring.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 
00020 #ifndef _RTL_USTRING_H_
00021 #define _RTL_USTRING_H_
00022 
00023 #include "sal/config.h"
00024 
00025 #include "osl/interlck.h"
00026 #include "rtl/string.h"
00027 #include "rtl/textenc.h"
00028 #include "sal/saldllapi.h"
00029 #include "sal/types.h"
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 /* ======================================================================= */
00036 
00049 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
00050         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
00051 
00070 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
00071         const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
00072 
00098 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare_WithLength(
00099         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00100 
00130 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength(
00131         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00132 
00158 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength(
00159         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00160 
00182 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength(
00183         const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
00184 
00204 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase(
00205         const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
00206 
00234 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength(
00235         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00236 
00269 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
00270         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00271 
00295 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
00296         const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00297 
00324 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength(
00325         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
00326 
00357 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength(
00358         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00359 
00389 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength(
00390         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00391 
00416 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase(
00417         const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00418 
00447 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
00448         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
00449 
00481 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
00482     sal_Unicode const * first, sal_Int32 firstLen,
00483     char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
00484 
00518 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
00519         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00520 
00533 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
00534         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
00535 
00551 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
00552         const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00553 
00568 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
00569         const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00570 
00587 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength(
00588         const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00589 
00605 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
00606         const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00607 
00625 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength(
00626         const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00627 
00643 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
00644         const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
00645 
00668 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength(
00669         const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00670 
00695 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
00696     sal_Unicode const * str, sal_Int32 len,
00697     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
00698 
00714 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
00715         const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
00716 
00739 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength(
00740         const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00741 
00766 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
00767     sal_Unicode const * str, sal_Int32 len,
00768     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
00769 
00784 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
00785         sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
00786 
00804 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar_WithLength(
00805         sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
00806 
00816 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase(
00817         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00818 
00831 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength(
00832         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00833 
00843 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase(
00844         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00845 
00858 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength(
00859         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00860 
00873 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
00874         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00875 
00892 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
00893         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00894 
00913 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
00914         sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
00915 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
00916 
00930 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
00931         sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00932 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
00933 
00953 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
00954         sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00955 #define RTL_USTR_MIN_RADIX          RTL_STR_MIN_RADIX
00956 #define RTL_USTR_MAX_RADIX          RTL_STR_MAX_RADIX
00957 #define RTL_USTR_MAX_VALUEOFINT32   RTL_STR_MAX_VALUEOFINT32
00958 
00978 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
00979         sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00980 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
00981 
00997 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
00998         sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
00999 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
01000 
01016 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
01017         sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
01018 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
01019 
01031 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_toBoolean(
01032         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01033 
01050 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
01051         const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
01052 
01069 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
01070         const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
01071 
01084 SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
01085         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01086 
01099 SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
01100         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01101 
01102 /* ======================================================================= */
01103 
01104 #if defined(SAL_W32)
01105 #pragma pack(push, 4)
01106 #endif
01107 
01111 typedef struct _rtl_uString
01112 {
01113     oslInterlockedCount refCount; /* opaque */
01114     sal_Int32           length;
01115     sal_Unicode         buffer[1];
01116 } rtl_uString;
01119 #if defined(SAL_W32)
01120 #pragma pack(pop)
01121 #endif
01122 
01123 /* ----------------------------------------------------------------------- */
01124 
01130 SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
01131         rtl_uString * str ) SAL_THROW_EXTERN_C();
01132 
01140 SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
01141         rtl_uString * str ) SAL_THROW_EXTERN_C();
01142 
01149 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
01150         rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
01151 
01165 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new_WithLength(
01166         rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
01167 
01181 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromString(
01182         rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
01183 
01197 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr(
01198         rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
01199 
01217 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr_WithLength(
01218         rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
01219 
01233 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromSubString(
01234         rtl_uString ** newStr, const rtl_uString * from,
01235         sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
01236 
01254 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii(
01255         rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
01256 
01261 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromLiteral(
01262         rtl_uString ** newStr, const sal_Char * value, sal_Int32 len,
01263         sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
01264 
01284 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromCodePoints(
01285     rtl_uString ** newString, sal_uInt32 const * codePoints,
01286     sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
01287 
01300 SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
01301         rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
01302 
01313 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
01314         const rtl_uString * str ) SAL_THROW_EXTERN_C();
01315 
01324 SAL_DLLPUBLIC sal_Unicode * SAL_CALL rtl_uString_getStr(
01325         rtl_uString * str ) SAL_THROW_EXTERN_C();
01326 
01344 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
01345         rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
01346 
01376 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceStrAt(
01377         rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
01378 
01403 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplace(
01404         rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
01405 
01427 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirst(
01428     rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
01429     rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
01430 
01455 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiL(
01456     rtl_uString ** newStr, rtl_uString * str, char const * from,
01457     sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
01458     SAL_THROW_EXTERN_C();
01459 
01487 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiLAsciiL(
01488     rtl_uString ** newStr, rtl_uString * str, char const * from,
01489     sal_Int32 fromLength, char const * to, sal_Int32 toLength,
01490     sal_Int32 * index) SAL_THROW_EXTERN_C();
01491 
01509 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAll(
01510     rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
01511     rtl_uString const * to) SAL_THROW_EXTERN_C();
01512 
01532 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllFromIndex(
01533     rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
01534     rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C();
01535 
01556 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiL(
01557     rtl_uString ** newStr, rtl_uString * str, char const * from,
01558     sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
01559 
01583 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiLAsciiL(
01584     rtl_uString ** newStr, rtl_uString * str, char const * from,
01585     sal_Int32 fromLength, char const * to, sal_Int32 toLength)
01586     SAL_THROW_EXTERN_C();
01587 
01607 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiLowerCase(
01608         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01609 
01629 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiUpperCase(
01630         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01631 
01651 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
01652         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01653 
01698 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
01699         rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
01700 
01701 /* ======================================================================= */
01702 
01716 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
01717 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
01718 // This is to avoid mistaken use with functions that accept string literals
01719 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
01720 // the argument and a following int argument with a default value (e.g. OUString::match()).
01721 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
01722     ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
01723 
01724 /* ======================================================================= */
01725 
01726 /* predefined constants for String-Conversion */
01727 #define OSTRING_TO_OUSTRING_CVTFLAGS    (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
01728                                          RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
01729                                          RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
01730 
01731 /* ----------------------------------------------------------------------- */
01732 
01765 SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
01766         rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
01767 
01768 /* ======================================================================= */
01769 /* Interning methods */
01770 
01790 SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
01791         rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
01792 
01828 SAL_DLLPUBLIC void SAL_CALL rtl_uString_internConvert(
01829                                          rtl_uString   ** newStr,
01830                                          const sal_Char * str,
01831                                          sal_Int32        len,
01832                                          rtl_TextEncoding encoding,
01833                                          sal_uInt32       convertFlags,
01834                                          sal_uInt32      *pInfo) SAL_THROW_EXTERN_C();
01835 
01888 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
01889     rtl_uString const * string, sal_Int32 * indexUtf16,
01890     sal_Int32 incrementCodePoints);
01891 
01925 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertStringToUString(
01926     rtl_uString ** target, char const * source, sal_Int32 length,
01927     rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
01928 
01929 #ifdef __cplusplus
01930 }
01931 #endif
01932 
01933 #endif /* _RTL_USTRING_H_ */
01934 
01935 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines