blob: a365cd44a68a0a407511b479776da5beb5e98e41 [file] [log] [blame]
Mark Slee31985722006-05-24 21:45:31 +00001#ifndef T_STRUCT_H
2#define T_STRUCT_H
3
4#include <vector>
5#include <string>
6
7#include "t_type.h"
Mark Sleee8540632006-05-30 09:24:40 +00008#include "t_field.h"
Mark Slee31985722006-05-24 21:45:31 +00009
10class t_struct : public t_type {
11 public:
Mark Slee9cb7c612006-09-01 22:17:45 +000012 t_struct() : is_xception_(false) {}
13 t_struct(const std::string& name) : t_type(name), is_xception_(false) {}
Mark Sleeb15a68b2006-06-07 06:46:24 +000014
Mark Slee31985722006-05-24 21:45:31 +000015 ~t_struct() {}
16
Mark Sleee8540632006-05-30 09:24:40 +000017 /** Set the struct name */
Mark Slee9cb7c612006-09-01 22:17:45 +000018 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 Sleee8540632006-05-30 09:24:40 +000026
27 /** Add a new field to the list */
Mark Slee9cb7c612006-09-01 22:17:45 +000028 void append(t_field* elem) {
29 members_.push_back(elem);
30 }
Mark Sleee8540632006-05-30 09:24:40 +000031
Mark Slee9cb7c612006-09-01 22:17:45 +000032 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 Slee31985722006-05-24 21:45:31 +000043
44 private:
Mark Sleee8540632006-05-30 09:24:40 +000045 std::vector<t_field*> members_;
Mark Slee9cb7c612006-09-01 22:17:45 +000046 bool is_xception_;
Mark Slee31985722006-05-24 21:45:31 +000047};
48
49#endif