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