blob: bc46017c641cf5ec3ac70363112f7f0fff0e88cb [file] [log] [blame]
Mark Sleee9ce01c2007-05-16 02:29:53 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Slee31985722006-05-24 21:45:31 +00007#ifndef T_ENUM_H
8#define T_ENUM_H
9
Mark Slee30152872006-11-28 01:24:07 +000010#include "t_enum_value.h"
Mark Slee31985722006-05-24 21:45:31 +000011#include <vector>
12
Mark Sleef5377b32006-10-10 01:42:59 +000013/**
Mark Slee30152872006-11-28 01:24:07 +000014 * An enumerated type. A list of constant objects with a name for the type.
Mark Sleef5377b32006-10-10 01:42:59 +000015 *
16 * @author Mark Slee <mcslee@facebook.com>
17 */
Mark Slee31985722006-05-24 21:45:31 +000018class t_enum : public t_type {
19 public:
Mark Sleef0712dc2006-10-25 19:03:57 +000020 t_enum(t_program* program) :
21 t_type(program) {}
Mark Slee31985722006-05-24 21:45:31 +000022
Mark Sleef5377b32006-10-10 01:42:59 +000023 void set_name(std::string name) {
24 name_ = name;
25 }
26
Mark Slee30152872006-11-28 01:24:07 +000027 void append(t_enum_value* constant) {
Mark Sleef5377b32006-10-10 01:42:59 +000028 constants_.push_back(constant);
29 }
Mark Slee31985722006-05-24 21:45:31 +000030
Mark Slee30152872006-11-28 01:24:07 +000031 const std::vector<t_enum_value*>& get_constants() {
Mark Sleef5377b32006-10-10 01:42:59 +000032 return constants_;
33 }
34
35 bool is_enum() const {
36 return true;
37 }
Mark Slee31985722006-05-24 21:45:31 +000038
39 private:
Mark Slee30152872006-11-28 01:24:07 +000040 std::vector<t_enum_value*> constants_;
Mark Slee31985722006-05-24 21:45:31 +000041};
42
43#endif