EnumType.h revision 2831d5145675ead9f2fb767bf5fe4ae56b88349f
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    std::string getJavaType() const override;
27    std::string getJavaSuffix() const override;
28
29    void emitReaderWriter(
30            Formatter &out,
31            const std::string &name,
32            const std::string &parcelObj,
33            bool parcelObjIsPointer,
34            bool isReader,
35            ErrorMode mode) const override;
36
37    status_t emitTypeDeclarations(Formatter &out) const override;
38    status_t emitJavaTypeDeclarations(Formatter &out) const override;
39
40private:
41    std::vector<EnumValue *> *mValues;
42    Type *mStorageType;
43
44    DISALLOW_COPY_AND_ASSIGN(EnumType);
45};
46
47struct EnumValue {
48    EnumValue(const char *name, const char *value = NULL);
49
50    std::string name() const;
51    const char *value() const;
52
53private:
54    std::string mName;
55    const char *mValue;
56
57    DISALLOW_COPY_AND_ASSIGN(EnumValue);
58};
59
60}  // namespace android
61
62#endif  // ENUM_TYPE_H_
63
64