/**************************************************************************
**
** This file is part of Nut project.
** https://github.com/HamedMasafi/Nut
**
** Nut is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Nut is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with Nut. If not, see .
**
**************************************************************************/
#ifndef DATEPHRASE_H
#define DATEPHRASE_H
#include "fieldphrase.h"
#include
#include
NUT_BEGIN_NAMESPACE
template
struct __is_date_helper
: public std::false_type { };
template<>
struct __is_date_helper
: public std::true_type { };
template<>
struct __is_date_helper
: public std::true_type { };
template<>
struct __is_date_helper
: public std::true_type { };
template
struct is_date
: public __is_date_helper::type>::type
{ };
template
inline bool is_valid_template() {return false;}
template <>
inline bool is_valid_template() {return true;}
template <>
inline bool is_valid_template() {return true;}
template <>
inline bool is_valid_template() {return true;}
template <>
inline bool is_valid_template() {return true;}
template
class NUT_EXPORT FieldPhrase::value>::type>
: public AbstractFieldPhrase
{
public:
FieldPhrase(const char *className, const char *s) :
AbstractFieldPhrase(className, s)
{}
AssignmentPhrase operator =(const T &other) {
return AssignmentPhrase(this, other);
}
ConditionalPhrase operator <(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::Less, other);
}
ConditionalPhrase operator <=(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::LessEqual, other);
}
ConditionalPhrase operator >(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::Greater, other);
}
ConditionalPhrase operator >=(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::GreaterEqual, other);
}
ConditionalPhrase between(const QVariant &min, const QVariant &max)
{
return ConditionalPhrase(this, PhraseData::Between,
QVariantList() << min << max);
}
// template::value, int>::type = 0>
ConditionalPhrase addYears(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddYearsDateTime, val);
return ConditionalPhrase(this, PhraseData::AddYears, val);
}
ConditionalPhrase addMonths(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddMonthsDateTime, val);
return ConditionalPhrase(this, PhraseData::AddMonths, val);
}
ConditionalPhrase addDays(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddDaysDateTime, val);
return ConditionalPhrase(this, PhraseData::AddDays, val);
}
ConditionalPhrase addHours(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddHoursDateTime, val);
return ConditionalPhrase(this, PhraseData::AddHours, val);
}
ConditionalPhrase addMinutes(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddMinutesDateTime, val);
return ConditionalPhrase(this, PhraseData::AddMinutes, val);
}
ConditionalPhrase addSeconds(int val) {
if (!is_valid_template())
return ConditionalPhrase();
if (std::is_same::value)
return ConditionalPhrase(this, PhraseData::AddSecondsDateTime, val);
return ConditionalPhrase(this, PhraseData::AddSeconds, val);
}
ConditionalPhrase year() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartYear);
}
ConditionalPhrase month() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartMonth);
}
ConditionalPhrase day() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartDay);
}
ConditionalPhrase hour() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartHour);
}
ConditionalPhrase minute() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartMinute);
}
ConditionalPhrase second() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartSecond);
}
ConditionalPhrase msec() {
if (!is_valid_template())
return ConditionalPhrase();
return ConditionalPhrase(this, PhraseData::DatePartMilisecond);
}
};
NUT_END_NAMESPACE
#endif // DATEPHRASE_H