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>
30*e8959efdSJim Jagielski #include <CoreFoundation/CoreFoundation.h>
31cdf0e10cSrcweir #include <postmac.h>
32cdf0e10cSrcweir #include <rtl/ustring.hxx>
33cdf0e10cSrcweir #include <sal/types.h>
34cdf0e10cSrcweir #include <osl/diagnose.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir enum InfoType {
37cdf0e10cSrcweir     FULLPATH,
38cdf0e10cSrcweir     FILENAME,
39cdf0e10cSrcweir     PATHWITHOUTLASTCOMPONENT
40cdf0e10cSrcweir };
41cdf0e10cSrcweir 
42cdf0e10cSrcweir rtl::OUString CFStringToOUString(const CFStringRef sOrig);
43cdf0e10cSrcweir rtl::OUString FSRefToOUString(FSRef fsRef, InfoType info = FULLPATH);
44cdf0e10cSrcweir rtl::OUString CFURLRefToOUString(CFURLRef aUrlRef, InfoType info);
45cdf0e10cSrcweir CFStringRef CFStringCreateWithOUString(const rtl::OUString& aString);
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //debug utils
48cdf0e10cSrcweir #define PARAMFILLER "\n                    "
49cdf0e10cSrcweir 
DBG_PRINT_ENTRY()50cdf0e10cSrcweir inline void DBG_PRINT_ENTRY() {
51cdf0e10cSrcweir     OSL_TRACE(">>> %s", __func__);
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname)54cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname) {
55cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s", classname, methodname);
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1)58cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1) {
59cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s", classname, methodname, PARAMFILLER, param1, value1);
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1)62cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const rtl::OUString& value1) {
63cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s", classname, methodname, PARAMFILLER, param1, OUStringToOString(value1, RTL_TEXTENCODING_UTF8).getStr());
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const CFStringRef value1)66cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const CFStringRef value1) {
67cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s =", classname, methodname, PARAMFILLER, param1);
68cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
69cdf0e10cSrcweir     CFShow(value1);
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const NSString * value1)73cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const NSString* value1) {
74cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s =", classname, methodname, PARAMFILLER, param1);
75cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
7622d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(value1));
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1)80cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1) {
81cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d", classname, methodname, PARAMFILLER, param1, value1);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1,const char * param2,const int value2)84cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1, const char* param2, const int value2) {
85cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const char * value1,const char * param2,const char * value2)88cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const char* value1, const char* param2, const char* value2) {
89cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %s", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const int value2)92cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const int value2) {
93cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %d", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const char * value2)96cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const char* value2) {
97cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %s", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const CFStringRef value2)100cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const CFStringRef value2) {
101cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
102cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
103cdf0e10cSrcweir     CFShow(value2);
104cdf0e10cSrcweir #endif
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const int value1,const char * param2,const NSString * value2)107cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const int value1, const char* param2, const NSString* value2) {
108cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname, methodname, PARAMFILLER, param1, value1, PARAMFILLER, param2, value2);
109cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
11022d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(value2));
111cdf0e10cSrcweir #endif
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1,const char * param2,const rtl::OUString & value2)114cdf0e10cSrcweir 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) {
115cdf0e10cSrcweir     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());
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
DBG_PRINT_ENTRY(const char * classname,const char * methodname,const char * param1,const rtl::OUString & value1,const char * param2,const int value2)118cdf0e10cSrcweir inline void DBG_PRINT_ENTRY(const char * classname, const char * methodname, const char* param1, const rtl::OUString& value1, const char* param2, const int value2) {
119cdf0e10cSrcweir     OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname, methodname, PARAMFILLER, param1, OUStringToOString(value1, RTL_TEXTENCODING_UTF8).getStr(), PARAMFILLER, param2, value2);
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir //exit method debugs
123cdf0e10cSrcweir 
DBG_PRINT_EXIT()124cdf0e10cSrcweir inline void DBG_PRINT_EXIT() {
125cdf0e10cSrcweir     OSL_TRACE("<<< %s", __func__);
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname)128cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname) {
129cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s", classname, methodname);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const char * retVal)132cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const char* retVal) {
133cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname, methodname, PARAMFILLER, retVal);
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,int retVal)136cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, int retVal) {
137cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %d", classname, methodname, PARAMFILLER, retVal);
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const CFStringRef retVal)140cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const CFStringRef retVal) {
141cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = ", classname, methodname, PARAMFILLER);
142cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
143cdf0e10cSrcweir     CFShow(retVal);
144cdf0e10cSrcweir #endif
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const NSString * retVal)147cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const NSString* retVal) {
148cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = ", classname, methodname, PARAMFILLER);
149cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
15022d2d811SHerbert Dürr     NSLog( const_cast<NSString*>(retVal));
151cdf0e10cSrcweir #endif
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
DBG_PRINT_EXIT(const char * classname,const char * methodname,const rtl::OUString & retVal)154cdf0e10cSrcweir inline void DBG_PRINT_EXIT(const char * classname, const char * methodname, const rtl::OUString& retVal) {
155cdf0e10cSrcweir     OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname, methodname, PARAMFILLER, OUStringToOString(retVal, RTL_TEXTENCODING_UTF8).getStr());
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir #endif //_CFSTRINGUTILITIES_HXX_
159