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

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

#include <qduration_p.h>

Inheritance diagram for QPatternist::Duration:
QPatternist::AbstractDuration QPatternist::AtomicValue QSharedData QPatternist::CppCastingHelper< AtomicValue >

Public Types

typedef AtomicValue::Ptr Ptr
 
- Public Types inherited from QPatternist::AbstractDuration
typedef QExplicitlySharedDataPointer< AbstractDurationPtr
 
typedef qint64 Value
 The amount in milli seconds. More...
 
- Public Types inherited from QPatternist::AtomicValue
typedef QList< AtomicValue::PtrList
 
typedef QExplicitlySharedDataPointer< AtomicValuePtr
 

Public Functions

virtual DayCountProperty days () const
 
virtual Item fromValue (const Value val) const
 
virtual HourProperty hours () const
 
virtual MinuteProperty minutes () const
 
virtual MonthProperty months () const
 
virtual MSecondProperty mseconds () const
 
virtual SecondProperty seconds () const
 
virtual QString stringValue () const
 
virtual ItemType::Ptr type () const
 
virtual Value value () const
 
virtual YearProperty years () const
 
- Public Functions inherited from QPatternist::AbstractDuration
bool isPositive () const
 
bool operator== (const AbstractDuration &other) 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 Duration::Ptr fromComponents (const bool isPositive, const YearProperty years, const MonthProperty months, const DayCountProperty days, const HourProperty hours, const MinuteProperty minutes, const SecondProperty seconds, const MSecondProperty mseconds)
 
static Duration::Ptr fromLexical (const QString &string)
 
- 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

 Duration (const bool isPositive, const YearProperty years, const MonthProperty months, const DayCountProperty days, const HourProperty hours, const MinuteProperty minutes, const SecondProperty seconds, const MSecondProperty mseconds)
 
- Protected Functions inherited from QPatternist::AbstractDuration
 AbstractDuration (const bool isPos)
 
- Protected Functions inherited from QPatternist::AtomicValue
 AtomicValue ()
 
- Protected Functions inherited from QPatternist::CppCastingHelper< AtomicValue >
 CppCastingHelper ()
 

Properties

const DayCountProperty m_days
 
const HourProperty m_hours
 
const MinuteProperty m_minutes
 
const MonthProperty m_months
 
const MSecondProperty m_mseconds
 
const SecondProperty m_seconds
 
const YearProperty m_years
 

Friends

class CommonValues
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::AbstractDuration
static AtomicValue::Ptr create (const CaptureTable &captTable, const QString &lexical, bool *isPositive, YearProperty *years, MonthProperty *months, DayCountProperty *days, HourProperty *hours, MinuteProperty *minutes, SecondProperty *seconds, MSecondProperty *mseconds)
 
static QString serializeMSeconds (const MSecondProperty mseconds)
 
- Protected Variables inherited from QPatternist::AbstractDuration
const bool m_isPositive
 

Detailed Description

Implements the value instance of the xs:duration type.

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

Definition at line 69 of file qduration_p.h.

Typedefs

◆ Ptr

Definition at line 72 of file qduration_p.h.

Constructors and Destructors

◆ Duration()

Duration::Duration ( const bool  isPositive,
const YearProperty  years,
const MonthProperty  months,
const DayCountProperty  days,
const HourProperty  hours,
const MinuteProperty  minutes,
const SecondProperty  seconds,
const MSecondProperty  mseconds 
)
protected

Definition at line 52 of file qduration.cpp.

Referenced by fromComponents(), and fromLexical().

59  : AbstractDuration(isPositiveP),
60  m_years(yearsP),
61  m_months(monthsP),
62  m_days(daysP),
63  m_hours(hoursP),
64  m_minutes(mins),
65  m_seconds(secs),
66  m_mseconds(msecs)
67 {
68 }
const DayCountProperty m_days
Definition: qduration_p.h:124
const SecondProperty m_seconds
Definition: qduration_p.h:127
const MinuteProperty m_minutes
Definition: qduration_p.h:126
const YearProperty m_years
Definition: qduration_p.h:122
const HourProperty m_hours
Definition: qduration_p.h:125
const MonthProperty m_months
Definition: qduration_p.h:123
const MSecondProperty m_mseconds
Definition: qduration_p.h:128

Functions

◆ days()

DayCountProperty Duration::days ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 214 of file qduration.cpp.

Referenced by fromLexical().

215 {
216  return m_days;
217 }
const DayCountProperty m_days
Definition: qduration_p.h:124

◆ fromComponents()

Duration::Ptr Duration::fromComponents ( const bool  isPositive,
const YearProperty  years,
const MonthProperty  months,
const DayCountProperty  days,
const HourProperty  hours,
const MinuteProperty  minutes,
const SecondProperty  seconds,
const MSecondProperty  mseconds 
)
static

Definition at line 113 of file qduration.cpp.

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

121 {
124 }
virtual YearProperty years() const
Definition: qduration.cpp:204
virtual HourProperty hours() const
Definition: qduration.cpp:219
Duration(const bool isPositive, const YearProperty years, const MonthProperty months, const DayCountProperty days, const HourProperty hours, const MinuteProperty minutes, const SecondProperty seconds, const MSecondProperty mseconds)
Definition: qduration.cpp:52
virtual MonthProperty months() const
Definition: qduration.cpp:209
virtual MSecondProperty mseconds() const
Definition: qduration.cpp:234
AtomicValue::Ptr Ptr
Definition: qduration_p.h:72
virtual SecondProperty seconds() const
Definition: qduration.cpp:229
virtual MinuteProperty minutes() const
Definition: qduration.cpp:224
virtual DayCountProperty days() const
Definition: qduration.cpp:214

◆ fromLexical()

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

Creates an instance from the lexical representation string.

Definition at line 70 of file qduration.cpp.

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

71 {
72  static const CaptureTable captureTable(
73  /* The extra paranthesis is a build fix for GCC 3.3. */
75  "^\\s*" /* Any preceding whitespace. */
76  "(-)?" /* Any minus sign. */
77  "P" /* Delimiter. */
78  "(?:(\\d+)Y)?" /* Year part. */
79  "(?:(\\d+)M)?" /* Month part. */
80  "(?:(\\d+)D)?" /* Day part. */
81  "(?:" /* Here starts the optional time part. */
82  "(T)" /* SchemaTime delimiter. */
83  "(?:(\\d+)H)?" /* Hour part. */
84  "(?:(\\d+)M)?" /* Minute part. */
85  "(?:(\\d+)(?:\\.(\\d+))?S)?" /* Seconds & milli seconds. */
86  ")?" /* End of optional time part. */
87  "\\s*$" /* Any terminating whitespace. */))),
88  /*yearP*/ 2,
89  /*monthP*/ 3,
90  /*dayP*/ 4,
91  /*tDelimiterP*/ 5,
92  /*hourP*/ 6,
93  /*minutesP*/ 7,
94  /*secondsP*/ 8,
95  /*msecondsP*/ 9);
96 
97  YearProperty years = 0;
100  HourProperty hours = 0;
102  SecondProperty sec = 0;
103  MSecondProperty msec = 0;
104  bool isPos;
105 
106  const AtomicValue::Ptr err(create(captureTable, lexical, &isPos, &years, &months,
107  &days, &hours, &minutes, &sec, &msec));
108 
109  return err ? err : Duration::Ptr(new Duration(isPos, years, months, days, hours,
110  minutes, sec, msec));
111 }
qint32 DayCountProperty
virtual YearProperty years() const
Definition: qduration.cpp:204
virtual HourProperty hours() const
Definition: qduration.cpp:219
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
Duration(const bool isPositive, const YearProperty years, const MonthProperty months, const DayCountProperty days, const HourProperty hours, const MinuteProperty minutes, const SecondProperty seconds, const MSecondProperty mseconds)
Definition: qduration.cpp:52
qint8 MinuteProperty
qint32 SecondProperty
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual MonthProperty months() const
Definition: qduration.cpp:209
qint8 MonthProperty
qint8 HourProperty
qint32 YearProperty
AtomicValue::Ptr Ptr
Definition: qduration_p.h:72
virtual MinuteProperty minutes() const
Definition: qduration.cpp:224
static AtomicValue::Ptr create(const CaptureTable &captTable, const QString &lexical, bool *isPositive, YearProperty *years, MonthProperty *months, DayCountProperty *days, HourProperty *hours, MinuteProperty *minutes, SecondProperty *seconds, MSecondProperty *mseconds)
qint16 MSecondProperty
virtual DayCountProperty days() const
Definition: qduration.cpp:214

◆ fromValue()

Item Duration::fromValue ( const Value  val) const
virtual

Always results in an assert crash. Calling this function makes no sense due to that the value space of xs:duration is not well defined.

Implements QPatternist::AbstractDuration.

Definition at line 133 of file qduration.cpp.

134 {
135  Q_ASSERT_X(false, Q_FUNC_INFO,
136  "Calling Duration::fromValue() makes no sense");
137  return Item();
138 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ hours()

HourProperty Duration::hours ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 219 of file qduration.cpp.

Referenced by fromLexical().

220 {
221  return m_hours;
222 }
const HourProperty m_hours
Definition: qduration_p.h:125

◆ minutes()

MinuteProperty Duration::minutes ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 224 of file qduration.cpp.

Referenced by fromLexical().

225 {
226  return m_minutes;
227 }
const MinuteProperty m_minutes
Definition: qduration_p.h:126

◆ months()

MonthProperty Duration::months ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 209 of file qduration.cpp.

Referenced by fromLexical().

210 {
211  return m_months;
212 }
const MonthProperty m_months
Definition: qduration_p.h:123

◆ mseconds()

MSecondProperty Duration::mseconds ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 234 of file qduration.cpp.

235 {
236  return m_mseconds;
237 }
const MSecondProperty m_mseconds
Definition: qduration_p.h:128

◆ seconds()

SecondProperty Duration::seconds ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 229 of file qduration.cpp.

230 {
231  return m_seconds;
232 }
const SecondProperty m_seconds
Definition: qduration_p.h:127

◆ stringValue()

QString Duration::stringValue ( ) const
virtual

Implements QPatternist::AtomicValue.

Definition at line 140 of file qduration.cpp.

141 {
142  QString retval;
143 
144  if(!m_isPositive)
145  retval.append(QLatin1Char('-'));
146 
147  retval.append(QLatin1Char('P'));
148 
149  if(m_years)
150  {
151  retval.append(QString::number(m_years));
152  retval.append(QLatin1Char('Y'));
153  }
154 
155  if(m_months)
156  {
158  retval.append(QLatin1Char('M'));
159  }
160 
161  if(m_days)
162  {
163  retval.append(QString::number(m_days));
164  retval.append(QLatin1Char('D'));
165  }
166 
167  if(!m_hours && !m_minutes && !m_seconds && !m_seconds)
168  {
169  if(!m_years && !m_months && !m_days)
170  return QLatin1String("PT0S");
171  else
172  return retval;
173  }
174 
175  retval.append(QLatin1Char('T'));
176 
177  if(m_hours)
178  {
179  retval.append(QString::number(m_hours));
180  retval.append(QLatin1Char('H'));
181  }
182 
183  if(m_minutes)
184  {
186  retval.append(QLatin1Char('M'));
187  }
188 
189  if(m_seconds || m_seconds)
190  {
192 
193  if(m_mseconds)
195 
196  retval.append(QLatin1Char('S'));
197  }
198  else if(!m_years && !m_months && !m_days && !m_hours && !m_minutes)
199  retval.append(QLatin1String("0S"));
200 
201  return retval;
202 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
const DayCountProperty m_days
Definition: qduration_p.h:124
const SecondProperty m_seconds
Definition: qduration_p.h:127
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const MinuteProperty m_minutes
Definition: qduration_p.h:126
QString & append(QChar c)
Definition: qstring.cpp:1777
const YearProperty m_years
Definition: qduration_p.h:122
const HourProperty m_hours
Definition: qduration_p.h:125
const MonthProperty m_months
Definition: qduration_p.h:123
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const MSecondProperty m_mseconds
Definition: qduration_p.h:128
static QString serializeMSeconds(const MSecondProperty mseconds)

◆ type()

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

Implements QPatternist::AtomicValue.

Definition at line 239 of file qduration.cpp.

240 {
242 }
static const AtomicType::Ptr xsDuration

◆ value()

AbstractDuration::Value Duration::value ( ) const
virtual

Always results in an assert crash. Calling this function makes no sense due to that the value space of xs:duration is not well defined.

Implements QPatternist::AbstractDuration.

Definition at line 126 of file qduration.cpp.

127 {
128  Q_ASSERT_X(false, Q_FUNC_INFO,
129  "Calling Duration::value() makes no sense");
130  return 0;
131 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ years()

YearProperty Duration::years ( ) const
virtual

Implements QPatternist::AbstractDuration.

Definition at line 204 of file qduration.cpp.

Referenced by fromLexical().

205 {
206  return m_years;
207 }
const YearProperty m_years
Definition: qduration_p.h:122

Friends and Related Functions

◆ CommonValues

friend class CommonValues
friend

Definition at line 111 of file qduration_p.h.

Properties

◆ m_days

const DayCountProperty QPatternist::Duration::m_days
private

Definition at line 124 of file qduration_p.h.

Referenced by days(), and stringValue().

◆ m_hours

const HourProperty QPatternist::Duration::m_hours
private

Definition at line 125 of file qduration_p.h.

Referenced by hours(), and stringValue().

◆ m_minutes

const MinuteProperty QPatternist::Duration::m_minutes
private

Definition at line 126 of file qduration_p.h.

Referenced by minutes(), and stringValue().

◆ m_months

const MonthProperty QPatternist::Duration::m_months
private

Definition at line 123 of file qduration_p.h.

Referenced by months(), and stringValue().

◆ m_mseconds

const MSecondProperty QPatternist::Duration::m_mseconds
private

Definition at line 128 of file qduration_p.h.

Referenced by mseconds(), and stringValue().

◆ m_seconds

const SecondProperty QPatternist::Duration::m_seconds
private

Definition at line 127 of file qduration_p.h.

Referenced by seconds(), and stringValue().

◆ m_years

const YearProperty QPatternist::Duration::m_years
private

Definition at line 122 of file qduration_p.h.

Referenced by stringValue(), and years().


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