blob: 4c545cde147f3a85b0a88f4bd687fc8b74d68757 [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 *
Mark Sleef5377b32006-10-10 01:42:59 +000016 */
Mark Slee31985722006-05-24 21:45:31 +000017class t_enum : public t_type {
18 public:
Mark Sleef0712dc2006-10-25 19:03:57 +000019 t_enum(t_program* program) :
20 t_type(program) {}
Mark Slee31985722006-05-24 21:45:31 +000021
Mark Slee32007a52008-01-18 00:57:59 +000022 void set_name(const std::string& name) {
Mark Sleef5377b32006-10-10 01:42:59 +000023 name_ = name;
24 }
Mark Slee32007a52008-01-18 00:57:59 +000025
Mark Slee30152872006-11-28 01:24:07 +000026 void append(t_enum_value* constant) {
Mark Sleef5377b32006-10-10 01:42:59 +000027 constants_.push_back(constant);
28 }
Mark Slee31985722006-05-24 21:45:31 +000029
Mark Slee30152872006-11-28 01:24:07 +000030 const std::vector<t_enum_value*>& get_constants() {
Mark Sleef5377b32006-10-10 01:42:59 +000031 return constants_;
32 }
33
34 bool is_enum() const {
35 return true;
36 }
Mark Slee31985722006-05-24 21:45:31 +000037
David Reiss18bf22d2007-08-28 20:49:17 +000038 virtual std::string get_fingerprint_material() const {
39 return "enum";
40 }
41
Mark Slee31985722006-05-24 21:45:31 +000042 private:
Mark Slee30152872006-11-28 01:24:07 +000043 std::vector<t_enum_value*> constants_;
Mark Slee31985722006-05-24 21:45:31 +000044};
45
46#endif