42 #include <QStringList> 58 #define error(msg) return ValidationError::createError(msg); 59 #define getCapt(sym) ((captTable.sym == -1) ? QString() : capts.at(captTable.sym)) 93 if(
getCapt(tDelimiter).isEmpty())
97 (!years &&
getCapt(day).isEmpty()))
99 error(QtXmlPatterns::tr(
"At least one component must be present."));
107 error(QtXmlPatterns::tr(
"At least one time component must appear " 108 "after the %1-delimiter.")
114 error(QtXmlPatterns::tr(
"At least one component must be present."));
118 *isPositive = capts.at(1).isEmpty();
128 hourCount =
getCapt(hour).toInt();
129 minCount =
getCapt(minutes).toInt();
130 secCount =
getCapt(seconds).toInt();
136 *mseconds = msecondsStr.
toInt();
140 minCount += secCount / 60;
141 *seconds = secCount % 60;
148 hourCount += minCount / 60;
149 *minutes = minCount % 60;
156 *days += hourCount / 24;
157 *hours = hourCount % 24;
169 *years =
getCapt(year).toInt();
170 monthCount =
getCapt(month).toInt();
174 *years += monthCount / 12;
175 *months = monthCount % 12;
178 *months = monthCount;
QExplicitlySharedDataPointer< AtomicValue > Ptr
virtual SecondProperty seconds() const =0
#define QT_END_NAMESPACE
This macro expands to.
Base class for classes implementing durations.
The QRegExp class provides pattern matching using regular expressions.
QString formatKeyword(const QString &keyword)
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
qint32 MinuteCountProperty
virtual MinuteProperty minutes() const =0
QString leftJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size width that contains this string padded by the fill character.
qint32 MonthCountProperty
The QString class provides a Unicode character string.
virtual MonthProperty months() const =0
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool isEmpty(const char *str)
virtual DayCountProperty days() const =0
QStringList capturedTexts() const
Returns a list of the captured text strings.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
The namespace for the internal API of QtXmlPatterns.
virtual HourProperty hours() const =0
virtual YearProperty years() const =0
QString & append(QChar c)
Contains functions used for formatting arguments, such as keywords and paths, in translated strings...
AbstractDuration(const bool isPos)
bool operator==(const AbstractDuration &other) const
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
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)
Acts as a mapping table for AbstractDuration::create() and describes where certain fields in a QRegEx...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
qint32 SecondCountProperty
virtual MSecondProperty mseconds() const =0
static QString serializeMSeconds(const MSecondProperty mseconds)