OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
t_struct.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef T_STRUCT_H
21 #define T_STRUCT_H
22 
23 #include <string>
24 
25 #include "t_type.h"
26 #include "t_struct_common.h"
27 #include "t_base_type.h"
28 
29 // Forward declare that puppy
30 class t_program;
31 
37 class t_struct : public t_struct_common {
38  public:
39  t_struct(t_program* program) :
40  t_struct_common(program),
41  is_xception_(false),
42  xsd_all_(false) {}
43 
44  t_struct(t_program* program, const std::string& name) :
45  t_struct_common(program, name),
46  is_xception_(false),
47  xsd_all_(false) {}
48 
49  virtual std::string get_struct_type_name() {
50  return "Struct";
51  }
52 
55  }
56 
57  void set_union(bool is_union) {
59  }
60 
61  void set_xsd_all(bool xsd_all) {
62  xsd_all_ = xsd_all;
63  }
64 
65  bool get_xsd_all() const {
66  return xsd_all_;
67  }
68 
69  bool is_struct() const {
70  return !is_xception_;
71  }
72 
73  bool is_xception() const {
74  return is_xception_;
75  }
76 
77  bool is_union() const {
78  return is_union_;
79  }
80 
81  t_field* get_field_by_name(std::string field_name) {
82  members_type::const_iterator m_iter;
83  for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
84  if ((*m_iter)->get_name() == field_name) {
85  return *m_iter;
86  }
87  }
88  return NULL;
89  }
90 
91 #ifdef SANDESH
92  virtual bool has_key_annotation() const;
93 #endif
94 
95  private:
97  bool is_union_;
98  bool xsd_all_;
99 };
100 
101 #endif
virtual std::string get_struct_type_name()
Definition: t_struct.h:49
t_struct(t_program *program)
Definition: t_struct.h:39
t_field * get_field_by_name(std::string field_name)
Definition: t_struct.h:81
bool is_union() const
Definition: t_struct.h:77
void set_xception(bool is_xception)
Definition: t_struct.h:53
bool is_xception_
Definition: t_struct.h:96
bool is_struct() const
Definition: t_struct.h:69
t_struct(t_program *program, const std::string &name)
Definition: t_struct.h:44
bool xsd_all_
Definition: t_struct.h:98
void set_union(bool is_union)
Definition: t_struct.h:57
void set_xsd_all(bool xsd_all)
Definition: t_struct.h:61
members_type members_in_id_order_
bool is_xception() const
Definition: t_struct.h:73
bool is_union_
Definition: t_struct.h:97
bool get_xsd_all() const
Definition: t_struct.h:65