KDELibs4Support

kdeversion.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (c) 2002 Simon Hausmann <[email protected]>
3  Copyright (c) 2002 Marc Mutz <[email protected]>
4  Copyright (c) 2003 Andreas Beckermann <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KDELIBS_KDEVERSION_H
23 #define KDELIBS_KDEVERSION_H
24 
25 /**
26  * @file kdeversion.h
27  * @brief The file contains macros and functions related to the KDE version.
28  */
29 
30 #include <kdelibs4support_export.h>
31 #include <kdelibs4support_version.h>
32 
33 /**
34  * @def KDE_VERSION_STRING
35  * @ingroup KDEMacros
36  * @brief Version of KDE as string, at compile time
37  *
38  * This macro contains the KDE version in string form. As it is a macro,
39  * it contains the version at compile time. See versionString() if you need
40  * the KDE version used at runtime.
41  *
42  * @note The version string might contain a section in parentheses,
43  * especially for development versions of KDE.
44  * If you use that macro directly for a file format (e.g. OASIS Open Document)
45  * or for a protocol (e.g. http) be careful that it is appropriate.
46  * (Fictional) example: "4.0.90 (>=20070101)"
47  */
48 #define KDE_VERSION_STRING KDELIBS4SUPPORT_VERSION_STRING
49 
50 /**
51  * @def KDE_VERSION_MAJOR
52  * @ingroup KDEMacros
53  * @brief Major version of KDE, at compile time
54  */
55 #define KDE_VERSION_MAJOR KDELIBS4SUPPORT_VERSION_MAJOR
56 /**
57  * @def KDE_VERSION_MINOR
58  * @ingroup KDEMacros
59  * @brief Minor version of KDE, at compile time
60  */
61 #define KDE_VERSION_MINOR KDELIBS4SUPPORT_VERSION_MINOR
62 /**
63  * @def KDE_VERSION_RELEASE
64  * @ingroup KDEMacros
65  * @brief Release version of KDE, at compile time
66  */
67 #define KDE_VERSION_RELEASE KDELIBS4SUPPORT_VERSION_PATCH
68 
69 /**
70  * @ingroup KDEMacros
71  * @brief Make a number from the major, minor and release number of a KDE version
72  *
73  * This function can be used for preprocessing when KDE_IS_VERSION is not
74  * appropriate.
75  */
76 #define KDE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
77 
78 /**
79  * @ingroup KDEMacros
80  * @brief Version of KDE as number, at compile time
81  *
82  * This macro contains the KDE version in number form. As it is a macro,
83  * it contains the version at compile time. See version() if you need
84  * the KDE version used at runtime.
85  */
86 #define KDE_VERSION \
87  KDE_MAKE_VERSION(KDE_VERSION_MAJOR,KDE_VERSION_MINOR,KDE_VERSION_RELEASE)
88 
89 /**
90  * @ingroup KDEMacros
91  * @brief Check if the KDE version matches a certain version or is higher
92  *
93  * This macro is typically used to compile conditionally a part of code:
94  * @code
95  * #if KDE_IS_VERSION(4,0,90)
96  * // Code for KDE 4.1
97  * #else
98  * // Code for KDE 4.0
99  * #endif
100  * @endcode
101  *
102  * @warning Especially during development phases of KDE, be careful
103  * when choosing the version number that you are checking against.
104  * Otherwise you might risk to break the next KDE release.
105  * Therefore be careful that development version have a
106  * version number lower than the released version, so do not check
107  * e.g. for KDE 4.1 with KDE_IS_VERSION(4,1,0)
108  * but with the actual version number at a time a needed feature was introduced.
109  */
110 #define KDE_IS_VERSION(a,b,c) ( KDE_VERSION >= KDE_MAKE_VERSION(a,b,c) )
111 
112 /**
113  * Namespace for general KDE functions.
114  */
115 namespace KDE
116 {
117 /**
118  * @brief Returns the encoded number of KDE's version, see the KDE_VERSION macro.
119  *
120  * In contrary to the macro KDE_VERSION
121  * this function returns the number of the actually
122  * installed KDE version, not the number of the KDE version that was
123  * installed when the program was compiled.
124  * @return the version number, encoded in a single uint
125  */
126 KDELIBS4SUPPORT_DEPRECATED_EXPORT unsigned int version();
127 /**
128  * @brief Returns the major number of KDE's version, e.g.
129  * 4 for KDE 4.1.2.
130  * @return the major version number
131  */
132 KDELIBS4SUPPORT_DEPRECATED_EXPORT unsigned int versionMajor();
133 /**
134  * @brief Returns the minor number of KDE's version, e.g.
135  * 1 for KDE 4.1.2.
136  * @return the minor version number
137  */
138 KDELIBS4SUPPORT_DEPRECATED_EXPORT unsigned int versionMinor();
139 /**
140  * @brief Returns the release of KDE's version, e.g.
141  * 2 for KDE 4.1.2.
142  * @return the release number
143  */
144 KDELIBS4SUPPORT_DEPRECATED_EXPORT unsigned int versionRelease();
145 /**
146  * @brief Returns the KDE version as string, e.g. "4.1.2".
147  *
148  * On contrary to the macro KDE_VERSION_STRING this function returns
149  * the version number of KDE at runtime.
150  * @return the KDE version. You can keep the string forever
151  */
152 KDELIBS4SUPPORT_DEPRECATED_EXPORT const char *versionString();
153 }
154 
155 #endif // KDELIBS_KDEVERSION_H
const char * versionString()
Returns the KDE version as string, e.g.
Definition: kdeversion.cpp:44
unsigned int versionRelease()
Returns the release of KDE&#39;s version, e.g.
Definition: kdeversion.cpp:39
Namespace for general KDE functions.
Definition: kde_file.h:158
unsigned int versionMinor()
Returns the minor number of KDE&#39;s version, e.g.
Definition: kdeversion.cpp:34
unsigned int versionMajor()
Returns the major number of KDE&#39;s version, e.g.
Definition: kdeversion.cpp:29
unsigned int version()
Returns the encoded number of KDE&#39;s version, see the KDE_VERSION macro.
Definition: kdeversion.cpp:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:50:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.