|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QTCONTACTSGLOBAL_H |
|
43 #define QTCONTACTSGLOBAL_H |
|
44 |
|
45 #include <qmobilityglobal.h> |
|
46 #include <QString> |
|
47 |
|
48 #define QTCONTACTS_VERSION_NAME "com.nokia.qt.mobility.contacts.api.version" |
|
49 #define QTCONTACTS_IMPLEMENTATION_VERSION_NAME "com.nokia.qt.mobility.contacts.implementation.version" |
|
50 #define QTCONTACTS_VERSION 1 |
|
51 |
|
52 QTM_BEGIN_NAMESPACE |
|
53 |
|
54 typedef quint32 QContactLocalId; // XXX Put this else where |
|
55 |
|
56 /* |
|
57 * Latin1Literal |
|
58 * |
|
59 * The idea of the Latin1Literal is to provide a POD-esque container |
|
60 * for constant strings which are defined in various places |
|
61 * (e.g., detail leaf class definition names, field keys, constant field values, etc). |
|
62 * We would ideally like these to be stored in the .rodata section to allow |
|
63 * sharing / minimise footprint. |
|
64 * |
|
65 * Given that the declare/define macros are const anyway, we changed the |
|
66 * member to a char array from a const char array, in order to squash |
|
67 * the compiler warning regarding uninitialised const value without |
|
68 * initialiser list in default ctor (POD requires default ctor). |
|
69 * Does it work as hoped? |
|
70 */ |
|
71 |
|
72 template <int N> struct Latin1Literal |
|
73 { |
|
74 //const char str[N]; // causes compiler warning due to uninitialized const value |
|
75 char str[N]; |
|
76 |
|
77 operator QLatin1String() const {return QLatin1String(str);} |
|
78 operator QString() const {return QString::fromLatin1(str, N-1);} |
|
79 }; |
|
80 |
|
81 template<int N> bool operator==(const Latin1Literal<N>& a, const QLatin1String& b) |
|
82 { |
|
83 return QLatin1String(a.str) == b; |
|
84 } |
|
85 |
|
86 template<int N> bool operator==(const Latin1Literal<N>& a, const QString& b) |
|
87 { |
|
88 return b == QLatin1String(a.str); |
|
89 } |
|
90 |
|
91 template<int N> bool operator==(const QLatin1String& b, const Latin1Literal<N>& a) |
|
92 { |
|
93 return QLatin1String(a.str) == b; |
|
94 } |
|
95 |
|
96 template<int N> bool operator==(const QString& b, const Latin1Literal<N>& a) |
|
97 { |
|
98 return b == QLatin1String(a.str); |
|
99 } |
|
100 |
|
101 template<int N> bool operator!=(const Latin1Literal<N>& a, const QLatin1String& b) |
|
102 { |
|
103 return QLatin1String(a.str) != b; |
|
104 } |
|
105 |
|
106 template<int N> bool operator!=(const Latin1Literal<N>& a, const QString& b) |
|
107 { |
|
108 return b != QLatin1String(a.str); |
|
109 } |
|
110 |
|
111 template<int N> bool operator!=(const QLatin1String& b, const Latin1Literal<N>& a) |
|
112 { |
|
113 return QLatin1String(a.str) != b; |
|
114 } |
|
115 |
|
116 template<int N> bool operator!=(const QString& b, const Latin1Literal<N>& a) |
|
117 { |
|
118 return b != QLatin1String(a.str); |
|
119 } |
|
120 |
|
121 #define Q_DECLARE_LATIN1_LITERAL(varname, str) static const Latin1Literal<sizeof(str)> varname |
|
122 #define Q_DEFINE_LATIN1_LITERAL(varname, str) const Latin1Literal<sizeof(str)> varname = {str} |
|
123 |
|
124 QTM_END_NAMESPACE |
|
125 |
|
126 // Not needed since this is a typedef, and qglobal already does this for the base type |
|
127 // Q_DECLARE_TYPEINFO(QTM_PREPEND_NAMESPACE(QContactLocalId), Q_PRIMITIVE_TYPE); |
|
128 |
|
129 #endif |