My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ustring.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef _RTL_USTRING_H_
30 #define _RTL_USTRING_H_
31 
32 #include <sal/types.h>
33 #include <osl/interlck.h>
34 #include <rtl/string.h>
35 #include <rtl/textenc.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* ======================================================================= */
42 
55 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
56  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
57 
76 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
77  const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
78 
104 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare_WithLength(
105  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
106 
137  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
138 
165  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
166 
189  const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
190 
211  const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
212 
241  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
242 
276  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
277 
301 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
302  const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
303 
331  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
332 
364  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
365 
396  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
397 
423  const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
424 
454  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
455 
488  sal_Unicode const * first, sal_Int32 firstLen,
489  char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
490 
525  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
526 
539 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
540  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
541 
558  const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
559 
574 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
575  const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
576 
594  const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
595 
611 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
612  const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
613 
632  const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
633 
649 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
650  const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
651 
675  const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
676 
702  sal_Unicode const * str, sal_Int32 len,
703  char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
704 
720 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
721  const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
722 
746  const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
747 
773  sal_Unicode const * str, sal_Int32 len,
774  char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
775 
790 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
791  sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
792 
811  sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
812 
824 
838  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
839 
851 
865  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
866 
879 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
881 
898 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
899  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
900 
919 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
921 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
922 
936 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
938 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
939 
959 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
960  sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
961 #define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
962 #define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
963 #define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
964 
984 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
985  sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
986 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
987 
1003 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
1004  sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
1005 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
1006 
1022 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
1023  sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
1024 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
1025 
1038  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1039 
1056 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
1057  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1058 
1075 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
1076  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1077 
1090 SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
1091  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1092 
1105 SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
1106  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1107 
1108 /* ======================================================================= */
1109 
1110 #if defined(SAL_W32)
1111 #pragma pack(push, 4)
1112 #endif
1113 
1117 typedef struct _rtl_uString
1118 {
1119  oslInterlockedCount refCount; /* opaque */
1120  sal_Int32 length;
1121  sal_Unicode buffer[1];
1122 } rtl_uString;
1125 #if defined(SAL_W32)
1126 #pragma pack(pop)
1127 #endif
1128 
1129 /* ----------------------------------------------------------------------- */
1130 
1136 SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
1137  rtl_uString * str ) SAL_THROW_EXTERN_C();
1138 
1146 SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
1147  rtl_uString * str ) SAL_THROW_EXTERN_C();
1148 
1155 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
1156  rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
1157 
1172  rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
1173 
1188  rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
1189 
1204  rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
1205 
1224  rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
1225 
1244  rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
1245 
1251  rtl_uString ** newStr, const sal_Char * value, sal_Int32 len,
1252  sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
1253 
1274  rtl_uString ** newString, sal_uInt32 const * codePoints,
1275  sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
1276 
1289 SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
1290  rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
1291 
1302 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
1303  const rtl_uString * str ) SAL_THROW_EXTERN_C();
1304 
1314  rtl_uString * str ) SAL_THROW_EXTERN_C();
1315 
1333 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
1334  rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
1335 
1366  rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
1367 
1393  rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
1394 
1417  rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1418  rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
1419 
1445  rtl_uString ** newStr, rtl_uString * str, char const * from,
1446  sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
1448 
1477  rtl_uString ** newStr, rtl_uString * str, char const * from,
1478  sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1479  sal_Int32 * index) SAL_THROW_EXTERN_C();
1480 
1499  rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1500  rtl_uString const * to) SAL_THROW_EXTERN_C();
1501 
1523  rtl_uString ** newStr, rtl_uString * str, char const * from,
1524  sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
1525 
1550  rtl_uString ** newStr, rtl_uString * str, char const * from,
1551  sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1553 
1574  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1575 
1596  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1597 
1617 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
1618  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1619 
1664 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
1665  rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
1666 
1667 /* ======================================================================= */
1668 
1682 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
1683 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
1684 // This is to avoid mistaken use with functions that accept string literals
1685 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
1686 // the argument and a following int argument with a default value (e.g. OUString::match()).
1687 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
1688  ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
1689 
1690 /* ======================================================================= */
1691 
1692 /* predefined constants for String-Conversion */
1693 #define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
1694  RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
1695  RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
1696 
1697 /* ----------------------------------------------------------------------- */
1698 
1731 SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
1732  rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
1733 
1734 /* ======================================================================= */
1735 /* Interning methods */
1736 
1756 SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
1757  rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
1758 
1795  rtl_uString ** newStr,
1796  const sal_Char * str,
1797  sal_Int32 len,
1798  rtl_TextEncoding encoding,
1799  sal_uInt32 convertFlags,
1800  sal_uInt32 *pInfo) SAL_THROW_EXTERN_C();
1801 
1854 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
1855  rtl_uString const * string, sal_Int32 * indexUtf16,
1856  sal_Int32 incrementCodePoints);
1857 
1892  rtl_uString ** target, char const * source, sal_Int32 length,
1893  rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
1894 
1895 #ifdef __cplusplus
1896 }
1897 #endif
1898 
1899 #endif /* _RTL_USTRING_H_ */
1900 
1901 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */