swift
Classes | Macros | Enumerations | Functions
Metaclass system

Compile-time reflection toolkit for iterating over members of value classes. More...

Classes

struct  swift::misc::MetaFlags< F >
 Type wrapper for passing MetaFlag to CMetaMember::has. More...
 
struct  swift::misc::CMetaMember< M, Flags >
 Literal aggregate type representing attributes of one member of a value class. More...
 
struct  swift::misc::CMetaMemberList< Members >
 Literal aggregate type representing attributes of the members of a value class. More...
 
class  swift::misc::CMetaClass
 Base class for meta classes. More...
 
class  swift::misc::CMetaClassIntrospector< MetaClass >
 An introspector for a metaclass. More...
 

Macros

#define SWIFT_METACLASS(CLASS, ...)
 Macro to define a nested metaclass that describes the attributes of its enclosing class. More...
 
#define SWIFT_METAMEMBER(MEMBER, ...)   makeMetaMember(&Class::m_##MEMBER, #MEMBER SWIFT_TRAILING_VA_ARGS(__VA_ARGS__))
 Macro to define an element within a metaclass. More...
 
#define SWIFT_METAMEMBER_NAMED(MEMBER, NAME, ...)    makeMetaMember(&Class::m_##MEMBER, NAME SWIFT_TRAILING_VA_ARGS(__VA_ARGS__))
 Same as SWIFT_METAMEMBER but the second parameter is a string literal containing the JSON name of the member.
 

Enumerations

enum  swift::misc::MetaFlag {
  swift::misc::DisabledForComparison = 1 << 0 , swift::misc::DisabledForMarshalling = 1 << 1 , swift::misc::DisabledForDebugging = 1 << 2 , swift::misc::DisabledForHashing = 1 << 3 ,
  swift::misc::DisabledForJson = 1 << 4 , swift::misc::CaseInsensitiveComparison = 1 << 5 , swift::misc::LosslessMarshalling = 1 << 6 , swift::misc::RequiredForJson = 1 << 7
}
 Metadata flags attached to members of a meta class. More...
 

Functions

template<quint64 A, quint64 B>
constexpr MetaFlags< A|B > swift::misc::operator| (MetaFlags< A >, MetaFlags< B >)
 Compile-time union of MetaFlags.
 
template<quint64 A, quint64 B>
constexpr MetaFlags< A &B > swift::misc::operator& (MetaFlags< A >, MetaFlags< B >)
 Compile-time intersection of MetaFlags.
 
template<typename T >
constexpr auto swift::misc::introspect ()
 Obtain the CMetaClassIntrospector for the metaclass of T. More...
 

Detailed Description

Compile-time reflection toolkit for iterating over members of value classes.

Macro Definition Documentation

◆ SWIFT_METACLASS

#define SWIFT_METACLASS (   CLASS,
  ... 
)
Value:
friend struct swift::misc::private_ns::CMetaClassAccessor; \
struct MetaClass : public swift::misc::CMetaClass \
{ \
using Class = CLASS; \
SWIFT_NO_EXPORT_CONSTEXPR static auto getMemberList() { return makeMetaMemberList(__VA_ARGS__); } \
}
Base class for meta classes.
Definition: metaclass.h:218

Macro to define a nested metaclass that describes the attributes of its enclosing class.

Use in the private section of the class.

Template Parameters
CLASSThe name of the class containing the member.
Note
A semicolon is needed at the end.

Definition at line 53 of file metaclass.h.

◆ SWIFT_METAMEMBER

#define SWIFT_METAMEMBER (   MEMBER,
  ... 
)    makeMetaMember(&Class::m_##MEMBER, #MEMBER SWIFT_TRAILING_VA_ARGS(__VA_ARGS__))

Macro to define an element within a metaclass.

Additional arguments can be supplied in the variadic part, which will be forwarded to CMetaClass::makeMetaMember.

Template Parameters
MEMBERThe name of the member without m_ part.
See also
SWIFT_METACLASS
SWIFT_METAMEMBER_NAMED
swift::misc::CMetaClass::makeMetaMember

Definition at line 73 of file metaclass.h.

Enumeration Type Documentation

◆ MetaFlag

Metadata flags attached to members of a meta class.

Enumerator
DisabledForComparison 

Element will be ignored by compare() and comparison operators.

DisabledForMarshalling 

Element will be ignored during DBus and QDataStream marshalling.

DisabledForDebugging 

Element will be ignored when streaming to QDebug.

DisabledForHashing 

Element will be ignored by qHash()

DisabledForJson 

Element will be ignored during JSON serialization.

CaseInsensitiveComparison 

Element will be compared case insensitively (must be a QString)

LosslessMarshalling 

Element marshalling will preserve data at the expense of size.

RequiredForJson 

Element is required when parsing from JSON.

Definition at line 200 of file metaclass.h.

Function Documentation

◆ introspect()

template<typename T >
constexpr auto swift::misc::introspect ( )
constexpr

Obtain the CMetaClassIntrospector for the metaclass of T.

Returns
swift::misc::CMetaClassIntrospector

Definition at line 287 of file metaclass.h.