Qt 4.8
Public Types | Public Functions | Static Public Functions | Protected Functions | Friends | List of all members
QPatternist::SchemaTime Class Reference

Implements the value instance of the xs:time type. More...

#include <qschematime_p.h>

Inheritance diagram for QPatternist::SchemaTime:
QPatternist::AbstractDateTime QPatternist::AtomicValue QSharedData QPatternist::CppCastingHelper< AtomicValue >

Public Types

typedef AtomicValue::Ptr Ptr
 
- Public Types inherited from QPatternist::AbstractDateTime
enum  { DefaultYear = 2000, DefaultMonth = 1, DefaultDay = 1 }
 
typedef QExplicitlySharedDataPointer< AbstractDateTimePtr
 
- Public Types inherited from QPatternist::AtomicValue
typedef QList< AtomicValue::PtrList
 
typedef QExplicitlySharedDataPointer< AtomicValuePtr
 

Public Functions

virtual Item fromValue (const QDateTime &dt) const
 
virtual QString stringValue () const
 
virtual ItemType::Ptr type () const
 
- Public Functions inherited from QPatternist::AbstractDateTime
 AbstractDateTime (const QDateTime &dateTime)
 
QString dateToString () const
 
QString timeToString () const
 
const QDateTimetoDateTime () const
 
- Public Functions inherited from QPatternist::AtomicValue
virtual bool evaluateEBV (const QExplicitlySharedDataPointer< DynamicContext > &context) const
 
virtual bool hasError () const
 
virtual ~AtomicValue ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 
- Public Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
const TCastTarget * as () const
 
TCastTarget * as ()
 

Static Public Functions

static SchemaTime::Ptr fromDateTime (const QDateTime &dt)
 
static SchemaTime::Ptr fromLexical (const QString &string)
 
- Static Public Functions inherited from QPatternist::AbstractDateTime
static bool isRangeValid (const QDate &date, QString &message)
 
static QString serializeMSeconds (const MSecondProperty msecs)
 
- Static Public Functions inherited from QPatternist::AtomicValue
static ItemType::Ptr qtToXDMType (const QXmlItem &item)
 
static QVariant toQt (const AtomicValue *const value)
 
static QVariant toQt (const AtomicValue::Ptr &value)
 
static Item toXDM (const QVariant &value)
 

Protected Functions

 SchemaTime (const QDateTime &dateTime)
 
- Protected Functions inherited from QPatternist::AbstractDateTime
QString zoneOffsetToString () const
 
- Protected Functions inherited from QPatternist::AtomicValue
 AtomicValue ()
 
- Protected Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
 CppCastingHelper ()
 

Friends

class CommonValues
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::AbstractDateTime
static void copyTimeSpec (const QDateTime &from, QDateTime &to)
 Makes the QDateTime::timeSpec() and QDateTime::zoneOffset() of ot * consistent to from. More...
 
static QDateTime create (AtomicValue::Ptr &errorMessage, const QString &lexicalSource, const CaptureTable &captTable)
 
- Protected Variables inherited from QPatternist::AbstractDateTime
const QDateTime m_dateTime
 

Detailed Description

Implements the value instance of the xs:time type.

The header file for this class was originally called Time.h, but this clashed with a system header on MinGW.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 72 of file qschematime_p.h.

Typedefs

◆ Ptr

Definition at line 75 of file qschematime_p.h.

Constructors and Destructors

◆ SchemaTime()

SchemaTime::SchemaTime ( const QDateTime dateTime)
protected

Definition at line 51 of file qschematime.cpp.

Referenced by fromDateTime(), and fromLexical().

51  : AbstractDateTime(dateTime)
52 {
53 }
AbstractDateTime(const QDateTime &dateTime)

Functions

◆ fromDateTime()

SchemaTime::Ptr SchemaTime::fromDateTime ( const QDateTime dt)
static

Definition at line 87 of file qschematime.cpp.

Referenced by QPatternist::AbstractDateTimeToTimeCaster::castFrom(), QPatternist::AdjustTimeToTimezoneFN::createValue(), QPatternist::CurrentTimeFN::evaluateSingleton(), fromValue(), and QPatternist::AtomicValue::toXDM().

88 {
89  Q_ASSERT(dt.isValid());
90  /* Singleton value, allocated once instead of each time it's needed. */
91  // STATIC DATA
92  static const QDate time_defaultDate(AbstractDateTime::DefaultYear,
95 
96  QDateTime result;
97  copyTimeSpec(dt, result);
98 
99  result.setDate(time_defaultDate);
100  result.setTime(dt.time());
101 
102  return SchemaTime::Ptr(new SchemaTime(result));
103 }
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
The QDate class provides date functions.
Definition: qdatetime.h:55
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
AtomicValue::Ptr Ptr
Definition: qschematime_p.h:75
SchemaTime(const QDateTime &dateTime)
Definition: qschematime.cpp:51
void setDate(const QDate &date)
Sets the date part of this datetime to date.
Definition: qdatetime.cpp:2399
void setTime(const QTime &time)
Sets the time part of this datetime to time.
Definition: qdatetime.cpp:2416
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
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368

◆ fromLexical()

SchemaTime::Ptr SchemaTime::fromLexical ( const QString string)
static

Creates an instance from the lexical representation string.

Definition at line 55 of file qschematime.cpp.

Referenced by QPatternist::StringToTimeCaster::castFrom().

56 {
57  static const CaptureTable captureTable( // STATIC DATA
58  /* The extra paranthesis is a build fix for GCC 3.3. */
60  "^\\s*" /* Any preceding whitespace. */
61  "(\\d{2})" /* Hour part */
62  ":" /* Delimiter. */
63  "(\\d{2})" /* Minutes part */
64  ":" /* Delimiter. */
65  "(\\d{2,})" /* Seconds part. */
66  "(?:\\.(\\d+))?" /* Milli seconds part. */
67  "(?:(\\+|-)(\\d{2}):(\\d{2})|(Z))?" /* The zone offset, "+08:24". */
68  "\\s*$" /* Any terminating whitespace. */))),
69  /*zoneOffsetSignP*/ 5,
70  /*zoneOffsetHourP*/ 6,
71  /*zoneOffsetMinuteP*/ 7,
72  /*zoneOffsetUTCSymbolP*/ 8,
73  /*yearP*/ -1,
74  /*monthP*/ -1,
75  /*dayP*/ -1,
76  /*hourP*/ 1,
77  /*minutesP*/ 2,
78  /*secondsP*/ 3,
79  /*msecondsP*/ 4);
80 
81  AtomicValue::Ptr err;
82  const QDateTime retval(create(err, lexical, captureTable));
83 
84  return err ? err : SchemaTime::Ptr(new SchemaTime(retval));
85 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QDateTime create(AtomicValue::Ptr &errorMessage, const QString &lexicalSource, const CaptureTable &captTable)
AtomicValue::Ptr Ptr
Definition: qschematime_p.h:75
SchemaTime(const QDateTime &dateTime)
Definition: qschematime.cpp:51
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ fromValue()

Item SchemaTime::fromValue ( const QDateTime dt) const
virtual

A factory function for creating instances that are of the dynamic type of this class, that represents dt.

The default implementation performs an assert() call. This function is not pure virtual because all sub-classes do not use it.

Reimplemented from QPatternist::AbstractDateTime.

Definition at line 105 of file qschematime.cpp.

106 {
107  Q_ASSERT(dt.isValid());
108  return fromDateTime(dt);
109 }
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static SchemaTime::Ptr fromDateTime(const QDateTime &dt)
Definition: qschematime.cpp:87

◆ stringValue()

QString SchemaTime::stringValue ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 111 of file qschematime.cpp.

112 {
113  return timeToString() + zoneOffsetToString();
114 }

◆ type()

ItemType::Ptr SchemaTime::type ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 116 of file qschematime.cpp.

117 {
118  return BuiltinTypes::xsTime;
119 }
static const AtomicType::Ptr xsTime

Friends and Related Functions

◆ CommonValues

friend class CommonValues
friend

Definition at line 88 of file qschematime_p.h.


The documentation for this class was generated from the following files: