110ce8018SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
310ce8018SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
410ce8018SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
510ce8018SAndrew Rist  * distributed with this work for additional information
610ce8018SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
710ce8018SAndrew Rist  * to you under the Apache License, Version 2.0 (the
810ce8018SAndrew Rist  * "License"); you may not use this file except in compliance
910ce8018SAndrew Rist  * with the License.  You may obtain a copy of the License at
1010ce8018SAndrew Rist  *
1110ce8018SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1210ce8018SAndrew Rist  *
1310ce8018SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1410ce8018SAndrew Rist  * software distributed under the License is distributed on an
1510ce8018SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1610ce8018SAndrew Rist  * KIND, either express or implied.  See the License for the
1710ce8018SAndrew Rist  * specific language governing permissions and limitations
1810ce8018SAndrew Rist  * under the License.
1910ce8018SAndrew Rist  *
2010ce8018SAndrew Rist  *************************************************************/
2110ce8018SAndrew Rist 
2210ce8018SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CFSTRINGUTILITIES_HXX_
25cdf0e10cSrcweir #define _CFSTRINGUTILITIES_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <premac.h>
28cdf0e10cSrcweir #include <Carbon/Carbon.h>
29cdf0e10cSrcweir #include <Cocoa/Cocoa.h>
30cdf0e10cSrcweir #include <postmac.h>
31cdf0e10cSrcweir #include <rtl/ustring.hxx>
32cdf0e10cSrcweir #include <sal/types.h>
33cdf0e10cSrcweir #include <osl/diagnose.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir enum InfoType {
36cdf0e10cSrcweir     FULLPATH,
37cdf0e10cSrcweir     FILENAME,
38cdf0e10cSrcweir     PATHWITHOUTLASTCOMPONENT
39cdf0e10cSrcweir };
40cdf0e10cSrcweir 
41cdf0e10cSrcweir rtl::OUString CFStringToOUString(const CFStringRef sOrig);
42cdf0e10cSrcweir rtl::OUString FSRefToOUString(FSRef fsRef, InfoType info = FULLPATH);
43cdf0e10cSrcweir rtl::OUString CFURLRefToOUString(CFURLRef aUrlRef, InfoType info);
44cdf0e10cSrcweir CFStringRef CFStringCreateWithOUString(const rtl::OUString& aString);
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //debug utils
47cdf0e10cSrcweir #define PARAMFILLER "\n                    "
48cdf0e10cSrcweir 
DBG_PRINT_ENTRY()49cdf0e10cSrcweir inline void DBG_PRINT_ENTRY() {
50cdf0e10cSrcweir     OSL_TRACE(">>> %s", __func__);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname)53cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname) {
54cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s", classname, methodname);
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1)57cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1) {
58cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s", classname, methodname, PARAMFILLER, param1, value1);
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1)61cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const rtl::OUString& value1) {
62cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s", classname, methodname, PARAMFILLER, param1, OUStringToOString(value1, RTL_TEXTENCODING_UTF8).getStr());
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const CFStringRef value1)65cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const CFStringRef value1) {
66cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s =", classname, methodname, PARAMFILLER, param1);
67cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
68cdf0e10cSrcweir     CFShow(value1);
69cdf0e10cSrcweir #endif
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const NSString * value1)72cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const NSString* value1) {
73cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s =", classname, methodname, PARAMFILLER, param1);
74cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
75*22d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(value1));
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1)79cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1) {
80cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d", classname, methodname, PARAMFILLER, param1, value1);
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1,const char * param2,const int value2)83cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1, const char* param2, const int value2) {
84cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1,const char * param2,const char * value2)87cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1, const char* param2, const char* value2) {
88cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %s", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const int value2)91cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const int value2) {
92cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %d", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const char * value2)95cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const char* value2) {
96cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %s", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const CFStringRef value2)99cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const CFStringRef value2) {
100cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
101cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
102cdf0e10cSrcweir     CFShow(value2);
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const NSString * value2)106cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const NSString* value2) {
107cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
108cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
109*22d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(value2));
110cdf0e10cSrcweir #endif
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1,const char * param2,const rtl::OUString & value2)113cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const rtl::OUString& value1, const char* param2, const rtl::OUString& value2) {
114cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %s", classname, methodname, PARAMFILLER, param1, OUStringToOString(value1, RTL_TEXTENCODING_UTF8).getStr(), PARAMFILLER, param2, OUStringToOString(value2, RTL_TEXTENCODING_UTF8).getStr());
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1,const char * param2,const int value2)117cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const rtl::OUString& value1, const char* param2, const int value2) {
118cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname, methodname, PARAMFILLER, param1, OUStringToOString(value1, RTL_TEXTENCODING_UTF8).getStr(), PARAMFILLER, param2, value2);
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir //exit method debugs
122cdf0e10cSrcweir 
DBG_PRINT_EXIT()123cdf0e10cSrcweir inline void DBG_PRINT_EXIT() {
124cdf0e10cSrcweir     OSL_TRACE("<<< %s", __func__);
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname)127cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname) {
128cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s", classname, methodname);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const char * retVal)131cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const char* retVal) {
132cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname, methodname, PARAMFILLER, retVal);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,int retVal)135cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, int retVal) {
136cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %d", classname, methodname, PARAMFILLER, retVal);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const CFStringRef retVal)139cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const CFStringRef retVal) {
140cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = ", classname, methodname, PARAMFILLER);
141cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
142cdf0e10cSrcweir     CFShow(retVal);
143cdf0e10cSrcweir #endif
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const NSString * retVal)146cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const NSString* retVal) {
147cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = ", classname, methodname, PARAMFILLER);
148cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
149*22d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(retVal));
150cdf0e10cSrcweir #endif
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const rtl::OUString & retVal)153cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const rtl::OUString& retVal) {
154cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname, methodname, PARAMFILLER, OUStringToOString(retVal, RTL_TEXTENCODING_UTF8).getStr());
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir #endif //_CFSTRINGUTILITIES_HXX_
158