PandA-2024.02
asn_type.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2015-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
41 #include "asn_type.hpp"
43 
44 #include <utility>
45 
47 #include "exceptions.hpp"
48 
49 AsnType::AsnType(const AsnType_Kind _kind) : kind(_kind)
50 {
51 }
52 
53 AsnType::~AsnType() = default;
54 
56 {
57  return kind;
58 }
59 
61 {
62 }
63 
64 ChoiceAsnType::ChoiceAsnType(std::list<std::pair<std::string, AsnTypeRef>> _element_type_list)
65  : AsnType(AsnType_Kind::CHOICE), element_type_list(std::move(_element_type_list))
66 {
67 }
68 
69 EnumeratedAsnType::EnumeratedAsnType(std::list<std::pair<std::string, unsigned int>> _named_number_list)
70  : AsnType(AsnType_Kind::ENUMERATED), named_number_list(std::move(_named_number_list))
71 {
72 }
73 
75 {
76 }
77 
79 {
80  THROW_ASSERT(_size.find("SIZE") != std::string::npos, _size);
81  THROW_ASSERT(_size.find("(") != std::string::npos, _size);
82  THROW_ASSERT(_size.find(")") != std::string::npos, _size);
83  const auto temp = _size.substr(_size.find('(') + 1);
84  const auto temp2 = temp.substr(0, temp.find(')'));
85  size = std::stoul(temp2);
86 }
87 
89 
91 {
92 }
93 
94 RedefineAsnType::RedefineAsnType(std::string _name) : AsnType(AsnType_Kind::REDEFINE), name(std::move(_name))
95 {
96 }
97 
98 SequenceAsnType::SequenceAsnType(std::list<std::pair<std::string, AsnTypeRef>> _fields)
99  : AsnType(AsnType_Kind::SEQUENCE), fields(std::move(_fields))
100 {
101 }
102 
103 SequenceOfAsnType::SequenceOfAsnType(std::string _element, const std::string& _size)
104  : AsnType(AsnType_Kind::SEQUENCEOF), element(std::move(_element))
105 {
106  THROW_ASSERT(_size.find("SIZE") != std::string::npos, _size);
107  THROW_ASSERT(_size.find("(") != std::string::npos, _size);
108  THROW_ASSERT(_size.find(")") != std::string::npos, _size);
109  const auto temp = _size.substr(_size.find('(') + 1);
110  const auto temp2 = temp.substr(0, temp.find(')'));
111  size = std::stoul(temp2);
112 }
113 
114 SetAsnType::SetAsnType(std::list<std::pair<std::string, AsnTypeRef>> _fields)
115  : AsnType(AsnType_Kind::SET), fields(std::move(_fields))
116 {
117 }
118 
119 SetOfAsnType::SetOfAsnType(std::string _element, const std::string& _size)
120  : AsnType(AsnType_Kind::SETOF), element(std::move(_element)), size(std::stoul(_size))
121 {
122 }
RealAsnType()
Constructor.
Definition: asn_type.cpp:90
SetAsnType(std::list< std::pair< std::string, AsnTypeRef >> _fields)
Constructor.
Definition: asn_type.cpp:114
size_t size
The number of elements in the sequence.
Definition: asn_type.hpp:195
SetOfAsnType(std::string element, const std::string &size)
Constructor.
Definition: asn_type.cpp:119
~OctetStringAsnType() override
Destructor.
exceptions managed by PandA
Definition of hash function for EdgeDescriptor.
Definition: graph.hpp:1321
SequenceAsnType(std::list< std::pair< std::string, AsnTypeRef >> _fields)
Constructor.
Definition: asn_type.cpp:98
OctetStringAsnType(const std::string &size)
Constructor.
Definition: asn_type.cpp:78
const AsnType_Kind kind
The actual kind.
Definition: asn_type.hpp:74
AsnType(const AsnType_Kind kind)
Constructor.
Definition: asn_type.cpp:49
kind
ChoiceAsnType(std::list< std::pair< std::string, AsnTypeRef >> element_type_list)
Constructor.
Definition: asn_type.cpp:64
virtual ~AsnType()
Destructor.
AsnType_Kind GetKind()
Return the type.
Definition: asn_type.cpp:55
BooleanAsnType()
Constructor.
Definition: asn_type.cpp:60
size_t size
The size.
Definition: asn_type.hpp:141
AsnType_Kind
Definition: asn_type.hpp:55
IntegerAsnType()
Constructor.
Definition: asn_type.cpp:74
Data classes storing information for asn types.
RedefineAsnType(std::string name)
Constructor.
Definition: asn_type.cpp:94
EnumeratedAsnType(std::list< std::pair< std::string, unsigned int >> named_number_list)
Constructor.
Definition: asn_type.cpp:69
SequenceOfAsnType(std::string element, const std::string &size)
Constructor.
Definition: asn_type.cpp:103
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13