Mark Slee | e9ce01c | 2007-05-16 02:29:53 +0000 | [diff] [blame] | 1 | // Copyright (c) 2006- Facebook |
2 | // Distributed under the Thrift Software License | ||||
3 | // | ||||
4 | // See accompanying file LICENSE or visit the Thrift site at: | ||||
5 | // http://developers.facebook.com/thrift/ | ||||
6 | |||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 7 | #ifndef T_ENUM_H |
8 | #define T_ENUM_H | ||||
9 | |||||
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 10 | #include "t_enum_value.h" |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 11 | #include <vector> |
12 | |||||
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 13 | /** |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 14 | * An enumerated type. A list of constant objects with a name for the type. |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 15 | * |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 16 | */ |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 17 | class t_enum : public t_type { |
18 | public: | ||||
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 19 | t_enum(t_program* program) : |
20 | t_type(program) {} | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 21 | |
Mark Slee | 32007a5 | 2008-01-18 00:57:59 +0000 | [diff] [blame] | 22 | void set_name(const std::string& name) { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 23 | name_ = name; |
24 | } | ||||
Mark Slee | 32007a5 | 2008-01-18 00:57:59 +0000 | [diff] [blame] | 25 | |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 26 | void append(t_enum_value* constant) { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 27 | constants_.push_back(constant); |
28 | } | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 29 | |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 30 | const std::vector<t_enum_value*>& get_constants() { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 31 | return constants_; |
32 | } | ||||
33 | |||||
34 | bool is_enum() const { | ||||
35 | return true; | ||||
36 | } | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 37 | |
David Reiss | 18bf22d | 2007-08-28 20:49:17 +0000 | [diff] [blame] | 38 | virtual std::string get_fingerprint_material() const { |
39 | return "enum"; | ||||
40 | } | ||||
41 | |||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 42 | private: |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 43 | std::vector<t_enum_value*> constants_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 44 | }; |
45 | |||||
46 | #endif |