Debian Codegraph @

src/global.h.in

raw
1 /*
2 Copyright 2009 Last.fm Ltd.
3 - Primarily authored by Max Howell, Jono Cole and Doug Mansell
4
5 This file is part of liblastfm.
6
7 liblastfm is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 liblastfm is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef LASTFM_GLOBAL_H
22 #define LASTFM_GLOBAL_H
23
24 #define LASTFM_VERSION @LASTFM_VERSION@
25 #define LASTFM_VERSION_STRING "@LASTFM_VERSION_STRING@"
26 #define LASTFM_MAJOR_VERSION @LASTFM_MAJOR_VERSION@
27 #define LASTFM_MINOR_VERSION @LASTFM_MINOR_VERSION@
28 #define LASTFM_PATCH_VERSION @LASTFM_PATCH_VERSION@
29
30
31 #ifndef LASTFM_LIB_STATIC
32 #ifdef LASTFM_LIB
33 #define LASTFM_DLLEXPORT Q_DECL_EXPORT
34 #else
35 #define LASTFM_DLLEXPORT Q_DECL_IMPORT
36 #endif
37 #ifdef LASTFM_FINGERPRINT_LIB
38 #define LASTFM_FINGERPRINT_DLLEXPORT Q_DECL_EXPORT
39 #else
40 #define LASTFM_FINGERPRINT_DLLEXPORT Q_DECL_IMPORT
41 #endif
42 #else // LASTFM_LIB_STATIC
43 #define LASTFM_DLLEXPORT
44 #define LASTFM_FINGERPRINT_DLLEXPORT
45 #endif // LASTFM_LIB_STATIC
46
47
48
49 #include <QMetaEnum>
50 #include <QString>
51
52 namespace lastfm
53 {
54 /** http://labs.trolltech.com/blogs/2008/10/09/coding-tip-pretty-printing-enum-values
55 * Tips for making this take a single parameter welcome! :)
56 *
57 * eg. lastfm::qMetaEnumString<QNetworkReply>( error, "NetworkError" );
58 */
59 template <typename T> static inline QString qMetaEnumString( int enum_value, const char* enum_name )
60 {
61 QMetaObject meta = T::staticMetaObject;
62 for (int i=0; i < meta.enumeratorCount(); ++i)
63 {
64 QMetaEnum m = meta.enumerator(i);
65 if (QLatin1String(m.name()) == QLatin1String(enum_name))
66 return QLatin1String(m.valueToKey(enum_value));
67 }
68 return QString("Unknown enum value for \"%1\": %2").arg( enum_name ).arg( enum_value );
69 }
70 }
71
72
73 #ifdef LASTFM_COLLAPSE_NAMESPACE
74 using namespace ::lastfm;
75 #endif
76
77
78 #endif //LASTFM_GLOBAL_H