34
* Representation of a C/C++ 'enum'.
35
* \see Puma::CEnumInfo */
37
/** \class CEnumInfo CEnumInfo.h Puma/infos/CEnumInfo.h
38
* A CEnumInfo object represents a C++ 'enum'. */
33
/** \class CEnumInfo CEnumInfo.h Puma/CEnumInfo.h
34
* Semantic information about an enumeration. */
39
35
class CEnumInfo : public CScopeRequest {
40
36
Array<CEnumeratorInfo*> _Enumerators;
41
37
CTypeInfo *_UnderlyingType;
44
/** Construct a new enumeration info object. */
46
/** Destroy the enum info object. If the object id is
47
* \c ENUM_INFO, Puma::CObjectInfo::CleanUp() is called. */
42
/** Destructor. If the object type is CObjectInfo::ENUM_INFO,
43
* then CObjectInfo::CleanUp() is called. */
50
46
/** Get the number of enumerators in this enumeration. */
51
47
unsigned Enumerators () const;
52
/** Get the n-th enumerator info.
53
* \param n The number of the enumerator.
54
* \return The enumerator info or \c NULL if \e n is invalid. */
48
/** Get the n-th enumerator.
49
* \param n The index of the enumerator.
50
* \return The enumerator or NULL if \e n is invalid. */
55
51
CEnumeratorInfo *Enumerator (unsigned n) const;
56
/** Get the info of the enumerator with the given name.
52
/** Get the enumerator with the given name.
57
53
* \param name The name of the enumerator.
58
* \return The enumerator info or \c NULL if no enumerator with that name. */
54
* \return The enumerator or NULL if no enumerator with that name. */
59
55
CEnumeratorInfo *Enumerator (const char *name) const;
61
/** Get the base info object of the info object. <b>The
62
* corresponding information is not yet set!</b>
63
* \return This method always returns \c NULL.
64
* \warning Do not use this method. */
65
CEnumInfo *BaseObject () const;
66
/** Get the info object of the enumeration definition.
67
* \return The info or \e this if the enumeration is not defined. */
57
/** Get the semantic object of the enumeration definition.
58
* \see CObjectInfo::DefObject() */
68
59
CEnumInfo *DefObject () const;
69
/** Get the type information object for the enumeration. */
60
/** Get the type information for the enumeration. */
70
61
CTypeEnum *TypeInfo () const;
72
63
/** Add a new enumerator to the enumeration.
73
* \param ei The enumerator info to add. */
64
* \param ei The enumerator. */
74
65
void addEnumerator (CEnumeratorInfo *ei);
75
66
/** Remove the given enumerator from the enumeration.
76
* \param ei The enumerator info to remove. */
67
* \param ei The enumerator. */
77
68
void removeEnumerator (const CEnumeratorInfo *ei);
79
/** Create a new enumerator info. The enumerator info is
80
* added to the enumeration. */
70
/** Create a semantic object for an enumerator. The new
71
* enumerator is added to the enumeration. */
81
72
CEnumeratorInfo *newEnumerator ();
82
/** Destroy the given enumerator info. The enumerator info is
73
/** Destroy the given enumerator. The enumerator is
83
74
* removed from the enumeration.
84
* \param ei The enumerator info to destroy. */
75
* \param ei The enumerator. */
85
76
void deleteEnumerator (const CEnumeratorInfo *ei);
87
/** Return \e true if the enumeration is defined. */
78
/** Check if the enumeration is defined. */
88
79
bool isDefined () const;
89
/** Return \e true if the enumeration is complete (defined)
90
* at the given position.
91
* \param pos The current source code position. */
80
/** Check if the enumeration is complete (defined)
81
* at the given source code position. The position
82
* is specified by the unique number of the CT_Token
83
* tree node representing the name of the enumeration.
84
* \param pos The source code position. */
92
85
bool isComplete (unsigned long pos = 0) const;
94
/** Return the underlying data type. */
87
/** Return the underlying data type of the enumeration.
88
* This is implementation-defined and defaults to \e int. */
95
89
CTypeInfo *UnderlyingType () const;
96
/** Set the underlying data type.
90
/** Set the underlying data type of the enumeration.
91
* This is implementation-defined and defaults to \e int.
97
92
* \param type The underlying type. */
98
93
void UnderlyingType (CTypeInfo *type);