blob: fc2a9ea988f97022526d24582fd59a5038af4788 [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
Andreas Huber31629bc2016-08-03 09:06:40 -070011struct EnumValue;
Andreas Huberc9410c72016-07-28 12:18:40 -070012
13struct EnumType : public NamedType {
Andreas Huber9ed827c2016-08-22 12:31:13 -070014 EnumType(const char *localName,
15 std::vector<EnumValue *> *values,
Andreas Huberc9410c72016-07-28 12:18:40 -070016 Type *storageType = NULL);
17
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070018 const Type *storageType() const;
19 const std::vector<EnumValue *> &values() const;
20
Andreas Huber737080b2016-08-02 15:38:04 -070021 const ScalarType *resolveToScalarType() const override;
22
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070023 bool isEnum() const override;
24
Andreas Huber881227d2016-08-02 14:20:21 -070025 std::string getCppType(StorageMode mode, std::string *extra) const override;
26
Andreas Huber2831d512016-08-15 09:33:47 -070027 std::string getJavaType() const override;
28 std::string getJavaSuffix() const override;
29
Andreas Huber881227d2016-08-02 14:20:21 -070030 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 status_t emitTypeDeclarations(Formatter &out) const override;
Andreas Huber2831d512016-08-15 09:33:47 -070039 status_t emitJavaTypeDeclarations(Formatter &out) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070040
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070041 status_t emitVtsTypeDeclarations(Formatter &out) const override;
42 status_t emitVtsArgumentType(Formatter &out) const override;
43
Andreas Huberc9410c72016-07-28 12:18:40 -070044private:
Andreas Huber881227d2016-08-02 14:20:21 -070045 std::vector<EnumValue *> *mValues;
Andreas Huberc9410c72016-07-28 12:18:40 -070046 Type *mStorageType;
47
48 DISALLOW_COPY_AND_ASSIGN(EnumType);
49};
50
Andreas Huber31629bc2016-08-03 09:06:40 -070051struct EnumValue {
52 EnumValue(const char *name, const char *value = NULL);
53
54 std::string name() const;
55 const char *value() const;
56
57private:
58 std::string mName;
59 const char *mValue;
60
61 DISALLOW_COPY_AND_ASSIGN(EnumValue);
62};
63
Andreas Huberc9410c72016-07-28 12:18:40 -070064} // namespace android
65
66#endif // ENUM_TYPE_H_
67