13 #include "cppwebframework_global.h" 20 class CPPWEBFRAMEWORKSHARED_EXPORT
Variant :
public QObject
32 explicit Variant(
int value) : variant(value) {}
36 explicit Variant(
double value) : variant(value) {}
40 explicit Variant(qlonglong value) : variant(value) {}
44 explicit Variant(
const QString &value) : variant(value) {}
48 explicit Variant(
const QByteArray &value) : variant(QString(value)) {}
55 inline int toInt(
bool *ok =
nullptr) const noexcept {
return variant.toInt(ok); }
59 inline void setInt(
int value) noexcept { variant = value; }
64 inline double toDouble(
bool *ok =
nullptr) const noexcept {
return variant.toDouble(ok); }
68 inline void setDouble(
double value) noexcept { variant = value; }
73 inline qlonglong
toLongLong(
bool *ok =
nullptr) const noexcept {
return variant.toLongLong(ok); }
77 inline void setLongLong(qlonglong value) noexcept { variant = value; }
81 inline QString
toString() const noexcept {
return variant.toString(); }
85 inline void setString(
const QString &value) noexcept { variant = value; }
Variant(int value)
Constructs a new variant with an integer value.
Definition: variant.h:32
Variant(double value)
Constructs a new variant with an double value.
Definition: variant.h:36
This class is designed to facilitate the passing of simple type parameters such as qlonglong...
Definition: variant.h:20
Variant(const QString &value)
Constructs a new variant with an QString value.
Definition: variant.h:44
void setDouble(double value) noexcept
Constructs a new variant with an double value.
Definition: variant.h:68
void setString(const QString &value) noexcept
Constructs a new variant with an QString value.
Definition: variant.h:85
double toDouble(bool *ok=nullptr) const noexcept
Returns the variant as a double if the variant has userType() QMetaType::Double, QMetaType::Float, QMetaType::Bool, QMetaType::QByteArray, QMetaType::Int, QMetaType::LongLong, QMetaType::QString, QMetaType::UInt, or QMetaType::ULongLong; otherwise returns 0.0.
Definition: variant.h:64
QString toString() const noexcept
Returns the variant as a QString if the variant has userType() QMetaType::QString, QMetaType::Bool, QMetaType::QByteArray, QMetaType::QChar, QMetaType::QDate, QMetaType::QDateTime, QMetaType::Double, QMetaType::Int, QMetaType::LongLong, QMetaType::QStringList, QMetaType::QTime, QMetaType::UInt, or QMetaType::ULongLong; otherwise returns an empty string.
Definition: variant.h:81
void setInt(int value) noexcept
Constructs a new variant with an int value.
Definition: variant.h:59
int toInt(bool *ok=nullptr) const noexcept
Returns the variant as an int if the variant has userType() QMetaType::Int, QMetaType::Bool, QMetaType::QByteArray, QMetaType::QChar, QMetaType::Double, QMetaType::LongLong, QMetaType::QString, QMetaType::UInt, or QMetaType::ULongLong; otherwise returns 0.
Definition: variant.h:55
Variant(const QByteArray &value)
Constructs a new variant and converts to QString.
Definition: variant.h:48
void setLongLong(qlonglong value) noexcept
Constructs a new variant with an qlonglong value.
Definition: variant.h:77
qlonglong toLongLong(bool *ok=nullptr) const noexcept
Returns the variant as a long long int if the variant has userType() QMetaType::LongLong, QMetaType::Bool, QMetaType::QByteArray, QMetaType::QChar, QMetaType::Double, QMetaType::Int, QMetaType::QString, QMetaType::UInt, or QMetaType::ULongLong; otherwise returns 0.
Definition: variant.h:73
Variant(qlonglong value)
Constructs a new variant with an qlonglong value.
Definition: variant.h:40