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