EnumType.h revision 8d3ac0c6112e02e3a705fd4f9d82e523f10b4287
1#ifndef ENUM_TYPE_H_ 2 3#define ENUM_TYPE_H_ 4 5#include "NamedType.h" 6 7#include <vector> 8 9namespace android { 10 11struct EnumValue; 12 13struct EnumType : public NamedType { 14 EnumType(std::vector<EnumValue *> *values, 15 Type *storageType = NULL); 16 17 const Type *storageType() const; 18 const std::vector<EnumValue *> &values() const; 19 20 const ScalarType *resolveToScalarType() const override; 21 22 bool isEnum() const override; 23 24 std::string getCppType(StorageMode mode, std::string *extra) const override; 25 26 void emitReaderWriter( 27 Formatter &out, 28 const std::string &name, 29 const std::string &parcelObj, 30 bool parcelObjIsPointer, 31 bool isReader, 32 ErrorMode mode) const override; 33 34 status_t emitTypeDeclarations(Formatter &out) const override; 35 36private: 37 std::vector<EnumValue *> *mValues; 38 Type *mStorageType; 39 40 DISALLOW_COPY_AND_ASSIGN(EnumType); 41}; 42 43struct EnumValue { 44 EnumValue(const char *name, const char *value = NULL); 45 46 std::string name() const; 47 const char *value() const; 48 49private: 50 std::string mName; 51 const char *mValue; 52 53 DISALLOW_COPY_AND_ASSIGN(EnumValue); 54}; 55 56} // namespace android 57 58#endif // ENUM_TYPE_H_ 59 60