Qt 4.8
Public Functions | Private Functions | Properties | Friends | List of all members
QMetaEnumBuilder Class Reference

The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder. More...

#include <qmetaobjectbuilder_p.h>

Public Functions

int addKey (const QByteArray &name, int value)
 Adds a new key called name to this enumerator, associated with value. More...
 
int index () const
 Returns the index of this enumerator within its QMetaObjectBuilder. More...
 
bool isFlag () const
 Returns true if this enumerator is used as a flag; otherwise returns false. More...
 
QByteArray key (int index) const
 Returns the key with the given index, or an empty QByteArray if no such key exists. More...
 
int keyCount () const
 Returns the number of keys. More...
 
QByteArray name () const
 Returns the name of the enumerator (without the scope). More...
 
 QMetaEnumBuilder ()
 
void removeKey (int index)
 Removes the key at index from this enumerator. More...
 
void setIsFlag (bool value)
 Sets this enumerator to be used as a flag if value is true. More...
 
int value (int index) const
 Returns the value with the given index; or returns -1 if there is no such value. More...
 

Private Functions

QMetaEnumBuilderPrivated_func () const
 
 QMetaEnumBuilder (const QMetaObjectBuilder *mobj, int index)
 

Properties

int _index
 
const QMetaObjectBuilder_mobj
 

Friends

class QMetaObjectBuilder
 

Detailed Description

The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder.

Warning
This function is not part of the public interface.

Definition at line 289 of file qmetaobjectbuilder_p.h.

Constructors and Destructors

◆ QMetaEnumBuilder() [1/2]

QMetaEnumBuilder::QMetaEnumBuilder ( )
inline
Warning
This function is not part of the public interface.

Definition at line 292 of file qmetaobjectbuilder_p.h.

292 : _mobj(0), _index(0) {}
const QMetaObjectBuilder * _mobj

◆ QMetaEnumBuilder() [2/2]

QMetaEnumBuilder::QMetaEnumBuilder ( const QMetaObjectBuilder mobj,
int  index 
)
inlineprivate

Definition at line 314 of file qmetaobjectbuilder_p.h.

315  : _mobj(mobj), _index(index) {}
const QMetaObjectBuilder * _mobj
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.

Functions

◆ addKey()

int QMetaEnumBuilder::addKey ( const QByteArray name,
int  value 
)

Adds a new key called name to this enumerator, associated with value.

Returns the index of the new key.

See also
keyCount(), key(), value(), removeKey()

Definition at line 2595 of file qmetaobjectbuilder.cpp.

Referenced by QMetaObjectBuilder::addEnumerator().

2596 {
2598  if (d) {
2599  int index = d->keys.size();
2600  d->keys += name;
2601  d->values += value;
2602  return index;
2603  } else {
2604  return -1;
2605  }
2606 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.
QByteArray name() const
Returns the name of the enumerator (without the scope).

◆ d_func()

QMetaEnumBuilderPrivate * QMetaEnumBuilder::d_func ( ) const
private

Definition at line 2484 of file qmetaobjectbuilder.cpp.

2485 {
2486  if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size())
2487  return &(_mobj->d->enumerators[_index]);
2488  else
2489  return 0;
2490 }
double d
Definition: qnumeric_p.h:62
QList< QMetaEnumBuilderPrivate > enumerators
QMetaObjectBuilderPrivate * d
const QMetaObjectBuilder * _mobj

◆ index()

int QMetaEnumBuilder::index ( ) const
inline

Returns the index of this enumerator within its QMetaObjectBuilder.

Definition at line 294 of file qmetaobjectbuilder_p.h.

294 { return _index; }

◆ isFlag()

bool QMetaEnumBuilder::isFlag ( ) const

Returns true if this enumerator is used as a flag; otherwise returns false.

See also
setIsFlag()

Definition at line 2524 of file qmetaobjectbuilder.cpp.

2525 {
2527  if (d)
2528  return d->isFlag;
2529  else
2530  return false;
2531 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const

◆ key()

QByteArray QMetaEnumBuilder::key ( int  index) const

Returns the key with the given index, or an empty QByteArray if no such key exists.

See also
keyCount(), addKey(), value()

Definition at line 2565 of file qmetaobjectbuilder.cpp.

2566 {
2568  if (d && index >= 0 && index < d->keys.size())
2569  return d->keys[index];
2570  else
2571  return QByteArray();
2572 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaEnumBuilderPrivate * d_func() const
QStringList keys
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.

◆ keyCount()

int QMetaEnumBuilder::keyCount ( ) const

Returns the number of keys.

See also
key(), addKey()

Definition at line 2550 of file qmetaobjectbuilder.cpp.

2551 {
2553  if (d)
2554  return d->keys.size();
2555  else
2556  return 0;
2557 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ name()

QByteArray QMetaEnumBuilder::name ( ) const

Returns the name of the enumerator (without the scope).

Definition at line 2509 of file qmetaobjectbuilder.cpp.

2510 {
2512  if (d)
2513  return d->name;
2514  else
2515  return QByteArray();
2516 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QMetaEnumBuilderPrivate * d_func() const

◆ removeKey()

void QMetaEnumBuilder::removeKey ( int  index)

Removes the key at index from this enumerator.

See also
addKey()

Definition at line 2613 of file qmetaobjectbuilder.cpp.

2614 {
2616  if (d && index >= 0 && index < d->keys.size()) {
2617  d->keys.removeAt(index);
2618  d->values.removeAt(index);
2619  }
2620 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const
QStringList keys
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ setIsFlag()

void QMetaEnumBuilder::setIsFlag ( bool  value)

Sets this enumerator to be used as a flag if value is true.

See also
isFlag()

Definition at line 2538 of file qmetaobjectbuilder.cpp.

Referenced by QMetaObjectBuilder::addEnumerator().

2539 {
2541  if (d)
2542  d->isFlag = value;
2543 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.

◆ value()

int QMetaEnumBuilder::value ( int  index) const

Returns the value with the given index; or returns -1 if there is no such value.

See also
keyCount(), addKey(), key()

Definition at line 2580 of file qmetaobjectbuilder.cpp.

2581 {
2583  if (d && index >= 0 && index < d->keys.size())
2584  return d->values[index];
2585  else
2586  return -1;
2587 }
double d
Definition: qnumeric_p.h:62
QMetaEnumBuilderPrivate * d_func() const
QStringList keys
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.

Friends and Related Functions

◆ QMetaObjectBuilder

friend class QMetaObjectBuilder
friend

Definition at line 312 of file qmetaobjectbuilder_p.h.

Properties

◆ _index

int QMetaEnumBuilder::_index
private

Definition at line 310 of file qmetaobjectbuilder_p.h.

◆ _mobj

const QMetaObjectBuilder* QMetaEnumBuilder::_mobj
private

Definition at line 309 of file qmetaobjectbuilder_p.h.


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