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