1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _CFSTRINGUTILITIES_HXX_
21 #define _CFSTRINGUTILITIES_HXX_
24 #include <Carbon/Carbon.h>
25 #include <Cocoa/Cocoa.h>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
29 #include <osl/diagnose.h>
34 PATHWITHOUTLASTCOMPONENT
37 rtl::OUString
CFStringToOUString(const CFStringRef sOrig
);
38 rtl::OUString
FSRefToOUString(FSRef fsRef
, InfoType info
= FULLPATH
);
39 rtl::OUString
CFURLRefToOUString(CFURLRef aUrlRef
, InfoType info
);
40 CFStringRef
CFStringCreateWithOUString(const rtl::OUString
& aString
);
43 #define PARAMFILLER "\n "
45 inline void DBG_PRINT_ENTRY() {
46 OSL_TRACE(">>> %s", __func__
);
49 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
) {
50 OSL_TRACE(">>> %s::%s", classname
, methodname
);
53 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const char* value1
) {
54 OSL_TRACE(">>> %s::%s%s%s = %s", classname
, methodname
, PARAMFILLER
, param1
, value1
);
57 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const rtl::OUString
& value1
) {
58 OSL_TRACE(">>> %s::%s%s%s = %s", classname
, methodname
, PARAMFILLER
, param1
, OUStringToOString(value1
, RTL_TEXTENCODING_UTF8
).getStr());
61 #if OSL_DEBUG_LEVEL > 1
62 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const CFStringRef value1
)
64 OSL_TRACE(">>> %s::%s%s%s =", classname
, methodname
, PARAMFILLER
, param1
);
69 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const CFStringRef
/* value1 */)
71 OSL_TRACE(">>> %s::%s%s%s =", classname
, methodname
, PARAMFILLER
, param1
);
75 #if OSL_DEBUG_LEVEL > 1
76 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const NSString
* value1
)
78 OSL_TRACE(">>> %s::%s%s%s =", classname
, methodname
, PARAMFILLER
, param1
);
82 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const NSString
* /* value1 */)
84 OSL_TRACE(">>> %s::%s%s%s =", classname
, methodname
, PARAMFILLER
, param1
);
88 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const int value1
) {
89 OSL_TRACE(">>> %s::%s%s%s = %d", classname
, methodname
, PARAMFILLER
, param1
, value1
);
92 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const char* value1
, const char* param2
, const int value2
) {
93 OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
96 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const char* value1
, const char* param2
, const char* value2
) {
97 OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %s", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
100 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const int value1
, const char* param2
, const int value2
) {
101 OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %d", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
104 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const int value1
, const char* param2
, const char* value2
) {
105 OSL_TRACE(">>> %s::%s%s%s = %d%s%s = %s", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
108 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const int value1
, const char* param2
, const CFStringRef value2
)
110 OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
111 #if OSL_DEBUG_LEVEL > 1
116 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const int value1
, const char* param2
, const NSString
* value2
)
118 OSL_TRACE(">>> %s::%s%s%s = %d%s%s =", classname
, methodname
, PARAMFILLER
, param1
, value1
, PARAMFILLER
, param2
, value2
);
119 #if OSL_DEBUG_LEVEL > 1
125 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
) {
126 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());
129 inline void DBG_PRINT_ENTRY(const char * classname
, const char * methodname
, const char* param1
, const rtl::OUString
& value1
, const char* param2
, const int value2
) {
130 OSL_TRACE(">>> %s::%s%s%s = %s%s%s = %d", classname
, methodname
, PARAMFILLER
, param1
, OUStringToOString(value1
, RTL_TEXTENCODING_UTF8
).getStr(), PARAMFILLER
, param2
, value2
);
135 inline void DBG_PRINT_EXIT() {
136 OSL_TRACE("<<< %s", __func__
);
139 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
) {
140 OSL_TRACE("<<< %s::%s", classname
, methodname
);
143 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const char* retVal
) {
144 OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname
, methodname
, PARAMFILLER
, retVal
);
147 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, int retVal
) {
148 OSL_TRACE("<<< %s::%s%sreturnValue = %d", classname
, methodname
, PARAMFILLER
, retVal
);
151 #if OSL_DEBUG_LEVEL > 1
152 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const CFStringRef retVal
)
154 OSL_TRACE("<<< %s::%s%sreturnValue = ", classname
, methodname
, PARAMFILLER
);
158 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const CFStringRef
/* retVal */)
160 OSL_TRACE("<<< %s::%s%sreturnValue = ", classname
, methodname
, PARAMFILLER
);
164 #if OSL_DEBUG_LEVEL > 1
165 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const NSString
* retVal
)
167 OSL_TRACE("<<< %s::%s%sreturnValue = ", classname
, methodname
, PARAMFILLER
);
171 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const NSString
* /* retVal */ )
173 OSL_TRACE("<<< %s::%s%sreturnValue = ", classname
, methodname
, PARAMFILLER
);
177 inline void DBG_PRINT_EXIT(const char * classname
, const char * methodname
, const rtl::OUString
& retVal
) {
178 OSL_TRACE("<<< %s::%s%sreturnValue = %s", classname
, methodname
, PARAMFILLER
, OUStringToOString(retVal
, RTL_TEXTENCODING_UTF8
).getStr());
181 #endif //_CFSTRINGUTILITIES_HXX_
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */