blob: a5877274c21b0777f095e1b31fabace620cb510a [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef ENUM_TYPE_H_
2
3#define ENUM_TYPE_H_
4
5#include "NamedType.h"
6
Andreas Huber881227d2016-08-02 14:20:21 -07007#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -07008
9namespace android {
10
11struct EnumValue {
12 EnumValue(const char *name, const char *value = NULL);
13
14 void dump(Formatter &out) const;
15
Andreas Huber881227d2016-08-02 14:20:21 -070016 std::string name() const;
17 const char *value() const;
18
Andreas Huberc9410c72016-07-28 12:18:40 -070019private:
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,
Andreas Huber881227d2016-08-02 14:20:21 -070028 std::vector<EnumValue *> *values,
Andreas Huberc9410c72016-07-28 12:18:40 -070029 Type *storageType = NULL);
30
31 void dump(Formatter &out) const override;
32
Andreas Huber737080b2016-08-02 15:38:04 -070033 const ScalarType *resolveToScalarType() const override;
34
Andreas Huber881227d2016-08-02 14:20:21 -070035 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
Andreas Huberc9410c72016-07-28 12:18:40 -070047private:
Andreas Huber881227d2016-08-02 14:20:21 -070048 std::vector<EnumValue *> *mValues;
Andreas Huberc9410c72016-07-28 12:18:40 -070049 Type *mStorageType;
50
51 DISALLOW_COPY_AND_ASSIGN(EnumType);
52};
53
54} // namespace android
55
56#endif // ENUM_TYPE_H_
57