LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/sandesh/compiler/parse - t_struct.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 20 29 69.0 %
Date: 2026-08-03 02:19:58 Functions: 7 10 70.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      32             : /**
      33             :  * A struct is a container for a set of member fields that has a name. Structs
      34             :  * are also used to implement exception types.
      35             :  *
      36             :  */
      37             : class t_struct : public t_struct_common {
      38             :  public:
      39       15098 :   t_struct(t_program* program) :
      40             :     t_struct_common(program),
      41       15098 :     is_xception_(false),
      42       15098 :     xsd_all_(false) {}
      43             : 
      44           0 :   t_struct(t_program* program, const std::string& name) :
      45             :     t_struct_common(program, name),
      46           0 :     is_xception_(false),
      47           0 :     xsd_all_(false) {}
      48             : 
      49        2202 :   virtual std::string get_struct_type_name() {
      50        2202 :     return "Struct";
      51             :   }
      52             : 
      53           0 :   void set_xception(bool is_xception) {
      54           0 :     is_xception_ = is_xception;
      55           0 :   }
      56             : 
      57        9048 :   void set_union(bool is_union) {
      58        9048 :     is_union_ = is_union;
      59        9048 :   }
      60             : 
      61        9048 :   void set_xsd_all(bool xsd_all) {
      62        9048 :     xsd_all_ = xsd_all;
      63        9048 :   }
      64             : 
      65           0 :   bool get_xsd_all() const {
      66           0 :     return xsd_all_;
      67             :   }
      68             : 
      69       28851 :   bool is_struct() const {
      70       28851 :     return !is_xception_;
      71             :   }
      72             : 
      73        1700 :   bool is_xception() const {
      74        1700 :     return is_xception_;
      75             :   }
      76             : 
      77             :   bool is_union() const {
      78             :     return is_union_;
      79             :   }
      80             : 
      81       15860 :   t_field* get_field_by_name(std::string field_name) {
      82       15860 :     members_type::const_iterator m_iter;
      83       35240 :     for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
      84       35240 :       if ((*m_iter)->get_name() == field_name) {
      85       15860 :         return *m_iter;
      86             :       }
      87             :     }
      88           0 :     return NULL;
      89             :   }
      90             : 
      91             : #ifdef SANDESH
      92             :   virtual bool has_key_annotation() const;
      93             : #endif
      94             : 
      95             :  private:
      96             :   bool is_xception_;
      97             :   bool is_union_;
      98             :   bool xsd_all_;
      99             : };
     100             : 
     101             : #endif

Generated by: LCOV version 1.14