Qt 4.8
qabstractdatetime_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_AbstractDateTime_H
53 #define Patternist_AbstractDateTime_H
54 
55 #include <QDateTime>
56 #include <QRegExp>
57 
58 #include "qitem_p.h"
59 
61 
63 
64 namespace QPatternist
65 {
81  {
82  public:
84 
85  AbstractDateTime(const QDateTime &dateTime);
86 
87  enum
88  {
89  DefaultYear = 2000,
92  };
93 
97  inline const QDateTime &toDateTime() const
98  {
99  return m_dateTime;
100  }
101 
102 
112  {
113  public:
114  CaptureTable(const QRegExp &exp,
115  const qint8 zoneOffsetSignP,
116  const qint8 zoneOffsetHourP,
117  const qint8 zoneOffsetMinuteP,
118  const qint8 zoneOffsetUTCSymbolP,
119  const qint8 yearP,
120  const qint8 monthP = -1,
121  const qint8 dayP = -1,
122  const qint8 hourP = -1,
123  const qint8 minutesP = -1,
124  const qint8 secondsP = -1,
125  const qint8 msecondsP = -1,
126  const qint8 yearSignP = -1) : regExp(exp)
127  , zoneOffsetSign(zoneOffsetSignP)
128  , zoneOffsetHour(zoneOffsetHourP)
129  , zoneOffsetMinute(zoneOffsetMinuteP)
130  , zoneOffsetUTCSymbol(zoneOffsetUTCSymbolP)
131  , year(yearP)
132  , month(monthP)
133  , day(dayP)
134  , hour(hourP)
135  , minutes(minutesP)
136  , seconds(secondsP)
137  , mseconds(msecondsP)
138  , yearSign(yearSignP)
139  {
140  Q_ASSERT(exp.isValid());
141  }
142 
148  const qint8 year;
149  const qint8 month;
150  const qint8 day;
151  const qint8 hour;
152  const qint8 minutes;
153  const qint8 seconds;
156 
157  private:
159  };
160 
165  QString timeToString() const;
166 
171  QString dateToString() const;
172 
178  static QString serializeMSeconds(const MSecondProperty msecs);
179 
187  virtual Item fromValue(const QDateTime &dt) const;
188 
195  static bool isRangeValid(const QDate &date,
196  QString &message);
197 
198  protected:
199 
205  QString zoneOffsetToString() const;
206 
207  static QDateTime create(AtomicValue::Ptr &errorMessage,
208  const QString &lexicalSource,
209  const CaptureTable &captTable);
210 
215  static void copyTimeSpec(const QDateTime &from,
216  QDateTime &to);
217 
219 
220  private:
222  {
231 
237  };
238 
248  const QStringList &capts,
249  const CaptureTable &captTable);
250 
251  static inline void setUtcOffset(QDateTime &result,
252  const ZoneOffsetParseResult zoResult,
253  const int zoOffset);
254  };
255 }
256 
258 
260 
261 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Base class for classes implementing values related to time, date or both.
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
Due to strong interdependencies, this file contains the definitions for the classes Item...
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
The QDate class provides date functions.
Definition: qdatetime.h:55
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
CaptureTable(const QRegExp &exp, const qint8 zoneOffsetSignP, const qint8 zoneOffsetHourP, const qint8 zoneOffsetMinuteP, const qint8 zoneOffsetUTCSymbolP, const qint8 yearP, const qint8 monthP=-1, const qint8 dayP=-1, const qint8 hourP=-1, const qint8 minutesP=-1, const qint8 secondsP=-1, const qint8 msecondsP=-1, const qint8 yearSignP=-1)
static void setUtcOffset(QDateTime &result, const ZoneOffsetParseResult zoResult, const int zoOffset)
static QDateTime create(AtomicValue::Ptr &errorMessage, const QString &lexicalSource, const CaptureTable &captTable)
bool isValid() const
Returns true if the regular expression is valid; otherwise returns false.
Definition: qregexp.cpp:3943
signed char qint8
Definition: qglobal.h:933
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
AbstractDateTime(const QDateTime &dateTime)
Base class for all classes representing atomic values.
Definition: qitem_p.h:118
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Acts as a mapping table for AbstractDateTime::create() and describes where certain fields in a QRegEx...
The namespace for the internal API of QtXmlPatterns.
const QDateTime & toDateTime() const
static ZOTotal parseZoneOffset(ZoneOffsetParseResult &result, const QStringList &capts, const CaptureTable &captTable)
Parses the zone offset. All types use zone offsets.
static void copyTimeSpec(const QDateTime &from, QDateTime &to)
Makes the QDateTime::timeSpec() and QDateTime::zoneOffset() of ot * consistent to from...
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 isRangeValid(const QDate &date, QString &message)
virtual Item fromValue(const QDateTime &dt) const
qint16 MSecondProperty
static QString serializeMSeconds(const MSecondProperty msecs)
qint32 ZOTotal
#define QT_END_HEADER
Definition: qglobal.h:137
QExplicitlySharedDataPointer< AbstractDateTime > Ptr