author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
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 QSTRINGBUILDER_H |
|
43 |
#define QSTRINGBUILDER_H |
|
44 |
||
45 |
#include <QtCore/qstring.h> |
|
46 |
||
47 |
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) |
|
48 |
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) |
|
49 |
# include <QtCore/qmap.h> |
|
50 |
# endif |
|
51 |
#endif |
|
52 |
||
53 |
#include <string.h> |
|
54 |
||
55 |
QT_BEGIN_HEADER |
|
56 |
||
57 |
QT_BEGIN_NAMESPACE |
|
58 |
||
59 |
QT_MODULE(Core) |
|
60 |
||
61 |
// ### Qt 5: merge with QLatin1String |
|
62 |
class QLatin1Literal |
|
63 |
{ |
|
64 |
public: |
|
65 |
int size() const { return m_size; } |
|
66 |
const char *data() const { return m_data; } |
|
67 |
||
68 |
template <int N> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
QLatin1Literal(const char (&str)[N]) |
0 | 70 |
: m_size(N - 1), m_data(str) {} |
71 |
||
72 |
private: |
|
73 |
const int m_size; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
74 |
const char * const m_data; |
0 | 75 |
}; |
76 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
struct Q_CORE_EXPORT QAbstractConcatenable |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
protected: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
static void convertFromAscii(const char *a, int len, QChar *&out); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
static inline void convertFromAscii(char a, QChar *&out) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
#ifndef QT_NO_TEXTCODEC |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
if (QString::codecForCStrings) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
*out++ = QChar::fromAscii(a); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
*out++ = QLatin1Char(a); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
}; |
0 | 92 |
|
93 |
template <typename T> struct QConcatenable {}; |
|
94 |
||
95 |
template <typename A, typename B> |
|
96 |
class QStringBuilder |
|
97 |
{ |
|
98 |
public: |
|
99 |
QStringBuilder(const A &a_, const B &b_) : a(a_), b(b_) {} |
|
100 |
||
101 |
operator QString() const |
|
102 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
103 |
const uint size = QConcatenable< QStringBuilder<A, B> >::size(*this); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
104 |
QString s(size, Qt::Uninitialized); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
|
0 | 106 |
QChar *d = s.data(); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
107 |
const QChar * const start = d; |
0 | 108 |
QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
109 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
110 |
if (!QConcatenable< QStringBuilder<A, B> >::ExactSize && int(size) != d - start) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
111 |
// this resize is necessary since we allocate a bit too much |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
112 |
// when dealing with variable sized 8-bit encodings |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
113 |
s.resize(d - start); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
114 |
} |
0 | 115 |
return s; |
116 |
} |
|
117 |
QByteArray toLatin1() const { return QString(*this).toLatin1(); } |
|
118 |
||
119 |
const A &a; |
|
120 |
const B &b; |
|
121 |
}; |
|
122 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
123 |
template <> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
124 |
class QStringBuilder <QString, QString> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
125 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
126 |
public: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
127 |
QStringBuilder(const QString &a_, const QString &b_) : a(a_), b(b_) {} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
128 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
129 |
operator QString() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
130 |
{ QString r(a); r += b; return r; } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
131 |
QByteArray toLatin1() const { return QString(*this).toLatin1(); } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
132 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
133 |
const QString &a; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
134 |
const QString &b; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
135 |
}; |
0 | 136 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
template <> struct QConcatenable<char> : private QAbstractConcatenable |
0 | 138 |
{ |
139 |
typedef char type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
140 |
enum { ExactSize = true }; |
0 | 141 |
static int size(const char) { return 1; } |
142 |
static inline void appendTo(const char c, QChar *&out) |
|
143 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
QAbstractConcatenable::convertFromAscii(c, out); |
0 | 145 |
} |
146 |
}; |
|
147 |
||
148 |
template <> struct QConcatenable<QLatin1Char> |
|
149 |
{ |
|
150 |
typedef QLatin1Char type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
151 |
enum { ExactSize = true }; |
0 | 152 |
static int size(const QLatin1Char) { return 1; } |
153 |
static inline void appendTo(const QLatin1Char c, QChar *&out) |
|
154 |
{ |
|
155 |
*out++ = c; |
|
156 |
} |
|
157 |
}; |
|
158 |
||
159 |
template <> struct QConcatenable<QChar> |
|
160 |
{ |
|
161 |
typedef QChar type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
162 |
enum { ExactSize = true }; |
0 | 163 |
static int size(const QChar) { return 1; } |
164 |
static inline void appendTo(const QChar c, QChar *&out) |
|
165 |
{ |
|
166 |
*out++ = c; |
|
167 |
} |
|
168 |
}; |
|
169 |
||
170 |
template <> struct QConcatenable<QCharRef> |
|
171 |
{ |
|
172 |
typedef QCharRef type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
173 |
enum { ExactSize = true }; |
0 | 174 |
static int size(const QCharRef &) { return 1; } |
175 |
static inline void appendTo(const QCharRef &c, QChar *&out) |
|
176 |
{ |
|
177 |
*out++ = QChar(c); |
|
178 |
} |
|
179 |
}; |
|
180 |
||
181 |
template <> struct QConcatenable<QLatin1String> |
|
182 |
{ |
|
183 |
typedef QLatin1String type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
184 |
enum { ExactSize = true }; |
0 | 185 |
static int size(const QLatin1String &a) { return qstrlen(a.latin1()); } |
186 |
static inline void appendTo(const QLatin1String &a, QChar *&out) |
|
187 |
{ |
|
188 |
for (const char *s = a.latin1(); *s; ) |
|
189 |
*out++ = QLatin1Char(*s++); |
|
190 |
} |
|
191 |
||
192 |
}; |
|
193 |
||
194 |
template <> struct QConcatenable<QLatin1Literal> |
|
195 |
{ |
|
196 |
typedef QLatin1Literal type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
197 |
enum { ExactSize = true }; |
0 | 198 |
static int size(const QLatin1Literal &a) { return a.size(); } |
199 |
static inline void appendTo(const QLatin1Literal &a, QChar *&out) |
|
200 |
{ |
|
201 |
for (const char *s = a.data(); *s; ) |
|
202 |
*out++ = QLatin1Char(*s++); |
|
203 |
} |
|
204 |
}; |
|
205 |
||
206 |
template <> struct QConcatenable<QString> |
|
207 |
{ |
|
208 |
typedef QString type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
209 |
enum { ExactSize = true }; |
0 | 210 |
static int size(const QString &a) { return a.size(); } |
211 |
static inline void appendTo(const QString &a, QChar *&out) |
|
212 |
{ |
|
213 |
const int n = a.size(); |
|
214 |
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
out += n; |
0 | 216 |
} |
217 |
}; |
|
218 |
||
219 |
template <> struct QConcatenable<QStringRef> |
|
220 |
{ |
|
221 |
typedef QStringRef type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
222 |
enum { ExactSize = true }; |
0 | 223 |
static int size(const QStringRef &a) { return a.size(); } |
224 |
static inline void appendTo(QStringRef a, QChar *&out) |
|
225 |
{ |
|
226 |
const int n = a.size(); |
|
227 |
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
out += n; |
0 | 229 |
} |
230 |
}; |
|
231 |
||
232 |
#ifndef QT_NO_CAST_FROM_ASCII |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable |
0 | 234 |
{ |
235 |
typedef char type[N]; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
236 |
enum { ExactSize = false }; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
static int size(const char[N]) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
return N - 1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
} |
0 | 241 |
static inline void appendTo(const char a[N], QChar *&out) |
242 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
QAbstractConcatenable::convertFromAscii(a, N, out); |
0 | 244 |
} |
245 |
}; |
|
246 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
template <int N> struct QConcatenable<const char[N]> : private QAbstractConcatenable |
0 | 248 |
{ |
249 |
typedef const char type[N]; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
250 |
enum { ExactSize = false }; |
0 | 251 |
static int size(const char[N]) { return N - 1; } |
252 |
static inline void appendTo(const char a[N], QChar *&out) |
|
253 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
QAbstractConcatenable::convertFromAscii(a, N, out); |
0 | 255 |
} |
256 |
}; |
|
257 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
template <> struct QConcatenable<const char *> : private QAbstractConcatenable |
0 | 259 |
{ |
260 |
typedef char const *type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
261 |
enum { ExactSize = false }; |
0 | 262 |
static int size(const char *a) { return qstrlen(a); } |
263 |
static inline void appendTo(const char *a, QChar *&out) |
|
264 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
QAbstractConcatenable::convertFromAscii(a, -1, out); |
0 | 266 |
} |
267 |
}; |
|
268 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable |
0 | 270 |
{ |
271 |
typedef QByteArray type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
272 |
enum { ExactSize = false }; |
0 | 273 |
static int size(const QByteArray &ba) { return qstrnlen(ba.constData(), ba.size()); } |
274 |
static inline void appendTo(const QByteArray &ba, QChar *&out) |
|
275 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
QAbstractConcatenable::convertFromAscii(ba.constData(), -1, out); |
0 | 277 |
} |
278 |
}; |
|
279 |
#endif |
|
280 |
||
281 |
template <typename A, typename B> |
|
282 |
struct QConcatenable< QStringBuilder<A, B> > |
|
283 |
{ |
|
284 |
typedef QStringBuilder<A, B> type; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
285 |
enum { ExactSize = QConcatenable<A>::ExactSize && QConcatenable<B>::ExactSize }; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
static int size(const type &p) |
0 | 287 |
{ |
288 |
return QConcatenable<A>::size(p.a) + QConcatenable<B>::size(p.b); |
|
289 |
} |
|
290 |
static inline void appendTo(const QStringBuilder<A, B> &p, QChar *&out) |
|
291 |
{ |
|
292 |
QConcatenable<A>::appendTo(p.a, out); |
|
293 |
QConcatenable<B>::appendTo(p.b, out); |
|
294 |
} |
|
295 |
}; |
|
296 |
||
297 |
template <typename A, typename B> |
|
298 |
QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type> |
|
299 |
operator%(const A &a, const B &b) |
|
300 |
{ |
|
301 |
return QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>(a, b); |
|
302 |
} |
|
303 |
||
304 |
#ifdef QT_USE_FAST_OPERATOR_PLUS |
|
305 |
template <typename A, typename B> |
|
306 |
QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type> |
|
307 |
operator+(const A &a, const B &b) |
|
308 |
{ |
|
309 |
return QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>(a, b); |
|
310 |
} |
|
311 |
#endif |
|
312 |
||
313 |
QT_END_NAMESPACE |
|
314 |
||
315 |
QT_END_HEADER |
|
316 |
||
317 |
#endif // QSTRINGBUILDER_H |