OpenSDN source code
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  * Modifications Copyright (c) Juniper Networks, Inc.
20  * Copyright Contributors to the OpenSDN project
21  */
22 
23 #ifndef T_STRUCT_H
24 #define T_STRUCT_H
25 
26 #include <string>
27 
28 #include "t_type.h"
29 #include "t_struct_common.h"
30 #include "t_base_type.h"
31 
32 // Forward declare that puppy
33 class t_program;
34 
40 class t_struct : public t_struct_common {
41  public:
42  t_struct(t_program* program) :
43  t_struct_common(program),
44  is_xception_(false),
45  xsd_all_(false) {}
46 
47  t_struct(t_program* program, const std::string& name) :
48  t_struct_common(program, name),
49  is_xception_(false),
50  xsd_all_(false) {}
51 
52  virtual std::string get_struct_type_name() {
53  return "Struct";
54  }
55 
58  }
59 
60  void set_union(bool is_union) {
62  }
63 
64  void set_xsd_all(bool xsd_all) {
65  xsd_all_ = xsd_all;
66  }
67 
68  bool get_xsd_all() const {
69  return xsd_all_;
70  }
71 
72  bool is_struct() const {
73  return !is_xception_;
74  }
75 
76  bool is_xception() const {
77  return is_xception_;
78  }
79 
80  bool is_union() const {
81  return is_union_;
82  }
83 
84  t_field* get_field_by_name(std::string field_name) {
85  members_type::const_iterator m_iter;
86  for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
87  if ((*m_iter)->get_name() == field_name) {
88  return *m_iter;
89  }
90  }
91  return NULL;
92  }
93 
94 #ifdef SANDESH
95  virtual bool has_key_annotation() const;
96 #endif
97 
98  private:
100  bool is_union_;
101  bool xsd_all_;
102 };
103 
104 #endif
members_type members_in_id_order_
bool is_xception() const
Definition: t_struct.h:76
bool is_union_
Definition: t_struct.h:100
bool is_struct() const
Definition: t_struct.h:72
void set_xsd_all(bool xsd_all)
Definition: t_struct.h:64
t_struct(t_program *program, const std::string &name)
Definition: t_struct.h:47
bool xsd_all_
Definition: t_struct.h:101
void set_union(bool is_union)
Definition: t_struct.h:60
bool is_xception_
Definition: t_struct.h:99
bool is_union() const
Definition: t_struct.h:80
bool get_xsd_all() const
Definition: t_struct.h:68
t_struct(t_program *program)
Definition: t_struct.h:42
virtual std::string get_struct_type_name()
Definition: t_struct.h:52
t_field * get_field_by_name(std::string field_name)
Definition: t_struct.h:84
void set_xception(bool is_xception)
Definition: t_struct.h:56