Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #ifndef T_STRUCT_H |
| 2 | #define T_STRUCT_H |
| 3 | |
| 4 | #include <vector> |
| 5 | #include <string> |
| 6 | |
| 7 | #include "t_type.h" |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 8 | #include "t_field.h" |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 9 | |
| 10 | class t_struct : public t_type { |
| 11 | public: |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 12 | t_struct() : is_xception_(false) {} |
| 13 | t_struct(const std::string& name) : t_type(name), is_xception_(false) {} |
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 14 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 15 | ~t_struct() {} |
| 16 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 17 | /** Set the struct name */ |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 18 | void set_name(const std::string& name) { |
| 19 | name_ = name; |
| 20 | } |
| 21 | |
| 22 | /** Mark as an exception */ |
| 23 | void set_xception(bool is_xception) { |
| 24 | is_xception_ = is_xception; |
| 25 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 26 | |
| 27 | /** Add a new field to the list */ |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 28 | void append(t_field* elem) { |
| 29 | members_.push_back(elem); |
| 30 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 31 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 32 | const std::vector<t_field*>& get_members() { |
| 33 | return members_; |
| 34 | } |
| 35 | |
| 36 | bool is_struct() const { |
| 37 | return !is_xception_; |
| 38 | } |
| 39 | |
| 40 | bool is_xception() const { |
| 41 | return is_xception_; |
| 42 | } |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 43 | |
| 44 | private: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 45 | std::vector<t_field*> members_; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 46 | bool is_xception_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #endif |