Dokit
Internal development documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
qtpokit_global.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2025 Paul Colby <git@colby.id.au>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4/*!
5 * \file
6 * Global QtPokit library macros.
7 */
8
9#ifndef QTPOKIT_GLOBAL_H
10#define QTPOKIT_GLOBAL_H
11
12#include <QtGlobal>
13
14/// \cond internal
15
16/*!
17 * QtPokit library export/import macro.
18 */
19#if defined(QTPOKIT_SHARED) || !defined(QTPOKIT_STATIC)
20# ifdef QTPOKIT_STATIC
21# error "Both QTPOKIT_SHARED and QTPOKIT_STATIC defined."
22# endif
23# if defined(QTPOKIT_LIBRARY)
24# define QTPOKIT_EXPORT Q_DECL_EXPORT
25# else
26# define QTPOKIT_EXPORT Q_DECL_IMPORT
27# endif
28#else
29# define QTPOKIT_EXPORT
30#endif
31
32/*!
33 * \def QTPOKIT_BEGIN_NAMESPACE
34 *
35 * Macro for starting the QtPokit library's top-most namespace (if one is defined).
36 *
37 * \sa QTPOKIT_END_NAMESPACE
38 * \sa QTPOKIT_NAMESPACE
39 */
40
41/*!
42 * \def QTPOKIT_END_NAMESPACE
43 *
44 * Macro for ending the QtPokit library's top-most namespace (if one is defined).
45 *
46 * \sa QTPOKIT_BEGIN_NAMESPACE
47 * \sa QTPOKIT_NAMESPACE
48 */
49
50/*!
51 * \def QTPOKIT_USE_NAMESPACE
52 *
53 * Macro for using the QtPokit library's top-most namespace (if one is defined).
54 *
55 * \sa QTPOKIT_USE_NAMESPACE_MEMBER
56 */
57
58/*!
59 * \def QTPOKIT_PREPEND_NAMESPACE
60 *
61 * Macro for prepending the QtPokit library's top-most namespace (if one is defined).
62 */
63
64/*!
65 * \def QTPOKIT_FORWARD_DECLARE
66 *
67 * Macro for forward declaring objects in the QtPokit library's top-most namespace (if one is defined).
68 *
69 * \sa QTPOKIT_FORWARD_DECLARE_CLASS
70 * \sa QTPOKIT_FORWARD_DECLARE_STRUCT
71 */
72
73#ifdef QTPOKIT_NAMESPACE
74 #define QTPOKIT_BEGIN_NAMESPACE namespace QTPOKIT_NAMESPACE {
75 #define QTPOKIT_END_NAMESPACE }
76 #define QTPOKIT_USE_NAMESPACE using namespace ::QTPOKIT_NAMESPACE;
77 #define QTPOKIT_PREPEND_NAMESPACE(name) ::QTPOKIT_NAMESPACE::name
78 #define QTPOKIT_FORWARD_DECLARE(type, name) QTPOKIT_BEGIN_NAMESPACE type name; QTPOKIT_END_NAMESPACE QTPOKIT_USE_NAMESPACE_MEMBER(name)
79 namespace QTPOKIT_NAMESPACE {}
80#else
81 #define QTPOKIT_BEGIN_NAMESPACE
82 #define QTPOKIT_END_NAMESPACE
83 #define QTPOKIT_USE_NAMESPACE
84 #define QTPOKIT_PREPEND_NAMESPACE(name) ::name
85 #define QTPOKIT_FORWARD_DECLARE(type, name) type name;
86#endif
87
88/*!
89 * Macro for forward declaring classes in the QtPokit library's top-most namespace (if one is defined).
90 *
91 * \sa QTPOKIT_FORWARD_DECLARE
92 * \sa QTPOKIT_FORWARD_DECLARE_STRUCT
93 */
94#define QTPOKIT_FORWARD_DECLARE_CLASS(name) QTPOKIT_FORWARD_DECLARE(class,name)
95
96/*!
97 * Macro for forward declaring classes in the QtPokit library's top-most namespace (if one is defined).
98 *
99 * \sa QTPOKIT_FORWARD_DECLARE
100 * \sa QTPOKIT_FORWARD_DECLARE_CLASS
101 */
102#define QTPOKIT_FORWARD_DECLARE_STRUCT(name) QTPOKIT_FORWARD_DECLARE(struct,name)
103
104/*!
105 * Macro for using a member of the QtPokit library's top-most namespace (if one is defined).
106 */
107#define QTPOKIT_USE_NAMESPACE_MEMBER(name) using QTPOKIT_PREPEND_NAMESPACE(name);
108
109/*!
110 * \def QTPOKIT_BEFRIEND_TEST
111 *
112 * Macro for befriending a related unit test class, but only when QT_TESTLIB_LIB is defined.
113 */
114
115#ifdef QT_TESTLIB_LIB
116 #define QTPOKIT_BEFRIEND_TEST(Class) friend class Test##Class;
117#else
118 #define QTPOKIT_BEFRIEND_TEST(Class)
119#endif
120
121/// \endcond
122
123#endif // QTPOKIT_GLOBAL_H