C++ Web Framework  3.0
Public Slots | Public Member Functions | List of all members
Variant Class Reference

This class is designed to facilitate the passing of simple type parameters such as qlonglong, double, int, and QString to the CSTL (C++ Server Pages Standard Tags Library). More...

#include <variant.h>

Inheritance diagram for Variant:
Inheritance graph
[legend]

Public Slots

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. More...
 
void setInt (int value) noexcept
 Constructs a new variant with an int value.
 
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. More...
 
void setDouble (double value) noexcept
 Constructs a new variant with an double value.
 
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. More...
 
void setLongLong (qlonglong value) noexcept
 Constructs a new variant with an qlonglong value.
 
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.
 
void setString (const QString &value) noexcept
 Constructs a new variant with an QString value.
 

Public Member Functions

 Variant ()=default
 Constructs an invalid variant.
 
 Variant (int value)
 Constructs a new variant with an integer value.
 
 Variant (double value)
 Constructs a new variant with an double value.
 
 Variant (qlonglong value)
 Constructs a new variant with an qlonglong value.
 
 Variant (const QString &value)
 Constructs a new variant with an QString value.
 
 Variant (const QByteArray &value)
 Constructs a new variant and converts to QString.
 

Detailed Description

This class is designed to facilitate the passing of simple type parameters such as qlonglong, double, int, and QString to the CSTL (C++ Server Pages Standard Tags Library).

Member Function Documentation

◆ toDouble

double Variant::toDouble ( bool *  ok = nullptr) const
inlineslotnoexcept

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.

Parameters
Ifok is non-null: *ok is set to true if the value could be converted to a double; otherwise *ok is set to false.

◆ toInt

int Variant::toInt ( bool *  ok = nullptr) const
inlineslotnoexcept

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.

Warning
: If the value is convertible to a QMetaType::LongLong but is too large to be represented in an int, the resulting arithmetic overflow will not be reflected in ok. A simple workaround is to use QString::toInt()
Parameters
Ifok is non-null: *ok is set to true if the value could be converted to an int; otherwise *ok is set to false.

◆ toLongLong

qlonglong Variant::toLongLong ( bool *  ok = nullptr) const
inlineslotnoexcept

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.

Parameters
Ifok is non-null: *ok is set to true if the value could be converted to an int; otherwise *ok is set to false.

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