Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | Friends | List of all members
QMetaObjectBuilder Class Reference

#include <qmetaobjectbuilder_p.h>

Public Types

enum  AddMember {
  ClassName = 0x00000001, SuperClass = 0x00000002, Methods = 0x00000004, Signals = 0x00000008,
  Slots = 0x00000010, Constructors = 0x00000020, Properties = 0x00000040, Enumerators = 0x00000080,
  ClassInfos = 0x00000100, RelatedMetaObjects = 0x00000200, StaticMetacall = 0x00000400, PublicMethods = 0x00000800,
  ProtectedMethods = 0x00001000, PrivateMethods = 0x00002000, AllMembers = 0x7FFFFFFF, AllPrimaryMembers = 0x7FFFFBFC
}
 This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject() More...
 
enum  MetaObjectFlag { DynamicMetaObject = 0x01 }
 
typedef QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction
 Typedef for static metacall functions. More...
 

Public Functions

int addClassInfo (const QByteArray &name, const QByteArray &value)
 Adds name and value as an item of class information to this class. More...
 
QMetaMethodBuilder addConstructor (const QByteArray &signature)
 Adds a new constructor to this class with the specified signature. More...
 
QMetaMethodBuilder addConstructor (const QMetaMethod &prototype)
 Adds a new constructor to this class that has the same information as prototype. More...
 
QMetaEnumBuilder addEnumerator (const QByteArray &name)
 Adds a new enumerator to this class with the specified name. More...
 
QMetaEnumBuilder addEnumerator (const QMetaEnum &prototype)
 Adds a new enumerator to this class that has the same information as prototype. More...
 
void addMetaObject (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members=AllMembers)
 Adds the contents of prototype to this meta object builder. More...
 
QMetaMethodBuilder addMethod (const QByteArray &signature)
 Adds a new public method to this class with the specified signature. More...
 
QMetaMethodBuilder addMethod (const QByteArray &signature, const QByteArray &returnType)
 Adds a new public method to this class with the specified signature and returnType. More...
 
QMetaMethodBuilder addMethod (const QMetaMethod &prototype)
 Adds a new public method to this class that has the same information as prototype. More...
 
QMetaPropertyBuilder addProperty (const QByteArray &name, const QByteArray &type, int notifierId=-1)
 Adds a new readable/writable property to this class with the specified name and type. More...
 
QMetaPropertyBuilder addProperty (const QMetaProperty &prototype)
 Adds a new property to this class that has the same information as prototype. More...
 
int addRelatedMetaObject (const QMetaObject *meta)
 Adds meta to this class as a related meta object. More...
 
QMetaMethodBuilder addSignal (const QByteArray &signature)
 Adds a new signal to this class with the specified signature. More...
 
QMetaMethodBuilder addSlot (const QByteArray &signature)
 Adds a new public slot to this class with the specified signature. More...
 
int classInfoCount () const
 Returns the number of items of class information in this class, exclusing the number of items of class information in the base class. More...
 
QByteArray classInfoName (int index) const
 Returns the name of the item of class information at index in this class. More...
 
QByteArray classInfoValue (int index) const
 Returns the value of the item of class information at index in this class. More...
 
QByteArray className () const
 Returns the name of the class being constructed by this meta object builder. More...
 
QMetaMethodBuilder constructor (int index) const
 Returns the constructor at index in this class. More...
 
int constructorCount () const
 Returns the number of constructors in this class. More...
 
void deserialize (QDataStream &stream, const QMap< QByteArray, const QMetaObject *> &references)
 Deserializes a meta object builder from stream into this meta object builder. More...
 
QMetaEnumBuilder enumerator (int index) const
 Returns the enumerator at index in this class. More...
 
int enumeratorCount () const
 Returns the number of enumerators in this class, excluding the number of enumerators in the base class. More...
 
MetaObjectFlags flags () const
 Returns the flags of the class being constructed by this meta object builder. More...
 
int indexOfClassInfo (const QByteArray &name)
 Finds an item of class information with the specified name and returns its index; otherwise returns -1. More...
 
int indexOfConstructor (const QByteArray &signature)
 Finds a constructor with the specified signature and returns its index; otherwise returns -1. More...
 
int indexOfEnumerator (const QByteArray &name)
 Finds an enumerator with the specified name and returns its index; otherwise returns -1. More...
 
int indexOfMethod (const QByteArray &signature)
 Finds a method with the specified signature and returns its index; otherwise returns -1. More...
 
int indexOfProperty (const QByteArray &name)
 Finds a property with the specified name and returns its index; otherwise returns -1. More...
 
int indexOfSignal (const QByteArray &signature)
 Finds a signal with the specified signature and returns its index; otherwise returns -1. More...
 
int indexOfSlot (const QByteArray &signature)
 Finds a slot with the specified signature and returns its index; otherwise returns -1. More...
 
QMetaMethodBuilder method (int index) const
 Returns the method at index in this class. More...
 
int methodCount () const
 Returns the number of methods in this class, excluding the number of methods in the base class. More...
 
QMetaPropertyBuilder property (int index) const
 Returns the property at index in this class. More...
 
int propertyCount () const
 Returns the number of properties in this class, excluding the number of properties in the base class. More...
 
 QMetaObjectBuilder ()
 Constructs a new QMetaObjectBuilder. More...
 
 QMetaObjectBuilder (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members=AllMembers)
 Constructs a new QMetaObjectBuilder which is a copy of the meta object information in prototype. More...
 
const QMetaObjectrelatedMetaObject (int index) const
 Returns the related meta object at index in this class. More...
 
int relatedMetaObjectCount () const
 Returns the number of related meta objects that are associated with this class. More...
 
void removeClassInfo (int index)
 Removes the item of class information at index from this class. More...
 
void removeConstructor (int index)
 Removes the constructor at index from this class. More...
 
void removeEnumerator (int index)
 Removes the enumerator at index from this class. More...
 
void removeMethod (int index)
 Removes the method at index from this class. More...
 
void removeProperty (int index)
 Removes the property at index from this class. More...
 
void removeRelatedMetaObject (int index)
 Removes the related meta object at index from this class. More...
 
void serialize (QDataStream &stream) const
 Serializes the contents of the meta object builder onto stream. More...
 
void setClassName (const QByteArray &name)
 Sets the name of the class being constructed by this meta object builder. More...
 
void setFlags (MetaObjectFlags)
 Sets the flags of the class being constructed by this meta object builder. More...
 
void setStaticMetacallFunction (QMetaObjectBuilder::StaticMetacallFunction value)
 Sets the static metacall function to use to construct objects of this class to value. More...
 
void setSuperClass (const QMetaObject *meta)
 Sets the superclass meta object of the class being constructed by this meta object builder to meta. More...
 
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction () const
 Returns the static metacall function to use to construct objects of this class. More...
 
const QMetaObjectsuperClass () const
 Returns the superclass meta object of the class being constructed by this meta object builder. More...
 
QMetaObjecttoMetaObject () const
 Converts this meta object builder into a concrete QMetaObject. More...
 
QByteArray toRelocatableData (bool *=0) const
 
virtual ~QMetaObjectBuilder ()
 Destroys this meta object builder. More...
 

Static Public Functions

static void fromRelocatableData (QMetaObject *, const QMetaObject *, const QByteArray &)
 

Properties

QMetaObjectBuilderPrivated
 

Friends

class QMetaEnumBuilder
 
class QMetaMethodBuilder
 
class QMetaPropertyBuilder
 

Detailed Description

Warning
This function is not part of the public interface.
Note
The QMetaObjectBuilder class supports building QMetaObject objects at runtime.

Definition at line 73 of file qmetaobjectbuilder_p.h.

Typedefs

◆ StaticMetacallFunction

Typedef for static metacall functions.

The three parameters are the call type value, the constructor index, and the array of parameters.

Definition at line 172 of file qmetaobjectbuilder_p.h.

Enumerations

◆ AddMember

This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject()

  • ClassName Add the class name.
  • SuperClass Add the super class.
  • Methods Add methods that aren't signals or slots.
  • Signals Add signals.
  • Slots Add slots.
  • Constructors Add constructors.
  • Properties Add properties.
  • Enumerators Add enumerators.
  • ClassInfos Add items of class information.
  • RelatedMetaObjects Add related meta objects.
  • StaticMetacall Add the static metacall function.
  • PublicMethods Add public methods (ignored for signals).
  • ProtectedMethods Add protected methods (ignored for signals).
  • PrivateMethods All private methods (ignored for signals).
  • AllMembers Add all members.
  • AllPrimaryMembers Add everything except the class name, super class, and static metacall function.
Enumerator
ClassName 
SuperClass 
Methods 
Signals 
Slots 
Constructors 
Properties 
Enumerators 
ClassInfos 
RelatedMetaObjects 
StaticMetacall 
PublicMethods 
ProtectedMethods 
PrivateMethods 
AllMembers 
AllPrimaryMembers 

Definition at line 76 of file qmetaobjectbuilder_p.h.

77  {
78  ClassName = 0x00000001,
79  SuperClass = 0x00000002,
80  Methods = 0x00000004,
81  Signals = 0x00000008,
82  Slots = 0x00000010,
83  Constructors = 0x00000020,
84  Properties = 0x00000040,
85  Enumerators = 0x00000080,
86  ClassInfos = 0x00000100,
87  RelatedMetaObjects = 0x00000200,
88  StaticMetacall = 0x00000400,
89  PublicMethods = 0x00000800,
90  ProtectedMethods = 0x00001000,
91  PrivateMethods = 0x00002000,
92  AllMembers = 0x7FFFFFFF,
93  AllPrimaryMembers = 0x7FFFFBFC
94  };

◆ MetaObjectFlag

Enumerator
DynamicMetaObject 

Definition at line 97 of file qmetaobjectbuilder_p.h.

Constructors and Destructors

◆ QMetaObjectBuilder() [1/2]

QMetaObjectBuilder::QMetaObjectBuilder ( )

Constructs a new QMetaObjectBuilder.

Definition at line 281 of file qmetaobjectbuilder.cpp.

282 {
284 }
QMetaObjectBuilderPrivate * d

◆ QMetaObjectBuilder() [2/2]

QMetaObjectBuilder::QMetaObjectBuilder ( const QMetaObject prototype,
QMetaObjectBuilder::AddMembers  members = AllMembers 
)
explicit

Constructs a new QMetaObjectBuilder which is a copy of the meta object information in prototype.

Note: the super class contents for prototype are not copied, only the immediate class that is defined by prototype.

The members parameter indicates which members of prototype should be added. The default is AllMembers.

See also
addMetaObject()

Definition at line 298 of file qmetaobjectbuilder.cpp.

299 {
301  addMetaObject(prototype, members);
302 }
QMetaObjectBuilderPrivate * d
void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members=AllMembers)
Adds the contents of prototype to this meta object builder.

◆ ~QMetaObjectBuilder()

QMetaObjectBuilder::~QMetaObjectBuilder ( )
virtual

Destroys this meta object builder.

Definition at line 307 of file qmetaobjectbuilder.cpp.

308 {
309  delete d;
310 }
QMetaObjectBuilderPrivate * d

Functions

◆ addClassInfo()

int QMetaObjectBuilder::addClassInfo ( const QByteArray name,
const QByteArray value 
)

Adds name and value as an item of class information to this class.

Returns the index of the new item of class information.

See also
classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
indexOfClassInfo()

Definition at line 681 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta(), and clone().

682 {
683  int index = d->classInfoNames.size();
684  d->classInfoNames += name;
685  d->classInfoValues += value;
686  return index;
687 }
QMetaObjectBuilderPrivate * d
const char * name
QList< QByteArray > classInfoValues
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
QList< QByteArray > classInfoNames

◆ addConstructor() [1/2]

QMetaMethodBuilder QMetaObjectBuilder::addConstructor ( const QByteArray signature)

Adds a new constructor to this class with the specified signature.

Returns an object that can be used to adjust the other attributes of the constructor. The signature will be normalized before it is added to the class.

See also
constructor(), constructorCount(), removeConstructor()
indexOfConstructor()

Definition at line 558 of file qmetaobjectbuilder.cpp.

559 {
560  int index = d->constructors.size();
562  return QMetaMethodBuilder(this, -(index + 1));
563 }
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaMethodBuilder
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addConstructor() [2/2]

QMetaMethodBuilder QMetaObjectBuilder::addConstructor ( const QMetaMethod prototype)

Adds a new constructor to this class that has the same information as prototype.

This is used to clone the constructors of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the constructor.

This function requires that prototype be a constructor.

See also
constructor(), constructorCount(), removeConstructor()
indexOfConstructor()

Definition at line 576 of file qmetaobjectbuilder.cpp.

577 {
579  QMetaMethodBuilder ctor = addConstructor(prototype.signature());
580  ctor.setReturnType(prototype.typeName());
581  ctor.setParameterNames(prototype.parameterNames());
582  ctor.setTag(prototype.tag());
583  ctor.setAccess(prototype.access());
584  ctor.setAttributes(prototype.attributes());
585  return ctor;
586 }
const char * typeName() const
Returns the return type of this method, or an empty string if the return type is void.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder...
QList< QByteArray > parameterNames() const
Returns a list of parameter names.
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
void setReturnType(const QByteArray &value)
Sets the return type for this method to value.
const char * tag() const
Returns the tag associated with this method.
QMetaMethodBuilder addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature.
int attributes() const
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
Access access() const
Returns the access specification of this method (private, protected, or public).

◆ addEnumerator() [1/2]

QMetaEnumBuilder QMetaObjectBuilder::addEnumerator ( const QByteArray name)

Adds a new enumerator to this class with the specified name.

Returns an object that can be used to adjust the other attributes of the enumerator.

See also
enumerator(), enumeratorCount(), removeEnumerator(),
indexOfEnumerator()

Definition at line 648 of file qmetaobjectbuilder.cpp.

649 {
650  int index = d->enumerators.size();
652  return QMetaEnumBuilder(this, index);
653 }
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addEnumerator() [2/2]

QMetaEnumBuilder QMetaObjectBuilder::addEnumerator ( const QMetaEnum prototype)

Adds a new enumerator to this class that has the same information as prototype.

This is used to clone the enumerators of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the enumerator.

See also
enumerator(), enumeratorCount(), removeEnumerator(),
indexOfEnumerator()

Definition at line 664 of file qmetaobjectbuilder.cpp.

665 {
666  QMetaEnumBuilder en = addEnumerator(prototype.name());
667  en.setIsFlag(prototype.isFlag());
668  int count = prototype.keyCount();
669  for (int index = 0; index < count; ++index)
670  en.addKey(prototype.key(index), prototype.value(index));
671  return en;
672 }
const char * key(int index) const
Returns the key with the given index, or 0 if no such key exists.
const char * name() const
Returns the name of the enumerator (without the scope).
int keyCount() const
Returns the number of keys.
void setIsFlag(bool value)
Sets this enumerator to be used as a flag if value is true.
QMetaEnumBuilder addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name.
bool isFlag() const
Returns true if this enumerator is used as a flag; otherwise returns false.
quint16 index
int addKey(const QByteArray &name, int value)
Adds a new key called name to this enumerator, associated with value.
The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder...
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.

◆ addMetaObject()

void QMetaObjectBuilder::addMetaObject ( const QMetaObject prototype,
QMetaObjectBuilder::AddMembers  members = AllMembers 
)

Adds the contents of prototype to this meta object builder.

This function is useful for cloning the contents of an existing QMetaObject.

The members parameter indicates which members of prototype should be added. The default is AllMembers.

Definition at line 720 of file qmetaobjectbuilder.cpp.

Referenced by addRelatedMetaObject().

721 {
722  Q_ASSERT(prototype);
723  int index;
724 
725  if ((members & ClassName) != 0)
726  d->className = prototype->className();
727 
728  if ((members & SuperClass) != 0)
729  d->superClass = prototype->superClass();
730 
731  if ((members & (Methods | Signals | Slots)) != 0) {
732  for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) {
733  QMetaMethod method = prototype->method(index);
734  if (method.methodType() != QMetaMethod::Signal) {
735  if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0)
736  continue;
737  if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0)
738  continue;
739  if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0)
740  continue;
741  }
742  if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) {
743  addMethod(method);
744  } else if (method.methodType() == QMetaMethod::Signal &&
745  (members & Signals) != 0) {
746  addMethod(method);
747  } else if (method.methodType() == QMetaMethod::Slot &&
748  (members & Slots) != 0) {
749  addMethod(method);
750  }
751  }
752  }
753 
754  if ((members & Constructors) != 0) {
755  for (index = 0; index < prototype->constructorCount(); ++index)
756  addConstructor(prototype->constructor(index));
757  }
758 
759  if ((members & Properties) != 0) {
760  for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index)
761  addProperty(prototype->property(index));
762  }
763 
764  if ((members & Enumerators) != 0) {
765  for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index)
766  addEnumerator(prototype->enumerator(index));
767  }
768 
769  if ((members & ClassInfos) != 0) {
770  for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) {
771  QMetaClassInfo ci = prototype->classInfo(index);
772  addClassInfo(ci.name(), ci.value());
773  }
774  }
775 
776  if ((members & RelatedMetaObjects) != 0) {
777 #ifdef Q_NO_DATA_RELOCATION
778  const QMetaObjectAccessor *objects = 0;
779 #else
780  const QMetaObject **objects;
781  if (priv(prototype->d.data)->revision < 2) {
782  objects = (const QMetaObject **)(prototype->d.extradata);
783  } else
784 #endif
785  {
786  const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
787  if (extra)
788  objects = extra->objects;
789  else
790  objects = 0;
791  }
792  if (objects) {
793  while (*objects != 0) {
794  addRelatedMetaObject(*objects);
795  ++objects;
796  }
797  }
798  }
799 
800  if ((members & StaticMetacall) != 0) {
801  if (priv(prototype->d.data)->revision >= 6) {
802  const QMetaObjectExtraData *extra =
803  (const QMetaObjectExtraData *)(prototype->d.extradata);
804  if (extra && extra->static_metacall)
806  }
807  }
808 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const QMetaObject * superClass
const void * extradata
Definition: qobjectdefs.h:472
void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value)
Sets the static metacall function to use to construct objects of this class to value.
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
int enumeratorOffset() const
Returns the enumerator offset for this class; i.e.
int constructorCount() const
Returns the number of constructors in this class.
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const char * value() const
Returns the value of this item.
QMetaObjectBuilderPrivate * d
const QMetaObject &(* QMetaObjectAccessor)()
Definition: qobjectdefs.h:476
int methodOffset() const
Returns the method offset for this class; i.e.
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
int addRelatedMetaObject(const QMetaObject *meta)
Adds meta to this class as a related meta object.
int enumeratorCount() const
Returns the number of enumerators in this class.
const char * name() const
Returns the name of this item.
int classInfoCount() const
Returns the number of items of class information in this class.
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
StaticMetacallFunction static_metacall
Definition: qobjectdefs.h:488
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
QMetaEnumBuilder addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name.
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
The QMetaClassInfo class provides additional information about a class.
Definition: qmetaobject.h:224
int classInfoOffset() const
Returns the class information offset for this class; i.e.
QMetaMethodBuilder addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature.
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
struct QMetaObject::@38 d
QMetaEnum enumerator(int index) const
Returns the meta-data for the enumerator with the given index.
quint16 index
QMetaMethod constructor(int index) const
Returns the meta-data for the constructor with the given index.
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
int addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class.
int propertyOffset() const
Returns the property offset for this class; i.e.
Access access() const
Returns the access specification of this method (private, protected, or public).
static const QMetaObjectPrivate * priv(const uint *data)
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
const QMetaObject ** objects
Definition: qobjectdefs.h:483
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ addMethod() [1/3]

QMetaMethodBuilder QMetaObjectBuilder::addMethod ( const QByteArray signature)

Adds a new public method to this class with the specified signature.

Returns an object that can be used to adjust the other attributes of the method. The signature will be normalized before it is added to the class.

See also
method(), methodCount(), removeMethod(), indexOfMethod()

Definition at line 462 of file qmetaobjectbuilder.cpp.

463 {
464  int index = d->methods.size();
466  return QMetaMethodBuilder(this, index);
467 }
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaMethodBuilder
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addMethod() [2/3]

QMetaMethodBuilder QMetaObjectBuilder::addMethod ( const QByteArray signature,
const QByteArray returnType 
)

Adds a new public method to this class with the specified signature and returnType.

Returns an object that can be used to adjust the other attributes of the method. The signature and returnType will be normalized before they are added to the class. If returnType is empty, then it indicates that the method has void as its return type.

See also
method(), methodCount(), removeMethod(), indexOfMethod()

Definition at line 480 of file qmetaobjectbuilder.cpp.

481 {
482  int index = d->methods.size();
484  (QMetaMethod::Method, signature, returnType));
485  return QMetaMethodBuilder(this, index);
486 }
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaMethodBuilder
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addMethod() [3/3]

QMetaMethodBuilder QMetaObjectBuilder::addMethod ( const QMetaMethod prototype)

Adds a new public method to this class that has the same information as prototype.

This is used to clone the methods of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the method.

This function will detect if prototype is an ordinary method, signal, slot, or constructor and act accordingly.

See also
method(), methodCount(), removeMethod(), indexOfMethod()

Definition at line 499 of file qmetaobjectbuilder.cpp.

500 {
502  if (prototype.methodType() == QMetaMethod::Method)
503  method = addMethod(prototype.signature());
504  else if (prototype.methodType() == QMetaMethod::Signal)
505  method = addSignal(prototype.signature());
506  else if (prototype.methodType() == QMetaMethod::Slot)
507  method = addSlot(prototype.signature());
508  else if (prototype.methodType() == QMetaMethod::Constructor)
509  method = addConstructor(prototype.signature());
510  method.setReturnType(prototype.typeName());
511  method.setParameterNames(prototype.parameterNames());
512  method.setTag(prototype.tag());
513  method.setAccess(prototype.access());
514  method.setAttributes(prototype.attributes());
515  return method;
516 }
void setAttributes(int value)
Sets the additional attributes for this method to value.
QMetaMethodBuilder addSlot(const QByteArray &signature)
Adds a new public slot to this class with the specified signature.
void setTag(const QByteArray &value)
Sets the tag associated with this method to value.
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
void setAccess(QMetaMethod::Access value)
Sets the access specification of this method (private, protected, or public) to value.
const char * typeName() const
Returns the return type of this method, or an empty string if the return type is void.
The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder...
QList< QByteArray > parameterNames() const
Returns a list of parameter names.
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
void setReturnType(const QByteArray &value)
Sets the return type for this method to value.
const char * tag() const
Returns the tag associated with this method.
QMetaMethodBuilder addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature.
int attributes() const
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
Access access() const
Returns the access specification of this method (private, protected, or public).
QMetaMethodBuilder addSignal(const QByteArray &signature)
Adds a new signal to this class with the specified signature.
void setParameterNames(const QList< QByteArray > &value)
Sets the list of parameter names for this method to value.

◆ addProperty() [1/2]

QMetaPropertyBuilder QMetaObjectBuilder::addProperty ( const QByteArray name,
const QByteArray type,
int  notifierId = -1 
)

Adds a new readable/writable property to this class with the specified name and type.

Returns an object that can be used to adjust the other attributes of the property. The type will be normalized before it is added to the class. notifierId will be registered as the property's notify signal.

See also
property(), propertyCount(), removeProperty(), indexOfProperty()

Definition at line 598 of file qmetaobjectbuilder.cpp.

Referenced by addConstructor(), QDeclarativeCompiler::buildDynamicMeta(), clone(), QDeclarativeCompiler::compileAlias(), QDeclarativeOpenMetaObjectType::createProperty(), and QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters().

599 {
600  int index = d->properties.size();
601  d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
602  return QMetaPropertyBuilder(this, index);
603 }
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaPropertyBuilder
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
QList< QMetaPropertyBuilderPrivate > properties

◆ addProperty() [2/2]

QMetaPropertyBuilder QMetaObjectBuilder::addProperty ( const QMetaProperty prototype)

Adds a new property to this class that has the same information as prototype.

This is used to clone the properties of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the property.

See also
property(), propertyCount(), removeProperty(), indexOfProperty()

Definition at line 613 of file qmetaobjectbuilder.cpp.

614 {
615  QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
616  property.setReadable(prototype.isReadable());
617  property.setWritable(prototype.isWritable());
618  property.setResettable(prototype.isResettable());
619  property.setDesignable(prototype.isDesignable());
620  property.setScriptable(prototype.isScriptable());
621  property.setStored(prototype.isStored());
622  property.setEditable(prototype.isEditable());
623  property.setUser(prototype.isUser());
624  property.setStdCppSet(prototype.hasStdCppSet());
625  property.setEnumOrFlag(prototype.isEnumType());
626  property.setConstant(prototype.isConstant());
627  property.setFinal(prototype.isFinal());
628  if (prototype.hasNotifySignal()) {
629  // Find an existing method for the notify signal, or add a new one.
630  QMetaMethod method = prototype.notifySignal();
631  int index = indexOfMethod(method.signature());
632  if (index == -1)
633  index = addMethod(method).index();
634  d->properties[property._index].notifySignal = index;
635  d->properties[property._index].setFlag(Notify, true);
636  }
637  return property;
638 }
bool isFinal() const
bool isScriptable(const QObject *obj=0) const
Returns true if the property is scriptable for the given object; otherwise returns false...
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
bool isUser(const QObject *obj=0) const
Returns true if this property is designated as the USER property, i.e., the one that the user can edi...
The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builde...
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
bool isEditable(const QObject *obj=0) const
Returns true if the property is constant; otherwise returns false.
QMetaObjectBuilderPrivate * d
int indexOfMethod(const QByteArray &signature)
Finds a method with the specified signature and returns its index; otherwise returns -1...
bool isEnumType() const
Returns true if the property&#39;s type is an enumeration value; otherwise returns false.
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
QMetaMethod notifySignal() const
Returns the QMetaMethod instance of the property change notifying signal if one was specified...
bool hasStdCppSet() const
Returns true if the property has a C++ setter function that follows Qt&#39;s standard "name" / "setName" ...
bool isResettable() const
Returns true if this property can be reset to a default value; otherwise returns false.
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
const char * name() const
Returns this property&#39;s name.
bool isStored(const QObject *obj=0) const
Returns true if the property is stored for object; otherwise returns false.
bool isDesignable(const QObject *obj=0) const
Returns true if this property is designable for the given object; otherwise returns false...
bool isReadable() const
Returns true if this property is readable; otherwise returns false.
quint16 index
QMetaPropertyBuilder property(int index) const
Returns the property at index in this class.
QList< QMetaPropertyBuilderPrivate > properties
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
void setReadable(bool value)
Sets this property to readable if value is true.
const char * typeName() const
Returns the name of this property&#39;s type.
int index() const
Returns the index of this method within its QMetaObjectBuilder.
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
bool isConstant() const

◆ addRelatedMetaObject()

int QMetaObjectBuilder::addRelatedMetaObject ( const QMetaObject meta)

Adds meta to this class as a related meta object.

Returns the index of the new related meta object entry.

Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.

See also
relatedMetaObjectCount(), relatedMetaObject()
removeRelatedMetaObject()

Definition at line 703 of file qmetaobjectbuilder.cpp.

Referenced by addClassInfo().

705 {
706  Q_ASSERT(meta);
707  int index = d->relatedMetaObjects.size();
708  d->relatedMetaObjects.append(meta);
709  return index;
710 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< const QMetaObject * > relatedMetaObjects
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addSignal()

QMetaMethodBuilder QMetaObjectBuilder::addSignal ( const QByteArray signature)

Adds a new signal to this class with the specified signature.

Returns an object that can be used to adjust the other attributes of the signal. The signature will be normalized before it is added to the class.

See also
addMethod(), addSlot(), indexOfSignal()

Definition at line 541 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta(), QDeclarativeCompiler::compileAlias(), and QDeclarativeOpenMetaObjectType::createProperty().

542 {
543  int index = d->methods.size();
546  return QMetaMethodBuilder(this, index);
547 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaMethodBuilder
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ addSlot()

QMetaMethodBuilder QMetaObjectBuilder::addSlot ( const QByteArray signature)

Adds a new public slot to this class with the specified signature.

Returns an object that can be used to adjust the other attributes of the slot. The signature will be normalized before it is added to the class.

See also
addMethod(), addSignal(), indexOfSlot()

Definition at line 526 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta().

527 {
528  int index = d->methods.size();
530  return QMetaMethodBuilder(this, index);
531 }
QMetaObjectBuilderPrivate * d
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
friend class QMetaMethodBuilder
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ classInfoCount()

int QMetaObjectBuilder::classInfoCount ( ) const

Returns the number of items of class information in this class, exclusing the number of items of class information in the base class.

See also
addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo()
indexOfClassInfo()

Definition at line 433 of file qmetaobjectbuilder.cpp.

434 {
435  return d->classInfoNames.size();
436 }
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QByteArray > classInfoNames

◆ classInfoName()

QByteArray QMetaObjectBuilder::classInfoName ( int  index) const

Returns the name of the item of class information at index in this class.

See also
classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo()
indexOfClassInfo()

Definition at line 892 of file qmetaobjectbuilder.cpp.

893 {
894  if (index >= 0 && index < d->classInfoNames.size())
895  return d->classInfoNames[index];
896  else
897  return QByteArray();
898 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
quint16 index
QList< QByteArray > classInfoNames

◆ classInfoValue()

QByteArray QMetaObjectBuilder::classInfoValue ( int  index) const

Returns the value of the item of class information at index in this class.

See also
classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo()
indexOfClassInfo()

Definition at line 907 of file qmetaobjectbuilder.cpp.

908 {
909  if (index >= 0 && index < d->classInfoValues.size())
910  return d->classInfoValues[index];
911  else
912  return QByteArray();
913 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
QList< QByteArray > classInfoValues
quint16 index

◆ className()

QByteArray QMetaObjectBuilder::className ( ) const

Returns the name of the class being constructed by this meta object builder.

The default value is an empty QByteArray.

See also
setClassName(), superClass()

Definition at line 318 of file qmetaobjectbuilder.cpp.

319 {
320  return d->className;
321 }
QMetaObjectBuilderPrivate * d

◆ constructor()

QMetaMethodBuilder QMetaObjectBuilder::constructor ( int  index) const

Returns the constructor at index in this class.

See also
methodCount(), addMethod(), removeMethod(), indexOfConstructor()

Definition at line 828 of file qmetaobjectbuilder.cpp.

829 {
830  if (index >= 0 && index < d->constructors.size())
831  return QMetaMethodBuilder(this, -(index + 1));
832  else
833  return QMetaMethodBuilder();
834 }
friend class QMetaMethodBuilder
quint16 index

◆ constructorCount()

int QMetaObjectBuilder::constructorCount ( ) const

Returns the number of constructors in this class.

See also
addConstructor(), constructor(), removeConstructor(), indexOfConstructor()

Definition at line 398 of file qmetaobjectbuilder.cpp.

399 {
400  return d->constructors.size();
401 }
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ deserialize()

void QMetaObjectBuilder::deserialize ( QDataStream stream,
const QMap< QByteArray, const QMetaObject *> &  references 
)

Deserializes a meta object builder from stream into this meta object builder.

The references parameter specifies a mapping from class names to QMetaObject instances for resolving the super class name and related meta objects in the object that is deserialized. The meta object for QObject is implicitly added to references and does not need to be supplied.

The QDataStream::status() value on stream will be set to QDataStream::ReadCorruptData if the input data is corrupt. The status will be set to QDataStream::ReadPastEnd if the input was exhausted before the full meta object was read.

See also
serialize()

Definition at line 1668 of file qmetaobjectbuilder.cpp.

Referenced by resolveClassName().

1670 {
1671  QByteArray name;
1672  const QMetaObject *cl;
1673  int index;
1674 
1675  // Clear all members in the builder to their default states.
1676  d->className.clear();
1678  d->classInfoNames.clear();
1679  d->classInfoValues.clear();
1680  d->methods.clear();
1681  d->properties.clear();
1682  d->enumerators.clear();
1683  d->constructors.clear();
1686 
1687  // Read the class and super class names.
1688  stream >> d->className;
1689  stream >> name;
1690  if (name.isEmpty()) {
1691  d->superClass = 0;
1692  } else if ((cl = resolveClassName(references, name)) != 0) {
1693  d->superClass = cl;
1694  } else {
1696  return;
1697  }
1698 
1699  // Read the counts for each type of class member.
1702  stream >> classInfoCount;
1703  stream >> methodCount;
1704  stream >> propertyCount;
1705  stream >> enumeratorCount;
1706  stream >> constructorCount;
1707  stream >> relatedMetaObjectCount;
1708  if (classInfoCount < 0 || methodCount < 0 ||
1709  propertyCount < 0 || enumeratorCount < 0 ||
1710  constructorCount < 0 || relatedMetaObjectCount < 0) {
1712  return;
1713  }
1714 
1715  // Read the items of class information.
1716  for (index = 0; index < classInfoCount; ++index) {
1717  if (stream.status() != QDataStream::Ok)
1718  return;
1719  QByteArray value;
1720  stream >> name;
1721  stream >> value;
1722  addClassInfo(name, value);
1723  }
1724 
1725  // Read the member methods.
1726  for (index = 0; index < methodCount; ++index) {
1727  if (stream.status() != QDataStream::Ok)
1728  return;
1729  stream >> name;
1730  addMethod(name);
1732  stream >> method->returnType;
1733  stream >> method->parameterNames;
1734  stream >> method->tag;
1735  stream >> method->attributes;
1736  if (method->methodType() == QMetaMethod::Constructor) {
1737  // Cannot add a constructor in this set of methods.
1739  return;
1740  }
1741  }
1742 
1743  // Read the properties.
1744  for (index = 0; index < propertyCount; ++index) {
1745  if (stream.status() != QDataStream::Ok)
1746  return;
1747  QByteArray type;
1748  stream >> name;
1749  stream >> type;
1750  addProperty(name, type);
1751  QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
1752  stream >> property->flags;
1753  stream >> property->notifySignal;
1754  if (property->notifySignal < -1 ||
1755  property->notifySignal >= d->methods.size()) {
1756  // Notify signal method index is out of range.
1758  return;
1759  }
1760  if (property->notifySignal >= 0 &&
1761  d->methods[property->notifySignal].methodType() != QMetaMethod::Signal) {
1762  // Notify signal method index does not refer to a signal.
1764  return;
1765  }
1766  }
1767 
1768  // Read the enumerators.
1769  for (index = 0; index < enumeratorCount; ++index) {
1770  if (stream.status() != QDataStream::Ok)
1771  return;
1772  stream >> name;
1773  addEnumerator(name);
1775  stream >> enumerator->isFlag;
1776  stream >> enumerator->keys;
1777  stream >> enumerator->values;
1778  if (enumerator->keys.size() != enumerator->values.size()) {
1779  // Mismatch between number of keys and number of values.
1781  return;
1782  }
1783  }
1784 
1785  // Read the constructor methods.
1786  for (index = 0; index < constructorCount; ++index) {
1787  if (stream.status() != QDataStream::Ok)
1788  return;
1789  stream >> name;
1790  addConstructor(name);
1792  stream >> method->returnType;
1793  stream >> method->parameterNames;
1794  stream >> method->tag;
1795  stream >> method->attributes;
1796  if (method->methodType() != QMetaMethod::Constructor) {
1797  // The type must be Constructor.
1799  return;
1800  }
1801  }
1802 
1803  // Read the related meta objects.
1804 #ifdef Q_NO_DATA_RELOCATION
1805  //### What do we do here
1806 #else
1807  for (index = 0; index < relatedMetaObjectCount; ++index) {
1808  if (stream.status() != QDataStream::Ok)
1809  return;
1810  stream >> name;
1811  cl = resolveClassName(references, name);
1812  if (!cl) {
1814  return;
1815  }
1817  }
1818 #endif
1819 
1820  // Read the extra data block, which is reserved for future use.
1821  stream >> name;
1822 }
Status status() const
Returns the status of the data stream.
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int type
Definition: qmetatype.cpp:239
const QMetaObject * superClass
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
QMetaMethodBuilder notifySignal() const
Returns the notify signal associated with this property.
void setStatus(Status status)
Sets the status of the data stream to the status given.
QMetaEnumBuilder enumerator(int index) const
Returns the enumerator at index in this class.
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
int methodCount() const
Returns the number of methods in this class, excluding the number of methods in the base class...
int enumeratorCount() const
Returns the number of enumerators in this class, excluding the number of enumerators in the base clas...
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
int addRelatedMetaObject(const QMetaObject *meta)
Adds meta to this class as a related meta object.
const char * name
QList< QByteArray > classInfoValues
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< QByteArray > parameterNames
int classInfoCount() const
Returns the number of items of class information in this class, exclusing the number of items of clas...
static const QMetaObject * resolveClassName(const QMap< QByteArray, const QMetaObject *> &references, const QByteArray &name)
QMetaEnumBuilder addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name.
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
QList< QMetaMethodBuilderPrivate > methods
QList< const QMetaObject * > relatedMetaObjects
QMetaMethodBuilder addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int relatedMetaObjectCount() const
Returns the number of related meta objects that are associated with this class.
quint16 index
int addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class.
QMetaPropertyBuilder property(int index) const
Returns the property at index in this class.
QList< QMetaPropertyBuilderPrivate > properties
int constructorCount() const
Returns the number of constructors in this class.
int propertyCount() const
Returns the number of properties in this class, excluding the number of properties in the base class...
void clear()
Clears the contents of the byte array and makes it empty.
QMetaMethod::MethodType methodType() const
QList< QByteArray > classInfoNames

◆ enumerator()

QMetaEnumBuilder QMetaObjectBuilder::enumerator ( int  index) const

Returns the enumerator at index in this class.

See also
enumeratorCount(), addEnumerator(), removeEnumerator()
indexOfEnumerator()

Definition at line 855 of file qmetaobjectbuilder.cpp.

856 {
857  if (index >= 0 && index < d->enumerators.size())
858  return QMetaEnumBuilder(this, index);
859  else
860  return QMetaEnumBuilder();
861 }
quint16 index

◆ enumeratorCount()

int QMetaObjectBuilder::enumeratorCount ( ) const

Returns the number of enumerators in this class, excluding the number of enumerators in the base class.

See also
addEnumerator(), enumerator(), removeEnumerator()
indexOfEnumerator()

Definition at line 421 of file qmetaobjectbuilder.cpp.

422 {
423  return d->enumerators.size();
424 }
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ flags()

QMetaObjectBuilder::MetaObjectFlags QMetaObjectBuilder::flags ( ) const

Returns the flags of the class being constructed by this meta object builder.

See also
setFlags()

Definition at line 365 of file qmetaobjectbuilder.cpp.

366 {
368 }
QMetaObjectBuilderPrivate * d
MetaObjectFlags

◆ fromRelocatableData()

void QMetaObjectBuilder::fromRelocatableData ( QMetaObject output,
const QMetaObject superclass,
const QByteArray data 
)
static

Definition at line 1501 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta(), and QDeclarativeVME::run().

1504 {
1505  if (!output)
1506  return;
1507 
1508  const char *buf = data.constData();
1509  const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
1510 
1511  quintptr stringdataOffset = (quintptr)dataMo->d.stringdata;
1512  quintptr dataOffset = (quintptr)dataMo->d.data;
1513 
1514  output->d.superdata = superclass;
1515  output->d.stringdata = buf + stringdataOffset;
1516  output->d.data = reinterpret_cast<const uint *>(buf + dataOffset);
1517 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
const char * stringdata
Definition: qobjectdefs.h:470
unsigned int uint
Definition: qglobal.h:996
const uint * data
Definition: qobjectdefs.h:471
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d

◆ indexOfClassInfo()

int QMetaObjectBuilder::indexOfClassInfo ( const QByteArray name)

Finds an item of class information with the specified name and returns its index; otherwise returns -1.

See also
classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
removeClassInfo()

Definition at line 1112 of file qmetaobjectbuilder.cpp.

1113 {
1114  for (int index = 0; index < d->classInfoNames.size(); ++index) {
1115  if (name == d->classInfoNames[index])
1116  return index;
1117  }
1118  return -1;
1119 }
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
QList< QByteArray > classInfoNames

◆ indexOfConstructor()

int QMetaObjectBuilder::indexOfConstructor ( const QByteArray signature)

Finds a constructor with the specified signature and returns its index; otherwise returns -1.

The signature will be normalized by this method.

See also
constructor(), constructorCount(), addConstructor(), removeConstructor()

Definition at line 1065 of file qmetaobjectbuilder.cpp.

1066 {
1068  for (int index = 0; index < d->constructors.size(); ++index) {
1069  if (sig == d->constructors[index].signature)
1070  return index;
1071  }
1072  return -1;
1073 }
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ indexOfEnumerator()

int QMetaObjectBuilder::indexOfEnumerator ( const QByteArray name)

Finds an enumerator with the specified name and returns its index; otherwise returns -1.

See also
enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()

Definition at line 1096 of file qmetaobjectbuilder.cpp.

1097 {
1098  for (int index = 0; index < d->enumerators.size(); ++index) {
1099  if (name == d->enumerators[index].name)
1100  return index;
1101  }
1102  return -1;
1103 }
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ indexOfMethod()

int QMetaObjectBuilder::indexOfMethod ( const QByteArray signature)

Finds a method with the specified signature and returns its index; otherwise returns -1.

The signature will be normalized by this method.

See also
method(), methodCount(), addMethod(), removeMethod()

Definition at line 1015 of file qmetaobjectbuilder.cpp.

1016 {
1018  for (int index = 0; index < d->methods.size(); ++index) {
1019  if (sig == d->methods[index].signature)
1020  return index;
1021  }
1022  return -1;
1023 }
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ indexOfProperty()

int QMetaObjectBuilder::indexOfProperty ( const QByteArray name)

Finds a property with the specified name and returns its index; otherwise returns -1.

See also
property(), propertyCount(), addProperty(), removeProperty()

Definition at line 1081 of file qmetaobjectbuilder.cpp.

1082 {
1083  for (int index = 0; index < d->properties.size(); ++index) {
1084  if (name == d->properties[index].name)
1085  return index;
1086  }
1087  return -1;
1088 }
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
QList< QMetaPropertyBuilderPrivate > properties

◆ indexOfSignal()

int QMetaObjectBuilder::indexOfSignal ( const QByteArray signature)

Finds a signal with the specified signature and returns its index; otherwise returns -1.

The signature will be normalized by this method.

See also
indexOfMethod(), indexOfSlot()

Definition at line 1031 of file qmetaobjectbuilder.cpp.

1032 {
1034  for (int index = 0; index < d->methods.size(); ++index) {
1035  if (sig == d->methods[index].signature &&
1036  d->methods[index].methodType() == QMetaMethod::Signal)
1037  return index;
1038  }
1039  return -1;
1040 }
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ indexOfSlot()

int QMetaObjectBuilder::indexOfSlot ( const QByteArray signature)

Finds a slot with the specified signature and returns its index; otherwise returns -1.

The signature will be normalized by this method.

See also
indexOfMethod(), indexOfSignal()

Definition at line 1048 of file qmetaobjectbuilder.cpp.

1049 {
1051  for (int index = 0; index < d->methods.size(); ++index) {
1052  if (sig == d->methods[index].signature &&
1053  d->methods[index].methodType() == QMetaMethod::Slot)
1054  return index;
1055  }
1056  return -1;
1057 }
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ method()

QMetaMethodBuilder QMetaObjectBuilder::method ( int  index) const

Returns the method at index in this class.

See also
methodCount(), addMethod(), removeMethod(), indexOfMethod()

Definition at line 815 of file qmetaobjectbuilder.cpp.

816 {
817  if (index >= 0 && index < d->methods.size())
818  return QMetaMethodBuilder(this, index);
819  else
820  return QMetaMethodBuilder();
821 }
friend class QMetaMethodBuilder
quint16 index

◆ methodCount()

int QMetaObjectBuilder::methodCount ( ) const

Returns the number of methods in this class, excluding the number of methods in the base class.

These include signals and slots as well as normal member functions.

See also
addMethod(), method(), removeMethod(), indexOfMethod()

Definition at line 388 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta(), and QDeclarativeCompiler::compileAlias().

389 {
390  return d->methods.size();
391 }
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ property()

QMetaPropertyBuilder QMetaObjectBuilder::property ( int  index) const

Returns the property at index in this class.

See also
methodCount(), addMethod(), removeMethod(), indexOfProperty()

Definition at line 841 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeOpenMetaObject::name().

842 {
843  if (index >= 0 && index < d->properties.size())
844  return QMetaPropertyBuilder(this, index);
845  else
846  return QMetaPropertyBuilder();
847 }
friend class QMetaPropertyBuilder
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
quint16 index

◆ propertyCount()

int QMetaObjectBuilder::propertyCount ( ) const

Returns the number of properties in this class, excluding the number of properties in the base class.

See also
addProperty(), property(), removeProperty(), indexOfProperty()

Definition at line 409 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeOpenMetaObjectType::createProperty().

410 {
411  return d->properties.size();
412 }
QMetaObjectBuilderPrivate * d
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QMetaPropertyBuilderPrivate > properties

◆ relatedMetaObject()

const QMetaObject * QMetaObjectBuilder::relatedMetaObject ( int  index) const

Returns the related meta object at index in this class.

Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.

See also
relatedMetaObjectCount(), addRelatedMetaObject()
removeRelatedMetaObject()

Definition at line 873 of file qmetaobjectbuilder.cpp.

874 {
875  if (index >= 0 && index < d->relatedMetaObjects.size())
876 #ifdef Q_NO_DATA_RELOCATION
877  return &((*(d->relatedMetaObjects[index]))());
878 #else
879  return d->relatedMetaObjects[index];
880 #endif
881  else
882  return 0;
883 }
QMetaObjectBuilderPrivate * d
QList< const QMetaObject * > relatedMetaObjects
quint16 index

◆ relatedMetaObjectCount()

int QMetaObjectBuilder::relatedMetaObjectCount ( ) const

Returns the number of related meta objects that are associated with this class.

Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.

See also
addRelatedMetaObject(), relatedMetaObject()
removeRelatedMetaObject()

Definition at line 449 of file qmetaobjectbuilder.cpp.

450 {
451  return d->relatedMetaObjects.size();
452 }
QMetaObjectBuilderPrivate * d
QList< const QMetaObject * > relatedMetaObjects
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ removeClassInfo()

void QMetaObjectBuilder::removeClassInfo ( int  index)

Removes the item of class information at index from this class.

The indices of all following items will be adjusted downwards by 1.

See also
classInfoCount(), addClassInfo(), classInfoName(), classInfoValue()
indexOfClassInfo()

Definition at line 983 of file qmetaobjectbuilder.cpp.

984 {
985  if (index >= 0 && index < d->classInfoNames.size()) {
988  }
989 }
QMetaObjectBuilderPrivate * d
QList< QByteArray > classInfoValues
quint16 index
QList< QByteArray > classInfoNames
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeConstructor()

void QMetaObjectBuilder::removeConstructor ( int  index)

Removes the constructor at index from this class.

The indices of all following constructors will be adjusted downwards by 1.

See also
constructorCount(), addConstructor(), constructor()
indexOfConstructor()

Definition at line 945 of file qmetaobjectbuilder.cpp.

946 {
947  if (index >= 0 && index < d->constructors.size())
949 }
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
quint16 index
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeEnumerator()

void QMetaObjectBuilder::removeEnumerator ( int  index)

Removes the enumerator at index from this class.

The indices of all following enumerators will be adjusted downwards by 1.

See also
enumertorCount(), addEnumerator(), enumerator()
indexOfEnumerator()

Definition at line 970 of file qmetaobjectbuilder.cpp.

971 {
972  if (index >= 0 && index < d->enumerators.size())
974 }
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
quint16 index
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeMethod()

void QMetaObjectBuilder::removeMethod ( int  index)

Removes the method at index from this class.

The indices of all following methods will be adjusted downwards by 1. If the method is registered as a notify signal on a property, then the notify signal will be removed from the property.

See also
methodCount(), addMethod(), method(), indexOfMethod()

Definition at line 923 of file qmetaobjectbuilder.cpp.

924 {
925  if (index >= 0 && index < d->methods.size()) {
927  for (int prop = 0; prop < d->properties.size(); ++prop) {
928  // Adjust the indices of property notify signal references.
929  if (d->properties[prop].notifySignal == index) {
930  d->properties[prop].notifySignal = -1;
931  d->properties[prop].setFlag(Notify, false);
932  } else if (d->properties[prop].notifySignal > index)
933  (d->properties[prop].notifySignal)--;
934  }
935  }
936 }
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > methods
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index
QList< QMetaPropertyBuilderPrivate > properties
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeProperty()

void QMetaObjectBuilder::removeProperty ( int  index)

Removes the property at index from this class.

The indices of all following properties will be adjusted downwards by 1.

See also
propertyCount(), addProperty(), property(), indexOfProperty()

Definition at line 957 of file qmetaobjectbuilder.cpp.

958 {
959  if (index >= 0 && index < d->properties.size())
961 }
QMetaObjectBuilderPrivate * d
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
quint16 index
QList< QMetaPropertyBuilderPrivate > properties
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ removeRelatedMetaObject()

void QMetaObjectBuilder::removeRelatedMetaObject ( int  index)

Removes the related meta object at index from this class.

The indices of all following related meta objects will be adjusted downwards by 1.

Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.

See also
relatedMetaObjectCount(), addRelatedMetaObject()
relatedMetaObject()

Definition at line 1003 of file qmetaobjectbuilder.cpp.

1004 {
1005  if (index >= 0 && index < d->relatedMetaObjects.size())
1007 }
QMetaObjectBuilderPrivate * d
QList< const QMetaObject * > relatedMetaObjects
quint16 index
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ serialize()

void QMetaObjectBuilder::serialize ( QDataStream stream) const

Serializes the contents of the meta object builder onto stream.

See also
deserialize()

Definition at line 1560 of file qmetaobjectbuilder.cpp.

1561 {
1562  int index;
1563 
1564  // Write the class and super class names.
1565  stream << d->className;
1566  if (d->superClass)
1567  stream << QByteArray(d->superClass->className());
1568  else
1569  stream << QByteArray();
1570 
1571  // Write the counts for each type of class member.
1572  stream << d->classInfoNames.size();
1573  stream << d->methods.size();
1574  stream << d->properties.size();
1575  stream << d->enumerators.size();
1576  stream << d->constructors.size();
1577  stream << d->relatedMetaObjects.size();
1578 
1579  // Write the items of class information.
1580  for (index = 0; index < d->classInfoNames.size(); ++index) {
1581  stream << d->classInfoNames[index];
1582  stream << d->classInfoValues[index];
1583  }
1584 
1585  // Write the methods.
1586  for (index = 0; index < d->methods.size(); ++index) {
1588  stream << method->signature;
1589  stream << method->returnType;
1590  stream << method->parameterNames;
1591  stream << method->tag;
1592  stream << method->attributes;
1593  }
1594 
1595  // Write the properties.
1596  for (index = 0; index < d->properties.size(); ++index) {
1597  const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
1598  stream << property->name;
1599  stream << property->type;
1600  stream << property->flags;
1601  stream << property->notifySignal;
1602  }
1603 
1604  // Write the enumerators.
1605  for (index = 0; index < d->enumerators.size(); ++index) {
1607  stream << enumerator->name;
1608  stream << enumerator->isFlag;
1609  stream << enumerator->keys;
1610  stream << enumerator->values;
1611  }
1612 
1613  // Write the constructors.
1614  for (index = 0; index < d->constructors.size(); ++index) {
1616  stream << method->signature;
1617  stream << method->returnType;
1618  stream << method->parameterNames;
1619  stream << method->tag;
1620  stream << method->attributes;
1621  }
1622 
1623  // Write the related meta objects.
1624 #ifdef Q_NO_DATA_RELOCATION
1625  //### What do we do here?
1626 #else
1627  for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
1628  const QMetaObject *meta = d->relatedMetaObjects[index];
1629  stream << QByteArray(meta->className());
1630  }
1631 #endif
1632 
1633  // Add an extra empty QByteArray for additional data in future versions.
1634  // This should help maintain backwards compatibility, allowing older
1635  // versions to read newer data.
1636  stream << QByteArray();
1637 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const QMetaObject * superClass
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
QMetaEnumBuilder enumerator(int index) const
Returns the enumerator at index in this class.
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
QList< QMetaMethodBuilderPrivate > constructors
QList< QByteArray > classInfoValues
QList< QByteArray > parameterNames
QList< QMetaMethodBuilderPrivate > methods
QList< const QMetaObject * > relatedMetaObjects
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
quint16 index
QList< QMetaPropertyBuilderPrivate > properties
QList< QByteArray > classInfoNames

◆ setClassName()

void QMetaObjectBuilder::setClassName ( const QByteArray name)

Sets the name of the class being constructed by this meta object builder.

See also
className(), setSuperClass()

Definition at line 329 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta(), and QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters().

330 {
331  d->className = name;
332 }
QMetaObjectBuilderPrivate * d
const char * name

◆ setFlags()

void QMetaObjectBuilder::setFlags ( MetaObjectFlags  flags)

Sets the flags of the class being constructed by this meta object builder.

See also
flags()

Definition at line 376 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta().

377 {
378  d->flags = flags;
379 }
MetaObjectFlags flags() const
Returns the flags of the class being constructed by this meta object builder.
QMetaObjectBuilderPrivate * d

◆ setStaticMetacallFunction()

void QMetaObjectBuilder::setStaticMetacallFunction ( QMetaObjectBuilder::StaticMetacallFunction  value)

Sets the static metacall function to use to construct objects of this class to value.

The default value is null.

See also
staticMetacallFunction()

Definition at line 1548 of file qmetaobjectbuilder.cpp.

Referenced by staticMetacallFunction().

1549 {
1550  d->staticMetacallFunction = value;
1551 }
QMetaObjectBuilderPrivate * d
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction

◆ setSuperClass()

void QMetaObjectBuilder::setSuperClass ( const QMetaObject meta)

Sets the superclass meta object of the class being constructed by this meta object builder to meta.

The meta parameter must not be null.

See also
superClass(), setClassName()

Definition at line 353 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters().

354 {
355  Q_ASSERT(meta);
356  d->superClass = meta;
357 }
const QMetaObject * superClass
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QMetaObjectBuilderPrivate * d

◆ staticMetacallFunction()

QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction ( ) const

Returns the static metacall function to use to construct objects of this class.

The default value is null.

See also
setStaticMetacallFunction()

Definition at line 1536 of file qmetaobjectbuilder.cpp.

1537 {
1538  return d->staticMetacallFunction;
1539 }
QMetaObjectBuilderPrivate * d
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction

◆ superClass()

const QMetaObject * QMetaObjectBuilder::superClass ( ) const

Returns the superclass meta object of the class being constructed by this meta object builder.

The default value is the meta object for QObject.

See also
setSuperClass(), className()

Definition at line 341 of file qmetaobjectbuilder.cpp.

342 {
343  return d->superClass;
344 }
const QMetaObject * superClass
QMetaObjectBuilderPrivate * d

◆ toMetaObject()

QMetaObject * QMetaObjectBuilder::toMetaObject ( ) const

Converts this meta object builder into a concrete QMetaObject.

The return value should be deallocated using qFree() once it is no longer needed.

The returned meta object is a snapshot of the state of the QMetaObjectBuilder. Any further modifications to the QMetaObjectBuilder will not be reflected in previous meta objects returned by this method.

Definition at line 1454 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeOpenMetaObjectType::createProperty(), QDeclarativeTypePrivate::init(), and QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters().

1455 {
1456  int size = buildMetaObject(d, 0, false);
1457  char *buf = reinterpret_cast<char *>(qMalloc(size));
1458  memset(buf, 0, size);
1459  buildMetaObject(d, buf, false);
1460  return reinterpret_cast<QMetaObject *>(buf);
1461 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
QMetaObjectBuilderPrivate * d
static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, bool relocatable)

◆ toRelocatableData()

QByteArray QMetaObjectBuilder::toRelocatableData ( bool *  ok = 0) const

Definition at line 1477 of file qmetaobjectbuilder.cpp.

Referenced by QDeclarativeCompiler::buildDynamicMeta().

1478 {
1479  int size = buildMetaObject(d, 0, true);
1480  if (size == -1) {
1481  if (ok) *ok = false;
1482  return QByteArray();
1483  }
1484 
1485  QByteArray data;
1486  data.resize(size);
1487  char *buf = data.data();
1488  memset(buf, 0, size);
1489  buildMetaObject(d, buf, true);
1490  if (ok) *ok = true;
1491  return data;
1492 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaObjectBuilderPrivate * d
static const char * data(const QByteArray &arr)
void resize(int size)
Sets the size of the byte array to size bytes.
static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, bool relocatable)

Friends and Related Functions

◆ QMetaEnumBuilder

friend class QMetaEnumBuilder
friend

Definition at line 195 of file qmetaobjectbuilder_p.h.

◆ QMetaMethodBuilder

friend class QMetaMethodBuilder
friend

Definition at line 193 of file qmetaobjectbuilder_p.h.

◆ QMetaPropertyBuilder

friend class QMetaPropertyBuilder
friend

Definition at line 194 of file qmetaobjectbuilder_p.h.

Properties

◆ d

QMetaObjectBuilderPrivate* QMetaObjectBuilder::d
private

Definition at line 191 of file qmetaobjectbuilder_p.h.


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