Qt 4.8
qatomiccomparators_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists purely as an
47 // implementation detail. This header file may change from version to
48 // version without notice, or even be removed.
49 //
50 // We mean it.
51 
52 #ifndef Patternist_AtomicComparators_H
53 #define Patternist_AtomicComparators_H
54 
55 #include "qabstractfloat_p.h"
56 #include "qatomiccomparator_p.h"
57 #include "qprimitives_p.h"
58 
65 
67 
68 namespace QPatternist
69 {
78  {
79  public:
89  virtual ComparisonResult compare(const Item &op1,
91  const Item &op2) const;
92 
101  virtual bool equals(const Item &op1,
102  const Item &op2) const;
103  };
104 
113  {
114  public:
118  virtual ComparisonResult compare(const Item &op1,
120  const Item &op2) const;
121 
125  virtual bool equals(const Item &op1,
126  const Item &op2) const;
127  };
128 
135  {
136  public:
137  virtual bool equals(const Item &op1,
138  const Item &op2) const;
139  };
140 
149  {
150  public:
151  virtual ComparisonResult compare(const Item &op1,
153  const Item &op2) const;
154 
155  virtual bool equals(const Item &op1,
156  const Item &op2) const;
157  };
158 
167  {
168  public:
169  virtual ComparisonResult compare(const Item &op1,
171  const Item &op2) const;
172 
173  virtual bool equals(const Item &op1,
174  const Item &op2) const;
175  };
176 
184  template<const AtomicComparator::Operator t_op>
186  {
187  public:
188  virtual ComparisonResult compare(const Item &o1,
190  const Item &o2) const
191  {
193  "Can only be instantiated with those two.");
194  Q_ASSERT(op == t_op);
195  Q_UNUSED(op); /* Needed when building in release mode. */
196 
197  const xsDouble v1 = o1.template as<Numeric>()->toDouble();
198  const xsDouble v2 = o2.template as<Numeric>()->toDouble();
199 
200  if(qIsNaN(v1) && !qIsNaN(v2))
201  return t_op == OperatorLessThanNaNLeast ? LessThan : GreaterThan;
202  if(!qIsNaN(v1) && qIsNaN(v2))
203  return t_op == OperatorLessThanNaNLeast ? GreaterThan : LessThan;
204 
205  if(Double::isEqual(v1, v2))
206  return Equal;
207  else if(v1 < v2)
208  return LessThan;
209  else
210  return GreaterThan;
211  }
212 
213  };
214 
221  {
222  public:
223  virtual ComparisonResult compare(const Item &op1,
225  const Item &op2) const;
226 
227  virtual bool equals(const Item &op1,
228  const Item &op2) const;
229  };
230 
237  {
238  public:
239  virtual ComparisonResult compare(const Item &op1,
241  const Item &op2) const;
242 
243  virtual bool equals(const Item &op1,
244  const Item &op2) const;
245  };
246 
253  {
254  public:
255  virtual bool equals(const Item &op1,
256  const Item &op2) const;
257  };
258 
265  {
266  public:
267  virtual ComparisonResult compare(const Item &op1,
269  const Item &op2) const;
270  virtual bool equals(const Item &op1,
271  const Item &op2) const;
272  };
273 
280  {
281  public:
282  virtual ComparisonResult compare(const Item &op1,
284  const Item &op2) const;
285  virtual bool equals(const Item &op1,
286  const Item &op2) const;
287 
288  private:
289  static inline QDateTime addDurationToDateTime(const QDateTime &dateTime,
290  const AbstractDuration *const duration);
291  };
292 }
293 
295 
297 
298 #endif
Performs case sensitive string comparison between xs:anyUri, xs:string, and xs:untypedAtomic.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Base class for classes implementing durations.
Compares xs:decimal values.
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
Performs case insensitive string comparison between xs:anyUri, xs:string, and xs:untypedAtomic.
Compares xs:base64Binary and xs:hexBinary values.
Base class for classes responsible of comparing two atomic values.
Compares xs:QName values.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Compares sub-classes of AbstractDuration.
virtual bool equals(const Item &op1, const Item &op2) const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Compares xs:boolean values.
The namespace for the internal API of QtXmlPatterns.
Compares xs:integer values.
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
static bool isEqual(const xsDouble a, const xsDouble b)
Contains enumerators and typedefs applying for Patternist on a global scale, as well as central docum...
static qreal toDouble(const QChar *&str)
virtual ComparisonResult compare(const Item &op1, const AtomicComparator::Operator op, const Item &op2) const
Compares sub-classes of AbstractDateTime.
Compares xs:double values for the purpose of sorting.
virtual ComparisonResult compare(const Item &o1, const AtomicComparator::Operator op, const Item &o2) const
#define QT_END_HEADER
Definition: qglobal.h:137
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define Q_FUNC_INFO
Definition: qglobal.h:1871