Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Baranyi, Botond | |
11 | * Beres, Szabolcs | |
12 | * Delic, Adam | |
13 | * Forstner, Matyas | |
14 | * Kovacs, Ferenc | |
15 | * Raduly, Csaba | |
16 | * Szabados, Kristof | |
17 | * Szabo, Bence Janos | |
18 | * Szabo, Janos Zoltan – initial implementation | |
19 | * Szalai, Gabor | |
20 | * | |
21 | ******************************************************************************/ | |
970ed795 EL |
22 | #include <string.h> |
23 | ||
24 | #include "Error.hh" | |
25 | #include "Logger.hh" | |
26 | #include "Encdec.hh" | |
27 | #include "BER.hh" | |
28 | #include "Param_Types.hh" | |
29 | ||
30 | #include "ASN_EmbeddedPDV.hh" | |
31 | ||
32 | #include "../common/dbgnew.hh" | |
33 | ||
34 | /* | |
35 | ||
36 | to do when regenerating: | |
37 | ||
38 | in .hh file: | |
39 | ||
40 | add __SUNPRO_CC ifdefs for single_value_struct | |
41 | ||
42 | in .cc file: | |
43 | ||
44 | replace '@EMBEDDED PDV' with 'EMBEDDED PDV' | |
45 | ||
46 | remove RAW and TEXT enc/dec functions | |
47 | ||
48 | make the type descriptors of embedded types static | |
49 | ||
50 | */ | |
51 | ||
52 | static const ASN_Tag_t EMBEDDED_PDV_identification_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
53 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_ber_ = { 1u, EMBEDDED_PDV_identification_tag_ }; | |
a38c6d4c | 54 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_descr_ = { "EMBEDDED PDV.identification", &EMBEDDED_PDV_identification_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
55 | |
56 | static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_abstract_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
57 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_abstract_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_abstract_tag_ }; | |
a38c6d4c | 58 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_abstract_descr_ = { "EMBEDDED PDV.identification.syntaxes.abstract", &EMBEDDED_PDV_identification_syntaxes_abstract_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
59 | |
60 | static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_transfer_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
61 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_transfer_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_transfer_tag_ }; | |
a38c6d4c | 62 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_transfer_descr_ = { "EMBEDDED PDV.identification.syntaxes.transfer", &EMBEDDED_PDV_identification_syntaxes_transfer_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
63 | |
64 | static const ASN_Tag_t EMBEDDED_PDV_identification_syntaxes_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
65 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntaxes_ber_ = { 1u, EMBEDDED_PDV_identification_syntaxes_tag_ }; | |
a38c6d4c | 66 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntaxes_descr_ = { "EMBEDDED PDV.identification.syntaxes", &EMBEDDED_PDV_identification_syntaxes_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
67 | |
68 | static const ASN_Tag_t EMBEDDED_PDV_identification_syntax_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
69 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_syntax_ber_ = { 1u, EMBEDDED_PDV_identification_syntax_tag_ }; | |
a38c6d4c | 70 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_syntax_descr_ = { "EMBEDDED PDV.identification.syntax", &EMBEDDED_PDV_identification_syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
71 | |
72 | static const ASN_Tag_t EMBEDDED_PDV_identification_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 2u }}; | |
73 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_presentation__context__id_ber_ = { 1u, EMBEDDED_PDV_identification_presentation__context__id_tag_ }; | |
a38c6d4c | 74 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_presentation__context__id_descr_ = { "EMBEDDED PDV.identification.presentation-context-id", &EMBEDDED_PDV_identification_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
75 | |
76 | static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
77 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_tag_ }; | |
a38c6d4c | 78 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_descr_ = { "EMBEDDED PDV.identification.context-negotiation.presentation-context-id", &EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
79 | |
80 | static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
81 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_tag_ }; | |
a38c6d4c | 82 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_descr_ = { "EMBEDDED PDV.identification.context-negotiation.transfer-syntax", &EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
83 | |
84 | static const ASN_Tag_t EMBEDDED_PDV_identification_context__negotiation_tag_[] = { { ASN_TAG_CONT, 3u }}; | |
85 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_context__negotiation_ber_ = { 1u, EMBEDDED_PDV_identification_context__negotiation_tag_ }; | |
a38c6d4c | 86 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_context__negotiation_descr_ = { "EMBEDDED PDV.identification.context-negotiation", &EMBEDDED_PDV_identification_context__negotiation_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
87 | |
88 | static const ASN_Tag_t EMBEDDED_PDV_identification_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 4u }}; | |
89 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_transfer__syntax_ber_ = { 1u, EMBEDDED_PDV_identification_transfer__syntax_tag_ }; | |
a38c6d4c | 90 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_transfer__syntax_descr_ = { "EMBEDDED PDV.identification.transfer-syntax", &EMBEDDED_PDV_identification_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
91 | |
92 | static const ASN_Tag_t EMBEDDED_PDV_identification_fixed_tag_[] = { { ASN_TAG_CONT, 5u }}; | |
93 | static const ASN_BERdescriptor_t EMBEDDED_PDV_identification_fixed_ber_ = { 1u, EMBEDDED_PDV_identification_fixed_tag_ }; | |
a38c6d4c | 94 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_identification_fixed_descr_ = { "EMBEDDED PDV.identification.fixed", &EMBEDDED_PDV_identification_fixed_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
95 | |
96 | static const ASN_Tag_t EMBEDDED_PDV_data__value_tag_[] = { { ASN_TAG_CONT, 2u }}; | |
97 | static const ASN_BERdescriptor_t EMBEDDED_PDV_data__value_ber_ = { 1u, EMBEDDED_PDV_data__value_tag_ }; | |
a38c6d4c | 98 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_data__value_descr_ = { "EMBEDDED PDV.data-value", &EMBEDDED_PDV_data__value_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
99 | |
100 | static const ASN_Tag_t EMBEDDED_PDV_data__value__descriptor_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
101 | static const ASN_BERdescriptor_t EMBEDDED_PDV_data__value__descriptor_ber_ = { 1u, EMBEDDED_PDV_data__value__descriptor_tag_ }; | |
a38c6d4c | 102 | static const TTCN_Typedescriptor_t EMBEDDED_PDV_data__value__descriptor_descr_ = { "EMBEDDED PDV.data-value-descriptor", &EMBEDDED_PDV_data__value__descriptor_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::GRAPHICSTRING }; |
970ed795 EL |
103 | |
104 | /******************** EMBEDDED_PDV_identification ********************/ | |
105 | ||
106 | void EMBEDDED_PDV_identification::clean_up() | |
107 | { | |
108 | switch (union_selection) { | |
109 | case ALT_syntaxes: | |
110 | delete field_syntaxes; | |
111 | break; | |
112 | case ALT_syntax: | |
113 | delete field_syntax; | |
114 | break; | |
115 | case ALT_presentation__context__id: | |
116 | delete field_presentation__context__id; | |
117 | break; | |
118 | case ALT_context__negotiation: | |
119 | delete field_context__negotiation; | |
120 | break; | |
121 | case ALT_transfer__syntax: | |
122 | delete field_transfer__syntax; | |
123 | break; | |
124 | case ALT_fixed: | |
125 | delete field_fixed; | |
126 | break; | |
127 | default: | |
128 | break; | |
129 | } | |
130 | union_selection = UNBOUND_VALUE; | |
131 | } | |
132 | ||
133 | void EMBEDDED_PDV_identification::copy_value(const EMBEDDED_PDV_identification& other_value) | |
134 | { | |
135 | switch (other_value.union_selection) { | |
136 | case ALT_syntaxes: | |
137 | field_syntaxes = new EMBEDDED_PDV_identification_syntaxes(*other_value.field_syntaxes); | |
138 | break; | |
139 | case ALT_syntax: | |
140 | field_syntax = new OBJID(*other_value.field_syntax); | |
141 | break; | |
142 | case ALT_presentation__context__id: | |
143 | field_presentation__context__id = new INTEGER(*other_value.field_presentation__context__id); | |
144 | break; | |
145 | case ALT_context__negotiation: | |
146 | field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation(*other_value.field_context__negotiation); | |
147 | break; | |
148 | case ALT_transfer__syntax: | |
149 | field_transfer__syntax = new OBJID(*other_value.field_transfer__syntax); | |
150 | break; | |
151 | case ALT_fixed: | |
152 | field_fixed = new ASN_NULL(*other_value.field_fixed); | |
153 | break; | |
154 | default: | |
155 | TTCN_error("Assignment of an unbound union value of type EMBEDDED PDV.identification."); | |
156 | } | |
157 | union_selection = other_value.union_selection; | |
158 | } | |
159 | ||
160 | EMBEDDED_PDV_identification::EMBEDDED_PDV_identification() | |
161 | { | |
162 | union_selection = UNBOUND_VALUE; | |
163 | } | |
164 | ||
165 | EMBEDDED_PDV_identification::EMBEDDED_PDV_identification(const EMBEDDED_PDV_identification& other_value) | |
166 | : Base_Type(other_value) | |
167 | { | |
168 | copy_value(other_value); | |
169 | } | |
170 | ||
171 | EMBEDDED_PDV_identification::~EMBEDDED_PDV_identification() | |
172 | { | |
173 | clean_up(); | |
174 | } | |
175 | ||
176 | EMBEDDED_PDV_identification& EMBEDDED_PDV_identification::operator=(const EMBEDDED_PDV_identification& other_value) | |
177 | { | |
178 | if (this != &other_value) { | |
179 | clean_up(); | |
180 | copy_value(other_value); | |
181 | } | |
182 | return *this; | |
183 | } | |
184 | ||
185 | boolean EMBEDDED_PDV_identification::operator==(const EMBEDDED_PDV_identification& other_value) const | |
186 | { | |
187 | if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type EMBEDDED PDV.identification."); | |
188 | if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type EMBEDDED PDV.identification."); | |
189 | if (union_selection != other_value.union_selection) return FALSE; | |
190 | switch (union_selection) { | |
191 | case ALT_syntaxes: | |
192 | return *field_syntaxes == *other_value.field_syntaxes; | |
193 | case ALT_syntax: | |
194 | return *field_syntax == *other_value.field_syntax; | |
195 | case ALT_presentation__context__id: | |
196 | return *field_presentation__context__id == *other_value.field_presentation__context__id; | |
197 | case ALT_context__negotiation: | |
198 | return *field_context__negotiation == *other_value.field_context__negotiation; | |
199 | case ALT_transfer__syntax: | |
200 | return *field_transfer__syntax == *other_value.field_transfer__syntax; | |
201 | case ALT_fixed: | |
202 | return *field_fixed == *other_value.field_fixed; | |
203 | default: | |
204 | return FALSE; | |
205 | } | |
206 | } | |
207 | ||
208 | EMBEDDED_PDV_identification_syntaxes& EMBEDDED_PDV_identification::syntaxes() | |
209 | { | |
210 | if (union_selection != ALT_syntaxes) { | |
211 | clean_up(); | |
212 | field_syntaxes = new EMBEDDED_PDV_identification_syntaxes; | |
213 | union_selection = ALT_syntaxes; | |
214 | } | |
215 | return *field_syntaxes; | |
216 | } | |
217 | ||
218 | const EMBEDDED_PDV_identification_syntaxes& EMBEDDED_PDV_identification::syntaxes() const | |
219 | { | |
220 | if (union_selection != ALT_syntaxes) TTCN_error("Using non-selected field syntaxes in a value of union type EMBEDDED PDV.identification."); | |
221 | return *field_syntaxes; | |
222 | } | |
223 | ||
224 | OBJID& EMBEDDED_PDV_identification::syntax() | |
225 | { | |
226 | if (union_selection != ALT_syntax) { | |
227 | clean_up(); | |
228 | field_syntax = new OBJID; | |
229 | union_selection = ALT_syntax; | |
230 | } | |
231 | return *field_syntax; | |
232 | } | |
233 | ||
234 | const OBJID& EMBEDDED_PDV_identification::syntax() const | |
235 | { | |
236 | if (union_selection != ALT_syntax) TTCN_error("Using non-selected field syntax in a value of union type EMBEDDED PDV.identification."); | |
237 | return *field_syntax; | |
238 | } | |
239 | ||
240 | INTEGER& EMBEDDED_PDV_identification::presentation__context__id() | |
241 | { | |
242 | if (union_selection != ALT_presentation__context__id) { | |
243 | clean_up(); | |
244 | field_presentation__context__id = new INTEGER; | |
245 | union_selection = ALT_presentation__context__id; | |
246 | } | |
247 | return *field_presentation__context__id; | |
248 | } | |
249 | ||
250 | const INTEGER& EMBEDDED_PDV_identification::presentation__context__id() const | |
251 | { | |
252 | if (union_selection != ALT_presentation__context__id) TTCN_error("Using non-selected field presentation_context_id in a value of union type EMBEDDED PDV.identification."); | |
253 | return *field_presentation__context__id; | |
254 | } | |
255 | ||
256 | EMBEDDED_PDV_identification_context__negotiation& EMBEDDED_PDV_identification::context__negotiation() | |
257 | { | |
258 | if (union_selection != ALT_context__negotiation) { | |
259 | clean_up(); | |
260 | field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation; | |
261 | union_selection = ALT_context__negotiation; | |
262 | } | |
263 | return *field_context__negotiation; | |
264 | } | |
265 | ||
266 | const EMBEDDED_PDV_identification_context__negotiation& EMBEDDED_PDV_identification::context__negotiation() const | |
267 | { | |
268 | if (union_selection != ALT_context__negotiation) TTCN_error("Using non-selected field context_negotiation in a value of union type EMBEDDED PDV.identification."); | |
269 | return *field_context__negotiation; | |
270 | } | |
271 | ||
272 | OBJID& EMBEDDED_PDV_identification::transfer__syntax() | |
273 | { | |
274 | if (union_selection != ALT_transfer__syntax) { | |
275 | clean_up(); | |
276 | field_transfer__syntax = new OBJID; | |
277 | union_selection = ALT_transfer__syntax; | |
278 | } | |
279 | return *field_transfer__syntax; | |
280 | } | |
281 | ||
282 | const OBJID& EMBEDDED_PDV_identification::transfer__syntax() const | |
283 | { | |
284 | if (union_selection != ALT_transfer__syntax) TTCN_error("Using non-selected field transfer_syntax in a value of union type EMBEDDED PDV.identification."); | |
285 | return *field_transfer__syntax; | |
286 | } | |
287 | ||
288 | ASN_NULL& EMBEDDED_PDV_identification::fixed() | |
289 | { | |
290 | if (union_selection != ALT_fixed) { | |
291 | clean_up(); | |
292 | field_fixed = new ASN_NULL; | |
293 | union_selection = ALT_fixed; | |
294 | } | |
295 | return *field_fixed; | |
296 | } | |
297 | ||
298 | const ASN_NULL& EMBEDDED_PDV_identification::fixed() const | |
299 | { | |
300 | if (union_selection != ALT_fixed) TTCN_error("Using non-selected field fixed in a value of union type EMBEDDED PDV.identification."); | |
301 | return *field_fixed; | |
302 | } | |
303 | ||
304 | boolean EMBEDDED_PDV_identification::ischosen(union_selection_type checked_selection) const | |
305 | { | |
306 | if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EMBEDDED PDV.identification."); | |
307 | if (union_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type EMBEDDED PDV.identification."); | |
308 | return union_selection == checked_selection; | |
309 | } | |
310 | ||
311 | boolean EMBEDDED_PDV_identification::is_bound() const | |
312 | { | |
313 | return UNBOUND_VALUE != union_selection; | |
314 | } | |
315 | ||
316 | boolean EMBEDDED_PDV_identification::is_value() const | |
317 | { | |
318 | switch (union_selection) { | |
319 | case ALT_syntaxes: | |
320 | return field_syntaxes->is_value(); | |
321 | case ALT_syntax: | |
322 | return field_syntax->is_value(); | |
323 | case ALT_presentation__context__id: | |
324 | return field_presentation__context__id->is_value(); | |
325 | case ALT_context__negotiation: | |
326 | return field_context__negotiation->is_value(); | |
327 | case ALT_transfer__syntax: | |
328 | return field_transfer__syntax->is_value(); | |
329 | case ALT_fixed: | |
330 | return field_fixed->is_value(); | |
331 | default: | |
332 | return FALSE; | |
333 | } | |
334 | } | |
335 | ||
336 | void EMBEDDED_PDV_identification::log() const | |
337 | { | |
338 | switch (union_selection) { | |
339 | case ALT_syntaxes: | |
340 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
341 | field_syntaxes->log(); | |
342 | TTCN_Logger::log_event_str(" }"); | |
343 | break; | |
344 | case ALT_syntax: | |
345 | TTCN_Logger::log_event_str("{ syntax := "); | |
346 | field_syntax->log(); | |
347 | TTCN_Logger::log_event_str(" }"); | |
348 | break; | |
349 | case ALT_presentation__context__id: | |
350 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
351 | field_presentation__context__id->log(); | |
352 | TTCN_Logger::log_event_str(" }"); | |
353 | break; | |
354 | case ALT_context__negotiation: | |
355 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
356 | field_context__negotiation->log(); | |
357 | TTCN_Logger::log_event_str(" }"); | |
358 | break; | |
359 | case ALT_transfer__syntax: | |
360 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
361 | field_transfer__syntax->log(); | |
362 | TTCN_Logger::log_event_str(" }"); | |
363 | break; | |
364 | case ALT_fixed: | |
365 | TTCN_Logger::log_event_str("{ fixed := "); | |
366 | field_fixed->log(); | |
367 | TTCN_Logger::log_event_str(" }"); | |
368 | break; | |
369 | default: | |
370 | TTCN_Logger::log_event_str("<unbound>"); | |
371 | break; | |
372 | } | |
373 | } | |
374 | ||
375 | void EMBEDDED_PDV_identification::set_param(Module_Param& param) | |
376 | { | |
377 | param.basic_check(Module_Param::BC_VALUE, "union value"); | |
3abe9331 | 378 | Module_Param_Ptr mp = ¶m; |
379 | if (param.get_type() == Module_Param::MP_Reference) { | |
380 | mp = param.get_referenced_param(); | |
381 | } | |
382 | if (mp->get_type()==Module_Param::MP_Value_List && mp->get_size()==0) return; | |
383 | if (mp->get_type()!=Module_Param::MP_Assignment_List) { | |
970ed795 EL |
384 | param.error("union value with field name was expected"); |
385 | } | |
3abe9331 | 386 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
387 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
388 | syntaxes().set_param(*mp_last); | |
389 | return; | |
390 | } | |
391 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
392 | syntax().set_param(*mp_last); | |
393 | return; | |
394 | } | |
395 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
396 | presentation__context__id().set_param(*mp_last); | |
397 | return; | |
398 | } | |
399 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
400 | context__negotiation().set_param(*mp_last); | |
401 | return; | |
402 | } | |
403 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
404 | transfer__syntax().set_param(*mp_last); | |
405 | return; | |
406 | } | |
407 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
408 | fixed().set_param(*mp_last); | |
409 | return; | |
410 | } | |
411 | mp_last->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last->get_id()->get_name()); | |
412 | } | |
413 | ||
3abe9331 | 414 | Module_Param* EMBEDDED_PDV_identification::get_param(Module_Param_Name& param_name) const |
415 | { | |
416 | if (!is_bound()) { | |
417 | return new Module_Param_Unbound(); | |
418 | } | |
419 | Module_Param* mp_field = NULL; | |
420 | switch(get_selection()) { | |
421 | case ALT_syntaxes: | |
422 | mp_field = field_syntaxes->get_param(param_name); | |
423 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes"))); | |
424 | break; | |
425 | case ALT_syntax: | |
426 | mp_field = field_syntax->get_param(param_name); | |
427 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax"))); | |
428 | break; | |
429 | case ALT_presentation__context__id: | |
430 | mp_field = field_presentation__context__id->get_param(param_name); | |
431 | mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
432 | break; | |
433 | case ALT_context__negotiation: | |
434 | mp_field = field_context__negotiation->get_param(param_name); | |
435 | mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation"))); | |
436 | break; | |
437 | case ALT_transfer__syntax: | |
438 | mp_field = field_transfer__syntax->get_param(param_name); | |
439 | mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
440 | break; | |
441 | case ALT_fixed: | |
442 | mp_field = field_fixed->get_param(param_name); | |
443 | mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed"))); | |
444 | break; | |
445 | default: | |
446 | break; | |
447 | } | |
448 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
449 | mp->add_elem(mp_field); | |
450 | return mp; | |
451 | } | |
452 | ||
970ed795 EL |
453 | void EMBEDDED_PDV_identification_template::set_param(Module_Param& param) |
454 | { | |
455 | param.basic_check(Module_Param::BC_TEMPLATE, "union template"); | |
3abe9331 | 456 | Module_Param_Ptr mp = ¶m; |
457 | if (param.get_type() == Module_Param::MP_Reference) { | |
458 | mp = param.get_referenced_param(); | |
459 | } | |
460 | switch (mp->get_type()) { | |
970ed795 EL |
461 | case Module_Param::MP_Omit: |
462 | *this = OMIT_VALUE; | |
463 | break; | |
464 | case Module_Param::MP_Any: | |
465 | *this = ANY_VALUE; | |
466 | break; | |
467 | case Module_Param::MP_AnyOrNone: | |
468 | *this = ANY_OR_OMIT; | |
469 | break; | |
470 | case Module_Param::MP_List_Template: | |
3abe9331 | 471 | case Module_Param::MP_ComplementList_Template: { |
472 | EMBEDDED_PDV_identification_template temp; | |
473 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
474 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
475 | for (size_t i=0; i<mp->get_size(); i++) { | |
476 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
970ed795 | 477 | } |
3abe9331 | 478 | *this = temp; |
479 | break; } | |
970ed795 | 480 | case Module_Param::MP_Value_List: |
3abe9331 | 481 | if (mp->get_size()==0) break; |
970ed795 EL |
482 | param.type_error("union template", "EMBEDDED PDV.identification"); |
483 | break; | |
484 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 485 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
486 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
487 | syntaxes().set_param(*mp_last); | |
488 | break; | |
489 | } | |
490 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
491 | syntax().set_param(*mp_last); | |
492 | break; | |
493 | } | |
494 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
495 | presentation__context__id().set_param(*mp_last); | |
496 | break; | |
497 | } | |
498 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
499 | context__negotiation().set_param(*mp_last); | |
500 | break; | |
501 | } | |
502 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
503 | transfer__syntax().set_param(*mp_last); | |
504 | break; | |
505 | } | |
506 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
507 | fixed().set_param(*mp_last); | |
508 | break; | |
509 | } | |
510 | mp_last->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last->get_id()->get_name()); | |
511 | } break; | |
512 | default: | |
513 | param.type_error("union template", "EMBEDDED PDV.identification"); | |
514 | } | |
3abe9331 | 515 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); |
516 | } | |
517 | ||
518 | Module_Param* EMBEDDED_PDV_identification_template::get_param(Module_Param_Name& param_name) const | |
519 | { | |
520 | Module_Param* mp = NULL; | |
521 | switch (template_selection) { | |
522 | case UNINITIALIZED_TEMPLATE: | |
523 | mp = new Module_Param_Unbound(); | |
524 | break; | |
525 | case OMIT_VALUE: | |
526 | mp = new Module_Param_Omit(); | |
527 | break; | |
528 | case ANY_VALUE: | |
529 | mp = new Module_Param_Any(); | |
530 | break; | |
531 | case ANY_OR_OMIT: | |
532 | mp = new Module_Param_AnyOrNone(); | |
533 | break; | |
534 | case SPECIFIC_VALUE: { | |
535 | Module_Param* mp_field = NULL; | |
536 | switch(single_value.union_selection) { | |
537 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
538 | mp_field = single_value.field_syntaxes->get_param(param_name); | |
539 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes"))); | |
540 | break; | |
541 | case EMBEDDED_PDV_identification::ALT_syntax: | |
542 | mp_field = single_value.field_syntax->get_param(param_name); | |
543 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax"))); | |
544 | break; | |
545 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
546 | mp_field = single_value.field_presentation__context__id->get_param(param_name); | |
547 | mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
548 | break; | |
549 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
550 | mp_field = single_value.field_context__negotiation->get_param(param_name); | |
551 | mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation"))); | |
552 | break; | |
553 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
554 | mp_field = single_value.field_transfer__syntax->get_param(param_name); | |
555 | mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
556 | break; | |
557 | case EMBEDDED_PDV_identification::ALT_fixed: | |
558 | mp_field = single_value.field_fixed->get_param(param_name); | |
559 | mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed"))); | |
560 | break; | |
561 | default: | |
562 | break; | |
563 | } | |
564 | mp = new Module_Param_Assignment_List(); | |
565 | mp->add_elem(mp_field); | |
566 | break; } | |
567 | case VALUE_LIST: | |
568 | case COMPLEMENTED_LIST: { | |
569 | if (template_selection == VALUE_LIST) { | |
570 | mp = new Module_Param_List_Template(); | |
571 | } | |
572 | else { | |
573 | mp = new Module_Param_ComplementList_Template(); | |
574 | } | |
575 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
576 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
577 | } | |
578 | break; } | |
579 | default: | |
580 | break; | |
581 | } | |
582 | if (is_ifpresent) { | |
583 | mp->set_ifpresent(); | |
584 | } | |
585 | return mp; | |
970ed795 EL |
586 | } |
587 | ||
588 | void EMBEDDED_PDV_identification::encode_text(Text_Buf& text_buf) const | |
589 | { | |
590 | text_buf.push_int(union_selection); | |
591 | switch (union_selection) { | |
592 | case ALT_syntaxes: | |
593 | field_syntaxes->encode_text(text_buf); | |
594 | break; | |
595 | case ALT_syntax: | |
596 | field_syntax->encode_text(text_buf); | |
597 | break; | |
598 | case ALT_presentation__context__id: | |
599 | field_presentation__context__id->encode_text(text_buf); | |
600 | break; | |
601 | case ALT_context__negotiation: | |
602 | field_context__negotiation->encode_text(text_buf); | |
603 | break; | |
604 | case ALT_transfer__syntax: | |
605 | field_transfer__syntax->encode_text(text_buf); | |
606 | break; | |
607 | case ALT_fixed: | |
608 | field_fixed->encode_text(text_buf); | |
609 | break; | |
610 | default: | |
611 | TTCN_error("Text encoder: Encoding an unbound value of union type EMBEDDED PDV.identification."); | |
612 | } | |
613 | } | |
614 | ||
615 | void EMBEDDED_PDV_identification::decode_text(Text_Buf& text_buf) | |
616 | { | |
617 | switch ((union_selection_type)text_buf.pull_int().get_val()) { | |
618 | case ALT_syntaxes: | |
619 | syntaxes().decode_text(text_buf); | |
620 | break; | |
621 | case ALT_syntax: | |
622 | syntax().decode_text(text_buf); | |
623 | break; | |
624 | case ALT_presentation__context__id: | |
625 | presentation__context__id().decode_text(text_buf); | |
626 | break; | |
627 | case ALT_context__negotiation: | |
628 | context__negotiation().decode_text(text_buf); | |
629 | break; | |
630 | case ALT_transfer__syntax: | |
631 | transfer__syntax().decode_text(text_buf); | |
632 | break; | |
633 | case ALT_fixed: | |
634 | fixed().decode_text(text_buf); | |
635 | break; | |
636 | default: | |
637 | TTCN_error("Text decoder: Unrecognized union selector was received for type EMBEDDED PDV.identification."); | |
638 | } | |
639 | } | |
640 | ||
641 | // No encode/decode for this implementation class | |
642 | //void EMBEDDED_PDV_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
643 | //void EMBEDDED_PDV_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
644 | ||
645 | ASN_BER_TLV_t *EMBEDDED_PDV_identification::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
646 | { | |
647 | BER_chk_descr(p_td); | |
648 | ASN_BER_TLV_t *new_tlv; | |
649 | TTCN_EncDec_ErrorContext ec_0("Alternative '"); | |
650 | TTCN_EncDec_ErrorContext ec_1; | |
651 | switch (union_selection) { | |
652 | case ALT_syntaxes: | |
653 | ec_1.set_msg("syntaxes': "); | |
654 | new_tlv = field_syntaxes->BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_, p_coding); | |
655 | break; | |
656 | case ALT_syntax: | |
657 | ec_1.set_msg("syntax': "); | |
658 | new_tlv = field_syntax->BER_encode_TLV(EMBEDDED_PDV_identification_syntax_descr_, p_coding); | |
659 | break; | |
660 | case ALT_presentation__context__id: | |
661 | ec_1.set_msg("presentation_context_id': "); | |
662 | new_tlv = field_presentation__context__id->BER_encode_TLV(EMBEDDED_PDV_identification_presentation__context__id_descr_, p_coding); | |
663 | break; | |
664 | case ALT_context__negotiation: | |
665 | ec_1.set_msg("context_negotiation': "); | |
666 | new_tlv = field_context__negotiation->BER_encode_TLV(EMBEDDED_PDV_identification_context__negotiation_descr_, p_coding); | |
667 | break; | |
668 | case ALT_transfer__syntax: | |
669 | ec_1.set_msg("transfer_syntax': "); | |
670 | new_tlv = field_transfer__syntax->BER_encode_TLV(EMBEDDED_PDV_identification_transfer__syntax_descr_, p_coding); | |
671 | break; | |
672 | case ALT_fixed: | |
673 | ec_1.set_msg("fixed': "); | |
674 | new_tlv = field_fixed->BER_encode_TLV(EMBEDDED_PDV_identification_fixed_descr_, p_coding); | |
675 | break; | |
676 | case UNBOUND_VALUE: | |
677 | new_tlv = BER_encode_chk_bound(FALSE); | |
678 | break; | |
679 | default: | |
680 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
681 | new_tlv = NULL; | |
682 | break; | |
683 | } | |
684 | return ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
685 | } | |
686 | ||
687 | boolean EMBEDDED_PDV_identification::BER_decode_set_selection(const ASN_BER_TLV_t& p_tlv) | |
688 | { | |
689 | clean_up(); | |
690 | field_syntaxes = new EMBEDDED_PDV_identification_syntaxes; | |
691 | union_selection = ALT_syntaxes; | |
692 | if (field_syntaxes->BER_decode_isMyMsg(EMBEDDED_PDV_identification_syntaxes_descr_, p_tlv)) return TRUE; | |
693 | delete field_syntaxes; | |
694 | field_syntax = new OBJID; | |
695 | union_selection = ALT_syntax; | |
696 | if (field_syntax->BER_decode_isMyMsg(EMBEDDED_PDV_identification_syntax_descr_, p_tlv)) return TRUE; | |
697 | delete field_syntax; | |
698 | field_presentation__context__id = new INTEGER; | |
699 | union_selection = ALT_presentation__context__id; | |
700 | if (field_presentation__context__id->BER_decode_isMyMsg(EMBEDDED_PDV_identification_presentation__context__id_descr_, p_tlv)) return TRUE; | |
701 | delete field_presentation__context__id; | |
702 | field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation; | |
703 | union_selection = ALT_context__negotiation; | |
704 | if (field_context__negotiation->BER_decode_isMyMsg(EMBEDDED_PDV_identification_context__negotiation_descr_, p_tlv)) return TRUE; | |
705 | delete field_context__negotiation; | |
706 | field_transfer__syntax = new OBJID; | |
707 | union_selection = ALT_transfer__syntax; | |
708 | if (field_transfer__syntax->BER_decode_isMyMsg(EMBEDDED_PDV_identification_transfer__syntax_descr_, p_tlv)) return TRUE; | |
709 | delete field_transfer__syntax; | |
710 | field_fixed = new ASN_NULL; | |
711 | union_selection = ALT_fixed; | |
712 | if (field_fixed->BER_decode_isMyMsg(EMBEDDED_PDV_identification_fixed_descr_, p_tlv)) return TRUE; | |
713 | delete field_fixed; | |
714 | union_selection = UNBOUND_VALUE; | |
715 | return FALSE; | |
716 | } | |
717 | ||
718 | boolean EMBEDDED_PDV_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv) | |
719 | { | |
720 | if (p_td.ber->n_tags == 0) { | |
721 | EMBEDDED_PDV_identification tmp_type; | |
722 | return tmp_type.BER_decode_set_selection(p_tlv); | |
723 | } else return Base_Type::BER_decode_isMyMsg(p_td, p_tlv); | |
724 | } | |
725 | ||
726 | boolean EMBEDDED_PDV_identification::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
727 | { | |
728 | BER_chk_descr(p_td); | |
729 | ASN_BER_TLV_t stripped_tlv; | |
730 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
731 | TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV.identification' type: "); | |
732 | ASN_BER_TLV_t tmp_tlv; | |
733 | if (!BER_decode_TLV_CHOICE(*p_td.ber, stripped_tlv, L_form, tmp_tlv) || !BER_decode_CHOICE_selection(BER_decode_set_selection(tmp_tlv), tmp_tlv)) return FALSE; | |
734 | TTCN_EncDec_ErrorContext ec_1("Alternative '"); | |
735 | TTCN_EncDec_ErrorContext ec_2; | |
736 | switch (union_selection) { | |
737 | case ALT_syntaxes: | |
738 | ec_2.set_msg("syntaxes': "); | |
739 | field_syntaxes->BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_, tmp_tlv, L_form); | |
740 | break; | |
741 | case ALT_syntax: | |
742 | ec_2.set_msg("syntax': "); | |
743 | field_syntax->BER_decode_TLV(EMBEDDED_PDV_identification_syntax_descr_, tmp_tlv, L_form); | |
744 | break; | |
745 | case ALT_presentation__context__id: | |
746 | ec_2.set_msg("presentation_context_id': "); | |
747 | field_presentation__context__id->BER_decode_TLV(EMBEDDED_PDV_identification_presentation__context__id_descr_, tmp_tlv, L_form); | |
748 | break; | |
749 | case ALT_context__negotiation: | |
750 | ec_2.set_msg("context_negotiation': "); | |
751 | field_context__negotiation->BER_decode_TLV(EMBEDDED_PDV_identification_context__negotiation_descr_, tmp_tlv, L_form); | |
752 | break; | |
753 | case ALT_transfer__syntax: | |
754 | ec_2.set_msg("transfer_syntax': "); | |
755 | field_transfer__syntax->BER_decode_TLV(EMBEDDED_PDV_identification_transfer__syntax_descr_, tmp_tlv, L_form); | |
756 | break; | |
757 | case ALT_fixed: | |
758 | ec_2.set_msg("fixed': "); | |
759 | field_fixed->BER_decode_TLV(EMBEDDED_PDV_identification_fixed_descr_, tmp_tlv, L_form); | |
760 | break; | |
761 | default: | |
762 | return FALSE; | |
763 | } | |
764 | return TRUE; | |
765 | } | |
766 | ||
767 | // FIXME maybe: XER_encode and decode is virtually identical to CHARACTER_STRING | |
768 | ||
769 | int EMBEDDED_PDV_identification::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 770 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
771 | { |
772 | int indenting = !is_canonical(flavor); | |
773 | int exer = is_exer(flavor); | |
774 | int encoded_length=(int)p_buf.get_len(); | |
775 | if (indenting) do_indent(p_buf, indent); | |
776 | p_buf.put_c('<'); | |
777 | if (exer) write_ns_prefix(p_td, p_buf); | |
778 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
779 | flavor &= XER_MASK; | |
780 | ++indent; | |
781 | switch (union_selection) { | |
782 | case ALT_syntaxes: | |
af710487 | 783 | field_syntaxes->XER_encode(EMBEDDED_PDV_identification_sxs_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
784 | break; |
785 | case ALT_syntax: | |
af710487 | 786 | field_syntax->XER_encode(EMBEDDED_PDV_identification_sx_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
787 | break; |
788 | case ALT_presentation__context__id: | |
af710487 | 789 | field_presentation__context__id->XER_encode(EMBEDDED_PDV_identification_pci_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
790 | break; |
791 | case ALT_context__negotiation: | |
af710487 | 792 | field_context__negotiation->XER_encode(EMBEDDED_PDV_identification_cn_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
793 | break; |
794 | case ALT_transfer__syntax: | |
af710487 | 795 | field_transfer__syntax->XER_encode(EMBEDDED_PDV_identification_ts_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
796 | break; |
797 | case ALT_fixed: | |
af710487 | 798 | field_fixed->XER_encode(EMBEDDED_PDV_identification_fix_xer_, p_buf, flavor, indent, 0);; |
970ed795 EL |
799 | break; |
800 | default: | |
801 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
802 | break; | |
803 | } | |
804 | ||
805 | if (indenting) do_indent(p_buf, --indent); | |
806 | p_buf.put_c('<'); | |
807 | p_buf.put_c('/'); | |
808 | if (exer) write_ns_prefix(p_td, p_buf); | |
809 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
810 | return (int)p_buf.get_len() - encoded_length; | |
811 | } | |
812 | ||
813 | int EMBEDDED_PDV_identification::XER_decode(const XERdescriptor_t& p_td, | |
feade998 | 814 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
815 | { |
816 | int exer = is_exer(flavor); | |
817 | // we are supposed to be parked on our element | |
818 | for (int success = 1; success == 1; success = reader.Read()) { | |
819 | int type = reader.NodeType(); | |
820 | switch (type) { | |
821 | case XML_READER_TYPE_ELEMENT: { | |
822 | if (verify_name(reader, p_td, exer)) { | |
823 | // it's us | |
824 | for (success = reader.Read(); success == 1; success = reader.Read()) { | |
825 | type = reader.NodeType(); | |
826 | if (XML_READER_TYPE_ELEMENT == type) break; | |
827 | else if (XML_READER_TYPE_END_ELEMENT == type) goto bail; | |
828 | } | |
829 | const char *name = (const char*)reader.Name(); | |
830 | // Avoid chained if-else on strcmp. Use the length as a hash. | |
831 | size_t namelen = strlen(name); | |
832 | switch (namelen) { | |
833 | case 8: // syntaxes | |
feade998 | 834 | syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
835 | break; |
836 | ||
837 | case 6: // syntax | |
feade998 | 838 | syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
839 | break; |
840 | ||
841 | case 23: // presentation-context-id | |
feade998 | 842 | presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
843 | break; |
844 | ||
845 | case 19: // context-negotiation | |
feade998 | 846 | context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
847 | break; |
848 | ||
849 | case 15: // transfer-syntax | |
feade998 | 850 | transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
851 | break; |
852 | ||
853 | case 5: // fixed | |
feade998 | 854 | fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
855 | break; |
856 | ||
857 | default: | |
858 | goto bail; | |
859 | } // switch | |
860 | } | |
861 | else { // it belongs to somebody else | |
862 | goto bail; | |
863 | } | |
864 | break; } | |
865 | case XML_READER_TYPE_END_ELEMENT: { | |
866 | // advance to the next thing and bail | |
867 | reader.Read(); | |
868 | goto bail; } | |
869 | } | |
870 | } | |
871 | bail: | |
872 | return 1; | |
873 | } | |
874 | ||
875 | /******************** EMBEDDED_PDV_identification_template ********************/ | |
876 | ||
877 | void EMBEDDED_PDV_identification_template::clean_up() | |
878 | { | |
879 | switch (template_selection) { | |
880 | case SPECIFIC_VALUE: | |
881 | switch (single_value.union_selection) { | |
882 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
883 | delete single_value.field_syntaxes; | |
884 | break; | |
885 | case EMBEDDED_PDV_identification::ALT_syntax: | |
886 | delete single_value.field_syntax; | |
887 | break; | |
888 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
889 | delete single_value.field_presentation__context__id; | |
890 | break; | |
891 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
892 | delete single_value.field_context__negotiation; | |
893 | break; | |
894 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
895 | delete single_value.field_transfer__syntax; | |
896 | break; | |
897 | case EMBEDDED_PDV_identification::ALT_fixed: | |
898 | delete single_value.field_fixed; | |
899 | break; | |
900 | default: | |
901 | break; | |
902 | } | |
903 | break; | |
904 | case VALUE_LIST: | |
905 | case COMPLEMENTED_LIST: | |
906 | delete [] value_list.list_value; | |
907 | break; | |
908 | default: | |
909 | break; | |
910 | } | |
911 | template_selection = UNINITIALIZED_TEMPLATE; | |
912 | } | |
913 | ||
914 | void EMBEDDED_PDV_identification_template::copy_value(const EMBEDDED_PDV_identification& other_value) | |
915 | { | |
916 | single_value.union_selection = other_value.get_selection(); | |
917 | switch (single_value.union_selection) { | |
918 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
919 | single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(other_value.syntaxes()); | |
920 | break; | |
921 | case EMBEDDED_PDV_identification::ALT_syntax: | |
922 | single_value.field_syntax = new OBJID_template(other_value.syntax()); | |
923 | break; | |
924 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
925 | single_value.field_presentation__context__id = new INTEGER_template(other_value.presentation__context__id()); | |
926 | break; | |
927 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
928 | single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(other_value.context__negotiation()); | |
929 | break; | |
930 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
931 | single_value.field_transfer__syntax = new OBJID_template(other_value.transfer__syntax()); | |
932 | break; | |
933 | case EMBEDDED_PDV_identification::ALT_fixed: | |
934 | single_value.field_fixed = new ASN_NULL_template(other_value.fixed()); | |
935 | break; | |
936 | default: | |
937 | TTCN_error("Initializing a template with an unbound value of type EMBEDDED PDV.identification."); | |
938 | } | |
939 | set_selection(SPECIFIC_VALUE); | |
940 | } | |
941 | ||
942 | void EMBEDDED_PDV_identification_template::copy_template(const EMBEDDED_PDV_identification_template& other_value) | |
943 | { | |
944 | switch (other_value.template_selection) { | |
945 | case SPECIFIC_VALUE: | |
946 | single_value.union_selection = other_value.single_value.union_selection; | |
947 | switch (single_value.union_selection) { | |
948 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
949 | single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(*other_value.single_value.field_syntaxes); | |
950 | break; | |
951 | case EMBEDDED_PDV_identification::ALT_syntax: | |
952 | single_value.field_syntax = new OBJID_template(*other_value.single_value.field_syntax); | |
953 | break; | |
954 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
955 | single_value.field_presentation__context__id = new INTEGER_template(*other_value.single_value.field_presentation__context__id); | |
956 | break; | |
957 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
958 | single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(*other_value.single_value.field_context__negotiation); | |
959 | break; | |
960 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
961 | single_value.field_transfer__syntax = new OBJID_template(*other_value.single_value.field_transfer__syntax); | |
962 | break; | |
963 | case EMBEDDED_PDV_identification::ALT_fixed: | |
964 | single_value.field_fixed = new ASN_NULL_template(*other_value.single_value.field_fixed); | |
965 | break; | |
966 | default: | |
967 | TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EMBEDDED PDV.identification."); | |
968 | } | |
969 | break; | |
970 | case OMIT_VALUE: | |
971 | case ANY_VALUE: | |
972 | case ANY_OR_OMIT: | |
973 | break; | |
974 | case VALUE_LIST: | |
975 | case COMPLEMENTED_LIST: | |
976 | value_list.n_values = other_value.value_list.n_values; | |
977 | value_list.list_value = new EMBEDDED_PDV_identification_template[value_list.n_values]; | |
978 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
979 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
980 | break; | |
981 | default: | |
982 | TTCN_error("Copying an uninitialized template of union type EMBEDDED PDV.identification."); | |
983 | } | |
984 | set_selection(other_value); | |
985 | } | |
986 | ||
987 | EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template() | |
988 | { | |
989 | } | |
990 | ||
991 | EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(template_sel other_value) | |
992 | : Base_Template(other_value) | |
993 | { | |
994 | check_single_selection(other_value); | |
995 | } | |
996 | ||
997 | EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification& other_value) | |
998 | { | |
999 | copy_value(other_value); | |
1000 | } | |
1001 | ||
1002 | EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const OPTIONAL<EMBEDDED_PDV_identification>& other_value) | |
1003 | { | |
1004 | switch (other_value.get_selection()) { | |
1005 | case OPTIONAL_PRESENT: | |
1006 | copy_value((const EMBEDDED_PDV_identification&)other_value); | |
1007 | break; | |
1008 | case OPTIONAL_OMIT: | |
1009 | set_selection(OMIT_VALUE); | |
1010 | break; | |
1011 | default: | |
1012 | TTCN_error("Creating a template of union type EMBEDDED PDV.identification from an unbound optional field."); | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification_template& other_value) | |
1017 | : Base_Template() | |
1018 | { | |
1019 | copy_template(other_value); | |
1020 | } | |
1021 | ||
1022 | EMBEDDED_PDV_identification_template::~EMBEDDED_PDV_identification_template() | |
1023 | { | |
1024 | clean_up(); | |
1025 | } | |
1026 | ||
1027 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(template_sel other_value) | |
1028 | { | |
1029 | check_single_selection(other_value); | |
1030 | clean_up(); | |
1031 | set_selection(other_value); | |
1032 | return *this; | |
1033 | } | |
1034 | ||
1035 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification& other_value) | |
1036 | { | |
1037 | clean_up(); | |
1038 | copy_value(other_value); | |
1039 | return *this; | |
1040 | } | |
1041 | ||
1042 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const OPTIONAL<EMBEDDED_PDV_identification>& other_value) | |
1043 | { | |
1044 | clean_up(); | |
1045 | switch (other_value.get_selection()) { | |
1046 | case OPTIONAL_PRESENT: | |
1047 | copy_value((const EMBEDDED_PDV_identification&)other_value); | |
1048 | break; | |
1049 | case OPTIONAL_OMIT: | |
1050 | set_selection(OMIT_VALUE); | |
1051 | break; | |
1052 | default: | |
1053 | TTCN_error("Assignment of an unbound optional field to a template of union type EMBEDDED PDV.identification."); | |
1054 | } | |
1055 | return *this; | |
1056 | } | |
1057 | ||
1058 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification_template& other_value) | |
1059 | { | |
1060 | if (&other_value != this) { | |
1061 | clean_up(); | |
1062 | copy_template(other_value); | |
1063 | } | |
1064 | return *this; | |
1065 | } | |
1066 | ||
3abe9331 | 1067 | boolean EMBEDDED_PDV_identification_template::match(const EMBEDDED_PDV_identification& other_value, |
1068 | boolean /* legacy */) const | |
970ed795 EL |
1069 | { |
1070 | switch (template_selection) { | |
1071 | case ANY_VALUE: | |
1072 | case ANY_OR_OMIT: | |
1073 | return TRUE; | |
1074 | case OMIT_VALUE: | |
1075 | return FALSE; | |
1076 | case SPECIFIC_VALUE: | |
1077 | { | |
1078 | EMBEDDED_PDV_identification::union_selection_type value_selection = other_value.get_selection(); | |
1079 | if (value_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) return FALSE; | |
1080 | if (value_selection != single_value.union_selection) return FALSE; | |
1081 | switch (value_selection) { | |
1082 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1083 | return single_value.field_syntaxes->match(other_value.syntaxes()); | |
1084 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1085 | return single_value.field_syntax->match(other_value.syntax()); | |
1086 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1087 | return single_value.field_presentation__context__id->match(other_value.presentation__context__id()); | |
1088 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1089 | return single_value.field_context__negotiation->match(other_value.context__negotiation()); | |
1090 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1091 | return single_value.field_transfer__syntax->match(other_value.transfer__syntax()); | |
1092 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1093 | return single_value.field_fixed->match(other_value.fixed()); | |
1094 | default: | |
1095 | TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EMBEDDED PDV.identification."); | |
1096 | } | |
1097 | } | |
1098 | break; // should never get here | |
1099 | case VALUE_LIST: | |
1100 | case COMPLEMENTED_LIST: | |
1101 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1102 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
1103 | return template_selection == COMPLEMENTED_LIST; | |
1104 | default: | |
1105 | TTCN_error ("Matching an uninitialized template of union type EMBEDDED PDV.identification."); | |
1106 | } | |
1107 | return FALSE; | |
1108 | } | |
1109 | ||
1110 | EMBEDDED_PDV_identification EMBEDDED_PDV_identification_template::valueof() const | |
1111 | { | |
1112 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
1113 | TTCN_error("Performing valueof or send operation on a non-specific template of union type EMBEDDED PDV.identification."); | |
1114 | EMBEDDED_PDV_identification ret_val; | |
1115 | switch (single_value.union_selection) { | |
1116 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1117 | ret_val.syntaxes() = single_value.field_syntaxes->valueof(); | |
1118 | break; | |
1119 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1120 | ret_val.syntax() = single_value.field_syntax->valueof(); | |
1121 | break; | |
1122 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1123 | ret_val.presentation__context__id() = single_value.field_presentation__context__id->valueof(); | |
1124 | break; | |
1125 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1126 | ret_val.context__negotiation() = single_value.field_context__negotiation->valueof(); | |
1127 | break; | |
1128 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1129 | ret_val.transfer__syntax() = single_value.field_transfer__syntax->valueof(); | |
1130 | break; | |
1131 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1132 | ret_val.fixed() = single_value.field_fixed->valueof(); | |
1133 | break; | |
1134 | default: | |
1135 | TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EMBEDDED PDV.identification."); | |
1136 | } | |
1137 | return ret_val; | |
1138 | } | |
1139 | ||
1140 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_identification_template::list_item(unsigned int list_index) const | |
1141 | { | |
1142 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type EMBEDDED PDV.identification."); | |
1143 | if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type EMBEDDED PDV.identification."); | |
1144 | return value_list.list_value[list_index]; | |
1145 | } | |
1146 | void EMBEDDED_PDV_identification_template::set_type(template_sel template_type, unsigned int list_length) | |
1147 | { | |
1148 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type EMBEDDED PDV.identification."); | |
1149 | clean_up(); | |
1150 | set_selection(template_type); | |
1151 | value_list.n_values = list_length; | |
1152 | value_list.list_value = new EMBEDDED_PDV_identification_template[list_length]; | |
1153 | } | |
1154 | ||
1155 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_template::syntaxes() | |
1156 | { | |
1157 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntaxes) { | |
1158 | template_sel old_selection = template_selection; | |
1159 | clean_up(); | |
1160 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template(ANY_VALUE); | |
1161 | else single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template; | |
1162 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_syntaxes; | |
1163 | set_selection(SPECIFIC_VALUE); | |
1164 | } | |
1165 | return *single_value.field_syntaxes; | |
1166 | } | |
1167 | ||
1168 | const EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_template::syntaxes() const | |
1169 | { | |
1170 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntaxes in a non-specific template of union type EMBEDDED PDV.identification."); | |
1171 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntaxes) TTCN_error("Accessing non-selected field syntaxes in a template of union type EMBEDDED PDV.identification."); | |
1172 | return *single_value.field_syntaxes; | |
1173 | } | |
1174 | ||
1175 | OBJID_template& EMBEDDED_PDV_identification_template::syntax() | |
1176 | { | |
1177 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntax) { | |
1178 | template_sel old_selection = template_selection; | |
1179 | clean_up(); | |
1180 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntax = new OBJID_template(ANY_VALUE); | |
1181 | else single_value.field_syntax = new OBJID_template; | |
1182 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_syntax; | |
1183 | set_selection(SPECIFIC_VALUE); | |
1184 | } | |
1185 | return *single_value.field_syntax; | |
1186 | } | |
1187 | ||
1188 | const OBJID_template& EMBEDDED_PDV_identification_template::syntax() const | |
1189 | { | |
1190 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntax in a non-specific template of union type EMBEDDED PDV.identification."); | |
1191 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_syntax) TTCN_error("Accessing non-selected field syntax in a template of union type EMBEDDED PDV.identification."); | |
1192 | return *single_value.field_syntax; | |
1193 | } | |
1194 | ||
1195 | INTEGER_template& EMBEDDED_PDV_identification_template::presentation__context__id() | |
1196 | { | |
1197 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_presentation__context__id) { | |
1198 | template_sel old_selection = template_selection; | |
1199 | clean_up(); | |
1200 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_presentation__context__id = new INTEGER_template(ANY_VALUE); | |
1201 | else single_value.field_presentation__context__id = new INTEGER_template; | |
1202 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_presentation__context__id; | |
1203 | set_selection(SPECIFIC_VALUE); | |
1204 | } | |
1205 | return *single_value.field_presentation__context__id; | |
1206 | } | |
1207 | ||
1208 | const INTEGER_template& EMBEDDED_PDV_identification_template::presentation__context__id() const | |
1209 | { | |
1210 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type EMBEDDED PDV.identification."); | |
1211 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_presentation__context__id) TTCN_error("Accessing non-selected field presentation_context_id in a template of union type EMBEDDED PDV.identification."); | |
1212 | return *single_value.field_presentation__context__id; | |
1213 | } | |
1214 | ||
1215 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_template::context__negotiation() | |
1216 | { | |
1217 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_context__negotiation) { | |
1218 | template_sel old_selection = template_selection; | |
1219 | clean_up(); | |
1220 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template(ANY_VALUE); | |
1221 | else single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template; | |
1222 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_context__negotiation; | |
1223 | set_selection(SPECIFIC_VALUE); | |
1224 | } | |
1225 | return *single_value.field_context__negotiation; | |
1226 | } | |
1227 | ||
1228 | const EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_template::context__negotiation() const | |
1229 | { | |
1230 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field context_negotiation in a non-specific template of union type EMBEDDED PDV.identification."); | |
1231 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_context__negotiation) TTCN_error("Accessing non-selected field context_negotiation in a template of union type EMBEDDED PDV.identification."); | |
1232 | return *single_value.field_context__negotiation; | |
1233 | } | |
1234 | ||
1235 | OBJID_template& EMBEDDED_PDV_identification_template::transfer__syntax() | |
1236 | { | |
1237 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_transfer__syntax) { | |
1238 | template_sel old_selection = template_selection; | |
1239 | clean_up(); | |
1240 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_transfer__syntax = new OBJID_template(ANY_VALUE); | |
1241 | else single_value.field_transfer__syntax = new OBJID_template; | |
1242 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_transfer__syntax; | |
1243 | set_selection(SPECIFIC_VALUE); | |
1244 | } | |
1245 | return *single_value.field_transfer__syntax; | |
1246 | } | |
1247 | ||
1248 | const OBJID_template& EMBEDDED_PDV_identification_template::transfer__syntax() const | |
1249 | { | |
1250 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type EMBEDDED PDV.identification."); | |
1251 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_transfer__syntax) TTCN_error("Accessing non-selected field transfer_syntax in a template of union type EMBEDDED PDV.identification."); | |
1252 | return *single_value.field_transfer__syntax; | |
1253 | } | |
1254 | ||
1255 | ASN_NULL_template& EMBEDDED_PDV_identification_template::fixed() | |
1256 | { | |
1257 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != EMBEDDED_PDV_identification::ALT_fixed) { | |
1258 | template_sel old_selection = template_selection; | |
1259 | clean_up(); | |
1260 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_fixed = new ASN_NULL_template(ANY_VALUE); | |
1261 | else single_value.field_fixed = new ASN_NULL_template; | |
1262 | single_value.union_selection = EMBEDDED_PDV_identification::ALT_fixed; | |
1263 | set_selection(SPECIFIC_VALUE); | |
1264 | } | |
1265 | return *single_value.field_fixed; | |
1266 | } | |
1267 | ||
1268 | const ASN_NULL_template& EMBEDDED_PDV_identification_template::fixed() const | |
1269 | { | |
1270 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field fixed in a non-specific template of union type EMBEDDED PDV.identification."); | |
1271 | if (single_value.union_selection != EMBEDDED_PDV_identification::ALT_fixed) TTCN_error("Accessing non-selected field fixed in a template of union type EMBEDDED PDV.identification."); | |
1272 | return *single_value.field_fixed; | |
1273 | } | |
1274 | ||
1275 | boolean EMBEDDED_PDV_identification_template::ischosen(EMBEDDED_PDV_identification::union_selection_type checked_selection) const | |
1276 | { | |
1277 | if (checked_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EMBEDDED PDV.identification."); | |
1278 | switch (template_selection) { | |
1279 | case SPECIFIC_VALUE: | |
1280 | if (single_value.union_selection == EMBEDDED_PDV_identification::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type EMBEDDED PDV.identification."); | |
1281 | return single_value.union_selection == checked_selection; | |
1282 | case VALUE_LIST: | |
1283 | { | |
1284 | if (value_list.n_values < 1) | |
1285 | TTCN_error("Internal error: Performing ischosen() operation on a template of union type EMBEDDED PDV.identification containing an empty list."); | |
1286 | boolean ret_val = value_list.list_value[0].ischosen(checked_selection); | |
1287 | boolean all_same = TRUE; | |
1288 | for (unsigned int list_count = 1; list_count < value_list.n_values; list_count++) { | |
1289 | if (value_list.list_value[list_count].ischosen(checked_selection) != ret_val) { | |
1290 | all_same = FALSE; | |
1291 | break; | |
1292 | } | |
1293 | } | |
1294 | if (all_same) return ret_val; | |
1295 | } | |
1296 | // FIXME really no break? | |
1297 | case ANY_VALUE: | |
1298 | case ANY_OR_OMIT: | |
1299 | case OMIT_VALUE: | |
1300 | case COMPLEMENTED_LIST: | |
1301 | TTCN_error("Performing ischosen() operation on a template of union type EMBEDDED PDV.identification, which does not determine unambiguously the chosen field of the matching values."); | |
1302 | default: | |
1303 | TTCN_error("Performing ischosen() operation on an uninitialized template of union type EMBEDDED PDV.identification"); | |
1304 | } | |
1305 | return FALSE; | |
1306 | } | |
1307 | ||
1308 | void EMBEDDED_PDV_identification_template::log() const | |
1309 | { | |
1310 | switch (template_selection) { | |
1311 | case SPECIFIC_VALUE: | |
1312 | switch (single_value.union_selection) { | |
1313 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1314 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
1315 | single_value.field_syntaxes->log(); | |
1316 | TTCN_Logger::log_event_str(" }"); | |
1317 | break; | |
1318 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1319 | TTCN_Logger::log_event_str("{ syntax := "); | |
1320 | single_value.field_syntax->log(); | |
1321 | TTCN_Logger::log_event_str(" }"); | |
1322 | break; | |
1323 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1324 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
1325 | single_value.field_presentation__context__id->log(); | |
1326 | TTCN_Logger::log_event_str(" }"); | |
1327 | break; | |
1328 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1329 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
1330 | single_value.field_context__negotiation->log(); | |
1331 | TTCN_Logger::log_event_str(" }"); | |
1332 | break; | |
1333 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1334 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
1335 | single_value.field_transfer__syntax->log(); | |
1336 | TTCN_Logger::log_event_str(" }"); | |
1337 | break; | |
1338 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1339 | TTCN_Logger::log_event_str("{ fixed := "); | |
1340 | single_value.field_fixed->log(); | |
1341 | TTCN_Logger::log_event_str(" }"); | |
1342 | break; | |
1343 | default: | |
1344 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1345 | break; | |
1346 | } | |
1347 | break; | |
1348 | case COMPLEMENTED_LIST: | |
1349 | TTCN_Logger::log_event_str("complement "); | |
1350 | // no break | |
1351 | case VALUE_LIST: | |
1352 | TTCN_Logger::log_char('('); | |
1353 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
1354 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
1355 | value_list.list_value[list_count].log(); | |
1356 | } | |
1357 | TTCN_Logger::log_char(')'); | |
1358 | break; | |
1359 | default: | |
1360 | log_generic(); | |
1361 | break; | |
1362 | } | |
1363 | log_ifpresent(); | |
1364 | } | |
1365 | ||
3abe9331 | 1366 | void EMBEDDED_PDV_identification_template::log_match(const EMBEDDED_PDV_identification& match_value, |
1367 | boolean /* legacy */) const | |
970ed795 EL |
1368 | { |
1369 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1370 | if(match(match_value)){ | |
1371 | TTCN_Logger::print_logmatch_buffer(); | |
1372 | TTCN_Logger::log_event_str(" matched "); | |
1373 | } | |
1374 | return; | |
1375 | } | |
1376 | if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) { | |
1377 | switch (single_value.union_selection) { | |
1378 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1379 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1380 | TTCN_Logger::log_logmatch_info(".syntaxes"); | |
1381 | single_value.field_syntaxes->log_match(match_value.syntaxes()); | |
1382 | }else{ | |
1383 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
1384 | single_value.field_syntaxes->log_match(match_value.syntaxes()); | |
1385 | TTCN_Logger::log_event_str(" }"); | |
1386 | } | |
1387 | break; | |
1388 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1389 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1390 | TTCN_Logger::log_logmatch_info(".syntax"); | |
1391 | single_value.field_syntax->log_match(match_value.syntax()); | |
1392 | }else{ | |
1393 | TTCN_Logger::log_event_str("{ syntax := "); | |
1394 | single_value.field_syntax->log_match(match_value.syntax()); | |
1395 | TTCN_Logger::log_event_str(" }"); | |
1396 | } | |
1397 | break; | |
1398 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1399 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1400 | TTCN_Logger::log_logmatch_info(".presentation_context_id"); | |
1401 | single_value.field_presentation__context__id->log_match(match_value.presentation__context__id()); | |
1402 | }else{ | |
1403 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
1404 | single_value.field_presentation__context__id->log_match(match_value.presentation__context__id()); | |
1405 | TTCN_Logger::log_event_str(" }"); | |
1406 | } | |
1407 | break; | |
1408 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1409 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1410 | TTCN_Logger::log_logmatch_info(".context_negotiation"); | |
1411 | single_value.field_context__negotiation->log_match(match_value.context__negotiation()); | |
1412 | }else{ | |
1413 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
1414 | single_value.field_context__negotiation->log_match(match_value.context__negotiation()); | |
1415 | TTCN_Logger::log_event_str(" }"); | |
1416 | } | |
1417 | break; | |
1418 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1419 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1420 | TTCN_Logger::log_logmatch_info(".transfer_syntax"); | |
1421 | single_value.field_transfer__syntax->log_match(match_value.transfer__syntax()); | |
1422 | }else{ | |
1423 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
1424 | single_value.field_transfer__syntax->log_match(match_value.transfer__syntax()); | |
1425 | TTCN_Logger::log_event_str(" }"); | |
1426 | } | |
1427 | break; | |
1428 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1429 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1430 | TTCN_Logger::log_logmatch_info(".fixed"); | |
1431 | single_value.field_fixed->log_match(match_value.fixed()); | |
1432 | }else{ | |
1433 | TTCN_Logger::log_event_str("{ fixed := "); | |
1434 | single_value.field_fixed->log_match(match_value.fixed()); | |
1435 | TTCN_Logger::log_event_str(" }"); | |
1436 | } | |
1437 | break; | |
1438 | default: | |
1439 | TTCN_Logger::print_logmatch_buffer(); | |
1440 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1441 | } | |
1442 | } else { | |
1443 | TTCN_Logger::print_logmatch_buffer(); | |
1444 | match_value.log(); | |
1445 | TTCN_Logger::log_event_str(" with "); | |
1446 | log(); | |
1447 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
1448 | else TTCN_Logger::log_event_str(" unmatched"); | |
1449 | } | |
1450 | } | |
1451 | ||
1452 | void EMBEDDED_PDV_identification_template::encode_text(Text_Buf& text_buf) const | |
1453 | { | |
1454 | encode_text_base(text_buf); | |
1455 | switch (template_selection) { | |
1456 | case SPECIFIC_VALUE: | |
1457 | text_buf.push_int(single_value.union_selection); | |
1458 | switch (single_value.union_selection) { | |
1459 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1460 | single_value.field_syntaxes->encode_text(text_buf); | |
1461 | break; | |
1462 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1463 | single_value.field_syntax->encode_text(text_buf); | |
1464 | break; | |
1465 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1466 | single_value.field_presentation__context__id->encode_text(text_buf); | |
1467 | break; | |
1468 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1469 | single_value.field_context__negotiation->encode_text(text_buf); | |
1470 | break; | |
1471 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1472 | single_value.field_transfer__syntax->encode_text(text_buf); | |
1473 | break; | |
1474 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1475 | single_value.field_fixed->encode_text(text_buf); | |
1476 | break; | |
1477 | default: | |
1478 | TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EMBEDDED PDV.identification."); | |
1479 | } | |
1480 | break; | |
1481 | case OMIT_VALUE: | |
1482 | case ANY_VALUE: | |
1483 | case ANY_OR_OMIT: | |
1484 | break; | |
1485 | case VALUE_LIST: | |
1486 | case COMPLEMENTED_LIST: | |
1487 | text_buf.push_int(value_list.n_values); | |
1488 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1489 | value_list.list_value[list_count].encode_text(text_buf); | |
1490 | break; | |
1491 | default: | |
1492 | TTCN_error("Text encoder: Encoding an uninitialized template of type EMBEDDED PDV.identification."); | |
1493 | } | |
1494 | } | |
1495 | ||
1496 | void EMBEDDED_PDV_identification_template::decode_text(Text_Buf& text_buf) | |
1497 | { | |
1498 | clean_up(); | |
1499 | decode_text_base(text_buf); | |
1500 | switch (template_selection) { | |
1501 | case SPECIFIC_VALUE: | |
1502 | { | |
1503 | single_value.union_selection = EMBEDDED_PDV_identification::UNBOUND_VALUE; | |
1504 | EMBEDDED_PDV_identification::union_selection_type new_selection = (EMBEDDED_PDV_identification::union_selection_type)text_buf.pull_int().get_val(); | |
1505 | switch (new_selection) { | |
1506 | case EMBEDDED_PDV_identification::ALT_syntaxes: | |
1507 | single_value.field_syntaxes = new EMBEDDED_PDV_identification_syntaxes_template; | |
1508 | single_value.field_syntaxes->decode_text(text_buf); | |
1509 | break; | |
1510 | case EMBEDDED_PDV_identification::ALT_syntax: | |
1511 | single_value.field_syntax = new OBJID_template; | |
1512 | single_value.field_syntax->decode_text(text_buf); | |
1513 | break; | |
1514 | case EMBEDDED_PDV_identification::ALT_presentation__context__id: | |
1515 | single_value.field_presentation__context__id = new INTEGER_template; | |
1516 | single_value.field_presentation__context__id->decode_text(text_buf); | |
1517 | break; | |
1518 | case EMBEDDED_PDV_identification::ALT_context__negotiation: | |
1519 | single_value.field_context__negotiation = new EMBEDDED_PDV_identification_context__negotiation_template; | |
1520 | single_value.field_context__negotiation->decode_text(text_buf); | |
1521 | break; | |
1522 | case EMBEDDED_PDV_identification::ALT_transfer__syntax: | |
1523 | single_value.field_transfer__syntax = new OBJID_template; | |
1524 | single_value.field_transfer__syntax->decode_text(text_buf); | |
1525 | break; | |
1526 | case EMBEDDED_PDV_identification::ALT_fixed: | |
1527 | single_value.field_fixed = new ASN_NULL_template; | |
1528 | single_value.field_fixed->decode_text(text_buf); | |
1529 | break; | |
1530 | default: | |
1531 | TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EMBEDDED PDV.identification."); | |
1532 | } | |
1533 | single_value.union_selection = new_selection; | |
1534 | } | |
1535 | break; | |
1536 | case OMIT_VALUE: | |
1537 | case ANY_VALUE: | |
1538 | case ANY_OR_OMIT: | |
1539 | break; | |
1540 | case VALUE_LIST: | |
1541 | case COMPLEMENTED_LIST: | |
1542 | value_list.n_values = text_buf.pull_int().get_val(); | |
1543 | value_list.list_value = new EMBEDDED_PDV_identification_template[value_list.n_values]; | |
1544 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1545 | value_list.list_value[list_count].decode_text(text_buf); | |
1546 | break; | |
1547 | default: | |
1548 | TTCN_error("Text decoder: Unrecognized selector was received in a template of type EMBEDDED PDV.identification."); | |
1549 | } | |
1550 | } | |
1551 | ||
3abe9331 | 1552 | boolean EMBEDDED_PDV_identification_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
1553 | { |
1554 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 1555 | return !match_omit(legacy); |
970ed795 EL |
1556 | } |
1557 | ||
3abe9331 | 1558 | boolean EMBEDDED_PDV_identification_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
1559 | { |
1560 | if (is_ifpresent) return TRUE; | |
1561 | switch (template_selection) { | |
1562 | case OMIT_VALUE: | |
1563 | case ANY_OR_OMIT: | |
1564 | return TRUE; | |
1565 | case VALUE_LIST: | |
1566 | case COMPLEMENTED_LIST: | |
3abe9331 | 1567 | if (legacy) { |
1568 | for (unsigned int i=0; i<value_list.n_values; i++) | |
1569 | if (value_list.list_value[i].match_omit()) | |
1570 | return template_selection==VALUE_LIST; | |
1571 | return template_selection==COMPLEMENTED_LIST; | |
1572 | } // else fall through | |
970ed795 EL |
1573 | default: |
1574 | return FALSE; | |
1575 | } | |
1576 | return FALSE; | |
1577 | } | |
1578 | ||
1579 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 1580 | void EMBEDDED_PDV_identification_template::check_restriction(template_res t_res, const char* t_name, |
1581 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
1582 | { |
1583 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
1584 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
1585 | case TR_VALUE: | |
1586 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
1587 | break; | |
1588 | case TR_OMIT: | |
1589 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
1590 | template_selection==SPECIFIC_VALUE)) return; | |
1591 | break; | |
1592 | case TR_PRESENT: | |
3abe9331 | 1593 | if (!match_omit(legacy)) return; |
970ed795 EL |
1594 | break; |
1595 | default: | |
1596 | return; | |
1597 | } | |
1598 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
1599 | get_res_name(t_res), t_name ? t_name : "EMBEDDED PDV.identification"); | |
1600 | } | |
1601 | #endif | |
1602 | ||
1603 | EMBEDDED_PDV_identification_syntaxes::EMBEDDED_PDV_identification_syntaxes() | |
1604 | { | |
1605 | } | |
1606 | ||
1607 | EMBEDDED_PDV_identification_syntaxes::EMBEDDED_PDV_identification_syntaxes(const OBJID& par_abstract, | |
1608 | const OBJID& par_transfer) | |
1609 | : field_abstract(par_abstract), | |
1610 | field_transfer(par_transfer) | |
1611 | { | |
1612 | } | |
1613 | ||
1614 | boolean EMBEDDED_PDV_identification_syntaxes::operator==(const EMBEDDED_PDV_identification_syntaxes& other_value) const | |
1615 | { | |
1616 | return field_abstract==other_value.field_abstract | |
1617 | && field_transfer==other_value.field_transfer; | |
1618 | } | |
1619 | ||
1620 | int EMBEDDED_PDV_identification_syntaxes::size_of() const | |
1621 | { | |
1622 | int ret_val = 2; | |
1623 | return ret_val; | |
1624 | } | |
1625 | ||
1626 | void EMBEDDED_PDV_identification_syntaxes::log() const | |
1627 | { | |
1628 | TTCN_Logger::log_event_str("{ abstract := "); | |
1629 | field_abstract.log(); | |
1630 | TTCN_Logger::log_event_str(", transfer := "); | |
1631 | field_transfer.log(); | |
1632 | TTCN_Logger::log_event_str(" }"); | |
1633 | } | |
1634 | ||
1635 | boolean EMBEDDED_PDV_identification_syntaxes::is_bound() const | |
1636 | { | |
1637 | if(field_abstract.is_bound()) return TRUE; | |
1638 | if(field_transfer.is_bound()) return TRUE; | |
1639 | return FALSE; | |
1640 | } | |
1641 | ||
1642 | boolean EMBEDDED_PDV_identification_syntaxes::is_value() const | |
1643 | { | |
1644 | if(!field_abstract.is_value()) return FALSE; | |
1645 | if(!field_transfer.is_value()) return FALSE; | |
1646 | return TRUE; | |
1647 | } | |
1648 | ||
1649 | void EMBEDDED_PDV_identification_syntaxes::clean_up() | |
1650 | { | |
1651 | field_abstract.clean_up(); | |
1652 | field_transfer.clean_up(); | |
1653 | } | |
1654 | ||
1655 | void EMBEDDED_PDV_identification_syntaxes::set_param(Module_Param& param) | |
1656 | { | |
1657 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 1658 | Module_Param_Ptr mp = ¶m; |
1659 | if (param.get_type() == Module_Param::MP_Reference) { | |
1660 | mp = param.get_referenced_param(); | |
1661 | } | |
1662 | switch (mp->get_type()) { | |
970ed795 | 1663 | case Module_Param::MP_Value_List: |
3abe9331 | 1664 | if (mp->get_size()==0) return; |
1665 | if (2!=mp->get_size()) { | |
1666 | param.error("record value of type EMBEDDED PDV.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 1667 | } |
3abe9331 | 1668 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0)); |
1669 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1)); | |
970ed795 EL |
1670 | break; |
1671 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 1672 | Vector<bool> value_used(mp->get_size()); |
1673 | value_used.resize(mp->get_size(), false); | |
1674 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1675 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
1676 | if (!strcmp(curr_param->get_id()->get_name(), "abstract")) { |
1677 | abstract().set_param(*curr_param); | |
1678 | value_used[val_idx]=true; | |
1679 | } | |
1680 | } | |
3abe9331 | 1681 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
1682 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
1683 | if (!strcmp(curr_param->get_id()->get_name(), "transfer")) { |
1684 | transfer().set_param(*curr_param); | |
1685 | value_used[val_idx]=true; | |
1686 | } | |
1687 | } | |
3abe9331 | 1688 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
1689 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
1690 | break; |
1691 | } | |
1692 | } break; | |
1693 | default: | |
1694 | param.type_error("record value", "EMBEDDED PDV.identification.syntaxes"); | |
1695 | } | |
1696 | } | |
1697 | ||
3abe9331 | 1698 | Module_Param* EMBEDDED_PDV_identification_syntaxes::get_param(Module_Param_Name& param_name) const |
970ed795 | 1699 | { |
3abe9331 | 1700 | if (!is_bound()) { |
1701 | return new Module_Param_Unbound(); | |
970ed795 | 1702 | } |
3abe9331 | 1703 | Module_Param* mp_field_abstract = field_abstract.get_param(param_name); |
1704 | mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract"))); | |
1705 | Module_Param* mp_field_transfer = field_transfer.get_param(param_name); | |
1706 | mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer"))); | |
1707 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
1708 | mp->add_elem(mp_field_abstract); | |
1709 | mp->add_elem(mp_field_transfer); | |
1710 | return mp; | |
970ed795 EL |
1711 | } |
1712 | ||
1713 | void EMBEDDED_PDV_identification_syntaxes::encode_text(Text_Buf& text_buf) const | |
1714 | { | |
1715 | field_abstract.encode_text(text_buf); | |
1716 | field_transfer.encode_text(text_buf); | |
1717 | } | |
1718 | ||
1719 | void EMBEDDED_PDV_identification_syntaxes::decode_text(Text_Buf& text_buf) | |
1720 | { | |
1721 | field_abstract.decode_text(text_buf); | |
1722 | field_transfer.decode_text(text_buf); | |
1723 | } | |
1724 | ||
1725 | // No encode/decode for this implementation class | |
1726 | //void EMBEDDED_PDV_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
1727 | //void EMBEDDED_PDV_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
1728 | ||
1729 | ASN_BER_TLV_t* EMBEDDED_PDV_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
1730 | { | |
1731 | BER_chk_descr(p_td); | |
1732 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
1733 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
1734 | TTCN_EncDec_ErrorContext ec_1; | |
1735 | ec_1.set_msg("abstract': "); | |
1736 | new_tlv->add_TLV(field_abstract.BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_abstract_descr_, p_coding)); | |
1737 | ec_1.set_msg("transfer': "); | |
1738 | new_tlv->add_TLV(field_transfer.BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_transfer_descr_, p_coding)); | |
1739 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
1740 | return new_tlv; | |
1741 | } | |
1742 | ||
1743 | boolean EMBEDDED_PDV_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
1744 | { | |
1745 | BER_chk_descr(p_td); | |
1746 | ASN_BER_TLV_t stripped_tlv; | |
1747 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
1748 | TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV.identification.syntaxes' type: "); | |
1749 | stripped_tlv.chk_constructed_flag(TRUE); | |
1750 | size_t V_pos=0; | |
1751 | ASN_BER_TLV_t tmp_tlv; | |
1752 | boolean tlv_present=FALSE; | |
1753 | { | |
1754 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
1755 | TTCN_EncDec_ErrorContext ec_2; | |
1756 | ec_2.set_msg("abstract': "); | |
1757 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
1758 | if(!tlv_present) return FALSE; | |
1759 | field_abstract.BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_abstract_descr_, tmp_tlv, L_form); | |
1760 | tlv_present=FALSE; | |
1761 | ec_2.set_msg("transfer': "); | |
1762 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
1763 | if(!tlv_present) return FALSE; | |
1764 | field_transfer.BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_transfer_descr_, tmp_tlv, L_form); | |
1765 | tlv_present=FALSE; | |
1766 | } | |
1767 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
1768 | return TRUE; | |
1769 | } | |
1770 | ||
1771 | int EMBEDDED_PDV_identification_syntaxes::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 1772 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
1773 | { |
1774 | int indenting = !is_canonical(flavor); | |
1775 | int exer = is_exer(flavor); | |
1776 | int encoded_length=(int)p_buf.get_len(); | |
1777 | if (indenting) do_indent(p_buf, indent); | |
1778 | p_buf.put_c('<'); | |
1779 | if (exer) write_ns_prefix(p_td, p_buf); | |
1780 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
1781 | ||
1782 | ++indent; | |
af710487 | 1783 | field_abstract.XER_encode(EMBEDDED_PDV_identification_sxs_abs_xer_, p_buf, flavor, indent, 0); |
1784 | field_transfer.XER_encode(EMBEDDED_PDV_identification_sxs_xfr_xer_, p_buf, flavor, indent, 0); | |
970ed795 EL |
1785 | |
1786 | if (indenting) do_indent(p_buf, --indent); | |
1787 | p_buf.put_c('<'); | |
1788 | p_buf.put_c('/'); | |
1789 | if (exer) write_ns_prefix(p_td, p_buf); | |
1790 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
1791 | return (int)p_buf.get_len() - encoded_length; | |
1792 | } | |
1793 | ||
1794 | int EMBEDDED_PDV_identification_syntaxes::XER_decode(const XERdescriptor_t& /*p_td*/, | |
feade998 | 1795 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
1796 | { // we stand on <syntaxes>, move ahead first |
1797 | int type; | |
1798 | for (int success = reader.Read(); success == 1; success = reader.Read()) | |
1799 | { | |
1800 | type = reader.NodeType(); | |
1801 | if (XML_READER_TYPE_ELEMENT == type) | |
1802 | // no verify_name for a CHOICE | |
1803 | break; | |
1804 | } | |
1805 | // FIXME this assumes the right element | |
feade998 | 1806 | field_abstract.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_, reader, flavor, flavor2, 0); |
1807 | field_transfer.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
1808 | for (int success = 1; success == 1; success = reader.Read()) |
1809 | { | |
1810 | type = reader.NodeType(); | |
1811 | if (XML_READER_TYPE_END_ELEMENT == type) | |
1812 | break; | |
1813 | } | |
1814 | return 0; // TODO maybe return proper value | |
1815 | } | |
1816 | ||
1817 | /******************** EMBEDDED_PDV_identification_syntaxes_template ********************/ | |
1818 | ||
1819 | struct EMBEDDED_PDV_identification_syntaxes_template::single_value_struct { | |
1820 | OBJID_template field_abstract; | |
1821 | OBJID_template field_transfer; | |
1822 | }; | |
1823 | ||
3abe9331 | 1824 | void EMBEDDED_PDV_identification_syntaxes_template::set_param(Module_Param& param) |
1825 | { | |
1826 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
1827 | Module_Param_Ptr mp = ¶m; | |
1828 | if (param.get_type() == Module_Param::MP_Reference) { | |
1829 | mp = param.get_referenced_param(); | |
1830 | } | |
1831 | switch (mp->get_type()) { | |
1832 | case Module_Param::MP_Omit: | |
1833 | *this = OMIT_VALUE; | |
1834 | break; | |
1835 | case Module_Param::MP_Any: | |
1836 | *this = ANY_VALUE; | |
1837 | break; | |
1838 | case Module_Param::MP_AnyOrNone: | |
1839 | *this = ANY_OR_OMIT; | |
1840 | break; | |
1841 | case Module_Param::MP_List_Template: | |
1842 | case Module_Param::MP_ComplementList_Template: { | |
1843 | EMBEDDED_PDV_identification_syntaxes_template temp; | |
1844 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
1845 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
1846 | for (size_t i=0; i<mp->get_size(); i++) { | |
1847 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
1848 | } | |
1849 | *this = temp; | |
1850 | break; } | |
1851 | case Module_Param::MP_Value_List: | |
1852 | if (mp->get_size()==0) break; | |
1853 | if (2!=mp->get_size()) { | |
1854 | param.error("record template of type EMBEDDED PDV.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size()); | |
1855 | } | |
1856 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0)); | |
1857 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1)); | |
1858 | break; | |
1859 | case Module_Param::MP_Assignment_List: { | |
1860 | Vector<bool> value_used(mp->get_size()); | |
1861 | value_used.resize(mp->get_size(), false); | |
1862 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1863 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
1864 | if (!strcmp(curr_param->get_id()->get_name(), "abstract")) { | |
1865 | abstract().set_param(*curr_param); | |
1866 | value_used[val_idx]=true; | |
1867 | } | |
1868 | } | |
1869 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1870 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
1871 | if (!strcmp(curr_param->get_id()->get_name(), "transfer")) { | |
1872 | transfer().set_param(*curr_param); | |
1873 | value_used[val_idx]=true; | |
1874 | } | |
1875 | } | |
1876 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
1877 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
1878 | break; | |
1879 | } | |
1880 | } break; | |
1881 | default: | |
1882 | param.type_error("record template", "EMBEDDED PDV.identification.syntaxes"); | |
1883 | } | |
1884 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
1885 | } | |
1886 | ||
1887 | Module_Param* EMBEDDED_PDV_identification_syntaxes_template::get_param(Module_Param_Name& param_name) const | |
1888 | { | |
1889 | Module_Param* mp = NULL; | |
1890 | switch (template_selection) { | |
1891 | case UNINITIALIZED_TEMPLATE: | |
1892 | mp = new Module_Param_Unbound(); | |
1893 | break; | |
1894 | case OMIT_VALUE: | |
1895 | mp = new Module_Param_Omit(); | |
1896 | break; | |
1897 | case ANY_VALUE: | |
1898 | mp = new Module_Param_Any(); | |
1899 | break; | |
1900 | case ANY_OR_OMIT: | |
1901 | mp = new Module_Param_AnyOrNone(); | |
1902 | break; | |
1903 | case SPECIFIC_VALUE: { | |
1904 | Module_Param* mp_field_abstract = single_value->field_abstract.get_param(param_name); | |
1905 | mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract"))); | |
1906 | Module_Param* mp_field_transfer = single_value->field_transfer.get_param(param_name); | |
1907 | mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer"))); | |
1908 | mp = new Module_Param_Assignment_List(); | |
1909 | mp->add_elem(mp_field_abstract); | |
1910 | mp->add_elem(mp_field_transfer); | |
1911 | break; } | |
1912 | case VALUE_LIST: | |
1913 | case COMPLEMENTED_LIST: { | |
1914 | if (template_selection == VALUE_LIST) { | |
1915 | mp = new Module_Param_List_Template(); | |
1916 | } | |
1917 | else { | |
1918 | mp = new Module_Param_ComplementList_Template(); | |
1919 | } | |
1920 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
1921 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
1922 | } | |
1923 | break; } | |
1924 | default: | |
1925 | break; | |
1926 | } | |
1927 | if (is_ifpresent) { | |
1928 | mp->set_ifpresent(); | |
1929 | } | |
1930 | return mp; | |
1931 | } | |
1932 | ||
970ed795 EL |
1933 | void EMBEDDED_PDV_identification_syntaxes_template::clean_up() |
1934 | { | |
1935 | switch (template_selection) { | |
1936 | case SPECIFIC_VALUE: | |
1937 | delete single_value; | |
1938 | break; | |
1939 | case VALUE_LIST: | |
1940 | case COMPLEMENTED_LIST: | |
1941 | delete [] value_list.list_value; | |
1942 | break; | |
1943 | default: | |
1944 | break; | |
1945 | } | |
1946 | template_selection = UNINITIALIZED_TEMPLATE; | |
1947 | } | |
1948 | ||
1949 | void EMBEDDED_PDV_identification_syntaxes_template::set_specific() | |
1950 | { | |
1951 | if (template_selection != SPECIFIC_VALUE) { | |
1952 | template_sel old_selection = template_selection; | |
1953 | clean_up(); | |
1954 | single_value = new single_value_struct; | |
1955 | set_selection(SPECIFIC_VALUE); | |
1956 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
1957 | single_value->field_abstract = ANY_VALUE; | |
1958 | single_value->field_transfer = ANY_VALUE; | |
1959 | } | |
1960 | } | |
1961 | } | |
1962 | ||
1963 | void EMBEDDED_PDV_identification_syntaxes_template::copy_value(const EMBEDDED_PDV_identification_syntaxes& other_value) | |
1964 | { | |
1965 | single_value = new single_value_struct; | |
1966 | single_value->field_abstract = other_value.abstract(); | |
1967 | single_value->field_transfer = other_value.transfer(); | |
1968 | set_selection(SPECIFIC_VALUE); | |
1969 | } | |
1970 | ||
1971 | void EMBEDDED_PDV_identification_syntaxes_template::copy_template(const EMBEDDED_PDV_identification_syntaxes_template& other_value) | |
1972 | { | |
1973 | switch (other_value.template_selection) { | |
1974 | case SPECIFIC_VALUE: | |
1975 | single_value = new single_value_struct(*other_value.single_value); | |
1976 | break; | |
1977 | case OMIT_VALUE: | |
1978 | case ANY_VALUE: | |
1979 | case ANY_OR_OMIT: | |
1980 | break; | |
1981 | case VALUE_LIST: | |
1982 | case COMPLEMENTED_LIST: | |
1983 | value_list.n_values = other_value.value_list.n_values; | |
1984 | value_list.list_value = new EMBEDDED_PDV_identification_syntaxes_template[value_list.n_values]; | |
1985 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1986 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
1987 | break; | |
1988 | default: | |
1989 | TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes."); | |
1990 | } | |
1991 | set_selection(other_value); | |
1992 | } | |
1993 | ||
1994 | EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template() | |
1995 | { | |
1996 | } | |
1997 | ||
1998 | EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(template_sel other_value) | |
1999 | : Base_Template(other_value) | |
2000 | { | |
2001 | check_single_selection(other_value); | |
2002 | } | |
2003 | ||
2004 | EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const EMBEDDED_PDV_identification_syntaxes& other_value) | |
2005 | { | |
2006 | copy_value(other_value); | |
2007 | } | |
2008 | ||
2009 | EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const OPTIONAL<EMBEDDED_PDV_identification_syntaxes>& other_value) | |
2010 | { | |
2011 | switch (other_value.get_selection()) { | |
2012 | case OPTIONAL_PRESENT: | |
2013 | copy_value((const EMBEDDED_PDV_identification_syntaxes&)other_value); | |
2014 | break; | |
2015 | case OPTIONAL_OMIT: | |
2016 | set_selection(OMIT_VALUE); | |
2017 | break; | |
2018 | default: | |
2019 | TTCN_error("Creating a template of type EMBEDDED PDV.identification.syntaxes from an unbound optional field."); | |
2020 | } | |
2021 | } | |
2022 | ||
2023 | EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const EMBEDDED_PDV_identification_syntaxes_template& other_value) | |
2024 | : Base_Template() | |
2025 | { | |
2026 | copy_template(other_value); | |
2027 | } | |
2028 | ||
2029 | EMBEDDED_PDV_identification_syntaxes_template::~EMBEDDED_PDV_identification_syntaxes_template() | |
2030 | { | |
2031 | clean_up(); | |
2032 | } | |
2033 | ||
2034 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_syntaxes_template::operator=(template_sel other_value) | |
2035 | { | |
2036 | check_single_selection(other_value); | |
2037 | clean_up(); | |
2038 | set_selection(other_value); | |
2039 | return *this; | |
2040 | } | |
2041 | ||
2042 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_syntaxes_template::operator=(const EMBEDDED_PDV_identification_syntaxes& other_value) | |
2043 | { | |
2044 | clean_up(); | |
2045 | copy_value(other_value); | |
2046 | return *this; | |
2047 | } | |
2048 | ||
2049 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_syntaxes_template::operator=(const OPTIONAL<EMBEDDED_PDV_identification_syntaxes>& other_value) | |
2050 | { | |
2051 | clean_up(); | |
2052 | switch (other_value.get_selection()) { | |
2053 | case OPTIONAL_PRESENT: | |
2054 | copy_value((const EMBEDDED_PDV_identification_syntaxes&)other_value); | |
2055 | break; | |
2056 | case OPTIONAL_OMIT: | |
2057 | set_selection(OMIT_VALUE); | |
2058 | break; | |
2059 | default: | |
2060 | TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV.identification.syntaxes."); | |
2061 | } | |
2062 | return *this; | |
2063 | } | |
2064 | ||
2065 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_syntaxes_template::operator=(const EMBEDDED_PDV_identification_syntaxes_template& other_value) | |
2066 | { | |
2067 | if (&other_value != this) { | |
2068 | clean_up(); | |
2069 | copy_template(other_value); | |
2070 | } | |
2071 | return *this; | |
2072 | } | |
2073 | ||
3abe9331 | 2074 | boolean EMBEDDED_PDV_identification_syntaxes_template::match(const EMBEDDED_PDV_identification_syntaxes& other_value, |
2075 | boolean /* legacy */) const | |
970ed795 EL |
2076 | { |
2077 | switch (template_selection) { | |
2078 | case ANY_VALUE: | |
2079 | case ANY_OR_OMIT: | |
2080 | return TRUE; | |
2081 | case OMIT_VALUE: | |
2082 | return FALSE; | |
2083 | case SPECIFIC_VALUE: | |
2084 | if (!other_value.abstract().is_bound()) return FALSE; | |
2085 | if (!single_value->field_abstract.match(other_value.abstract())) return FALSE; | |
2086 | if (!other_value.transfer().is_bound()) return FALSE; | |
2087 | if (!single_value->field_transfer.match(other_value.transfer())) return FALSE; | |
2088 | return TRUE; | |
2089 | case VALUE_LIST: | |
2090 | case COMPLEMENTED_LIST: | |
2091 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2092 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
2093 | return template_selection == COMPLEMENTED_LIST; | |
2094 | default: | |
2095 | TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes."); | |
2096 | } | |
2097 | return FALSE; | |
2098 | } | |
2099 | ||
2100 | EMBEDDED_PDV_identification_syntaxes EMBEDDED_PDV_identification_syntaxes_template::valueof() const | |
2101 | { | |
2102 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
2103 | TTCN_error("Performing valueof or send operation on a non-specific template of type EMBEDDED PDV.identification.syntaxes."); | |
2104 | EMBEDDED_PDV_identification_syntaxes ret_val; | |
2105 | ret_val.abstract() = single_value->field_abstract.valueof(); | |
2106 | ret_val.transfer() = single_value->field_transfer.valueof(); | |
2107 | return ret_val; | |
2108 | } | |
2109 | ||
2110 | void EMBEDDED_PDV_identification_syntaxes_template::set_type(template_sel template_type, unsigned int list_length) | |
2111 | { | |
2112 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
2113 | TTCN_error("Setting an invalid list for a template of type EMBEDDED PDV.identification.syntaxes."); | |
2114 | clean_up(); | |
2115 | set_selection(template_type); | |
2116 | value_list.n_values = list_length; | |
2117 | value_list.list_value = new EMBEDDED_PDV_identification_syntaxes_template[list_length]; | |
2118 | } | |
2119 | ||
2120 | EMBEDDED_PDV_identification_syntaxes_template& EMBEDDED_PDV_identification_syntaxes_template::list_item(unsigned int list_index) const | |
2121 | { | |
2122 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
2123 | TTCN_error("Accessing a list element of a non-list template of type EMBEDDED PDV.identification.syntaxes."); | |
2124 | if (list_index >= value_list.n_values) | |
2125 | TTCN_error("Index overflow in a value list template of type EMBEDDED PDV.identification.syntaxes."); | |
2126 | return value_list.list_value[list_index]; | |
2127 | } | |
2128 | ||
2129 | OBJID_template& EMBEDDED_PDV_identification_syntaxes_template::abstract() | |
2130 | { | |
2131 | set_specific(); | |
2132 | return single_value->field_abstract; | |
2133 | } | |
2134 | ||
2135 | const OBJID_template& EMBEDDED_PDV_identification_syntaxes_template::abstract() const | |
2136 | { | |
2137 | if (template_selection != SPECIFIC_VALUE) | |
2138 | TTCN_error("Accessing field abstract of a non-specific template of type EMBEDDED PDV.identification.syntaxes."); | |
2139 | return single_value->field_abstract; | |
2140 | } | |
2141 | ||
2142 | OBJID_template& EMBEDDED_PDV_identification_syntaxes_template::transfer() | |
2143 | { | |
2144 | set_specific(); | |
2145 | return single_value->field_transfer; | |
2146 | } | |
2147 | ||
2148 | const OBJID_template& EMBEDDED_PDV_identification_syntaxes_template::transfer() const | |
2149 | { | |
2150 | if (template_selection != SPECIFIC_VALUE) | |
2151 | TTCN_error("Accessing field transfer of a non-specific template of type EMBEDDED PDV.identification.syntaxes."); | |
2152 | return single_value->field_transfer; | |
2153 | } | |
2154 | ||
2155 | int EMBEDDED_PDV_identification_syntaxes_template::size_of() const | |
2156 | { | |
2157 | switch (template_selection) | |
2158 | { | |
2159 | case SPECIFIC_VALUE: | |
2160 | { | |
2161 | int ret_val = 2; | |
2162 | return ret_val; | |
2163 | } | |
2164 | case VALUE_LIST: | |
2165 | { | |
2166 | if (value_list.n_values<1) | |
2167 | TTCN_error("Internal error: Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing an empty list."); | |
2168 | int item_size = value_list.list_value[0].size_of(); | |
2169 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
2170 | { | |
2171 | if (value_list.list_value[i].size_of()!=item_size) | |
2172 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing a value list with different sizes."); | |
2173 | } | |
2174 | return item_size; | |
2175 | } | |
2176 | case OMIT_VALUE: | |
2177 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing omit value."); | |
2178 | case ANY_VALUE: | |
2179 | case ANY_OR_OMIT: | |
2180 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing */? value."); | |
2181 | case COMPLEMENTED_LIST: | |
2182 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing complemented list."); | |
2183 | default: | |
2184 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes."); | |
2185 | } | |
2186 | return 0; | |
2187 | } | |
2188 | ||
2189 | void EMBEDDED_PDV_identification_syntaxes_template::log() const | |
2190 | { | |
2191 | switch (template_selection) { | |
2192 | case SPECIFIC_VALUE: | |
2193 | TTCN_Logger::log_event_str("{ abstract := "); | |
2194 | single_value->field_abstract.log(); | |
2195 | TTCN_Logger::log_event_str(", transfer := "); | |
2196 | single_value->field_transfer.log(); | |
2197 | TTCN_Logger::log_event_str(" }"); | |
2198 | break; | |
2199 | case COMPLEMENTED_LIST: | |
2200 | TTCN_Logger::log_event_str("complement "); | |
2201 | // no break | |
2202 | case VALUE_LIST: | |
2203 | TTCN_Logger::log_char('('); | |
2204 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
2205 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
2206 | value_list.list_value[list_count].log(); | |
2207 | } | |
2208 | TTCN_Logger::log_char(')'); | |
2209 | break; | |
2210 | default: | |
2211 | log_generic(); | |
2212 | break; | |
2213 | } | |
2214 | log_ifpresent(); | |
2215 | } | |
2216 | ||
3abe9331 | 2217 | void EMBEDDED_PDV_identification_syntaxes_template::log_match(const EMBEDDED_PDV_identification_syntaxes& match_value, |
2218 | boolean /* legacy */) const | |
970ed795 EL |
2219 | { |
2220 | if (template_selection == SPECIFIC_VALUE) { | |
2221 | TTCN_Logger::log_event_str("{ abstract := "); | |
2222 | single_value->field_abstract.log_match(match_value.abstract()); | |
2223 | TTCN_Logger::log_event_str(", transfer := "); | |
2224 | single_value->field_transfer.log_match(match_value.transfer()); | |
2225 | TTCN_Logger::log_event_str(" }"); | |
2226 | } else { | |
2227 | match_value.log(); | |
2228 | TTCN_Logger::log_event_str(" with "); | |
2229 | log(); | |
2230 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2231 | else TTCN_Logger::log_event_str(" unmatched"); | |
2232 | } | |
2233 | } | |
2234 | ||
2235 | void EMBEDDED_PDV_identification_syntaxes_template::encode_text(Text_Buf& text_buf) const | |
2236 | { | |
2237 | encode_text_base(text_buf); | |
2238 | switch (template_selection) { | |
2239 | case SPECIFIC_VALUE: | |
2240 | single_value->field_abstract.encode_text(text_buf); | |
2241 | single_value->field_transfer.encode_text(text_buf); | |
2242 | break; | |
2243 | case OMIT_VALUE: | |
2244 | case ANY_VALUE: | |
2245 | case ANY_OR_OMIT: | |
2246 | break; | |
2247 | case VALUE_LIST: | |
2248 | case COMPLEMENTED_LIST: | |
2249 | text_buf.push_int(value_list.n_values); | |
2250 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2251 | value_list.list_value[list_count].encode_text(text_buf); | |
2252 | break; | |
2253 | default: | |
2254 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes."); | |
2255 | } | |
2256 | } | |
2257 | ||
2258 | void EMBEDDED_PDV_identification_syntaxes_template::decode_text(Text_Buf& text_buf) | |
2259 | { | |
2260 | clean_up(); | |
2261 | decode_text_base(text_buf); | |
2262 | switch (template_selection) { | |
2263 | case SPECIFIC_VALUE: | |
2264 | single_value = new single_value_struct; | |
2265 | single_value->field_abstract.decode_text(text_buf); | |
2266 | single_value->field_transfer.decode_text(text_buf); | |
2267 | break; | |
2268 | case OMIT_VALUE: | |
2269 | case ANY_VALUE: | |
2270 | case ANY_OR_OMIT: | |
2271 | break; | |
2272 | case VALUE_LIST: | |
2273 | case COMPLEMENTED_LIST: | |
2274 | value_list.n_values = text_buf.pull_int().get_val(); | |
2275 | value_list.list_value = new EMBEDDED_PDV_identification_syntaxes_template[value_list.n_values]; | |
2276 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2277 | value_list.list_value[list_count].decode_text(text_buf); | |
2278 | break; | |
2279 | default: | |
2280 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV.identification.syntaxes."); | |
2281 | } | |
2282 | } | |
2283 | ||
3abe9331 | 2284 | boolean EMBEDDED_PDV_identification_syntaxes_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
2285 | { |
2286 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 2287 | return !match_omit(legacy); |
970ed795 EL |
2288 | } |
2289 | ||
3abe9331 | 2290 | boolean EMBEDDED_PDV_identification_syntaxes_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
2291 | { |
2292 | if (is_ifpresent) return TRUE; | |
2293 | switch (template_selection) { | |
2294 | case OMIT_VALUE: | |
2295 | case ANY_OR_OMIT: | |
2296 | return TRUE; | |
2297 | case VALUE_LIST: | |
2298 | case COMPLEMENTED_LIST: | |
3abe9331 | 2299 | if (legacy) { |
2300 | for (unsigned int i=0; i<value_list.n_values; i++) | |
2301 | if (value_list.list_value[i].match_omit()) | |
2302 | return template_selection==VALUE_LIST; | |
2303 | return template_selection==COMPLEMENTED_LIST; | |
2304 | } // else fall through | |
970ed795 EL |
2305 | default: |
2306 | return FALSE; | |
2307 | } | |
2308 | return FALSE; | |
2309 | } | |
2310 | ||
2311 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 2312 | void EMBEDDED_PDV_identification_syntaxes_template::check_restriction(template_res t_res, const char* t_name, |
2313 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
2314 | { |
2315 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
2316 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
2317 | case TR_VALUE: | |
2318 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
2319 | break; | |
2320 | case TR_OMIT: | |
2321 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
2322 | template_selection==SPECIFIC_VALUE)) return; | |
2323 | break; | |
2324 | case TR_PRESENT: | |
3abe9331 | 2325 | if (!match_omit(legacy)) return; |
970ed795 EL |
2326 | break; |
2327 | default: | |
2328 | return; | |
2329 | } | |
2330 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
2331 | get_res_name(t_res), t_name ? t_name : "EMBEDDED PDV.identification.syntaxes"); | |
2332 | } | |
2333 | #endif | |
2334 | ||
2335 | EMBEDDED_PDV_identification_context__negotiation::EMBEDDED_PDV_identification_context__negotiation() | |
2336 | { | |
2337 | } | |
2338 | ||
2339 | EMBEDDED_PDV_identification_context__negotiation::EMBEDDED_PDV_identification_context__negotiation(const INTEGER& par_presentation__context__id, | |
2340 | const OBJID& par_transfer__syntax) | |
2341 | : field_presentation__context__id(par_presentation__context__id), | |
2342 | field_transfer__syntax(par_transfer__syntax) | |
2343 | { | |
2344 | } | |
2345 | ||
2346 | boolean EMBEDDED_PDV_identification_context__negotiation::operator==(const EMBEDDED_PDV_identification_context__negotiation& other_value) const | |
2347 | { | |
2348 | return field_presentation__context__id==other_value.field_presentation__context__id | |
2349 | && field_transfer__syntax==other_value.field_transfer__syntax; | |
2350 | } | |
2351 | ||
2352 | int EMBEDDED_PDV_identification_context__negotiation::size_of() const | |
2353 | { | |
2354 | int ret_val = 2; | |
2355 | return ret_val; | |
2356 | } | |
2357 | ||
2358 | void EMBEDDED_PDV_identification_context__negotiation::log() const | |
2359 | { | |
2360 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2361 | field_presentation__context__id.log(); | |
2362 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2363 | field_transfer__syntax.log(); | |
2364 | TTCN_Logger::log_event_str(" }"); | |
2365 | } | |
2366 | ||
2367 | boolean EMBEDDED_PDV_identification_context__negotiation::is_bound() const | |
2368 | { | |
2369 | if(field_presentation__context__id.is_bound()) return TRUE; | |
2370 | if(field_transfer__syntax.is_bound()) return TRUE; | |
2371 | return FALSE; | |
2372 | } | |
2373 | ||
2374 | boolean EMBEDDED_PDV_identification_context__negotiation::is_value() const | |
2375 | { | |
2376 | if(!field_presentation__context__id.is_value()) return FALSE; | |
2377 | if(!field_transfer__syntax.is_value()) return FALSE; | |
2378 | return TRUE; | |
2379 | } | |
2380 | ||
2381 | void EMBEDDED_PDV_identification_context__negotiation::clean_up() | |
2382 | { | |
2383 | field_presentation__context__id.clean_up(); | |
2384 | field_transfer__syntax.clean_up(); | |
2385 | } | |
2386 | ||
2387 | void EMBEDDED_PDV_identification_context__negotiation::set_param(Module_Param& param) | |
2388 | { | |
2389 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 2390 | Module_Param_Ptr mp = ¶m; |
2391 | if (param.get_type() == Module_Param::MP_Reference) { | |
2392 | mp = param.get_referenced_param(); | |
2393 | } | |
2394 | switch (mp->get_type()) { | |
970ed795 | 2395 | case Module_Param::MP_Value_List: |
3abe9331 | 2396 | if (mp->get_size()==0) return; |
2397 | if (2!=mp->get_size()) { | |
2398 | param.error("record value of type EMBEDDED PDV.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 2399 | } |
3abe9331 | 2400 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0)); |
2401 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1)); | |
970ed795 EL |
2402 | break; |
2403 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 2404 | Vector<bool> value_used(mp->get_size()); |
2405 | value_used.resize(mp->get_size(), false); | |
2406 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2407 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
2408 | if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) { |
2409 | presentation__context__id().set_param(*curr_param); | |
2410 | value_used[val_idx]=true; | |
2411 | } | |
2412 | } | |
3abe9331 | 2413 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
2414 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
2415 | if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) { |
2416 | transfer__syntax().set_param(*curr_param); | |
2417 | value_used[val_idx]=true; | |
2418 | } | |
2419 | } | |
3abe9331 | 2420 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
2421 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
2422 | break; |
2423 | } | |
2424 | } break; | |
2425 | default: | |
2426 | param.type_error("record value", "EMBEDDED PDV.identification.context-negotiation"); | |
2427 | } | |
2428 | } | |
2429 | ||
3abe9331 | 2430 | Module_Param* EMBEDDED_PDV_identification_context__negotiation::get_param(Module_Param_Name& param_name) const |
970ed795 | 2431 | { |
3abe9331 | 2432 | if (!is_bound()) { |
2433 | return new Module_Param_Unbound(); | |
970ed795 | 2434 | } |
3abe9331 | 2435 | Module_Param* mp_field_presentation_context_id = field_presentation__context__id.get_param(param_name); |
2436 | mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
2437 | Module_Param* mp_field_transfer_syntax = field_transfer__syntax.get_param(param_name); | |
2438 | mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
2439 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
2440 | mp->add_elem(mp_field_presentation_context_id); | |
2441 | mp->add_elem(mp_field_transfer_syntax); | |
2442 | return mp; | |
970ed795 EL |
2443 | } |
2444 | ||
2445 | void EMBEDDED_PDV_identification_context__negotiation::encode_text(Text_Buf& text_buf) const | |
2446 | { | |
2447 | field_presentation__context__id.encode_text(text_buf); | |
2448 | field_transfer__syntax.encode_text(text_buf); | |
2449 | } | |
2450 | ||
2451 | void EMBEDDED_PDV_identification_context__negotiation::decode_text(Text_Buf& text_buf) | |
2452 | { | |
2453 | field_presentation__context__id.decode_text(text_buf); | |
2454 | field_transfer__syntax.decode_text(text_buf); | |
2455 | } | |
2456 | ||
2457 | // No encode/decode for this implementation class | |
2458 | //void EMBEDDED_PDV_identification_context__negotiation::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
2459 | //void EMBEDDED_PDV_identification_context__negotiation::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
2460 | ||
2461 | ||
2462 | ASN_BER_TLV_t* EMBEDDED_PDV_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
2463 | { | |
2464 | BER_chk_descr(p_td); | |
2465 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
2466 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
2467 | TTCN_EncDec_ErrorContext ec_1; | |
2468 | ec_1.set_msg("presentation_context_id': "); | |
2469 | new_tlv->add_TLV(field_presentation__context__id.BER_encode_TLV(EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_descr_, p_coding)); | |
2470 | ec_1.set_msg("transfer_syntax': "); | |
2471 | new_tlv->add_TLV(field_transfer__syntax.BER_encode_TLV(EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_descr_, p_coding)); | |
2472 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
2473 | return new_tlv; | |
2474 | } | |
2475 | ||
2476 | boolean EMBEDDED_PDV_identification_context__negotiation::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
2477 | { | |
2478 | BER_chk_descr(p_td); | |
2479 | ASN_BER_TLV_t stripped_tlv; | |
2480 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
2481 | TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV.identification.context-negotiation' type: "); | |
2482 | stripped_tlv.chk_constructed_flag(TRUE); | |
2483 | size_t V_pos=0; | |
2484 | ASN_BER_TLV_t tmp_tlv; | |
2485 | boolean tlv_present=FALSE; | |
2486 | { | |
2487 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
2488 | TTCN_EncDec_ErrorContext ec_2; | |
2489 | ec_2.set_msg("presentation_context_id': "); | |
2490 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
2491 | if(!tlv_present) return FALSE; | |
2492 | field_presentation__context__id.BER_decode_TLV(EMBEDDED_PDV_identification_context__negotiation_presentation__context__id_descr_, tmp_tlv, L_form); | |
2493 | tlv_present=FALSE; | |
2494 | ec_2.set_msg("transfer_syntax': "); | |
2495 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
2496 | if(!tlv_present) return FALSE; | |
2497 | field_transfer__syntax.BER_decode_TLV(EMBEDDED_PDV_identification_context__negotiation_transfer__syntax_descr_, tmp_tlv, L_form); | |
2498 | tlv_present=FALSE; | |
2499 | } | |
2500 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
2501 | return TRUE; | |
2502 | } | |
2503 | ||
2504 | int EMBEDDED_PDV_identification_context__negotiation::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 2505 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
2506 | { |
2507 | int indenting = !is_canonical(flavor); | |
2508 | int exer = is_exer(flavor); | |
2509 | int encoded_length=(int)p_buf.get_len(); | |
2510 | if (indenting) do_indent(p_buf, indent); | |
2511 | p_buf.put_c('<'); | |
2512 | if (exer) write_ns_prefix(p_td, p_buf); | |
2513 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
2514 | ||
2515 | ++indent; | |
af710487 | 2516 | field_presentation__context__id.XER_encode(EMBEDDED_PDV_identification_cn_pci_xer_, p_buf, flavor, indent, 0); |
2517 | field_transfer__syntax .XER_encode(EMBEDDED_PDV_identification_cn_tsx_xer_, p_buf, flavor, indent, 0); | |
970ed795 EL |
2518 | |
2519 | if (indenting) do_indent(p_buf, --indent); | |
2520 | p_buf.put_c('<'); | |
2521 | p_buf.put_c('/'); | |
2522 | if (exer) write_ns_prefix(p_td, p_buf); | |
2523 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
2524 | return (int)p_buf.get_len() - encoded_length; | |
2525 | } | |
2526 | ||
2527 | int EMBEDDED_PDV_identification_context__negotiation::XER_decode( | |
feade998 | 2528 | const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
2529 | { |
2530 | int exer = is_exer(flavor); | |
2531 | int type = reader.NodeType(), depth = -1; | |
2532 | const char* name = (const char*)reader.Name(); | |
2533 | int success = reader.Ok(); | |
2534 | if (type==XML_READER_TYPE_ELEMENT && check_name(name, p_td, exer)) { | |
2535 | verify_name(reader, p_td, exer); | |
2536 | depth = reader.Depth(); | |
2537 | success = reader.Read(); | |
2538 | } | |
feade998 | 2539 | field_presentation__context__id.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_, reader, flavor, flavor2, 0); |
2540 | field_transfer__syntax .XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
2541 | for (; success == 1; success = reader.Read()) { |
2542 | type = reader.NodeType(); | |
2543 | if (XML_READER_TYPE_END_ELEMENT == type) { | |
2544 | verify_end(reader, p_td, depth, exer); | |
2545 | reader.Read(); | |
2546 | break; | |
2547 | } | |
2548 | } | |
2549 | return 0; // TODO sensible return value | |
2550 | } | |
2551 | ||
2552 | struct EMBEDDED_PDV_identification_context__negotiation_template::single_value_struct { | |
2553 | INTEGER_template field_presentation__context__id; | |
2554 | OBJID_template field_transfer__syntax; | |
2555 | }; | |
2556 | ||
3abe9331 | 2557 | void EMBEDDED_PDV_identification_context__negotiation_template::set_param(Module_Param& param) |
2558 | { | |
2559 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
2560 | Module_Param_Ptr mp = ¶m; | |
2561 | if (param.get_type() == Module_Param::MP_Reference) { | |
2562 | mp = param.get_referenced_param(); | |
2563 | } | |
2564 | switch (mp->get_type()) { | |
2565 | case Module_Param::MP_Omit: | |
2566 | *this = OMIT_VALUE; | |
2567 | break; | |
2568 | case Module_Param::MP_Any: | |
2569 | *this = ANY_VALUE; | |
2570 | break; | |
2571 | case Module_Param::MP_AnyOrNone: | |
2572 | *this = ANY_OR_OMIT; | |
2573 | break; | |
2574 | case Module_Param::MP_List_Template: | |
2575 | case Module_Param::MP_ComplementList_Template: { | |
2576 | EMBEDDED_PDV_identification_context__negotiation_template temp; | |
2577 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
2578 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
2579 | for (size_t i=0; i<mp->get_size(); i++) { | |
2580 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
2581 | } | |
2582 | *this = temp; | |
2583 | break; } | |
2584 | case Module_Param::MP_Value_List: | |
2585 | if (mp->get_size()==0) break; | |
2586 | if (2!=mp->get_size()) { | |
2587 | param.error("record template of type EMBEDDED PDV.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size()); | |
2588 | } | |
2589 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0)); | |
2590 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1)); | |
2591 | break; | |
2592 | case Module_Param::MP_Assignment_List: { | |
2593 | Vector<bool> value_used(mp->get_size()); | |
2594 | value_used.resize(mp->get_size(), false); | |
2595 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2596 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
2597 | if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) { | |
2598 | presentation__context__id().set_param(*curr_param); | |
2599 | value_used[val_idx]=true; | |
2600 | } | |
2601 | } | |
2602 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2603 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
2604 | if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) { | |
2605 | transfer__syntax().set_param(*curr_param); | |
2606 | value_used[val_idx]=true; | |
2607 | } | |
2608 | } | |
2609 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
2610 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
2611 | break; | |
2612 | } | |
2613 | } break; | |
2614 | default: | |
2615 | param.type_error("record template", "EMBEDDED PDV.identification.context-negotiation"); | |
2616 | } | |
2617 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
2618 | } | |
2619 | ||
2620 | Module_Param* EMBEDDED_PDV_identification_context__negotiation_template::get_param(Module_Param_Name& param_name) const | |
2621 | { | |
2622 | Module_Param* mp = NULL; | |
2623 | switch (template_selection) { | |
2624 | case UNINITIALIZED_TEMPLATE: | |
2625 | mp = new Module_Param_Unbound(); | |
2626 | break; | |
2627 | case OMIT_VALUE: | |
2628 | mp = new Module_Param_Omit(); | |
2629 | break; | |
2630 | case ANY_VALUE: | |
2631 | mp = new Module_Param_Any(); | |
2632 | break; | |
2633 | case ANY_OR_OMIT: | |
2634 | mp = new Module_Param_AnyOrNone(); | |
2635 | break; | |
2636 | case SPECIFIC_VALUE: { | |
2637 | Module_Param* mp_field_presentation_context_id = single_value->field_presentation__context__id.get_param(param_name); | |
2638 | mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
2639 | Module_Param* mp_field_transfer_syntax = single_value->field_transfer__syntax.get_param(param_name); | |
2640 | mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
2641 | mp = new Module_Param_Assignment_List(); | |
2642 | mp->add_elem(mp_field_presentation_context_id); | |
2643 | mp->add_elem(mp_field_transfer_syntax); | |
2644 | break; } | |
2645 | case VALUE_LIST: | |
2646 | case COMPLEMENTED_LIST: { | |
2647 | if (template_selection == VALUE_LIST) { | |
2648 | mp = new Module_Param_List_Template(); | |
2649 | } | |
2650 | else { | |
2651 | mp = new Module_Param_ComplementList_Template(); | |
2652 | } | |
2653 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
2654 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
2655 | } | |
2656 | break; } | |
2657 | default: | |
2658 | break; | |
2659 | } | |
2660 | if (is_ifpresent) { | |
2661 | mp->set_ifpresent(); | |
2662 | } | |
2663 | return mp; | |
2664 | } | |
2665 | ||
970ed795 EL |
2666 | void EMBEDDED_PDV_identification_context__negotiation_template::clean_up() |
2667 | { | |
2668 | switch (template_selection) { | |
2669 | case SPECIFIC_VALUE: | |
2670 | delete single_value; | |
2671 | break; | |
2672 | case VALUE_LIST: | |
2673 | case COMPLEMENTED_LIST: | |
2674 | delete [] value_list.list_value; | |
2675 | break; | |
2676 | default: | |
2677 | break; | |
2678 | } | |
2679 | template_selection = UNINITIALIZED_TEMPLATE; | |
2680 | } | |
2681 | ||
2682 | void EMBEDDED_PDV_identification_context__negotiation_template::set_specific() | |
2683 | { | |
2684 | if (template_selection != SPECIFIC_VALUE) { | |
2685 | template_sel old_selection = template_selection; | |
2686 | clean_up(); | |
2687 | single_value = new single_value_struct; | |
2688 | set_selection(SPECIFIC_VALUE); | |
2689 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
2690 | single_value->field_presentation__context__id = ANY_VALUE; | |
2691 | single_value->field_transfer__syntax = ANY_VALUE; | |
2692 | } | |
2693 | } | |
2694 | } | |
2695 | ||
2696 | void EMBEDDED_PDV_identification_context__negotiation_template::copy_value(const EMBEDDED_PDV_identification_context__negotiation& other_value) | |
2697 | { | |
2698 | single_value = new single_value_struct; | |
2699 | single_value->field_presentation__context__id = other_value.presentation__context__id(); | |
2700 | single_value->field_transfer__syntax = other_value.transfer__syntax(); | |
2701 | set_selection(SPECIFIC_VALUE); | |
2702 | } | |
2703 | ||
2704 | void EMBEDDED_PDV_identification_context__negotiation_template::copy_template(const EMBEDDED_PDV_identification_context__negotiation_template& other_value) | |
2705 | { | |
2706 | switch (other_value.template_selection) { | |
2707 | case SPECIFIC_VALUE: | |
2708 | single_value = new single_value_struct(*other_value.single_value); | |
2709 | break; | |
2710 | case OMIT_VALUE: | |
2711 | case ANY_VALUE: | |
2712 | case ANY_OR_OMIT: | |
2713 | break; | |
2714 | case VALUE_LIST: | |
2715 | case COMPLEMENTED_LIST: | |
2716 | value_list.n_values = other_value.value_list.n_values; | |
2717 | value_list.list_value = new EMBEDDED_PDV_identification_context__negotiation_template[value_list.n_values]; | |
2718 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2719 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
2720 | break; | |
2721 | default: | |
2722 | TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation."); | |
2723 | } | |
2724 | set_selection(other_value); | |
2725 | } | |
2726 | ||
2727 | EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template() | |
2728 | { | |
2729 | } | |
2730 | ||
2731 | EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(template_sel other_value) | |
2732 | : Base_Template(other_value) | |
2733 | { | |
2734 | check_single_selection(other_value); | |
2735 | } | |
2736 | ||
2737 | EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const EMBEDDED_PDV_identification_context__negotiation& other_value) | |
2738 | { | |
2739 | copy_value(other_value); | |
2740 | } | |
2741 | ||
2742 | EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const OPTIONAL<EMBEDDED_PDV_identification_context__negotiation>& other_value) | |
2743 | { | |
2744 | switch (other_value.get_selection()) { | |
2745 | case OPTIONAL_PRESENT: | |
2746 | copy_value((const EMBEDDED_PDV_identification_context__negotiation&)other_value); | |
2747 | break; | |
2748 | case OPTIONAL_OMIT: | |
2749 | set_selection(OMIT_VALUE); | |
2750 | break; | |
2751 | default: | |
2752 | TTCN_error("Creating a template of type EMBEDDED PDV.identification.context-negotiation from an unbound optional field."); | |
2753 | } | |
2754 | } | |
2755 | ||
2756 | EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const EMBEDDED_PDV_identification_context__negotiation_template& other_value) | |
2757 | : Base_Template() | |
2758 | { | |
2759 | copy_template(other_value); | |
2760 | } | |
2761 | ||
2762 | EMBEDDED_PDV_identification_context__negotiation_template::~EMBEDDED_PDV_identification_context__negotiation_template() | |
2763 | { | |
2764 | clean_up(); | |
2765 | } | |
2766 | ||
2767 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_context__negotiation_template::operator=(template_sel other_value) | |
2768 | { | |
2769 | check_single_selection(other_value); | |
2770 | clean_up(); | |
2771 | set_selection(other_value); | |
2772 | return *this; | |
2773 | } | |
2774 | ||
2775 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const EMBEDDED_PDV_identification_context__negotiation& other_value) | |
2776 | { | |
2777 | clean_up(); | |
2778 | copy_value(other_value); | |
2779 | return *this; | |
2780 | } | |
2781 | ||
2782 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const OPTIONAL<EMBEDDED_PDV_identification_context__negotiation>& other_value) | |
2783 | { | |
2784 | clean_up(); | |
2785 | switch (other_value.get_selection()) { | |
2786 | case OPTIONAL_PRESENT: | |
2787 | copy_value((const EMBEDDED_PDV_identification_context__negotiation&)other_value); | |
2788 | break; | |
2789 | case OPTIONAL_OMIT: | |
2790 | set_selection(OMIT_VALUE); | |
2791 | break; | |
2792 | default: | |
2793 | TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV.identification.context-negotiation."); | |
2794 | } | |
2795 | return *this; | |
2796 | } | |
2797 | ||
2798 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const EMBEDDED_PDV_identification_context__negotiation_template& other_value) | |
2799 | { | |
2800 | if (&other_value != this) { | |
2801 | clean_up(); | |
2802 | copy_template(other_value); | |
2803 | } | |
2804 | return *this; | |
2805 | } | |
2806 | ||
3abe9331 | 2807 | boolean EMBEDDED_PDV_identification_context__negotiation_template::match(const EMBEDDED_PDV_identification_context__negotiation& other_value, |
2808 | boolean /* legacy */) const | |
970ed795 EL |
2809 | { |
2810 | switch (template_selection) { | |
2811 | case ANY_VALUE: | |
2812 | case ANY_OR_OMIT: | |
2813 | return TRUE; | |
2814 | case OMIT_VALUE: | |
2815 | return FALSE; | |
2816 | case SPECIFIC_VALUE: | |
2817 | if (!other_value.presentation__context__id().is_bound()) return FALSE; | |
2818 | if (!single_value->field_presentation__context__id.match(other_value.presentation__context__id())) return FALSE; | |
2819 | if (!other_value.transfer__syntax().is_bound()) return FALSE; | |
2820 | if (!single_value->field_transfer__syntax.match(other_value.transfer__syntax())) return FALSE; | |
2821 | return TRUE; | |
2822 | case VALUE_LIST: | |
2823 | case COMPLEMENTED_LIST: | |
2824 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2825 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
2826 | return template_selection == COMPLEMENTED_LIST; | |
2827 | default: | |
2828 | TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation."); | |
2829 | } | |
2830 | return FALSE; | |
2831 | } | |
2832 | ||
2833 | EMBEDDED_PDV_identification_context__negotiation EMBEDDED_PDV_identification_context__negotiation_template::valueof() const | |
2834 | { | |
2835 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
2836 | TTCN_error("Performing valueof or send operation on a non-specific template of type EMBEDDED PDV.identification.context-negotiation."); | |
2837 | EMBEDDED_PDV_identification_context__negotiation ret_val; | |
2838 | ret_val.presentation__context__id() = single_value->field_presentation__context__id.valueof(); | |
2839 | ret_val.transfer__syntax() = single_value->field_transfer__syntax.valueof(); | |
2840 | return ret_val; | |
2841 | } | |
2842 | ||
2843 | void EMBEDDED_PDV_identification_context__negotiation_template::set_type(template_sel template_type, unsigned int list_length) | |
2844 | { | |
2845 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
2846 | TTCN_error("Setting an invalid list for a template of type EMBEDDED PDV.identification.context-negotiation."); | |
2847 | clean_up(); | |
2848 | set_selection(template_type); | |
2849 | value_list.n_values = list_length; | |
2850 | value_list.list_value = new EMBEDDED_PDV_identification_context__negotiation_template[list_length]; | |
2851 | } | |
2852 | ||
2853 | EMBEDDED_PDV_identification_context__negotiation_template& EMBEDDED_PDV_identification_context__negotiation_template::list_item(unsigned int list_index) const | |
2854 | { | |
2855 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
2856 | TTCN_error("Accessing a list element of a non-list template of type EMBEDDED PDV.identification.context-negotiation."); | |
2857 | if (list_index >= value_list.n_values) | |
2858 | TTCN_error("Index overflow in a value list template of type EMBEDDED PDV.identification.context-negotiation."); | |
2859 | return value_list.list_value[list_index]; | |
2860 | } | |
2861 | ||
2862 | INTEGER_template& EMBEDDED_PDV_identification_context__negotiation_template::presentation__context__id() | |
2863 | { | |
2864 | set_specific(); | |
2865 | return single_value->field_presentation__context__id; | |
2866 | } | |
2867 | ||
2868 | const INTEGER_template& EMBEDDED_PDV_identification_context__negotiation_template::presentation__context__id() const | |
2869 | { | |
2870 | if (template_selection != SPECIFIC_VALUE) | |
2871 | TTCN_error("Accessing field presentation_context_id of a non-specific template of type EMBEDDED PDV.identification.context-negotiation."); | |
2872 | return single_value->field_presentation__context__id; | |
2873 | } | |
2874 | ||
2875 | OBJID_template& EMBEDDED_PDV_identification_context__negotiation_template::transfer__syntax() | |
2876 | { | |
2877 | set_specific(); | |
2878 | return single_value->field_transfer__syntax; | |
2879 | } | |
2880 | ||
2881 | const OBJID_template& EMBEDDED_PDV_identification_context__negotiation_template::transfer__syntax() const | |
2882 | { | |
2883 | if (template_selection != SPECIFIC_VALUE) | |
2884 | TTCN_error("Accessing field transfer_syntax of a non-specific template of type EMBEDDED PDV.identification.context-negotiation."); | |
2885 | return single_value->field_transfer__syntax; | |
2886 | } | |
2887 | ||
2888 | int EMBEDDED_PDV_identification_context__negotiation_template::size_of() const | |
2889 | { | |
2890 | switch (template_selection) | |
2891 | { | |
2892 | case SPECIFIC_VALUE: | |
2893 | { | |
2894 | int ret_val = 2; | |
2895 | return ret_val; | |
2896 | } | |
2897 | case VALUE_LIST: | |
2898 | { | |
2899 | if (value_list.n_values<1) | |
2900 | TTCN_error("Internal error: Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing an empty list."); | |
2901 | int item_size = value_list.list_value[0].size_of(); | |
2902 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
2903 | { | |
2904 | if (value_list.list_value[i].size_of()!=item_size) | |
2905 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing a value list with different sizes."); | |
2906 | } | |
2907 | return item_size; | |
2908 | } | |
2909 | case OMIT_VALUE: | |
2910 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing omit value."); | |
2911 | case ANY_VALUE: | |
2912 | case ANY_OR_OMIT: | |
2913 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing */? value."); | |
2914 | case COMPLEMENTED_LIST: | |
2915 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing complemented list."); | |
2916 | default: | |
2917 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation."); | |
2918 | } | |
2919 | return 0; | |
2920 | } | |
2921 | ||
2922 | void EMBEDDED_PDV_identification_context__negotiation_template::log() const | |
2923 | { | |
2924 | switch (template_selection) { | |
2925 | case SPECIFIC_VALUE: | |
2926 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2927 | single_value->field_presentation__context__id.log(); | |
2928 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2929 | single_value->field_transfer__syntax.log(); | |
2930 | TTCN_Logger::log_event_str(" }"); | |
2931 | break; | |
2932 | case COMPLEMENTED_LIST: | |
2933 | TTCN_Logger::log_event_str("complement "); | |
2934 | // no break | |
2935 | case VALUE_LIST: | |
2936 | TTCN_Logger::log_char('('); | |
2937 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
2938 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
2939 | value_list.list_value[list_count].log(); | |
2940 | } | |
2941 | TTCN_Logger::log_char(')'); | |
2942 | break; | |
2943 | default: | |
2944 | log_generic(); | |
2945 | break; | |
2946 | } | |
2947 | log_ifpresent(); | |
2948 | } | |
2949 | ||
3abe9331 | 2950 | void EMBEDDED_PDV_identification_context__negotiation_template::log_match(const EMBEDDED_PDV_identification_context__negotiation& match_value, |
2951 | boolean /* legacy */) const | |
970ed795 EL |
2952 | { |
2953 | if (template_selection == SPECIFIC_VALUE) { | |
2954 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2955 | single_value->field_presentation__context__id.log_match(match_value.presentation__context__id()); | |
2956 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2957 | single_value->field_transfer__syntax.log_match(match_value.transfer__syntax()); | |
2958 | TTCN_Logger::log_event_str(" }"); | |
2959 | } else { | |
2960 | match_value.log(); | |
2961 | TTCN_Logger::log_event_str(" with "); | |
2962 | log(); | |
2963 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2964 | else TTCN_Logger::log_event_str(" unmatched"); | |
2965 | } | |
2966 | } | |
2967 | ||
2968 | void EMBEDDED_PDV_identification_context__negotiation_template::encode_text(Text_Buf& text_buf) const | |
2969 | { | |
2970 | encode_text_base(text_buf); | |
2971 | switch (template_selection) { | |
2972 | case SPECIFIC_VALUE: | |
2973 | single_value->field_presentation__context__id.encode_text(text_buf); | |
2974 | single_value->field_transfer__syntax.encode_text(text_buf); | |
2975 | break; | |
2976 | case OMIT_VALUE: | |
2977 | case ANY_VALUE: | |
2978 | case ANY_OR_OMIT: | |
2979 | break; | |
2980 | case VALUE_LIST: | |
2981 | case COMPLEMENTED_LIST: | |
2982 | text_buf.push_int(value_list.n_values); | |
2983 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2984 | value_list.list_value[list_count].encode_text(text_buf); | |
2985 | break; | |
2986 | default: | |
2987 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation."); | |
2988 | } | |
2989 | } | |
2990 | ||
2991 | void EMBEDDED_PDV_identification_context__negotiation_template::decode_text(Text_Buf& text_buf) | |
2992 | { | |
2993 | clean_up(); | |
2994 | decode_text_base(text_buf); | |
2995 | switch (template_selection) { | |
2996 | case SPECIFIC_VALUE: | |
2997 | single_value = new single_value_struct; | |
2998 | single_value->field_presentation__context__id.decode_text(text_buf); | |
2999 | single_value->field_transfer__syntax.decode_text(text_buf); | |
3000 | break; | |
3001 | case OMIT_VALUE: | |
3002 | case ANY_VALUE: | |
3003 | case ANY_OR_OMIT: | |
3004 | break; | |
3005 | case VALUE_LIST: | |
3006 | case COMPLEMENTED_LIST: | |
3007 | value_list.n_values = text_buf.pull_int().get_val(); | |
3008 | value_list.list_value = new EMBEDDED_PDV_identification_context__negotiation_template[value_list.n_values]; | |
3009 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3010 | value_list.list_value[list_count].decode_text(text_buf); | |
3011 | break; | |
3012 | default: | |
3013 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV.identification.context-negotiation."); | |
3014 | } | |
3015 | } | |
3016 | ||
3abe9331 | 3017 | boolean EMBEDDED_PDV_identification_context__negotiation_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
3018 | { |
3019 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 3020 | return !match_omit(legacy); |
970ed795 EL |
3021 | } |
3022 | ||
3abe9331 | 3023 | boolean EMBEDDED_PDV_identification_context__negotiation_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
3024 | { |
3025 | if (is_ifpresent) return TRUE; | |
3026 | switch (template_selection) { | |
3027 | case OMIT_VALUE: | |
3028 | case ANY_OR_OMIT: | |
3029 | return TRUE; | |
3030 | case VALUE_LIST: | |
3031 | case COMPLEMENTED_LIST: | |
3abe9331 | 3032 | if (legacy) { |
3033 | for (unsigned int i=0; i<value_list.n_values; i++) | |
3034 | if (value_list.list_value[i].match_omit()) | |
3035 | return template_selection==VALUE_LIST; | |
3036 | return template_selection==COMPLEMENTED_LIST; | |
3037 | } // else fall through | |
970ed795 EL |
3038 | default: |
3039 | return FALSE; | |
3040 | } | |
3041 | return FALSE; | |
3042 | } | |
3043 | ||
3044 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3045 | void EMBEDDED_PDV_identification_context__negotiation_template::check_restriction(template_res t_res, const char* t_name, |
3046 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3047 | { |
3048 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3049 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3050 | case TR_VALUE: | |
3051 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3052 | break; | |
3053 | case TR_OMIT: | |
3054 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3055 | template_selection==SPECIFIC_VALUE)) return; | |
3056 | break; | |
3057 | case TR_PRESENT: | |
3abe9331 | 3058 | if (!match_omit(legacy)) return; |
970ed795 EL |
3059 | break; |
3060 | default: | |
3061 | return; | |
3062 | } | |
3063 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
3064 | get_res_name(t_res), t_name ? t_name : "EMBEDDED PDV.identification.context-negotiation"); | |
3065 | } | |
3066 | #endif | |
3067 | ||
3068 | EMBEDDED_PDV::EMBEDDED_PDV() | |
3069 | { | |
3070 | } | |
3071 | ||
3072 | EMBEDDED_PDV::EMBEDDED_PDV(const EMBEDDED_PDV_identification& par_identification, | |
3073 | const OPTIONAL<UNIVERSAL_CHARSTRING>& par_data__value__descriptor, | |
3074 | const OCTETSTRING& par_data__value) | |
3075 | : field_identification(par_identification), | |
3076 | field_data__value__descriptor(par_data__value__descriptor), | |
3077 | field_data__value(par_data__value) | |
3078 | { | |
3079 | } | |
3080 | ||
3081 | boolean EMBEDDED_PDV::operator==(const EMBEDDED_PDV& other_value) const | |
3082 | { | |
3083 | return field_identification==other_value.field_identification | |
3084 | && field_data__value__descriptor==other_value.field_data__value__descriptor | |
3085 | && field_data__value==other_value.field_data__value; | |
3086 | } | |
3087 | ||
3088 | int EMBEDDED_PDV::size_of() const | |
3089 | { | |
3090 | int ret_val = 2; | |
3091 | if (field_data__value__descriptor.ispresent()) ret_val++; | |
3092 | return ret_val; | |
3093 | } | |
3094 | ||
3095 | void EMBEDDED_PDV::log() const | |
3096 | { | |
3097 | TTCN_Logger::log_event_str("{ identification := "); | |
3098 | field_identification.log(); | |
3099 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3100 | field_data__value__descriptor.log(); | |
3101 | TTCN_Logger::log_event_str(", data_value := "); | |
3102 | field_data__value.log(); | |
3103 | TTCN_Logger::log_event_str(" }"); | |
3104 | } | |
3105 | ||
3106 | boolean EMBEDDED_PDV::is_bound() const | |
3107 | { | |
3108 | if(field_identification.is_bound()) return TRUE; | |
3109 | if(OPTIONAL_OMIT == field_data__value__descriptor.get_selection() || field_data__value__descriptor.is_bound()) return TRUE; | |
3110 | if(field_data__value.is_bound()) return TRUE; | |
3111 | return FALSE; | |
3112 | } | |
3113 | ||
3114 | boolean EMBEDDED_PDV::is_value() const | |
3115 | { | |
3116 | if(!field_identification.is_value()) return FALSE; | |
3117 | if(OPTIONAL_OMIT != field_data__value__descriptor.get_selection() && !field_data__value__descriptor.is_value()) return FALSE; | |
3118 | if(!field_data__value.is_value()) return FALSE; | |
3119 | return TRUE; | |
3120 | } | |
3121 | ||
3122 | void EMBEDDED_PDV::clean_up() | |
3123 | { | |
3124 | field_identification.clean_up(); | |
3125 | field_data__value__descriptor.clean_up(); | |
3126 | field_data__value.clean_up(); | |
3127 | } | |
3128 | ||
3129 | void EMBEDDED_PDV::set_param(Module_Param& param) | |
3130 | { | |
3131 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 3132 | Module_Param_Ptr mp = ¶m; |
3133 | if (param.get_type() == Module_Param::MP_Reference) { | |
3134 | mp = param.get_referenced_param(); | |
3135 | } | |
3136 | switch (mp->get_type()) { | |
970ed795 | 3137 | case Module_Param::MP_Value_List: |
3abe9331 | 3138 | if (mp->get_size()==0) return; |
3139 | if (3!=mp->get_size()) { | |
3140 | param.error("record value of type EMBEDDED PDV has 3 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 3141 | } |
3abe9331 | 3142 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0)); |
3143 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1)); | |
3144 | if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*mp->get_elem(2)); | |
970ed795 EL |
3145 | break; |
3146 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 3147 | Vector<bool> value_used(mp->get_size()); |
3148 | value_used.resize(mp->get_size(), false); | |
3149 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3150 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3151 | if (!strcmp(curr_param->get_id()->get_name(), "identification")) { |
3152 | identification().set_param(*curr_param); | |
3153 | value_used[val_idx]=true; | |
3154 | } | |
3155 | } | |
3abe9331 | 3156 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
3157 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3158 | if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) { |
3159 | data__value__descriptor().set_param(*curr_param); | |
3160 | value_used[val_idx]=true; | |
3161 | } | |
3162 | } | |
3abe9331 | 3163 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
3164 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3165 | if (!strcmp(curr_param->get_id()->get_name(), "data_value")) { |
3166 | data__value().set_param(*curr_param); | |
3167 | value_used[val_idx]=true; | |
3168 | } | |
3169 | } | |
3abe9331 | 3170 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
3171 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
3172 | break; |
3173 | } | |
3174 | } break; | |
3175 | default: | |
3176 | param.type_error("record value", "EMBEDDED PDV"); | |
3177 | } | |
3178 | } | |
3179 | ||
3abe9331 | 3180 | Module_Param* EMBEDDED_PDV::get_param(Module_Param_Name& param_name) const |
970ed795 | 3181 | { |
3abe9331 | 3182 | if (!is_bound()) { |
3183 | return new Module_Param_Unbound(); | |
970ed795 | 3184 | } |
3abe9331 | 3185 | Module_Param* mp_field_identification = field_identification.get_param(param_name); |
3186 | mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification"))); | |
3187 | Module_Param* mp_field_data_value_descriptor = field_data__value__descriptor.get_param(param_name); | |
3188 | mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor"))); | |
3189 | Module_Param* mp_field_data_value = field_data__value.get_param(param_name); | |
3190 | mp_field_data_value->set_id(new Module_Param_FieldName(mcopystr("data_value"))); | |
3191 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
3192 | mp->add_elem(mp_field_identification); | |
3193 | mp->add_elem(mp_field_data_value_descriptor); | |
3194 | mp->add_elem(mp_field_data_value); | |
3195 | return mp; | |
970ed795 EL |
3196 | } |
3197 | ||
3198 | void EMBEDDED_PDV::encode_text(Text_Buf& text_buf) const | |
3199 | { | |
3200 | field_identification.encode_text(text_buf); | |
3201 | field_data__value__descriptor.encode_text(text_buf); | |
3202 | field_data__value.encode_text(text_buf); | |
3203 | } | |
3204 | ||
3205 | void EMBEDDED_PDV::decode_text(Text_Buf& text_buf) | |
3206 | { | |
3207 | field_identification.decode_text(text_buf); | |
3208 | field_data__value__descriptor.decode_text(text_buf); | |
3209 | field_data__value.decode_text(text_buf); | |
3210 | } | |
3211 | ||
3212 | void EMBEDDED_PDV::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
3213 | { | |
3214 | va_list pvar; | |
3215 | va_start(pvar, p_coding); | |
3216 | switch(p_coding) { | |
3217 | case TTCN_EncDec::CT_BER: { | |
3218 | TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name); | |
3219 | unsigned BER_coding=va_arg(pvar, unsigned); | |
3220 | BER_encode_chk_coding(BER_coding); | |
3221 | ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding); | |
3222 | tlv->put_in_buffer(p_buf); | |
3223 | ASN_BER_TLV_t::destruct(tlv); | |
3224 | break;} | |
3225 | case TTCN_EncDec::CT_RAW: { | |
3226 | TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name); | |
3227 | TTCN_EncDec_ErrorContext::error_internal | |
3228 | ("No RAW descriptor available for type '%s'.", p_td.name); | |
3229 | break;} | |
3230 | case TTCN_EncDec::CT_TEXT: { | |
3231 | TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name); | |
3232 | TTCN_EncDec_ErrorContext::error_internal | |
3233 | ("No TEXT descriptor available for type '%s'.", p_td.name); | |
3234 | break;} | |
3235 | case TTCN_EncDec::CT_XER: { | |
3236 | TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name); | |
3237 | unsigned XER_coding=va_arg(pvar, unsigned); | |
af710487 | 3238 | XER_encode(*p_td.xer,p_buf, XER_coding, 0, 0); |
970ed795 EL |
3239 | break;} |
3240 | case TTCN_EncDec::CT_JSON: { | |
3241 | TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name); | |
3242 | TTCN_EncDec_ErrorContext::error_internal | |
3243 | ("No JSON descriptor available for type '%s'.", p_td.name); | |
3244 | break;} | |
3245 | default: | |
3246 | TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name); | |
3247 | } | |
3248 | va_end(pvar); | |
3249 | } | |
3250 | ||
3251 | void EMBEDDED_PDV::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
3252 | { | |
3253 | va_list pvar; | |
3254 | va_start(pvar, p_coding); | |
3255 | switch(p_coding) { | |
3256 | case TTCN_EncDec::CT_BER: { | |
3257 | TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name); | |
3258 | unsigned L_form=va_arg(pvar, unsigned); | |
3259 | ASN_BER_TLV_t tlv; | |
3260 | BER_decode_str2TLV(p_buf, tlv, L_form); | |
3261 | BER_decode_TLV(p_td, tlv, L_form); | |
3262 | if(tlv.isComplete) p_buf.increase_pos(tlv.get_len()); | |
3263 | break;} | |
3264 | case TTCN_EncDec::CT_RAW: { | |
3265 | TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name); | |
3266 | TTCN_EncDec_ErrorContext::error_internal | |
3267 | ("No RAW descriptor available for type '%s'.", p_td.name); | |
3268 | break;} | |
3269 | case TTCN_EncDec::CT_TEXT: { | |
3270 | TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name); | |
3271 | TTCN_EncDec_ErrorContext::error_internal | |
3272 | ("No TEXT descriptor available for type '%s'.", p_td.name); | |
3273 | break;} | |
3274 | case TTCN_EncDec::CT_XER: { | |
3275 | TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name); | |
3276 | unsigned XER_coding=va_arg(pvar, unsigned); | |
3277 | XmlReaderWrap reader(p_buf); | |
3278 | int success = reader.Read(); | |
3279 | for (; success==1; success=reader.Read()) { | |
3280 | int type = reader.NodeType(); | |
3281 | if (type==XML_READER_TYPE_ELEMENT) | |
3282 | break; | |
3283 | } | |
feade998 | 3284 | XER_decode(*p_td.xer, reader, XER_coding, XER_NONE, 0); |
970ed795 EL |
3285 | size_t bytes = reader.ByteConsumed(); |
3286 | p_buf.set_pos(bytes); | |
3287 | break;} | |
3288 | case TTCN_EncDec::CT_JSON: { | |
3289 | TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name); | |
3290 | TTCN_EncDec_ErrorContext::error_internal | |
3291 | ("No JSON descriptor available for type '%s'.", p_td.name); | |
3292 | break;} | |
3293 | default: | |
3294 | TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name); | |
3295 | } | |
3296 | va_end(pvar); | |
3297 | } | |
3298 | ||
3299 | ASN_BER_TLV_t* EMBEDDED_PDV::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
3300 | { | |
3301 | BER_chk_descr(p_td); | |
3302 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
3303 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
3304 | TTCN_EncDec_ErrorContext ec_1; | |
3305 | ec_1.set_msg("identification': "); | |
3306 | new_tlv->add_TLV(field_identification.BER_encode_TLV(EMBEDDED_PDV_identification_descr_, p_coding)); | |
3307 | ec_1.set_msg("data_value_descriptor': "); | |
3308 | new_tlv->add_TLV(field_data__value__descriptor.BER_encode_TLV(EMBEDDED_PDV_data__value__descriptor_descr_, p_coding)); | |
3309 | ec_1.set_msg("data_value': "); | |
3310 | new_tlv->add_TLV(field_data__value.BER_encode_TLV(EMBEDDED_PDV_data__value_descr_, p_coding)); | |
3311 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
3312 | return new_tlv; | |
3313 | } | |
3314 | ||
3315 | boolean EMBEDDED_PDV::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
3316 | { | |
3317 | BER_chk_descr(p_td); | |
3318 | ASN_BER_TLV_t stripped_tlv; | |
3319 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
3320 | TTCN_EncDec_ErrorContext ec_0("While decoding 'EMBEDDED PDV' type: "); | |
3321 | stripped_tlv.chk_constructed_flag(TRUE); | |
3322 | size_t V_pos=0; | |
3323 | ASN_BER_TLV_t tmp_tlv; | |
3324 | boolean tlv_present=FALSE; | |
3325 | { | |
3326 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
3327 | TTCN_EncDec_ErrorContext ec_2; | |
3328 | ec_2.set_msg("identification': "); | |
3329 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3330 | if(!tlv_present) return FALSE; | |
3331 | field_identification.BER_decode_TLV(EMBEDDED_PDV_identification_descr_, tmp_tlv, L_form); | |
3332 | tlv_present=FALSE; | |
3333 | ec_2.set_msg("data_value_descriptor': "); | |
3334 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3335 | if(!tlv_present) field_data__value__descriptor=OMIT_VALUE; | |
3336 | else { | |
3337 | field_data__value__descriptor.BER_decode_TLV(EMBEDDED_PDV_data__value__descriptor_descr_, tmp_tlv, L_form); | |
3338 | if(field_data__value__descriptor.ispresent()) tlv_present=FALSE; | |
3339 | } | |
3340 | ec_2.set_msg("data_value': "); | |
3341 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3342 | if(!tlv_present) return FALSE; | |
3343 | field_data__value.BER_decode_TLV(EMBEDDED_PDV_data__value_descr_, tmp_tlv, L_form); | |
3344 | tlv_present=FALSE; | |
3345 | } | |
3346 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
3347 | return TRUE; | |
3348 | } | |
3349 | ||
3350 | int EMBEDDED_PDV::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 3351 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const { |
970ed795 EL |
3352 | if(!is_bound()) { |
3353 | TTCN_EncDec_ErrorContext::error | |
3354 | (TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); | |
3355 | } | |
3356 | int indenting = !is_canonical(flavor); | |
3357 | int exer = is_exer(flavor); | |
3358 | int encoded_length=(int)p_buf.get_len(); | |
3359 | if (indenting) do_indent(p_buf, indent); | |
3360 | p_buf.put_c('<'); | |
3361 | if (exer) write_ns_prefix(p_td, p_buf); | |
3362 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
3363 | flavor &= XER_MASK; | |
3364 | ++indent; | |
af710487 | 3365 | field_identification .XER_encode(EMBEDDED_PDV_identification_xer_ , p_buf, flavor, indent, 0); |
970ed795 EL |
3366 | if (field_data__value__descriptor.is_value()) { |
3367 | TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG, | |
3368 | "data-value-descriptor not allowed for EMBEDDED PDV"); | |
3369 | } | |
af710487 | 3370 | field_data__value__descriptor.XER_encode(EMBEDDED_PDV_data_value_descriptor_xer_, p_buf, flavor, indent, 0); |
3371 | field_data__value .XER_encode(EMBEDDED_PDV_data_value_xer_ , p_buf, flavor, indent, 0); | |
970ed795 EL |
3372 | |
3373 | if (indenting) do_indent(p_buf, --indent); | |
3374 | p_buf.put_c('<'); | |
3375 | p_buf.put_c('/'); | |
3376 | if (exer) write_ns_prefix(p_td, p_buf); | |
3377 | p_buf.put_s((size_t)p_td.namelens[exer] - 1 + indenting, (const unsigned char*)p_td.names[exer]); | |
3378 | return (int)p_buf.get_len() - encoded_length; | |
3379 | } | |
3380 | ||
feade998 | 3381 | int EMBEDDED_PDV::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
3382 | { |
3383 | int exer = is_exer(flavor); | |
3384 | int depth = 1, type, success; | |
3385 | for (success = reader.Ok(); success == 1; success = reader.Read()) { | |
3386 | type = reader.NodeType(); | |
3387 | if (type==XML_READER_TYPE_ELEMENT) { | |
3388 | verify_name(reader, p_td, exer); | |
3389 | depth = reader.Depth(); | |
3390 | reader.Read(); | |
3391 | break; | |
3392 | } | |
3393 | } | |
feade998 | 3394 | field_identification .XER_decode(EMBEDDED_PDV_identification_xer_ , reader, flavor, flavor2, 0); |
3395 | field_data__value__descriptor.XER_decode(EMBEDDED_PDV_data_value_descriptor_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
3396 | if (field_data__value__descriptor.is_value()) { |
3397 | TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG, | |
3398 | "data-value-descriptor not allowed for EMBEDDED PDV"); | |
3399 | } | |
feade998 | 3400 | field_data__value .XER_decode(EMBEDDED_PDV_data_value_xer_ , reader, flavor, flavor2, 0); |
970ed795 EL |
3401 | for (success = reader.Read(); success == 1; success = reader.Read()) { |
3402 | type = reader.NodeType(); | |
3403 | if (XML_READER_TYPE_END_ELEMENT == type) { | |
3404 | verify_end(reader, p_td, depth, exer); | |
3405 | reader.Read(); | |
3406 | break; | |
3407 | } | |
3408 | } | |
3409 | return 1; | |
3410 | } | |
3411 | ||
3412 | struct EMBEDDED_PDV_template::single_value_struct { | |
3413 | EMBEDDED_PDV_identification_template field_identification; | |
3414 | UNIVERSAL_CHARSTRING_template field_data__value__descriptor; | |
3415 | OCTETSTRING_template field_data__value; | |
3416 | }; | |
3417 | ||
3abe9331 | 3418 | void EMBEDDED_PDV_template::set_param(Module_Param& param) |
3419 | { | |
3420 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
3421 | Module_Param_Ptr mp = ¶m; | |
3422 | if (param.get_type() == Module_Param::MP_Reference) { | |
3423 | mp = param.get_referenced_param(); | |
3424 | } | |
3425 | switch (mp->get_type()) { | |
3426 | case Module_Param::MP_Omit: | |
3427 | *this = OMIT_VALUE; | |
3428 | break; | |
3429 | case Module_Param::MP_Any: | |
3430 | *this = ANY_VALUE; | |
3431 | break; | |
3432 | case Module_Param::MP_AnyOrNone: | |
3433 | *this = ANY_OR_OMIT; | |
3434 | break; | |
3435 | case Module_Param::MP_List_Template: | |
3436 | case Module_Param::MP_ComplementList_Template: { | |
3437 | EMBEDDED_PDV_template temp; | |
3438 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
3439 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
3440 | for (size_t i=0; i<mp->get_size(); i++) { | |
3441 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
3442 | } | |
3443 | *this = temp; | |
3444 | break; } | |
3445 | case Module_Param::MP_Value_List: | |
3446 | if (mp->get_size()==0) break; | |
3447 | if (3!=mp->get_size()) { | |
3448 | param.error("record template of type EMBEDDED PDV has 3 fields but list value has %d fields", (int)mp->get_size()); | |
3449 | } | |
3450 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0)); | |
3451 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1)); | |
3452 | if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*mp->get_elem(2)); | |
3453 | break; | |
3454 | case Module_Param::MP_Assignment_List: { | |
3455 | Vector<bool> value_used(mp->get_size()); | |
3456 | value_used.resize(mp->get_size(), false); | |
3457 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3458 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3459 | if (!strcmp(curr_param->get_id()->get_name(), "identification")) { | |
3460 | identification().set_param(*curr_param); | |
3461 | value_used[val_idx]=true; | |
3462 | } | |
3463 | } | |
3464 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3465 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3466 | if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) { | |
3467 | data__value__descriptor().set_param(*curr_param); | |
3468 | value_used[val_idx]=true; | |
3469 | } | |
3470 | } | |
3471 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3472 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3473 | if (!strcmp(curr_param->get_id()->get_name(), "data_value")) { | |
3474 | data__value().set_param(*curr_param); | |
3475 | value_used[val_idx]=true; | |
3476 | } | |
3477 | } | |
3478 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
3479 | mp->get_elem(val_idx)->error("Non existent field name in type EMBEDDED PDV: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
3480 | break; | |
3481 | } | |
3482 | } break; | |
3483 | default: | |
3484 | param.type_error("record template", "EMBEDDED PDV"); | |
3485 | } | |
3486 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
3487 | } | |
3488 | ||
3489 | Module_Param* EMBEDDED_PDV_template::get_param(Module_Param_Name& param_name) const | |
3490 | { | |
3491 | Module_Param* mp = NULL; | |
3492 | switch (template_selection) { | |
3493 | case UNINITIALIZED_TEMPLATE: | |
3494 | mp = new Module_Param_Unbound(); | |
3495 | break; | |
3496 | case OMIT_VALUE: | |
3497 | mp = new Module_Param_Omit(); | |
3498 | break; | |
3499 | case ANY_VALUE: | |
3500 | mp = new Module_Param_Any(); | |
3501 | break; | |
3502 | case ANY_OR_OMIT: | |
3503 | mp = new Module_Param_AnyOrNone(); | |
3504 | break; | |
3505 | case SPECIFIC_VALUE: { | |
3506 | Module_Param* mp_field_identification = single_value->field_identification.get_param(param_name); | |
3507 | mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification"))); | |
3508 | Module_Param* mp_field_data_value_descriptor = single_value->field_data__value__descriptor.get_param(param_name); | |
3509 | mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor"))); | |
3510 | Module_Param* mp_field_string_value = single_value->field_data__value.get_param(param_name); | |
3511 | mp_field_string_value->set_id(new Module_Param_FieldName(mcopystr("data_value"))); | |
3512 | mp = new Module_Param_Assignment_List(); | |
3513 | mp->add_elem(mp_field_identification); | |
3514 | mp->add_elem(mp_field_data_value_descriptor); | |
3515 | mp->add_elem(mp_field_string_value); | |
3516 | break; } | |
3517 | case VALUE_LIST: | |
3518 | case COMPLEMENTED_LIST: { | |
3519 | if (template_selection == VALUE_LIST) { | |
3520 | mp = new Module_Param_List_Template(); | |
3521 | } | |
3522 | else { | |
3523 | mp = new Module_Param_ComplementList_Template(); | |
3524 | } | |
3525 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
3526 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
3527 | } | |
3528 | break; } | |
3529 | default: | |
3530 | break; | |
3531 | } | |
3532 | if (is_ifpresent) { | |
3533 | mp->set_ifpresent(); | |
3534 | } | |
3535 | return mp; | |
3536 | } | |
3537 | ||
970ed795 EL |
3538 | void EMBEDDED_PDV_template::clean_up() |
3539 | { | |
3540 | switch (template_selection) { | |
3541 | case SPECIFIC_VALUE: | |
3542 | delete single_value; | |
3543 | break; | |
3544 | case VALUE_LIST: | |
3545 | case COMPLEMENTED_LIST: | |
3546 | delete [] value_list.list_value; | |
3547 | break; | |
3548 | default: | |
3549 | break; | |
3550 | } | |
3551 | template_selection = UNINITIALIZED_TEMPLATE; | |
3552 | } | |
3553 | ||
3554 | void EMBEDDED_PDV_template::set_specific() | |
3555 | { | |
3556 | if (template_selection != SPECIFIC_VALUE) { | |
3557 | template_sel old_selection = template_selection; | |
3558 | clean_up(); | |
3559 | single_value = new single_value_struct; | |
3560 | set_selection(SPECIFIC_VALUE); | |
3561 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
3562 | single_value->field_identification = ANY_VALUE; | |
3563 | single_value->field_data__value__descriptor = ANY_OR_OMIT; | |
3564 | single_value->field_data__value = ANY_VALUE; | |
3565 | } | |
3566 | } | |
3567 | } | |
3568 | ||
3569 | void EMBEDDED_PDV_template::copy_value(const EMBEDDED_PDV& other_value) | |
3570 | { | |
3571 | single_value = new single_value_struct; | |
3572 | single_value->field_identification = other_value.identification(); | |
3573 | if (other_value.data__value__descriptor().ispresent()) single_value->field_data__value__descriptor = (const UNIVERSAL_CHARSTRING&)(other_value.data__value__descriptor()); | |
3574 | else single_value->field_data__value__descriptor = OMIT_VALUE; | |
3575 | single_value->field_data__value = other_value.data__value(); | |
3576 | set_selection(SPECIFIC_VALUE); | |
3577 | } | |
3578 | ||
3579 | void EMBEDDED_PDV_template::copy_template(const EMBEDDED_PDV_template& other_value) | |
3580 | { | |
3581 | switch (other_value.template_selection) { | |
3582 | case SPECIFIC_VALUE: | |
3583 | single_value = new single_value_struct(*other_value.single_value); | |
3584 | break; | |
3585 | case OMIT_VALUE: | |
3586 | case ANY_VALUE: | |
3587 | case ANY_OR_OMIT: | |
3588 | break; | |
3589 | case VALUE_LIST: | |
3590 | case COMPLEMENTED_LIST: | |
3591 | value_list.n_values = other_value.value_list.n_values; | |
3592 | value_list.list_value = new EMBEDDED_PDV_template[value_list.n_values]; | |
3593 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3594 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
3595 | break; | |
3596 | default: | |
3597 | TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV."); | |
3598 | } | |
3599 | set_selection(other_value); | |
3600 | } | |
3601 | ||
3602 | EMBEDDED_PDV_template::EMBEDDED_PDV_template() | |
3603 | { | |
3604 | } | |
3605 | ||
3606 | EMBEDDED_PDV_template::EMBEDDED_PDV_template(template_sel other_value) | |
3607 | : Base_Template(other_value) | |
3608 | { | |
3609 | check_single_selection(other_value); | |
3610 | } | |
3611 | ||
3612 | EMBEDDED_PDV_template::EMBEDDED_PDV_template(const EMBEDDED_PDV& other_value) | |
3613 | { | |
3614 | copy_value(other_value); | |
3615 | } | |
3616 | ||
3617 | EMBEDDED_PDV_template::EMBEDDED_PDV_template(const OPTIONAL<EMBEDDED_PDV>& other_value) | |
3618 | { | |
3619 | switch (other_value.get_selection()) { | |
3620 | case OPTIONAL_PRESENT: | |
3621 | copy_value((const EMBEDDED_PDV&)other_value); | |
3622 | break; | |
3623 | case OPTIONAL_OMIT: | |
3624 | set_selection(OMIT_VALUE); | |
3625 | break; | |
3626 | default: | |
3627 | TTCN_error("Creating a template of type EMBEDDED PDV from an unbound optional field."); | |
3628 | } | |
3629 | } | |
3630 | ||
3631 | EMBEDDED_PDV_template::EMBEDDED_PDV_template(const EMBEDDED_PDV_template& other_value) | |
3632 | : Base_Template() | |
3633 | { | |
3634 | copy_template(other_value); | |
3635 | } | |
3636 | ||
3637 | EMBEDDED_PDV_template::~EMBEDDED_PDV_template() | |
3638 | { | |
3639 | clean_up(); | |
3640 | } | |
3641 | ||
3642 | EMBEDDED_PDV_template& EMBEDDED_PDV_template::operator=(template_sel other_value) | |
3643 | { | |
3644 | check_single_selection(other_value); | |
3645 | clean_up(); | |
3646 | set_selection(other_value); | |
3647 | return *this; | |
3648 | } | |
3649 | ||
3650 | EMBEDDED_PDV_template& EMBEDDED_PDV_template::operator=(const EMBEDDED_PDV& other_value) | |
3651 | { | |
3652 | clean_up(); | |
3653 | copy_value(other_value); | |
3654 | return *this; | |
3655 | } | |
3656 | ||
3657 | EMBEDDED_PDV_template& EMBEDDED_PDV_template::operator=(const OPTIONAL<EMBEDDED_PDV>& other_value) | |
3658 | { | |
3659 | clean_up(); | |
3660 | switch (other_value.get_selection()) { | |
3661 | case OPTIONAL_PRESENT: | |
3662 | copy_value((const EMBEDDED_PDV&)other_value); | |
3663 | break; | |
3664 | case OPTIONAL_OMIT: | |
3665 | set_selection(OMIT_VALUE); | |
3666 | break; | |
3667 | default: | |
3668 | TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV."); | |
3669 | } | |
3670 | return *this; | |
3671 | } | |
3672 | ||
3673 | EMBEDDED_PDV_template& EMBEDDED_PDV_template::operator=(const EMBEDDED_PDV_template& other_value) | |
3674 | { | |
3675 | if (&other_value != this) { | |
3676 | clean_up(); | |
3677 | copy_template(other_value); | |
3678 | } | |
3679 | return *this; | |
3680 | } | |
3681 | ||
3abe9331 | 3682 | boolean EMBEDDED_PDV_template::match(const EMBEDDED_PDV& other_value, |
3683 | boolean /* legacy */) const | |
970ed795 EL |
3684 | { |
3685 | switch (template_selection) { | |
3686 | case ANY_VALUE: | |
3687 | case ANY_OR_OMIT: | |
3688 | return TRUE; | |
3689 | case OMIT_VALUE: | |
3690 | return FALSE; | |
3691 | case SPECIFIC_VALUE: | |
3692 | if (!other_value.identification().is_bound()) return FALSE; | |
3693 | if (!single_value->field_identification.match(other_value.identification())) return FALSE; | |
3694 | if (!other_value.data__value__descriptor().is_bound()) return FALSE; | |
3695 | if (other_value.data__value__descriptor().ispresent() ? !single_value->field_data__value__descriptor.match((const UNIVERSAL_CHARSTRING&)other_value.data__value__descriptor()) : !single_value->field_data__value__descriptor.match_omit()) return FALSE; | |
3696 | if (!other_value.data__value().is_bound()) return FALSE; | |
3697 | if (!single_value->field_data__value.match(other_value.data__value())) return FALSE; | |
3698 | return TRUE; | |
3699 | case VALUE_LIST: | |
3700 | case COMPLEMENTED_LIST: | |
3701 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3702 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
3703 | return template_selection == COMPLEMENTED_LIST; | |
3704 | default: | |
3705 | TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV."); | |
3706 | } | |
3707 | return FALSE; | |
3708 | } | |
3709 | ||
3710 | EMBEDDED_PDV EMBEDDED_PDV_template::valueof() const | |
3711 | { | |
3712 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
3713 | TTCN_error("Performing valueof or send operation on a non-specific template of type EMBEDDED PDV."); | |
3714 | EMBEDDED_PDV ret_val; | |
3715 | ret_val.identification() = single_value->field_identification.valueof(); | |
3716 | if (single_value->field_data__value__descriptor.is_omit()) ret_val.data__value__descriptor() = OMIT_VALUE; | |
3717 | else ret_val.data__value__descriptor() = single_value->field_data__value__descriptor.valueof(); | |
3718 | ret_val.data__value() = single_value->field_data__value.valueof(); | |
3719 | return ret_val; | |
3720 | } | |
3721 | ||
3722 | void EMBEDDED_PDV_template::set_type(template_sel template_type, unsigned int list_length) | |
3723 | { | |
3724 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
3725 | TTCN_error("Setting an invalid list for a template of type EMBEDDED PDV."); | |
3726 | clean_up(); | |
3727 | set_selection(template_type); | |
3728 | value_list.n_values = list_length; | |
3729 | value_list.list_value = new EMBEDDED_PDV_template[list_length]; | |
3730 | } | |
3731 | ||
3732 | EMBEDDED_PDV_template& EMBEDDED_PDV_template::list_item(unsigned int list_index) const | |
3733 | { | |
3734 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
3735 | TTCN_error("Accessing a list element of a non-list template of type EMBEDDED PDV."); | |
3736 | if (list_index >= value_list.n_values) | |
3737 | TTCN_error("Index overflow in a value list template of type EMBEDDED PDV."); | |
3738 | return value_list.list_value[list_index]; | |
3739 | } | |
3740 | ||
3741 | EMBEDDED_PDV_identification_template& EMBEDDED_PDV_template::identification() | |
3742 | { | |
3743 | set_specific(); | |
3744 | return single_value->field_identification; | |
3745 | } | |
3746 | ||
3747 | const EMBEDDED_PDV_identification_template& EMBEDDED_PDV_template::identification() const | |
3748 | { | |
3749 | if (template_selection != SPECIFIC_VALUE) | |
3750 | TTCN_error("Accessing field identification of a non-specific template of type EMBEDDED PDV."); | |
3751 | return single_value->field_identification; | |
3752 | } | |
3753 | ||
3754 | UNIVERSAL_CHARSTRING_template& EMBEDDED_PDV_template::data__value__descriptor() | |
3755 | { | |
3756 | set_specific(); | |
3757 | return single_value->field_data__value__descriptor; | |
3758 | } | |
3759 | ||
3760 | const UNIVERSAL_CHARSTRING_template& EMBEDDED_PDV_template::data__value__descriptor() const | |
3761 | { | |
3762 | if (template_selection != SPECIFIC_VALUE) | |
3763 | TTCN_error("Accessing field data_value_descriptor of a non-specific template of type EMBEDDED PDV."); | |
3764 | return single_value->field_data__value__descriptor; | |
3765 | } | |
3766 | ||
3767 | OCTETSTRING_template& EMBEDDED_PDV_template::data__value() | |
3768 | { | |
3769 | set_specific(); | |
3770 | return single_value->field_data__value; | |
3771 | } | |
3772 | ||
3773 | const OCTETSTRING_template& EMBEDDED_PDV_template::data__value() const | |
3774 | { | |
3775 | if (template_selection != SPECIFIC_VALUE) | |
3776 | TTCN_error("Accessing field data_value of a non-specific template of type EMBEDDED PDV."); | |
3777 | return single_value->field_data__value; | |
3778 | } | |
3779 | ||
3780 | int EMBEDDED_PDV_template::size_of() const | |
3781 | { | |
3782 | switch (template_selection) | |
3783 | { | |
3784 | case SPECIFIC_VALUE: | |
3785 | { | |
3786 | int ret_val = 2; | |
3787 | if (single_value->field_data__value__descriptor.is_present()) ret_val++; | |
3788 | return ret_val; | |
3789 | } | |
3790 | case VALUE_LIST: | |
3791 | { | |
3792 | if (value_list.n_values<1) | |
3793 | TTCN_error("Internal error: Performing sizeof() operation on a template of type EMBEDDED PDV containing an empty list."); | |
3794 | int item_size = value_list.list_value[0].size_of(); | |
3795 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
3796 | { | |
3797 | if (value_list.list_value[i].size_of()!=item_size) | |
3798 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV containing a value list with different sizes."); | |
3799 | } | |
3800 | return item_size; | |
3801 | } | |
3802 | case OMIT_VALUE: | |
3803 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV containing omit value."); | |
3804 | case ANY_VALUE: | |
3805 | case ANY_OR_OMIT: | |
3806 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV containing */? value."); | |
3807 | case COMPLEMENTED_LIST: | |
3808 | TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV containing complemented list."); | |
3809 | default: | |
3810 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV."); | |
3811 | } | |
3812 | return 0; | |
3813 | } | |
3814 | ||
3815 | void EMBEDDED_PDV_template::log() const | |
3816 | { | |
3817 | switch (template_selection) { | |
3818 | case SPECIFIC_VALUE: | |
3819 | TTCN_Logger::log_event_str("{ identification := "); | |
3820 | single_value->field_identification.log(); | |
3821 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3822 | single_value->field_data__value__descriptor.log(); | |
3823 | TTCN_Logger::log_event_str(", data_value := "); | |
3824 | single_value->field_data__value.log(); | |
3825 | TTCN_Logger::log_event_str(" }"); | |
3826 | break; | |
3827 | case COMPLEMENTED_LIST: | |
3828 | TTCN_Logger::log_event_str("complement "); | |
3829 | // no break | |
3830 | case VALUE_LIST: | |
3831 | TTCN_Logger::log_char('('); | |
3832 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
3833 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
3834 | value_list.list_value[list_count].log(); | |
3835 | } | |
3836 | TTCN_Logger::log_char(')'); | |
3837 | break; | |
3838 | default: | |
3839 | log_generic(); | |
3840 | break; | |
3841 | } | |
3842 | log_ifpresent(); | |
3843 | } | |
3844 | ||
3abe9331 | 3845 | void EMBEDDED_PDV_template::log_match(const EMBEDDED_PDV& match_value, |
3846 | boolean /* legacy */) const | |
970ed795 EL |
3847 | { |
3848 | if (template_selection == SPECIFIC_VALUE) { | |
3849 | TTCN_Logger::log_event_str("{ identification := "); | |
3850 | single_value->field_identification.log_match(match_value.identification()); | |
3851 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3852 | if (match_value.data__value__descriptor().ispresent()) single_value->field_data__value__descriptor.log_match(match_value.data__value__descriptor()); | |
3853 | else { | |
3854 | single_value->field_data__value__descriptor.log(); | |
3855 | if (single_value->field_data__value__descriptor.match_omit()) TTCN_Logger::log_event_str(" matched"); | |
3856 | else TTCN_Logger::log_event_str(" unmatched"); | |
3857 | ||
3858 | } | |
3859 | TTCN_Logger::log_event_str(", data_value := "); | |
3860 | single_value->field_data__value.log_match(match_value.data__value()); | |
3861 | TTCN_Logger::log_event_str(" }"); | |
3862 | } else { | |
3863 | match_value.log(); | |
3864 | TTCN_Logger::log_event_str(" with "); | |
3865 | log(); | |
3866 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
3867 | else TTCN_Logger::log_event_str(" unmatched"); | |
3868 | } | |
3869 | } | |
3870 | ||
3871 | void EMBEDDED_PDV_template::encode_text(Text_Buf& text_buf) const | |
3872 | { | |
3873 | encode_text_base(text_buf); | |
3874 | switch (template_selection) { | |
3875 | case SPECIFIC_VALUE: | |
3876 | single_value->field_identification.encode_text(text_buf); | |
3877 | single_value->field_data__value__descriptor.encode_text(text_buf); | |
3878 | single_value->field_data__value.encode_text(text_buf); | |
3879 | break; | |
3880 | case OMIT_VALUE: | |
3881 | case ANY_VALUE: | |
3882 | case ANY_OR_OMIT: | |
3883 | break; | |
3884 | case VALUE_LIST: | |
3885 | case COMPLEMENTED_LIST: | |
3886 | text_buf.push_int(value_list.n_values); | |
3887 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3888 | value_list.list_value[list_count].encode_text(text_buf); | |
3889 | break; | |
3890 | default: | |
3891 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV."); | |
3892 | } | |
3893 | } | |
3894 | ||
3895 | void EMBEDDED_PDV_template::decode_text(Text_Buf& text_buf) | |
3896 | { | |
3897 | clean_up(); | |
3898 | decode_text_base(text_buf); | |
3899 | switch (template_selection) { | |
3900 | case SPECIFIC_VALUE: | |
3901 | single_value = new single_value_struct; | |
3902 | single_value->field_identification.decode_text(text_buf); | |
3903 | single_value->field_data__value__descriptor.decode_text(text_buf); | |
3904 | single_value->field_data__value.decode_text(text_buf); | |
3905 | break; | |
3906 | case OMIT_VALUE: | |
3907 | case ANY_VALUE: | |
3908 | case ANY_OR_OMIT: | |
3909 | break; | |
3910 | case VALUE_LIST: | |
3911 | case COMPLEMENTED_LIST: | |
3912 | value_list.n_values = text_buf.pull_int().get_val(); | |
3913 | value_list.list_value = new EMBEDDED_PDV_template[value_list.n_values]; | |
3914 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3915 | value_list.list_value[list_count].decode_text(text_buf); | |
3916 | break; | |
3917 | default: | |
3918 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV."); | |
3919 | } | |
3920 | } | |
3921 | ||
3abe9331 | 3922 | boolean EMBEDDED_PDV_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
3923 | { |
3924 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 3925 | return !match_omit(legacy); |
970ed795 EL |
3926 | } |
3927 | ||
3abe9331 | 3928 | boolean EMBEDDED_PDV_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
3929 | { |
3930 | if (is_ifpresent) return TRUE; | |
3931 | switch (template_selection) { | |
3932 | case OMIT_VALUE: | |
3933 | case ANY_OR_OMIT: | |
3934 | return TRUE; | |
3935 | case VALUE_LIST: | |
3936 | case COMPLEMENTED_LIST: | |
3abe9331 | 3937 | if (legacy) { |
3938 | // legacy behavior: 'omit' can appear in the value/complement list | |
3939 | for (unsigned int i=0; i<value_list.n_values; i++) | |
3940 | if (value_list.list_value[i].match_omit()) | |
3941 | return template_selection==VALUE_LIST; | |
3942 | return template_selection==COMPLEMENTED_LIST; | |
3943 | } | |
3944 | // else fall through | |
970ed795 EL |
3945 | default: |
3946 | return FALSE; | |
3947 | } | |
3948 | return FALSE; | |
3949 | } | |
3950 | ||
3951 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3952 | void EMBEDDED_PDV_template::check_restriction(template_res t_res, const char* t_name, |
3953 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3954 | { |
3955 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3956 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3957 | case TR_VALUE: | |
3958 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3959 | break; | |
3960 | case TR_OMIT: | |
3961 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3962 | template_selection==SPECIFIC_VALUE)) return; | |
3963 | break; | |
3964 | case TR_PRESENT: | |
3abe9331 | 3965 | if (!match_omit(legacy)) return; |
970ed795 EL |
3966 | break; |
3967 | default: | |
3968 | return; | |
3969 | } | |
3970 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
3971 | get_res_name(t_res), t_name ? t_name : "EMBEDDED PDV"); | |
3972 | } | |
3973 | #endif |