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

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

#include <qgyearmonth_p.h>

Inheritance diagram for QPatternist::GYearMonth:
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 QString stringValue () const
 
virtual ItemType::Ptr type () const
 
- Public Functions inherited from QPatternist::AbstractDateTime
 AbstractDateTime (const QDateTime &dateTime)
 
QString dateToString () const
 
virtual Item fromValue (const QDateTime &dt) 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 GYearMonth::Ptr fromDateTime (const QDateTime &dt)
 
static GYearMonth::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

 GYearMonth (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:gYearMonth type.

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

Definition at line 69 of file qgyearmonth_p.h.

Typedefs

◆ Ptr

Definition at line 72 of file qgyearmonth_p.h.

Constructors and Destructors

◆ GYearMonth()

GYearMonth::GYearMonth ( const QDateTime dateTime)
protected

Definition at line 50 of file qgyearmonth.cpp.

Referenced by fromDateTime(), and fromLexical().

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

Functions

◆ fromDateTime()

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

Definition at line 85 of file qgyearmonth.cpp.

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

86 {
87  QDateTime result(QDate(dt.date().year(), dt.date().month(), DefaultDay));
88  copyTimeSpec(dt, result);
89 
90  return GYearMonth::Ptr(new GYearMonth(result));
91 }
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
The QDate class provides date functions.
Definition: qdatetime.h:55
GYearMonth(const QDateTime &dateTime)
Definition: qgyearmonth.cpp:50
static void copyTimeSpec(const QDateTime &from, QDateTime &to)
Makes the QDateTime::timeSpec() and QDateTime::zoneOffset() of ot * consistent to from...
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
AtomicValue::Ptr Ptr
Definition: qgyearmonth_p.h:72
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353

◆ fromLexical()

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

Creates an instance from the lexical representation string.

Definition at line 54 of file qgyearmonth.cpp.

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

55 {
56  static const CaptureTable captureTable( // STATIC DATA
57  /* The extra paranthesis is a build fix for GCC 3.3. */
59  "^\\s*" /* Any preceding whitespace. */
60  "(-?)" /* Any preceding minus. */
61  "(\\d{4,})" /* The year part. */
62  "-" /* Delimiter. */
63  "(\\d{2})" /* The month part. */
64  "(?:(\\+|-)(\\d{2}):(\\d{2})|(Z))?" /* The zone offset, "+08:24". */
65  "\\s*$" /* Any terminating whitespace. */))),
66  /*zoneOffsetSignP*/ 4,
67  /*zoneOffsetHourP*/ 5,
68  /*zoneOffsetMinuteP*/ 6,
69  /*zoneOffsetUTCSymbolP*/ 7,
70  /*yearP*/ 2,
71  /*monthP*/ 3,
72  /*dayP*/ -1,
73  /*hourP*/ -1,
74  /*minutesP*/ -1,
75  /*secondsP*/ -1,
76  /*msecondsP*/ -1,
77  /*yearSign*/ 1);
78 
79  AtomicValue::Ptr err;
80  const QDateTime retval(create(err, lexical, captureTable));
81 
82  return err ? err : GYearMonth::Ptr(new GYearMonth(retval));
83 }
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)
GYearMonth(const QDateTime &dateTime)
Definition: qgyearmonth.cpp:50
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
AtomicValue::Ptr Ptr
Definition: qgyearmonth_p.h:72

◆ stringValue()

QString GYearMonth::stringValue ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 93 of file qgyearmonth.cpp.

94 {
95  return m_dateTime.toString(QLatin1String("yyyy-MM")) + zoneOffsetToString();
96 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628

◆ type()

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

Implements QPatternist::AtomicValue.

Definition at line 98 of file qgyearmonth.cpp.

99 {
101 }
static const AtomicType::Ptr xsGYearMonth

Friends and Related Functions

◆ CommonValues

friend class CommonValues
friend

Definition at line 84 of file qgyearmonth_p.h.


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