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