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  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 
00029 #ifndef _RTL_USTRING_H_
00030 #define _RTL_USTRING_H_
00031 
00032 #include <sal/types.h>
00033 #include <osl/interlck.h>
00034 #include <rtl/string.h>
00035 #include <rtl/textenc.h>
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 /* ======================================================================= */
00042 
00055 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
00056         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
00057 
00076 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
00077         const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
00078 
00104 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare_WithLength(
00105         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00106 
00136 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength(
00137         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00138 
00164 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength(
00165         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00166 
00188 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength(
00189         const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
00190 
00210 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase(
00211         const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
00212 
00240 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength(
00241         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00242 
00275 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
00276         const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00277 
00301 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
00302         const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00303 
00330 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength(
00331         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
00332 
00363 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength(
00364         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00365 
00395 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength(
00396         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
00397 
00422 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase(
00423         const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
00424 
00453 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
00454         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
00455 
00487 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
00488     sal_Unicode const * first, sal_Int32 firstLen,
00489     char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
00490 
00524 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
00525         const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
00526 
00539 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
00540         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
00541 
00557 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
00558         const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00559 
00574 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
00575         const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00576 
00593 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength(
00594         const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00595 
00611 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
00612         const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00613 
00631 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength(
00632         const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00633 
00649 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
00650         const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
00651 
00674 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength(
00675         const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00676 
00701 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
00702     sal_Unicode const * str, sal_Int32 len,
00703     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
00704 
00720 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
00721         const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
00722 
00745 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength(
00746         const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
00747 
00772 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
00773     sal_Unicode const * str, sal_Int32 len,
00774     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
00775 
00790 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
00791         sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
00792 
00810 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar_WithLength(
00811         sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
00812 
00822 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase(
00823         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00824 
00837 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength(
00838         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00839 
00849 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase(
00850         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00851 
00864 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength(
00865         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00866 
00879 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
00880         sal_Unicode * str ) SAL_THROW_EXTERN_C();
00881 
00898 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
00899         sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
00900 
00919 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
00920         sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
00921 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
00922 
00936 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
00937         sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
00938 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
00939 
00959 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
00960         sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00961 #define RTL_USTR_MIN_RADIX          RTL_STR_MIN_RADIX
00962 #define RTL_USTR_MAX_RADIX          RTL_STR_MAX_RADIX
00963 #define RTL_USTR_MAX_VALUEOFINT32   RTL_STR_MAX_VALUEOFINT32
00964 
00984 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
00985         sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
00986 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
00987 
01003 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
01004         sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
01005 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
01006 
01022 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
01023         sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
01024 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
01025 
01037 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_toBoolean(
01038         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01039 
01056 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
01057         const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
01058 
01075 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
01076         const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
01077 
01090 SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
01091         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01092 
01105 SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
01106         const sal_Unicode * str ) SAL_THROW_EXTERN_C();
01107 
01108 /* ======================================================================= */
01109 
01110 #if defined(SAL_W32)
01111 #pragma pack(push, 4)
01112 #endif
01113 
01117 typedef struct _rtl_uString
01118 {
01119     oslInterlockedCount refCount; /* opaque */
01120     sal_Int32           length;
01121     sal_Unicode         buffer[1];
01122 } rtl_uString;
01125 #if defined(SAL_W32)
01126 #pragma pack(pop)
01127 #endif
01128 
01129 /* ----------------------------------------------------------------------- */
01130 
01136 SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
01137         rtl_uString * str ) SAL_THROW_EXTERN_C();
01138 
01146 SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
01147         rtl_uString * str ) SAL_THROW_EXTERN_C();
01148 
01155 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
01156         rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
01157 
01171 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new_WithLength(
01172         rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
01173 
01187 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromString(
01188         rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
01189 
01203 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr(
01204         rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
01205 
01223 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr_WithLength(
01224         rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
01225 
01243 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii(
01244         rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
01245 
01250 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromLiteral(
01251         rtl_uString ** newStr, const sal_Char * value, sal_Int32 len,
01252         sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
01253 
01273 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromCodePoints(
01274     rtl_uString ** newString, sal_uInt32 const * codePoints,
01275     sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
01276 
01289 SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
01290         rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
01291 
01302 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
01303         const rtl_uString * str ) SAL_THROW_EXTERN_C();
01304 
01313 SAL_DLLPUBLIC sal_Unicode * SAL_CALL rtl_uString_getStr(
01314         rtl_uString * str ) SAL_THROW_EXTERN_C();
01315 
01333 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
01334         rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
01335 
01365 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceStrAt(
01366         rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
01367 
01392 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplace(
01393         rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
01394 
01416 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirst(
01417     rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
01418     rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
01419 
01444 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiL(
01445     rtl_uString ** newStr, rtl_uString * str, char const * from,
01446     sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
01447     SAL_THROW_EXTERN_C();
01448 
01476 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiLAsciiL(
01477     rtl_uString ** newStr, rtl_uString * str, char const * from,
01478     sal_Int32 fromLength, char const * to, sal_Int32 toLength,
01479     sal_Int32 * index) SAL_THROW_EXTERN_C();
01480 
01498 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAll(
01499     rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
01500     rtl_uString const * to) SAL_THROW_EXTERN_C();
01501 
01522 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiL(
01523     rtl_uString ** newStr, rtl_uString * str, char const * from,
01524     sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
01525 
01549 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiLAsciiL(
01550     rtl_uString ** newStr, rtl_uString * str, char const * from,
01551     sal_Int32 fromLength, char const * to, sal_Int32 toLength)
01552     SAL_THROW_EXTERN_C();
01553 
01573 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiLowerCase(
01574         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01575 
01595 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiUpperCase(
01596         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01597 
01617 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
01618         rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
01619 
01664 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
01665         rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
01666 
01667 /* ======================================================================= */
01668 
01682 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
01683 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
01684 // This is to avoid mistaken use with functions that accept string literals
01685 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
01686 // the argument and a following int argument with a default value (e.g. OUString::match()).
01687 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
01688     ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
01689 
01690 /* ======================================================================= */
01691 
01692 /* predefined constants for String-Conversion */
01693 #define OSTRING_TO_OUSTRING_CVTFLAGS    (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
01694                                          RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
01695                                          RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
01696 
01697 /* ----------------------------------------------------------------------- */
01698 
01731 SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
01732         rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
01733 
01734 /* ======================================================================= */
01735 /* Interning methods */
01736 
01756 SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
01757         rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
01758 
01794 SAL_DLLPUBLIC void SAL_CALL rtl_uString_internConvert(
01795                                          rtl_uString   ** newStr,
01796                                          const sal_Char * str,
01797                                          sal_Int32        len,
01798                                          rtl_TextEncoding encoding,
01799                                          sal_uInt32       convertFlags,
01800                                          sal_uInt32      *pInfo) SAL_THROW_EXTERN_C();
01801 
01854 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
01855     rtl_uString const * string, sal_Int32 * indexUtf16,
01856     sal_Int32 incrementCodePoints);
01857 
01891 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertStringToUString(
01892     rtl_uString ** target, char const * source, sal_Int32 length,
01893     rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
01894 
01895 #ifdef __cplusplus
01896 }
01897 #endif
01898 
01899 #endif /* _RTL_USTRING_H_ */
01900 
01901 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines