QtGStreamer 1.2.0
|
#include <QGlib/Value>
Public Member Functions | |
Value () | |
Value (const GValue *gvalue) | |
Value (Type type) | |
Value (bool val) | |
Value (char val) | |
Value (uchar val) | |
Value (int val) | |
Value (uint val) | |
Value (long val) | |
Value (ulong val) | |
Value (qint64 val) | |
Value (quint64 val) | |
Value (float val) | |
Value (double val) | |
Value (const char *val) | |
Value (const QByteArray &val) | |
Value (const QString &val) | |
Value (const Value &other) | |
Value & | operator= (const Value &other) |
void | init (Type type) |
template<typename T > | |
void | init () |
bool | isValid () const |
Type | type () const |
bool | canTransformTo (Type type) const |
Value | transformTo (Type type) const |
void | clear () |
template<typename T > | |
T | get (bool *ok=NULL) const |
template<typename T > | |
void | set (const T &data) |
bool | toBool (bool *ok=NULL) const |
char | toChar (bool *ok=NULL) const |
uchar | toUChar (bool *ok=NULL) const |
int | toInt (bool *ok=NULL) const |
uint | toUInt (bool *ok=NULL) const |
long | toLong (bool *ok=NULL) const |
ulong | toULong (bool *ok=NULL) const |
qint64 | toInt64 (bool *ok=NULL) const |
quint64 | toUInt64 (bool *ok=NULL) const |
QByteArray | toByteArray (bool *ok=NULL) const |
QString | toString (bool *ok=NULL) const |
Error | toError (bool *ok=NULL) const |
operator GValue * () | |
operator const GValue * () const | |
Static Public Member Functions | |
template<typename T > | |
static Value | create (const T &data) |
static void | registerValueVTable (Type type, const ValueVTable &vtable) |
Related Symbols | |
(Note that these are not member symbols.) | |
QDebug | operator<< (QDebug debug, const Value &value) |
Wrapper class for GValue.
This class serves as a wrapper for GValue. GValue is a data type that can hold different types of values inside, like a QVariant.
A Value object holds a single value of a single type() at a time. To create a new Value, use the static create() method or one of the constructors. To get the held value, use the template get() method or one of the toT() functions (ex. toInt()).
To set a value to an invalid Value (on which isValid() returns false), you must first initialize this Value using one of the init() methods (preferably the template one) in order to tell it what kind of value it is going to hold. Once initialized to hold a specific type, you can use the set() method to set a value. To change the type that this value holds, you can call the init() method again at any time. In this case, though, any previously held value will be lost.
QGlib::Value::Value | ( | ) |
|
explicit |
|
explicit |
QGlib::Value::Value | ( | bool | val | ) |
Creates a new Value of Type::Bool and sets it to hold val.
QGlib::Value::Value | ( | char | val | ) |
Creates a new Value of Type::Char and sets it to hold val.
QGlib::Value::Value | ( | uchar | val | ) |
Creates a new Value of Type::Uchar and sets it to hold val.
QGlib::Value::Value | ( | int | val | ) |
Creates a new Value of Type::Int and sets it to hold val.
QGlib::Value::Value | ( | uint | val | ) |
Creates a new Value of Type::Uint and sets it to hold val.
QGlib::Value::Value | ( | long | val | ) |
Creates a new Value of Type::Long and sets it to hold val.
QGlib::Value::Value | ( | ulong | val | ) |
Creates a new Value of Type::Ulong and sets it to hold val.
QGlib::Value::Value | ( | qint64 | val | ) |
Creates a new Value of Type::Int64 and sets it to hold val.
QGlib::Value::Value | ( | quint64 | val | ) |
Creates a new Value of Type::Uint64 and sets it to hold val.
QGlib::Value::Value | ( | float | val | ) |
Creates a new Value of Type::Float and sets it to hold val.
QGlib::Value::Value | ( | double | val | ) |
Creates a new Value of Type::Double and sets it to hold val.
QGlib::Value::Value | ( | const char * | val | ) |
Creates a new Value of Type::String and sets it to hold val.
QGlib::Value::Value | ( | const QByteArray & | val | ) |
Creates a new Value of Type::String and sets it to hold val.
QGlib::Value::Value | ( | const QString & | val | ) |
Creates a new Value of Type::String and sets it to hold val.
|
inlinestatic |
void QGlib::Value::init | ( | Type | type | ) |
|
inline |
bool QGlib::Value::isValid | ( | ) | const |
Type QGlib::Value::type | ( | ) | const |
bool QGlib::Value::canTransformTo | ( | Type | type | ) | const |
void QGlib::Value::clear | ( | ) |
T QGlib::Value::get | ( | bool * | ok = NULL | ) | const |
Retrieves the value stored in this Value instance, as the specified type T. The bindings take care of calling the appropriate g_value_get_* method depending on the type T. Note though that this is only meant to be used with the types of the bindings, not their C types. This means that if for example the Value has been initialized to hold a GstObject pointer, you can use:
but not this:
If the underlying stored value is not of the type T, this method will attempt to convert it to type T. If this is not possible, a default constructed value will be returned.
If ok has been specified, it is set to true if the value was retrieved successfully or false if there was an error (probably conversion error) and a default constructed value has been returned.
void QGlib::Value::set | ( | const T & | data | ) |
Sets this Value instance to hold the specified data. As with get(), the bindings take care of calling the appropriate g_value_set_* method depending on the type T, but note that this is only meant to be used with the types of the bindings.
If this Value instance has been initialized to hold a different type of data than T, a conversion to the correct type() will be attempted. If the conversion fails, the Value will remain unaffected and a warning will be printed.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the held value as a QGlib::Error. Equivalent to get<QGlib::Error>(ok);
QGlib::Value::operator GValue * | ( | ) |
This is a cast operator that gives access to the underlying GValue instance. It is provided for convenience, to be able to pass this Value as argument to C functions that expect a GValue pointer. Use this feature with care. Do not store the pointer, as it may go away at any time. This Value instance keeps control of this pointer. If you need to store it, use g_value_copy() to copy it first.
QGlib::Value::operator const GValue * | ( | ) | const |
|
static |
Registers the given ValueVTable vtable for the given type. This is provided to let you add support for a custom type, if necessary. You should normally not need to do that, as most types are handled by the handlers of their parent types.
|
related |