blob: 810f3bee78c58f02ecfb824973fb71461eb60eb9 [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 Slee32007a52008-01-18 00:57:59 +000023 void set_name(const std::string& name) {
Mark Sleef5377b32006-10-10 01:42:59 +000024 name_ = name;
25 }
Mark Slee32007a52008-01-18 00:57:59 +000026
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
David Reiss18bf22d2007-08-28 20:49:17 +000039 virtual std::string get_fingerprint_material() const {
40 return "enum";
41 }
42
Mark Slee31985722006-05-24 21:45:31 +000043 private:
Mark Slee30152872006-11-28 01:24:07 +000044 std::vector<t_enum_value*> constants_;
Mark Slee31985722006-05-24 21:45:31 +000045};
46
47#endif