EnumType.h revision 85eabdbe56720dcdcf130e5ca83129d47b143768
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(const char *localName, 15 std::vector<EnumValue *> *values, 16 Type *storageType = NULL); 17 18 const Type *storageType() const; 19 const std::vector<EnumValue *> &values() const; 20 21 const ScalarType *resolveToScalarType() const override; 22 23 bool isEnum() const override; 24 25 std::string getCppType(StorageMode mode, std::string *extra) const override; 26 27 std::string getJavaType() const override; 28 std::string getJavaSuffix() const override; 29 30 void emitReaderWriter( 31 Formatter &out, 32 const std::string &name, 33 const std::string &parcelObj, 34 bool parcelObjIsPointer, 35 bool isReader, 36 ErrorMode mode) const override; 37 38 void emitJavaFieldReaderWriter( 39 Formatter &out, 40 const std::string &blobName, 41 const std::string &fieldName, 42 const std::string &offset, 43 bool isReader) const override; 44 45 status_t emitTypeDeclarations(Formatter &out) const override; 46 47 status_t emitJavaTypeDeclarations( 48 Formatter &out, bool atTopLevel) const override; 49 50 status_t emitVtsTypeDeclarations(Formatter &out) const override; 51 status_t emitVtsAttributeType(Formatter &out) const override; 52 53 void getAlignmentAndSize(size_t *align, size_t *size) const override; 54 55private: 56 void getTypeChain(std::vector<const EnumType *> *out) const; 57 std::vector<EnumValue *> *mValues; 58 Type *mStorageType; 59 60 DISALLOW_COPY_AND_ASSIGN(EnumType); 61}; 62 63struct EnumValue { 64 EnumValue(const char *name, const char *value = NULL); 65 66 std::string name() const; 67 const char *value() const; 68 69private: 70 std::string mName; 71 const char *mValue; 72 73 DISALLOW_COPY_AND_ASSIGN(EnumValue); 74}; 75 76} // namespace android 77 78#endif // ENUM_TYPE_H_ 79 80