NuriaProject Framework
0.1
The NuriaProject Framework
|
The MetaField class lets you access fields of types. More...
#include <metaobject.hpp>
Public Types | |
enum | Access { NoAccess = 0x00, ReadOnly = 0x01, WriteOnly = 0x02, ReadWrite = ReadOnly | WriteOnly } |
Public Member Functions | |
MetaField () | |
Access | access () const |
MetaAnnotation | annotation (int idx) const |
int | annotationCount () const |
int | annotationLowerBound (const QByteArray &name) const |
int | annotationUpperBound (const QByteArray &name) const |
bool | isValid () const |
QByteArray | name () const |
QVariant | read (void *instance) const |
QByteArray | typeName () const |
bool | write (void *instance, const QVariant &value) |
Friends | |
class | MetaObject |
The MetaField class lets you access fields of types.
A new value is only set if the condition is true
. If it doesn't, write() fails and nothing happens.
Please see MetaObject for further information on NURIA_REQUIRE.
The getter must return the field value and may take optional arguments. The setter must take the field value as first argument and may take additional optional arguments. A setter is allowed to return either void or bool. In the latter case, a result value of true
indicates success and false
indicates failure. This is passed through to the caller through write().
Accessor methods won't be exposed as usual methods. Custom annotations tacked to accessor methods are applied to the field.
Access right flags.
Nuria::MetaField::MetaField | ( | ) |
Creates a invalid instance.
Access Nuria::MetaField::access | ( | ) | const |
Returns access flags for this field.
MetaAnnotation Nuria::MetaField::annotation | ( | int | idx | ) | const |
Returns the MetaAnnotation instance for the annotation at idx.
int Nuria::MetaField::annotationCount | ( | ) | const |
Returns the number of known annotations.
int Nuria::MetaField::annotationLowerBound | ( | const QByteArray & | name | ) | const |
Returns the index of the first annotation name. Returns -1
if there's no annotation called like that.
int Nuria::MetaField::annotationUpperBound | ( | const QByteArray & | name | ) | const |
Returns the index of the last annotation name. Returns -1
if there's no annotation called like that.
bool Nuria::MetaField::isValid | ( | ) | const |
Returns true
if this instance is valid.
QByteArray Nuria::MetaField::name | ( | ) | const |
Returns the name of the field.
QVariant Nuria::MetaField::read | ( | void * | instance | ) | const |
Attempts to read the current value from instance.
QByteArray Nuria::MetaField::typeName | ( | ) | const |
Returns the type name of the field.
bool Nuria::MetaField::write | ( | void * | instance, |
const QVariant & | value | ||
) |
Attempts to set the current value int instance. On failure false
is returned.