blob: 58667d89d7c408fe738a46a20d5429e14e91808e [file] [log] [blame]
Mark Slee31985722006-05-24 21:45:31 +00001#ifndef T_FUNCTION_H
2#define T_FUNCTION_H
3
4#include <string>
5#include "t_type.h"
6#include "t_struct.h"
7
8/**
9 * Representation of a function. Key parst are return type, function name,
Mark Slee52f643d2006-08-09 00:03:43 +000010 * optional modifiers, and an argument list.
Mark Slee31985722006-05-24 21:45:31 +000011 *
12 * @author Mark Slee <mcslee@facebook.com>
13 */
14class t_function {
15 public:
Mark Slee52f643d2006-08-09 00:03:43 +000016 t_function(t_type* returntype,
17 std::string name,
18 t_struct* arglist,
19 bool async=false) :
20 returntype_(returntype),
21 name_(name),
22 arglist_(arglist),
Mark Slee9cb7c612006-09-01 22:17:45 +000023 async_(async) {
24 xceptions_ = new t_struct;
25 }
26
27
28 t_function(t_type* returntype,
29 std::string name,
30 t_struct* arglist,
31 t_struct* xceptions,
32 bool async=false) :
33 returntype_(returntype),
34 name_(name),
35 arglist_(arglist),
36 xceptions_(xceptions),
Mark Slee52f643d2006-08-09 00:03:43 +000037 async_(async) {}
Mark Slee31985722006-05-24 21:45:31 +000038
39 ~t_function() {}
40
Mark Slee31985722006-05-24 21:45:31 +000041 t_type* get_returntype() const { return returntype_; }
42 const std::string& get_name() const { return name_; }
43 t_struct* get_arglist() const { return arglist_; }
Mark Slee9cb7c612006-09-01 22:17:45 +000044 t_struct* get_xceptions() const { return xceptions_; }
Mark Slee52f643d2006-08-09 00:03:43 +000045 bool is_async() const { return async_; }
Mark Sleeb15a68b2006-06-07 06:46:24 +000046
Mark Slee31985722006-05-24 21:45:31 +000047 private:
48 t_type* returntype_;
49 std::string name_;
50 t_struct* arglist_;
Mark Slee9cb7c612006-09-01 22:17:45 +000051 t_struct* xceptions_;
Mark Slee52f643d2006-08-09 00:03:43 +000052 bool async_;
Mark Slee31985722006-05-24 21:45:31 +000053};
54
55#endif