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  *
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_STRING_H_
30 #define _RTL_STRING_H_
31 
32 #include <sal/types.h>
33 #include <osl/interlck.h>
34 #include <rtl/textcvt.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* ======================================================================= */
41 
54 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_getLength(
55  const sal_Char * str ) SAL_THROW_EXTERN_C();
56 
75 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare(
76  const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
77 
103 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_compare_WithLength(
104  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
105 
136  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
137 
164  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
165 
186  const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
187 
216  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
217 
251  const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
252 
265 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
266  const sal_Char * str ) SAL_THROW_EXTERN_C();
267 
283 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
284  const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
285 
300 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfChar(
301  const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
302 
320  const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
321 
337 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfChar(
338  const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
339 
358  const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
359 
375 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_indexOfStr(
376  const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
377 
401  const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
402 
418 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_lastIndexOfStr(
419  const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
420 
444  const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
445 
460 SAL_DLLPUBLIC void SAL_CALL rtl_str_replaceChar(
461  sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
462 
481  sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
482 
493  sal_Char * str ) SAL_THROW_EXTERN_C();
494 
508  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
509 
520  sal_Char * str ) SAL_THROW_EXTERN_C();
521 
535  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
536 
549 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim(
550  sal_Char * str ) SAL_THROW_EXTERN_C();
551 
568 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_trim_WithLength(
569  sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
570 
589 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfBoolean(
590  sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C();
591 #define RTL_STR_MAX_VALUEOFBOOLEAN 6
592 
606 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfChar(
607  sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
608 #define RTL_STR_MAX_VALUEOFCHAR 2
609 
629 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt32(
630  sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
631 #define RTL_STR_MIN_RADIX 2
632 #define RTL_STR_MAX_RADIX 36
633 #define RTL_STR_MAX_VALUEOFINT32 33
634 
654 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfInt64(
655  sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
656 #define RTL_STR_MAX_VALUEOFINT64 65
657 
673 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfFloat(
674  sal_Char * str, float f ) SAL_THROW_EXTERN_C();
675 #define RTL_STR_MAX_VALUEOFFLOAT 15
676 
692 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_valueOfDouble(
693  sal_Char * str, double d ) SAL_THROW_EXTERN_C();
694 #define RTL_STR_MAX_VALUEOFDOUBLE 25
695 
708  const sal_Char * str ) SAL_THROW_EXTERN_C();
709 
726 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
727  const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
728 
745 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_str_toInt64(
746  const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
747 
760 SAL_DLLPUBLIC float SAL_CALL rtl_str_toFloat(
761  const sal_Char * str ) SAL_THROW_EXTERN_C();
762 
775 SAL_DLLPUBLIC double SAL_CALL rtl_str_toDouble(
776  const sal_Char * str ) SAL_THROW_EXTERN_C();
777 
778 /* ======================================================================= */
779 
780 #ifdef SAL_W32
781 # pragma pack(push, 8)
782 #endif
783 
787 typedef struct _rtl_String
788 {
789  oslInterlockedCount refCount; /* opaque */
790  sal_Int32 length;
791  sal_Char buffer[1];
792 } rtl_String;
795 #if defined(SAL_W32)
796 #pragma pack(pop)
797 #endif
798 
799 /* ----------------------------------------------------------------------- */
800 
806 SAL_DLLPUBLIC void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C();
807 
815 SAL_DLLPUBLIC void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C();
816 
823 SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C();
824 
838 SAL_DLLPUBLIC void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C();
839 
853 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C();
854 
868 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
869 
887 SAL_DLLPUBLIC void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
888 
893 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();
894 
907 SAL_DLLPUBLIC void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C();
908 
919 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C();
920 
929 SAL_DLLPUBLIC sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C();
930 
948 SAL_DLLPUBLIC void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C();
949 
980  rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C();
981 
1006 SAL_DLLPUBLIC void SAL_CALL rtl_string_newReplace(
1007  rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
1008 
1037  rtl_String ** newStr, rtl_String * str, char const * from,
1038  sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1039  sal_Int32 * index) SAL_THROW_EXTERN_C();
1040 
1065  rtl_String ** newStr, rtl_String * str, char const * from,
1066  sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1068 
1089  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1090 
1111  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1112 
1132 SAL_DLLPUBLIC void SAL_CALL rtl_string_newTrim(
1133  rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
1134 
1179 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_string_getToken(
1180  rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
1181 
1182 /* ======================================================================= */
1183 
1198 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
1199 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
1200 // This is to avoid mistaken use with functions that accept string literals
1201 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
1202 // the argument and a following int argument with a default value (e.g. OString::match()).
1203 #define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
1204  ((sal_Int32)SAL_N_ELEMENTS(constAsciiStr)-1)
1205 
1219 #define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1))
1220 
1221 /* ======================================================================= */
1222 
1223 /* predefined constants for String-Conversion */
1224 #define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
1225  RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
1226  RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
1227  RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\
1228  RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
1229 
1230 /* ----------------------------------------------------------------------- */
1231 
1264 SAL_DLLPUBLIC void SAL_CALL rtl_uString2String(
1265  rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
1266 
1298  rtl_String ** pTarget,
1299  sal_Unicode const * pSource,
1300  sal_Int32 nLength,
1301  rtl_TextEncoding nEncoding,
1302  sal_uInt32 nFlags)
1304 
1305 #ifdef __cplusplus
1306 }
1307 #endif
1308 
1309 #endif /* _RTL_STRING_H_ */
1310 
1311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */