My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
string.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 _RTL_STRING_H_
21 #define _RTL_STRING_H_
22 
23 #include "sal/config.h"
24 
25 #include "osl/interlck.h"
26 #include "rtl/textcvt.h"
27 #include "sal/saldllapi.h"
28 #include "sal/types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* ======================================================================= */
35 
48 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_getLength(
49  const sal_Char * str ) SAL_THROW_EXTERN_C();
50 
69 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare(
70  const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
71 
97 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare_WithLength(
98  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
99 
130  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
131 
158  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
159 
180  const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
181 
210  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
211 
245  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
246 
259 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
260  const sal_Char * str ) SAL_THROW_EXTERN_C();
261 
277 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
278  const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
279 
294 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar(
295  const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
296 
314  const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
315 
331 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar(
332  const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
333 
352  const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
353 
369 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr(
370  const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
371 
395  const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
396 
412 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr(
413  const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
414 
438  const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
439 
454 SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar(
455  sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
456 
475  sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
476 
487  sal_Char * str ) SAL_THROW_EXTERN_C();
488 
502  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
503 
514  sal_Char * str ) SAL_THROW_EXTERN_C();
515 
529  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
530 
543 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim(
544  sal_Char * str ) SAL_THROW_EXTERN_C();
545 
562 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim_WithLength(
563  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
564 
583 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfBoolean(
584  sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C();
585 #define RTL_STR_MAX_VALUEOFBOOLEAN 6
586 
600 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfChar(
601  sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
602 #define RTL_STR_MAX_VALUEOFCHAR 2
603 
623 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt32(
624  sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
625 #define RTL_STR_MIN_RADIX 2
626 #define RTL_STR_MAX_RADIX 36
627 #define RTL_STR_MAX_VALUEOFINT32 33
628 
648 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt64(
649  sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
650 #define RTL_STR_MAX_VALUEOFINT64 65
651 
667 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfFloat(
668  sal_Char * str, float f ) SAL_THROW_EXTERN_C();
669 #define RTL_STR_MAX_VALUEOFFLOAT 15
670 
686 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfDouble(
687  sal_Char * str, double d ) SAL_THROW_EXTERN_C();
688 #define RTL_STR_MAX_VALUEOFDOUBLE 25
689 
702  const sal_Char * str ) SAL_THROW_EXTERN_C();
703 
720 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
721  const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
722 
739 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_str_toInt64(
740  const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
741 
754 SAL_DLLPUBLIC float SAL_CALL rtl_str_toFloat(
755  const sal_Char * str ) SAL_THROW_EXTERN_C();
756 
769 SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble(
770  const sal_Char * str ) SAL_THROW_EXTERN_C();
771 
772 /* ======================================================================= */
773 
774 #ifdef SAL_W32
775 # pragma pack(push, 8)
776 #endif
777 
781 typedef struct _rtl_String
782 {
783  oslInterlockedCount refCount; /* opaque */
784  sal_Int32 length;
785  sal_Char buffer[1];
786 } rtl_String;
789 #if defined(SAL_W32)
790 #pragma pack(pop)
791 #endif
792 
793 /* ----------------------------------------------------------------------- */
794 
800 SAL_DLLPUBLIC void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C();
801 
809 SAL_DLLPUBLIC void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C();
810 
817 SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C();
818 
832 SAL_DLLPUBLIC void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C();
833 
847 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C();
848 
862 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
863 
881 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
882 
897  rtl_String ** newStr, const rtl_String * from,
898  sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
899 
904 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromLiteral( rtl_String ** newStr, const sal_Char * value, sal_Int32 len, sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
905 
918 SAL_DLLPUBLIC void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C();
919 
930 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C();
931 
940 SAL_DLLPUBLIC sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C();
941 
959 SAL_DLLPUBLIC void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C();
960 
991  rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C();
992 
1017 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplace(
1018  rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
1019 
1048  rtl_String ** newStr, rtl_String * str, char const * from,
1049  sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1050  sal_Int32 * index) SAL_THROW_EXTERN_C();
1051 
1076  rtl_String ** newStr, rtl_String * str, char const * from,
1077  sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1079 
1100  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1101 
1122  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1123 
1143 SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
1144  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1145 
1190 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
1191  rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
1192 
1193 /* ======================================================================= */
1194 
1209 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
1210 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
1211 // This is to avoid mistaken use with functions that accept string literals
1212 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
1213 // the argument and a following int argument with a default value (e.g. OString::match()).
1214 #define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
1215  ((sal_Int32)SAL_N_ELEMENTS(constAsciiStr)-1)
1216 
1230 #define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1))
1231 
1232 /* ======================================================================= */
1233 
1234 /* predefined constants for String-Conversion */
1235 #define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
1236  RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
1237  RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
1238  RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\
1239  RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
1240 
1241 /* ----------------------------------------------------------------------- */
1242 
1275 SAL_DLLPUBLIC void SAL_CALL rtl_uString2String(
1276  rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
1277 
1309  rtl_String ** pTarget,
1310  sal_Unicode const * pSource,
1311  sal_Int32 nLength,
1312  rtl_TextEncoding nEncoding,
1313  sal_uInt32 nFlags)
1315 
1316 #ifdef __cplusplus
1317 }
1318 #endif
1319 
1320 #endif /* _RTL_STRING_H_ */
1321 
1322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */