Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #ifndef T_FIELD_H |
2 | #define T_FIELD_H | ||||
3 | |||||
4 | #include <string> | ||||
5 | |||||
6 | /** | ||||
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame^] | 7 | * Class to represent a field in a thrift structure. A field has a data type, |
8 | * a symbolic name, and a numeric identifier. | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 9 | * |
10 | * @author Mark Slee <mcslee@facebook.com> | ||||
11 | */ | ||||
12 | class t_field { | ||||
13 | public: | ||||
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 14 | t_field(t_type* type, std::string name) : |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame^] | 15 | type_(type), |
16 | name_(name), | ||||
17 | key_(0) {} | ||||
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 18 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 19 | t_field(t_type* type, std::string name, int32_t key) : |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame^] | 20 | type_(type), |
21 | name_(name), | ||||
22 | key_(key) {} | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 23 | |
24 | ~t_field() {} | ||||
25 | |||||
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame^] | 26 | t_type* get_type() const { |
27 | return type_; | ||||
28 | } | ||||
29 | |||||
30 | const std::string& get_name() const { | ||||
31 | return name_; | ||||
32 | } | ||||
33 | |||||
34 | int32_t get_key() const { | ||||
35 | return key_; | ||||
36 | } | ||||
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 37 | |
38 | private: | ||||
39 | t_type* type_; | ||||
40 | std::string name_; | ||||
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 41 | int32_t key_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 42 | }; |
43 | |||||
44 | #endif |