Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #ifndef T_FUNCTION_H |
| 2 | #define T_FUNCTION_H |
| 3 | |
| 4 | #include <string> |
| 5 | #include "t_type.h" |
| 6 | #include "t_struct.h" |
ccheever | f53b5cf | 2007-02-05 20:33:11 +0000 | [diff] [blame] | 7 | #include "t_doc.h" |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 8 | |
| 9 | /** |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 10 | * Representation of a function. Key parts are return type, function name, |
| 11 | * optional modifiers, and an argument list, which is implemented as a thrift |
| 12 | * struct. |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 13 | * |
| 14 | * @author Mark Slee <mcslee@facebook.com> |
| 15 | */ |
ccheever | f53b5cf | 2007-02-05 20:33:11 +0000 | [diff] [blame] | 16 | class t_function : public t_doc { |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 17 | public: |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 18 | t_function(t_type* returntype, |
| 19 | std::string name, |
| 20 | t_struct* arglist, |
| 21 | bool async=false) : |
| 22 | returntype_(returntype), |
| 23 | name_(name), |
| 24 | arglist_(arglist), |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 25 | async_(async) { |
Mark Slee | f0712dc | 2006-10-25 19:03:57 +0000 | [diff] [blame] | 26 | xceptions_ = new t_struct(NULL); |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 29 | t_function(t_type* returntype, |
| 30 | std::string name, |
| 31 | t_struct* arglist, |
| 32 | t_struct* xceptions, |
| 33 | bool async=false) : |
| 34 | returntype_(returntype), |
| 35 | name_(name), |
| 36 | arglist_(arglist), |
| 37 | xceptions_(xceptions), |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 38 | async_(async) {} |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 39 | |
| 40 | ~t_function() {} |
| 41 | |
Mark Slee | f5377b3 | 2006-10-10 01:42:59 +0000 | [diff] [blame] | 42 | t_type* get_returntype() const { |
| 43 | return returntype_; |
| 44 | } |
| 45 | |
| 46 | const std::string& get_name() const { |
| 47 | return name_; |
| 48 | } |
| 49 | |
| 50 | t_struct* get_arglist() const { |
| 51 | return arglist_; |
| 52 | } |
| 53 | |
| 54 | t_struct* get_xceptions() const { |
| 55 | return xceptions_; |
| 56 | } |
| 57 | |
| 58 | bool is_async() const { |
| 59 | return async_; |
| 60 | } |
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 61 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 62 | private: |
| 63 | t_type* returntype_; |
| 64 | std::string name_; |
| 65 | t_struct* arglist_; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame] | 66 | t_struct* xceptions_; |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 67 | bool async_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | #endif |