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 | * |
16 | * @author Mark Slee <mcslee@facebook.com> | ||||
17 | */ | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 18 | class t_enum : public t_type { |
19 | public: | ||||
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 20 | t_enum(t_program* program) : |
21 | t_type(program) {} | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 22 | |
Mark Slee | 32007a5 | 2008-01-18 00:57:59 +0000 | [diff] [blame^] | 23 | void set_name(const std::string& name) { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 24 | name_ = name; |
25 | } | ||||
Mark Slee | 32007a5 | 2008-01-18 00:57:59 +0000 | [diff] [blame^] | 26 | |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 27 | void append(t_enum_value* constant) { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 28 | constants_.push_back(constant); |
29 | } | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 30 | |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 31 | const std::vector<t_enum_value*>& get_constants() { |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 32 | return constants_; |
33 | } | ||||
34 | |||||
35 | bool is_enum() const { | ||||
36 | return true; | ||||
37 | } | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 38 | |
David Reiss | 18bf22d | 2007-08-28 20:49:17 +0000 | [diff] [blame] | 39 | virtual std::string get_fingerprint_material() const { |
40 | return "enum"; | ||||
41 | } | ||||
42 | |||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 43 | private: |
Mark Slee | 3015287 | 2006-11-28 01:24:07 +0000 | [diff] [blame] | 44 | std::vector<t_enum_value*> constants_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 45 | }; |
46 | |||||
47 | #endif |