LibreOffice
LibreOffice 5.0 SDK 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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_USTRING_H
21 #define INCLUDED_RTL_USTRING_H
22 
23 #include <sal/config.h>
24 
25 #include <osl/interlck.h>
26 #include <rtl/string.h>
27 #include <rtl/textenc.h>
28 #include <sal/saldllapi.h>
29 #include <sal/types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* ======================================================================= */
36 
49 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
50  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
51 
70 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
71  const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
72 
99  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
100 
131  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
132 
159  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
160 
183  const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
184 
205  const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
206 
235  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
236 
270  const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
271 
295 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
296  const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
297 
325  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
326 
358  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
359 
390  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
391 
417  const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
418 
448  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
449 
482  sal_Unicode const * first, sal_Int32 firstLen,
483  char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
484 
519  const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
520 
533 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
534  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
535 
552  const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
553 
568 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
569  const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
570 
588  const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
589 
605 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
606  const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
607 
626  const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
627 
643 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
644  const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
645 
669  const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
670 
696  sal_Unicode const * str, sal_Int32 len,
697  char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
698 
714 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
715  const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
716 
740  const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
741 
767  sal_Unicode const * str, sal_Int32 len,
768  char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
769 
784 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
785  sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
786 
805  sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
806 
818 
832  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
833 
845 
859  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
860 
873 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
875 
892 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
893  sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
894 
913 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
915 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
916 
930 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
932 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
933 
953 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
954  sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
955 #define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
956 #define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
957 #define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
958 
978 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
979  sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
980 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
981 
1001 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfUInt64(
1002  sal_Unicode * str, sal_uInt64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1003 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
1004 
1020 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
1021  sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
1022 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
1023 
1039 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
1040  sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
1041 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
1042 
1055  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1056 
1073 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
1074  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1075 
1094 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_ustr_toUInt32(
1095  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1096 
1113 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
1114  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1115 
1134 SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_toUInt64(
1135  const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1136 
1149 SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
1150  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1151 
1164 SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
1165  const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1166 
1167 /* ======================================================================= */
1168 
1169 #if defined(SAL_W32)
1170 #pragma pack(push, 4)
1171 #endif
1172 
1176 typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
1177 {
1178  oslInterlockedCount refCount; /* opaque */
1179  sal_Int32 length;
1180  sal_Unicode buffer[1];
1181 } rtl_uString;
1184 #if defined(SAL_W32)
1185 #pragma pack(pop)
1186 #endif
1187 
1188 /* ----------------------------------------------------------------------- */
1189 
1195 SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
1196  rtl_uString * str ) SAL_THROW_EXTERN_C();
1197 
1205 SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
1206  rtl_uString * str ) SAL_THROW_EXTERN_C();
1207 
1214 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
1215  rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
1216 
1238 SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
1239 
1254  rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
1255 
1270  rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
1271 
1286  rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
1287 
1306  rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
1307 
1324  rtl_uString ** newStr, const rtl_uString * from,
1325  sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
1326 
1345  rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
1346 
1352  rtl_uString ** newStr, const sal_Char * value, sal_Int32 len,
1353  sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
1354 
1375  rtl_uString ** newString, sal_uInt32 const * codePoints,
1376  sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
1377 
1390 SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
1391  rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
1392 
1403 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
1404  const rtl_uString * str ) SAL_THROW_EXTERN_C();
1405 
1415  rtl_uString * str ) SAL_THROW_EXTERN_C();
1416 
1434 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
1435  rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
1436 
1467  rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
1468 
1494  rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
1495 
1518  rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1519  rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
1520 
1546  rtl_uString ** newStr, rtl_uString * str, char const * from,
1547  sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
1549 
1578  rtl_uString ** newStr, rtl_uString * str, char const * from,
1579  sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1580  sal_Int32 * index) SAL_THROW_EXTERN_C();
1581 
1600  rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1601  rtl_uString const * to) SAL_THROW_EXTERN_C();
1602 
1623  rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1624  rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C();
1625 
1647  rtl_uString ** newStr, rtl_uString * str, char const * from,
1648  sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
1649 
1674  rtl_uString ** newStr, rtl_uString * str, char const * from,
1675  sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1677 
1698  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1699 
1720  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1721 
1741 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
1742  rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1743 
1788 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
1789  rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
1790 
1791 /* ======================================================================= */
1792 
1806 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
1807 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
1808 // This is to avoid mistaken use with functions that accept string literals
1809 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
1810 // the argument and a following int argument with a default value (e.g. OUString::match()).
1811 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
1812  ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
1813 
1814 /* ======================================================================= */
1815 
1816 /* predefined constants for String-Conversion */
1817 #define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
1818  RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
1819  RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
1820 
1821 /* ----------------------------------------------------------------------- */
1822 
1855 SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
1856  rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
1857 
1858 /* ======================================================================= */
1859 /* Interning methods */
1860 
1880 SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
1881  rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
1882 
1919  rtl_uString ** newStr,
1920  const sal_Char * str,
1921  sal_Int32 len,
1922  rtl_TextEncoding encoding,
1923  sal_uInt32 convertFlags,
1924  sal_uInt32 *pInfo) SAL_THROW_EXTERN_C();
1925 
1978 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
1979  rtl_uString const * string, sal_Int32 * indexUtf16,
1980  sal_Int32 incrementCodePoints);
1981 
2016  rtl_uString ** target, char const * source, sal_Int32 length,
2017  rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
2018 
2035 SAL_DLLPUBLIC void SAL_CALL rtl_uString_ensureCapacity( rtl_uString ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
2036 
2037 #ifdef __cplusplus
2038 }
2039 #endif
2040 
2041 #endif // INCLUDED_RTL_USTRING_H
2042 
2043 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */