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 ///////////////////////////////////////////////////////////////////////////////
14 #include "Param_Types.hh"
16 #include "ASN_EmbeddedPDV.hh"
18 #include "../common/dbgnew.hh"
22 to do when regenerating:
26 add __SUNPRO_CC ifdefs for single_value_struct
30 replace '@EMBEDDED PDV' with 'EMBEDDED PDV'
32 remove RAW and TEXT enc/dec functions
34 make the type descriptors of embedded types static
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
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
};
90 /******************** EMBEDDED_PDV_identification ********************/
92 void EMBEDDED_PDV_identification::clean_up()
94 switch (union_selection
) {
96 delete field_syntaxes
;
101 case ALT_presentation__context__id
:
102 delete field_presentation__context__id
;
104 case ALT_context__negotiation
:
105 delete field_context__negotiation
;
107 case ALT_transfer__syntax
:
108 delete field_transfer__syntax
;
116 union_selection
= UNBOUND_VALUE
;
119 void EMBEDDED_PDV_identification::copy_value(const EMBEDDED_PDV_identification
& other_value
)
121 switch (other_value
.union_selection
) {
123 field_syntaxes
= new EMBEDDED_PDV_identification_syntaxes(*other_value
.field_syntaxes
);
126 field_syntax
= new OBJID(*other_value
.field_syntax
);
128 case ALT_presentation__context__id
:
129 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
131 case ALT_context__negotiation
:
132 field_context__negotiation
= new EMBEDDED_PDV_identification_context__negotiation(*other_value
.field_context__negotiation
);
134 case ALT_transfer__syntax
:
135 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
138 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
141 TTCN_error("Assignment of an unbound union value of type EMBEDDED PDV.identification.");
143 union_selection
= other_value
.union_selection
;
146 EMBEDDED_PDV_identification::EMBEDDED_PDV_identification()
148 union_selection
= UNBOUND_VALUE
;
151 EMBEDDED_PDV_identification::EMBEDDED_PDV_identification(const EMBEDDED_PDV_identification
& other_value
)
152 : Base_Type(other_value
)
154 copy_value(other_value
);
157 EMBEDDED_PDV_identification::~EMBEDDED_PDV_identification()
162 EMBEDDED_PDV_identification
& EMBEDDED_PDV_identification::operator=(const EMBEDDED_PDV_identification
& other_value
)
164 if (this != &other_value
) {
166 copy_value(other_value
);
171 boolean
EMBEDDED_PDV_identification::operator==(const EMBEDDED_PDV_identification
& other_value
) const
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
) {
178 return *field_syntaxes
== *other_value
.field_syntaxes
;
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
;
188 return *field_fixed
== *other_value
.field_fixed
;
194 EMBEDDED_PDV_identification_syntaxes
& EMBEDDED_PDV_identification::syntaxes()
196 if (union_selection
!= ALT_syntaxes
) {
198 field_syntaxes
= new EMBEDDED_PDV_identification_syntaxes
;
199 union_selection
= ALT_syntaxes
;
201 return *field_syntaxes
;
204 const EMBEDDED_PDV_identification_syntaxes
& EMBEDDED_PDV_identification::syntaxes() const
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
;
210 OBJID
& EMBEDDED_PDV_identification::syntax()
212 if (union_selection
!= ALT_syntax
) {
214 field_syntax
= new OBJID
;
215 union_selection
= ALT_syntax
;
217 return *field_syntax
;
220 const OBJID
& EMBEDDED_PDV_identification::syntax() const
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
;
226 INTEGER
& EMBEDDED_PDV_identification::presentation__context__id()
228 if (union_selection
!= ALT_presentation__context__id
) {
230 field_presentation__context__id
= new INTEGER
;
231 union_selection
= ALT_presentation__context__id
;
233 return *field_presentation__context__id
;
236 const INTEGER
& EMBEDDED_PDV_identification::presentation__context__id() const
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
;
242 EMBEDDED_PDV_identification_context__negotiation
& EMBEDDED_PDV_identification::context__negotiation()
244 if (union_selection
!= ALT_context__negotiation
) {
246 field_context__negotiation
= new EMBEDDED_PDV_identification_context__negotiation
;
247 union_selection
= ALT_context__negotiation
;
249 return *field_context__negotiation
;
252 const EMBEDDED_PDV_identification_context__negotiation
& EMBEDDED_PDV_identification::context__negotiation() const
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
;
258 OBJID
& EMBEDDED_PDV_identification::transfer__syntax()
260 if (union_selection
!= ALT_transfer__syntax
) {
262 field_transfer__syntax
= new OBJID
;
263 union_selection
= ALT_transfer__syntax
;
265 return *field_transfer__syntax
;
268 const OBJID
& EMBEDDED_PDV_identification::transfer__syntax() const
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
;
274 ASN_NULL
& EMBEDDED_PDV_identification::fixed()
276 if (union_selection
!= ALT_fixed
) {
278 field_fixed
= new ASN_NULL
;
279 union_selection
= ALT_fixed
;
284 const ASN_NULL
& EMBEDDED_PDV_identification::fixed() const
286 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type EMBEDDED PDV.identification.");
290 boolean
EMBEDDED_PDV_identification::ischosen(union_selection_type checked_selection
) const
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
;
297 boolean
EMBEDDED_PDV_identification::is_bound() const
299 return UNBOUND_VALUE
!= union_selection
;
302 boolean
EMBEDDED_PDV_identification::is_value() const
304 switch (union_selection
) {
306 return field_syntaxes
->is_value();
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();
316 return field_fixed
->is_value();
322 void EMBEDDED_PDV_identification::log() const
324 switch (union_selection
) {
326 TTCN_Logger::log_event_str("{ syntaxes := ");
327 field_syntaxes
->log();
328 TTCN_Logger::log_event_str(" }");
331 TTCN_Logger::log_event_str("{ syntax := ");
333 TTCN_Logger::log_event_str(" }");
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(" }");
340 case ALT_context__negotiation
:
341 TTCN_Logger::log_event_str("{ context_negotiation := ");
342 field_context__negotiation
->log();
343 TTCN_Logger::log_event_str(" }");
345 case ALT_transfer__syntax
:
346 TTCN_Logger::log_event_str("{ transfer_syntax := ");
347 field_transfer__syntax
->log();
348 TTCN_Logger::log_event_str(" }");
351 TTCN_Logger::log_event_str("{ fixed := ");
353 TTCN_Logger::log_event_str(" }");
356 TTCN_Logger::log_event_str("<unbound>");
361 void EMBEDDED_PDV_identification::set_param(Module_Param
& param
)
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");
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
);
373 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
374 syntax().set_param(*mp_last
);
377 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
378 presentation__context__id().set_param(*mp_last
);
381 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
382 context__negotiation().set_param(*mp_last
);
385 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
386 transfer__syntax().set_param(*mp_last
);
389 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
390 fixed().set_param(*mp_last
);
393 mp_last
->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last
->get_id()->get_name());
396 void EMBEDDED_PDV_identification_template::set_param(Module_Param
& param
)
398 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
399 switch (param
.get_type()) {
400 case Module_Param::MP_Omit
:
403 case Module_Param::MP_Any
:
406 case Module_Param::MP_AnyOrNone
:
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
));
416 case Module_Param::MP_Value_List
:
417 if (param
.get_size()==0) break;
418 param
.type_error("union template", "EMBEDDED PDV.identification");
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
);
426 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
427 syntax().set_param(*mp_last
);
430 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
431 presentation__context__id().set_param(*mp_last
);
434 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
435 context__negotiation().set_param(*mp_last
);
438 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
439 transfer__syntax().set_param(*mp_last
);
442 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
443 fixed().set_param(*mp_last
);
446 mp_last
->error("Field %s does not exist in type EMBEDDED PDV.identification.", mp_last
->get_id()->get_name());
449 param
.type_error("union template", "EMBEDDED PDV.identification");
451 is_ifpresent
= param
.get_ifpresent();
454 void EMBEDDED_PDV_identification::encode_text(Text_Buf
& text_buf
) const
456 text_buf
.push_int(union_selection
);
457 switch (union_selection
) {
459 field_syntaxes
->encode_text(text_buf
);
462 field_syntax
->encode_text(text_buf
);
464 case ALT_presentation__context__id
:
465 field_presentation__context__id
->encode_text(text_buf
);
467 case ALT_context__negotiation
:
468 field_context__negotiation
->encode_text(text_buf
);
470 case ALT_transfer__syntax
:
471 field_transfer__syntax
->encode_text(text_buf
);
474 field_fixed
->encode_text(text_buf
);
477 TTCN_error("Text encoder: Encoding an unbound value of union type EMBEDDED PDV.identification.");
481 void EMBEDDED_PDV_identification::decode_text(Text_Buf
& text_buf
)
483 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
485 syntaxes().decode_text(text_buf
);
488 syntax().decode_text(text_buf
);
490 case ALT_presentation__context__id
:
491 presentation__context__id().decode_text(text_buf
);
493 case ALT_context__negotiation
:
494 context__negotiation().decode_text(text_buf
);
496 case ALT_transfer__syntax
:
497 transfer__syntax().decode_text(text_buf
);
500 fixed().decode_text(text_buf
);
503 TTCN_error("Text decoder: Unrecognized union selector was received for type EMBEDDED PDV.identification.");
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, ...)
511 ASN_BER_TLV_t
*EMBEDDED_PDV_identification::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
514 ASN_BER_TLV_t
*new_tlv
;
515 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
516 TTCN_EncDec_ErrorContext ec_1
;
517 switch (union_selection
) {
519 ec_1
.set_msg("syntaxes': ");
520 new_tlv
= field_syntaxes
->BER_encode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_
, p_coding
);
523 ec_1
.set_msg("syntax': ");
524 new_tlv
= field_syntax
->BER_encode_TLV(EMBEDDED_PDV_identification_syntax_descr_
, p_coding
);
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
);
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
);
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
);
539 ec_1
.set_msg("fixed': ");
540 new_tlv
= field_fixed
->BER_encode_TLV(EMBEDDED_PDV_identification_fixed_descr_
, p_coding
);
543 new_tlv
= BER_encode_chk_bound(FALSE
);
546 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
550 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
553 boolean
EMBEDDED_PDV_identification::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
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
;
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
;
580 union_selection
= UNBOUND_VALUE
;
584 boolean
EMBEDDED_PDV_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
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
);
592 boolean
EMBEDDED_PDV_identification::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
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
) {
604 ec_2
.set_msg("syntaxes': ");
605 field_syntaxes
->BER_decode_TLV(EMBEDDED_PDV_identification_syntaxes_descr_
, tmp_tlv
, L_form
);
608 ec_2
.set_msg("syntax': ");
609 field_syntax
->BER_decode_TLV(EMBEDDED_PDV_identification_syntax_descr_
, tmp_tlv
, L_form
);
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
);
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
);
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
);
624 ec_2
.set_msg("fixed': ");
625 field_fixed
->BER_decode_TLV(EMBEDDED_PDV_identification_fixed_descr_
, tmp_tlv
, L_form
);
633 // FIXME maybe: XER_encode and decode is virtually identical to CHARACTER_STRING
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
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
);
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
]);
647 switch (union_selection
) {
649 field_syntaxes
->XER_encode(EMBEDDED_PDV_identification_sxs_xer_
, p_buf
, flavor
, indent
, 0);;
652 field_syntax
->XER_encode(EMBEDDED_PDV_identification_sx_xer_
, p_buf
, flavor
, indent
, 0);;
654 case ALT_presentation__context__id
:
655 field_presentation__context__id
->XER_encode(EMBEDDED_PDV_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);;
657 case ALT_context__negotiation
:
658 field_context__negotiation
->XER_encode(EMBEDDED_PDV_identification_cn_xer_
, p_buf
, flavor
, indent
, 0);;
660 case ALT_transfer__syntax
:
661 field_transfer__syntax
->XER_encode(EMBEDDED_PDV_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);;
664 field_fixed
->XER_encode(EMBEDDED_PDV_identification_fix_xer_
, p_buf
, flavor
, indent
, 0);;
667 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
671 if (indenting
) do_indent(p_buf
, --indent
);
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
;
679 int EMBEDDED_PDV_identification::XER_decode(const XERdescriptor_t
& p_td
,
680 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
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();
687 case XML_READER_TYPE_ELEMENT
: {
688 if (verify_name(reader
, p_td
, exer
)) {
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
;
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
);
700 syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_
, reader
, flavor
, 0);
704 syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_
, reader
, flavor
, 0);
707 case 23: // presentation-context-id
708 presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_
, reader
, flavor
, 0);
711 case 19: // context-negotiation
712 context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_
, reader
, flavor
, 0);
715 case 15: // transfer-syntax
716 transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_
, reader
, flavor
, 0);
720 fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_
, reader
, flavor
, 0);
727 else { // it belongs to somebody else
731 case XML_READER_TYPE_END_ELEMENT
: {
732 // advance to the next thing and bail
741 /******************** EMBEDDED_PDV_identification_template ********************/
743 void EMBEDDED_PDV_identification_template::clean_up()
745 switch (template_selection
) {
747 switch (single_value
.union_selection
) {
748 case EMBEDDED_PDV_identification::ALT_syntaxes
:
749 delete single_value
.field_syntaxes
;
751 case EMBEDDED_PDV_identification::ALT_syntax
:
752 delete single_value
.field_syntax
;
754 case EMBEDDED_PDV_identification::ALT_presentation__context__id
:
755 delete single_value
.field_presentation__context__id
;
757 case EMBEDDED_PDV_identification::ALT_context__negotiation
:
758 delete single_value
.field_context__negotiation
;
760 case EMBEDDED_PDV_identification::ALT_transfer__syntax
:
761 delete single_value
.field_transfer__syntax
;
763 case EMBEDDED_PDV_identification::ALT_fixed
:
764 delete single_value
.field_fixed
;
771 case COMPLEMENTED_LIST
:
772 delete [] value_list
.list_value
;
777 template_selection
= UNINITIALIZED_TEMPLATE
;
780 void EMBEDDED_PDV_identification_template::copy_value(const EMBEDDED_PDV_identification
& other_value
)
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());
787 case EMBEDDED_PDV_identification::ALT_syntax
:
788 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
790 case EMBEDDED_PDV_identification::ALT_presentation__context__id
:
791 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
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());
796 case EMBEDDED_PDV_identification::ALT_transfer__syntax
:
797 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
799 case EMBEDDED_PDV_identification::ALT_fixed
:
800 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
803 TTCN_error("Initializing a template with an unbound value of type EMBEDDED PDV.identification.");
805 set_selection(SPECIFIC_VALUE
);
808 void EMBEDDED_PDV_identification_template::copy_template(const EMBEDDED_PDV_identification_template
& other_value
)
810 switch (other_value
.template_selection
) {
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
);
817 case EMBEDDED_PDV_identification::ALT_syntax
:
818 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
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
);
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
);
826 case EMBEDDED_PDV_identification::ALT_transfer__syntax
:
827 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
829 case EMBEDDED_PDV_identification::ALT_fixed
:
830 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
833 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EMBEDDED PDV.identification.");
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
]);
848 TTCN_error("Copying an uninitialized template of union type EMBEDDED PDV.identification.");
850 set_selection(other_value
);
853 EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template()
857 EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(template_sel other_value
)
858 : Base_Template(other_value
)
860 check_single_selection(other_value
);
863 EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification
& other_value
)
865 copy_value(other_value
);
868 EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const OPTIONAL
<EMBEDDED_PDV_identification
>& other_value
)
870 switch (other_value
.get_selection()) {
871 case OPTIONAL_PRESENT
:
872 copy_value((const EMBEDDED_PDV_identification
&)other_value
);
875 set_selection(OMIT_VALUE
);
878 TTCN_error("Creating a template of union type EMBEDDED PDV.identification from an unbound optional field.");
882 EMBEDDED_PDV_identification_template::EMBEDDED_PDV_identification_template(const EMBEDDED_PDV_identification_template
& other_value
)
885 copy_template(other_value
);
888 EMBEDDED_PDV_identification_template::~EMBEDDED_PDV_identification_template()
893 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_identification_template::operator=(template_sel other_value
)
895 check_single_selection(other_value
);
897 set_selection(other_value
);
901 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification
& other_value
)
904 copy_value(other_value
);
908 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_identification_template::operator=(const OPTIONAL
<EMBEDDED_PDV_identification
>& other_value
)
911 switch (other_value
.get_selection()) {
912 case OPTIONAL_PRESENT
:
913 copy_value((const EMBEDDED_PDV_identification
&)other_value
);
916 set_selection(OMIT_VALUE
);
919 TTCN_error("Assignment of an unbound optional field to a template of union type EMBEDDED PDV.identification.");
924 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_identification_template::operator=(const EMBEDDED_PDV_identification_template
& other_value
)
926 if (&other_value
!= this) {
928 copy_template(other_value
);
933 boolean
EMBEDDED_PDV_identification_template::match(const EMBEDDED_PDV_identification
& other_value
) const
935 switch (template_selection
) {
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());
960 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EMBEDDED PDV.identification.");
963 break; // should never get here
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
;
970 TTCN_error ("Matching an uninitialized template of union type EMBEDDED PDV.identification.");
975 EMBEDDED_PDV_identification
EMBEDDED_PDV_identification_template::valueof() const
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();
984 case EMBEDDED_PDV_identification::ALT_syntax
:
985 ret_val
.syntax() = single_value
.field_syntax
->valueof();
987 case EMBEDDED_PDV_identification::ALT_presentation__context__id
:
988 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
990 case EMBEDDED_PDV_identification::ALT_context__negotiation
:
991 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
993 case EMBEDDED_PDV_identification::ALT_transfer__syntax
:
994 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
996 case EMBEDDED_PDV_identification::ALT_fixed
:
997 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1000 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EMBEDDED PDV.identification.");
1005 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_identification_template::list_item(unsigned int list_index
) const
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
];
1011 void EMBEDDED_PDV_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
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.");
1015 set_selection(template_type
);
1016 value_list
.n_values
= list_length
;
1017 value_list
.list_value
= new EMBEDDED_PDV_identification_template
[list_length
];
1020 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_template::syntaxes()
1022 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_syntaxes
) {
1023 template_sel old_selection
= template_selection
;
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
);
1030 return *single_value
.field_syntaxes
;
1033 const EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_template::syntaxes() const
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
;
1040 OBJID_template
& EMBEDDED_PDV_identification_template::syntax()
1042 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_syntax
) {
1043 template_sel old_selection
= template_selection
;
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
);
1050 return *single_value
.field_syntax
;
1053 const OBJID_template
& EMBEDDED_PDV_identification_template::syntax() const
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
;
1060 INTEGER_template
& EMBEDDED_PDV_identification_template::presentation__context__id()
1062 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_presentation__context__id
) {
1063 template_sel old_selection
= template_selection
;
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
);
1070 return *single_value
.field_presentation__context__id
;
1073 const INTEGER_template
& EMBEDDED_PDV_identification_template::presentation__context__id() const
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
;
1080 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_template::context__negotiation()
1082 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_context__negotiation
) {
1083 template_sel old_selection
= template_selection
;
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
);
1090 return *single_value
.field_context__negotiation
;
1093 const EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_template::context__negotiation() const
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
;
1100 OBJID_template
& EMBEDDED_PDV_identification_template::transfer__syntax()
1102 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_transfer__syntax
) {
1103 template_sel old_selection
= template_selection
;
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
);
1110 return *single_value
.field_transfer__syntax
;
1113 const OBJID_template
& EMBEDDED_PDV_identification_template::transfer__syntax() const
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
;
1120 ASN_NULL_template
& EMBEDDED_PDV_identification_template::fixed()
1122 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EMBEDDED_PDV_identification::ALT_fixed
) {
1123 template_sel old_selection
= template_selection
;
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
);
1130 return *single_value
.field_fixed
;
1133 const ASN_NULL_template
& EMBEDDED_PDV_identification_template::fixed() const
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
;
1140 boolean
EMBEDDED_PDV_identification_template::ischosen(EMBEDDED_PDV_identification::union_selection_type checked_selection
) const
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
;
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
) {
1159 if (all_same
) return ret_val
;
1161 // FIXME really no break?
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.");
1168 TTCN_error("Performing ischosen() operation on an uninitialized template of union type EMBEDDED PDV.identification");
1173 void EMBEDDED_PDV_identification_template::log() const
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(" }");
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(" }");
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(" }");
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(" }");
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(" }");
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(" }");
1209 TTCN_Logger::log_event_str("<invalid selector>");
1213 case COMPLEMENTED_LIST
:
1214 TTCN_Logger::log_event_str("complement ");
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();
1222 TTCN_Logger::log_char(')');
1231 void EMBEDDED_PDV_identification_template::log_match(const EMBEDDED_PDV_identification
& match_value
) const
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 ");
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());
1247 TTCN_Logger::log_event_str("{ syntaxes := ");
1248 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1249 TTCN_Logger::log_event_str(" }");
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());
1257 TTCN_Logger::log_event_str("{ syntax := ");
1258 single_value
.field_syntax
->log_match(match_value
.syntax());
1259 TTCN_Logger::log_event_str(" }");
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());
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(" }");
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());
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(" }");
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());
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(" }");
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());
1297 TTCN_Logger::log_event_str("{ fixed := ");
1298 single_value
.field_fixed
->log_match(match_value
.fixed());
1299 TTCN_Logger::log_event_str(" }");
1303 TTCN_Logger::print_logmatch_buffer();
1304 TTCN_Logger::log_event_str("<invalid selector>");
1307 TTCN_Logger::print_logmatch_buffer();
1309 TTCN_Logger::log_event_str(" with ");
1311 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1312 else TTCN_Logger::log_event_str(" unmatched");
1316 void EMBEDDED_PDV_identification_template::encode_text(Text_Buf
& text_buf
) const
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
);
1326 case EMBEDDED_PDV_identification::ALT_syntax
:
1327 single_value
.field_syntax
->encode_text(text_buf
);
1329 case EMBEDDED_PDV_identification::ALT_presentation__context__id
:
1330 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1332 case EMBEDDED_PDV_identification::ALT_context__negotiation
:
1333 single_value
.field_context__negotiation
->encode_text(text_buf
);
1335 case EMBEDDED_PDV_identification::ALT_transfer__syntax
:
1336 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1338 case EMBEDDED_PDV_identification::ALT_fixed
:
1339 single_value
.field_fixed
->encode_text(text_buf
);
1342 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EMBEDDED PDV.identification.");
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
);
1356 TTCN_error("Text encoder: Encoding an uninitialized template of type EMBEDDED PDV.identification.");
1360 void EMBEDDED_PDV_identification_template::decode_text(Text_Buf
& text_buf
)
1363 decode_text_base(text_buf
);
1364 switch (template_selection
) {
1365 case SPECIFIC_VALUE
:
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
);
1374 case EMBEDDED_PDV_identification::ALT_syntax
:
1375 single_value
.field_syntax
= new OBJID_template
;
1376 single_value
.field_syntax
->decode_text(text_buf
);
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
);
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
);
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
);
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
);
1395 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EMBEDDED PDV.identification.");
1397 single_value
.union_selection
= new_selection
;
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
);
1412 TTCN_error("Text decoder: Unrecognized selector was received in a template of type EMBEDDED PDV.identification.");
1416 boolean
EMBEDDED_PDV_identification_template::is_present() const
1418 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1419 return !match_omit();
1422 boolean
EMBEDDED_PDV_identification_template::match_omit() const
1424 if (is_ifpresent
) return TRUE
;
1425 switch (template_selection
) {
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
;
1441 #ifndef TITAN_RUNTIME_2
1442 void EMBEDDED_PDV_identification_template::check_restriction(template_res t_res
, const char* t_name
) const
1444 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1445 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1447 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1450 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1451 template_selection
==SPECIFIC_VALUE
)) return;
1454 if (!match_omit()) return;
1459 TTCN_error("Restriction `%s' on template of type %s violated.",
1460 get_res_name(t_res
), t_name
? t_name
: "EMBEDDED PDV.identification");
1464 EMBEDDED_PDV_identification_syntaxes::EMBEDDED_PDV_identification_syntaxes()
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
)
1475 boolean
EMBEDDED_PDV_identification_syntaxes::operator==(const EMBEDDED_PDV_identification_syntaxes
& other_value
) const
1477 return field_abstract
==other_value
.field_abstract
1478 && field_transfer
==other_value
.field_transfer
;
1481 int EMBEDDED_PDV_identification_syntaxes::size_of() const
1487 void EMBEDDED_PDV_identification_syntaxes::log() const
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(" }");
1496 boolean
EMBEDDED_PDV_identification_syntaxes::is_bound() const
1498 if(field_abstract
.is_bound()) return TRUE
;
1499 if(field_transfer
.is_bound()) return TRUE
;
1503 boolean
EMBEDDED_PDV_identification_syntaxes::is_value() const
1505 if(!field_abstract
.is_value()) return FALSE
;
1506 if(!field_transfer
.is_value()) return FALSE
;
1510 void EMBEDDED_PDV_identification_syntaxes::clean_up()
1512 field_abstract
.clean_up();
1513 field_transfer
.clean_up();
1516 void EMBEDDED_PDV_identification_syntaxes::set_param(Module_Param
& param
)
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());
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));
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;
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;
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());
1551 param
.type_error("record value", "EMBEDDED PDV.identification.syntaxes");
1555 void EMBEDDED_PDV_identification_syntaxes_template::set_param(Module_Param
& param
)
1557 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
1558 switch (param
.get_type()) {
1559 case Module_Param::MP_Omit
:
1562 case Module_Param::MP_Any
:
1565 case Module_Param::MP_AnyOrNone
:
1566 *this = ANY_OR_OMIT
;
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
));
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());
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));
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;
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;
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());
1606 param
.type_error("record template", "EMBEDDED PDV.identification.syntaxes");
1608 is_ifpresent
= param
.get_ifpresent();
1611 void EMBEDDED_PDV_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
1613 field_abstract
.encode_text(text_buf
);
1614 field_transfer
.encode_text(text_buf
);
1617 void EMBEDDED_PDV_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
1619 field_abstract
.decode_text(text_buf
);
1620 field_transfer
.decode_text(text_buf
);
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, ...)
1627 ASN_BER_TLV_t
* EMBEDDED_PDV_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
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
);
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
)
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
);
1649 ASN_BER_TLV_t tmp_tlv
;
1650 boolean tlv_present
=FALSE
;
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
);
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
);
1665 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
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
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
);
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
]);
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);
1684 if (indenting
) do_indent(p_buf
, --indent
);
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
;
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
1696 for (int success
= reader
.Read(); success
== 1; success
= reader
.Read())
1698 type
= reader
.NodeType();
1699 if (XML_READER_TYPE_ELEMENT
== type
)
1700 // no verify_name for a CHOICE
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())
1708 type
= reader
.NodeType();
1709 if (XML_READER_TYPE_END_ELEMENT
== type
)
1712 return 0; // TODO maybe return proper value
1715 /******************** EMBEDDED_PDV_identification_syntaxes_template ********************/
1717 struct EMBEDDED_PDV_identification_syntaxes_template::single_value_struct
{
1718 OBJID_template field_abstract
;
1719 OBJID_template field_transfer
;
1722 void EMBEDDED_PDV_identification_syntaxes_template::clean_up()
1724 switch (template_selection
) {
1725 case SPECIFIC_VALUE
:
1726 delete single_value
;
1729 case COMPLEMENTED_LIST
:
1730 delete [] value_list
.list_value
;
1735 template_selection
= UNINITIALIZED_TEMPLATE
;
1738 void EMBEDDED_PDV_identification_syntaxes_template::set_specific()
1740 if (template_selection
!= SPECIFIC_VALUE
) {
1741 template_sel old_selection
= template_selection
;
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
;
1752 void EMBEDDED_PDV_identification_syntaxes_template::copy_value(const EMBEDDED_PDV_identification_syntaxes
& other_value
)
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
);
1760 void EMBEDDED_PDV_identification_syntaxes_template::copy_template(const EMBEDDED_PDV_identification_syntaxes_template
& other_value
)
1762 switch (other_value
.template_selection
) {
1763 case SPECIFIC_VALUE
:
1764 single_value
= new single_value_struct(*other_value
.single_value
);
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
]);
1778 TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes.");
1780 set_selection(other_value
);
1783 EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template()
1787 EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(template_sel other_value
)
1788 : Base_Template(other_value
)
1790 check_single_selection(other_value
);
1793 EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const EMBEDDED_PDV_identification_syntaxes
& other_value
)
1795 copy_value(other_value
);
1798 EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const OPTIONAL
<EMBEDDED_PDV_identification_syntaxes
>& other_value
)
1800 switch (other_value
.get_selection()) {
1801 case OPTIONAL_PRESENT
:
1802 copy_value((const EMBEDDED_PDV_identification_syntaxes
&)other_value
);
1805 set_selection(OMIT_VALUE
);
1808 TTCN_error("Creating a template of type EMBEDDED PDV.identification.syntaxes from an unbound optional field.");
1812 EMBEDDED_PDV_identification_syntaxes_template::EMBEDDED_PDV_identification_syntaxes_template(const EMBEDDED_PDV_identification_syntaxes_template
& other_value
)
1815 copy_template(other_value
);
1818 EMBEDDED_PDV_identification_syntaxes_template::~EMBEDDED_PDV_identification_syntaxes_template()
1823 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_syntaxes_template::operator=(template_sel other_value
)
1825 check_single_selection(other_value
);
1827 set_selection(other_value
);
1831 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_syntaxes_template::operator=(const EMBEDDED_PDV_identification_syntaxes
& other_value
)
1834 copy_value(other_value
);
1838 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_syntaxes_template::operator=(const OPTIONAL
<EMBEDDED_PDV_identification_syntaxes
>& other_value
)
1841 switch (other_value
.get_selection()) {
1842 case OPTIONAL_PRESENT
:
1843 copy_value((const EMBEDDED_PDV_identification_syntaxes
&)other_value
);
1846 set_selection(OMIT_VALUE
);
1849 TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV.identification.syntaxes.");
1854 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_syntaxes_template::operator=(const EMBEDDED_PDV_identification_syntaxes_template
& other_value
)
1856 if (&other_value
!= this) {
1858 copy_template(other_value
);
1863 boolean
EMBEDDED_PDV_identification_syntaxes_template::match(const EMBEDDED_PDV_identification_syntaxes
& other_value
) const
1865 switch (template_selection
) {
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
;
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
;
1883 TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes.");
1888 EMBEDDED_PDV_identification_syntaxes
EMBEDDED_PDV_identification_syntaxes_template::valueof() const
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();
1898 void EMBEDDED_PDV_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
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.");
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
];
1908 EMBEDDED_PDV_identification_syntaxes_template
& EMBEDDED_PDV_identification_syntaxes_template::list_item(unsigned int list_index
) const
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
];
1917 OBJID_template
& EMBEDDED_PDV_identification_syntaxes_template::abstract()
1920 return single_value
->field_abstract
;
1923 const OBJID_template
& EMBEDDED_PDV_identification_syntaxes_template::abstract() const
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
;
1930 OBJID_template
& EMBEDDED_PDV_identification_syntaxes_template::transfer()
1933 return single_value
->field_transfer
;
1936 const OBJID_template
& EMBEDDED_PDV_identification_syntaxes_template::transfer() const
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
;
1943 int EMBEDDED_PDV_identification_syntaxes_template::size_of() const
1945 switch (template_selection
)
1947 case SPECIFIC_VALUE
:
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
++)
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.");
1965 TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.syntaxes containing omit value.");
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.");
1972 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes.");
1977 void EMBEDDED_PDV_identification_syntaxes_template::log() const
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(" }");
1987 case COMPLEMENTED_LIST
:
1988 TTCN_Logger::log_event_str("complement ");
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();
1996 TTCN_Logger::log_char(')');
2005 void EMBEDDED_PDV_identification_syntaxes_template::log_match(const EMBEDDED_PDV_identification_syntaxes
& match_value
) const
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(" }");
2015 TTCN_Logger::log_event_str(" with ");
2017 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2018 else TTCN_Logger::log_event_str(" unmatched");
2022 void EMBEDDED_PDV_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
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
);
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
);
2041 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes.");
2045 void EMBEDDED_PDV_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
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
);
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
);
2067 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV.identification.syntaxes.");
2071 boolean
EMBEDDED_PDV_identification_syntaxes_template::is_present() const
2073 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2074 return !match_omit();
2077 boolean
EMBEDDED_PDV_identification_syntaxes_template::match_omit() const
2079 if (is_ifpresent
) return TRUE
;
2080 switch (template_selection
) {
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
;
2096 #ifndef TITAN_RUNTIME_2
2097 void EMBEDDED_PDV_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
) const
2099 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2100 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2102 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2105 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2106 template_selection
==SPECIFIC_VALUE
)) return;
2109 if (!match_omit()) return;
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");
2119 EMBEDDED_PDV_identification_context__negotiation::EMBEDDED_PDV_identification_context__negotiation()
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
)
2130 boolean
EMBEDDED_PDV_identification_context__negotiation::operator==(const EMBEDDED_PDV_identification_context__negotiation
& other_value
) const
2132 return field_presentation__context__id
==other_value
.field_presentation__context__id
2133 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2136 int EMBEDDED_PDV_identification_context__negotiation::size_of() const
2142 void EMBEDDED_PDV_identification_context__negotiation::log() const
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(" }");
2151 boolean
EMBEDDED_PDV_identification_context__negotiation::is_bound() const
2153 if(field_presentation__context__id
.is_bound()) return TRUE
;
2154 if(field_transfer__syntax
.is_bound()) return TRUE
;
2158 boolean
EMBEDDED_PDV_identification_context__negotiation::is_value() const
2160 if(!field_presentation__context__id
.is_value()) return FALSE
;
2161 if(!field_transfer__syntax
.is_value()) return FALSE
;
2165 void EMBEDDED_PDV_identification_context__negotiation::clean_up()
2167 field_presentation__context__id
.clean_up();
2168 field_transfer__syntax
.clean_up();
2171 void EMBEDDED_PDV_identification_context__negotiation::set_param(Module_Param
& param
)
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());
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));
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;
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;
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());
2206 param
.type_error("record value", "EMBEDDED PDV.identification.context-negotiation");
2210 void EMBEDDED_PDV_identification_context__negotiation_template::set_param(Module_Param
& param
)
2212 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2213 switch (param
.get_type()) {
2214 case Module_Param::MP_Omit
:
2217 case Module_Param::MP_Any
:
2220 case Module_Param::MP_AnyOrNone
:
2221 *this = ANY_OR_OMIT
;
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
));
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());
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));
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;
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;
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());
2261 param
.type_error("record template", "EMBEDDED PDV.identification.context-negotiation");
2263 is_ifpresent
= param
.get_ifpresent();
2266 void EMBEDDED_PDV_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2268 field_presentation__context__id
.encode_text(text_buf
);
2269 field_transfer__syntax
.encode_text(text_buf
);
2272 void EMBEDDED_PDV_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2274 field_presentation__context__id
.decode_text(text_buf
);
2275 field_transfer__syntax
.decode_text(text_buf
);
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, ...)
2283 ASN_BER_TLV_t
* EMBEDDED_PDV_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
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
);
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
)
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
);
2305 ASN_BER_TLV_t tmp_tlv
;
2306 boolean tlv_present
=FALSE
;
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
);
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
);
2321 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
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
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
);
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
]);
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);
2340 if (indenting
) do_indent(p_buf
, --indent
);
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
;
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
*)
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();
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
);
2370 return 0; // TODO sensible return value
2373 struct EMBEDDED_PDV_identification_context__negotiation_template::single_value_struct
{
2374 INTEGER_template field_presentation__context__id
;
2375 OBJID_template field_transfer__syntax
;
2378 void EMBEDDED_PDV_identification_context__negotiation_template::clean_up()
2380 switch (template_selection
) {
2381 case SPECIFIC_VALUE
:
2382 delete single_value
;
2385 case COMPLEMENTED_LIST
:
2386 delete [] value_list
.list_value
;
2391 template_selection
= UNINITIALIZED_TEMPLATE
;
2394 void EMBEDDED_PDV_identification_context__negotiation_template::set_specific()
2396 if (template_selection
!= SPECIFIC_VALUE
) {
2397 template_sel old_selection
= template_selection
;
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
;
2408 void EMBEDDED_PDV_identification_context__negotiation_template::copy_value(const EMBEDDED_PDV_identification_context__negotiation
& other_value
)
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
);
2416 void EMBEDDED_PDV_identification_context__negotiation_template::copy_template(const EMBEDDED_PDV_identification_context__negotiation_template
& other_value
)
2418 switch (other_value
.template_selection
) {
2419 case SPECIFIC_VALUE
:
2420 single_value
= new single_value_struct(*other_value
.single_value
);
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
]);
2434 TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation.");
2436 set_selection(other_value
);
2439 EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template()
2443 EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(template_sel other_value
)
2444 : Base_Template(other_value
)
2446 check_single_selection(other_value
);
2449 EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const EMBEDDED_PDV_identification_context__negotiation
& other_value
)
2451 copy_value(other_value
);
2454 EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const OPTIONAL
<EMBEDDED_PDV_identification_context__negotiation
>& other_value
)
2456 switch (other_value
.get_selection()) {
2457 case OPTIONAL_PRESENT
:
2458 copy_value((const EMBEDDED_PDV_identification_context__negotiation
&)other_value
);
2461 set_selection(OMIT_VALUE
);
2464 TTCN_error("Creating a template of type EMBEDDED PDV.identification.context-negotiation from an unbound optional field.");
2468 EMBEDDED_PDV_identification_context__negotiation_template::EMBEDDED_PDV_identification_context__negotiation_template(const EMBEDDED_PDV_identification_context__negotiation_template
& other_value
)
2471 copy_template(other_value
);
2474 EMBEDDED_PDV_identification_context__negotiation_template::~EMBEDDED_PDV_identification_context__negotiation_template()
2479 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_context__negotiation_template::operator=(template_sel other_value
)
2481 check_single_selection(other_value
);
2483 set_selection(other_value
);
2487 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const EMBEDDED_PDV_identification_context__negotiation
& other_value
)
2490 copy_value(other_value
);
2494 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const OPTIONAL
<EMBEDDED_PDV_identification_context__negotiation
>& other_value
)
2497 switch (other_value
.get_selection()) {
2498 case OPTIONAL_PRESENT
:
2499 copy_value((const EMBEDDED_PDV_identification_context__negotiation
&)other_value
);
2502 set_selection(OMIT_VALUE
);
2505 TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV.identification.context-negotiation.");
2510 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_context__negotiation_template::operator=(const EMBEDDED_PDV_identification_context__negotiation_template
& other_value
)
2512 if (&other_value
!= this) {
2514 copy_template(other_value
);
2519 boolean
EMBEDDED_PDV_identification_context__negotiation_template::match(const EMBEDDED_PDV_identification_context__negotiation
& other_value
) const
2521 switch (template_selection
) {
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
;
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
;
2539 TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation.");
2544 EMBEDDED_PDV_identification_context__negotiation
EMBEDDED_PDV_identification_context__negotiation_template::valueof() const
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();
2554 void EMBEDDED_PDV_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
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.");
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
];
2564 EMBEDDED_PDV_identification_context__negotiation_template
& EMBEDDED_PDV_identification_context__negotiation_template::list_item(unsigned int list_index
) const
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
];
2573 INTEGER_template
& EMBEDDED_PDV_identification_context__negotiation_template::presentation__context__id()
2576 return single_value
->field_presentation__context__id
;
2579 const INTEGER_template
& EMBEDDED_PDV_identification_context__negotiation_template::presentation__context__id() const
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
;
2586 OBJID_template
& EMBEDDED_PDV_identification_context__negotiation_template::transfer__syntax()
2589 return single_value
->field_transfer__syntax
;
2592 const OBJID_template
& EMBEDDED_PDV_identification_context__negotiation_template::transfer__syntax() const
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
;
2599 int EMBEDDED_PDV_identification_context__negotiation_template::size_of() const
2601 switch (template_selection
)
2603 case SPECIFIC_VALUE
:
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
++)
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.");
2621 TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV.identification.context-negotiation containing omit value.");
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.");
2628 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation.");
2633 void EMBEDDED_PDV_identification_context__negotiation_template::log() const
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(" }");
2643 case COMPLEMENTED_LIST
:
2644 TTCN_Logger::log_event_str("complement ");
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();
2652 TTCN_Logger::log_char(')');
2661 void EMBEDDED_PDV_identification_context__negotiation_template::log_match(const EMBEDDED_PDV_identification_context__negotiation
& match_value
) const
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(" }");
2671 TTCN_Logger::log_event_str(" with ");
2673 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2674 else TTCN_Logger::log_event_str(" unmatched");
2678 void EMBEDDED_PDV_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
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
);
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
);
2697 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation.");
2701 void EMBEDDED_PDV_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
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
);
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
);
2723 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV.identification.context-negotiation.");
2727 boolean
EMBEDDED_PDV_identification_context__negotiation_template::is_present() const
2729 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2730 return !match_omit();
2733 boolean
EMBEDDED_PDV_identification_context__negotiation_template::match_omit() const
2735 if (is_ifpresent
) return TRUE
;
2736 switch (template_selection
) {
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
;
2752 #ifndef TITAN_RUNTIME_2
2753 void EMBEDDED_PDV_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
) const
2755 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2756 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2758 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2761 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2762 template_selection
==SPECIFIC_VALUE
)) return;
2765 if (!match_omit()) return;
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");
2775 EMBEDDED_PDV::EMBEDDED_PDV()
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
)
2788 boolean
EMBEDDED_PDV::operator==(const EMBEDDED_PDV
& other_value
) const
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
;
2795 int EMBEDDED_PDV::size_of() const
2798 if (field_data__value__descriptor
.ispresent()) ret_val
++;
2802 void EMBEDDED_PDV::log() const
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(" }");
2813 boolean
EMBEDDED_PDV::is_bound() const
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
;
2821 boolean
EMBEDDED_PDV::is_value() const
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
;
2829 void EMBEDDED_PDV::clean_up()
2831 field_identification
.clean_up();
2832 field_data__value__descriptor
.clean_up();
2833 field_data__value
.clean_up();
2836 void EMBEDDED_PDV::set_param(Module_Param
& param
)
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());
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));
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;
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;
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;
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());
2879 param
.type_error("record value", "EMBEDDED PDV");
2883 void EMBEDDED_PDV_template::set_param(Module_Param
& param
)
2885 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2886 switch (param
.get_type()) {
2887 case Module_Param::MP_Omit
:
2890 case Module_Param::MP_Any
:
2893 case Module_Param::MP_AnyOrNone
:
2894 *this = ANY_OR_OMIT
;
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
));
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());
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));
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;
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;
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;
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());
2942 param
.type_error("record template", "EMBEDDED PDV");
2944 is_ifpresent
= param
.get_ifpresent();
2947 void EMBEDDED_PDV::encode_text(Text_Buf
& text_buf
) const
2949 field_identification
.encode_text(text_buf
);
2950 field_data__value__descriptor
.encode_text(text_buf
);
2951 field_data__value
.encode_text(text_buf
);
2954 void EMBEDDED_PDV::decode_text(Text_Buf
& text_buf
)
2956 field_identification
.decode_text(text_buf
);
2957 field_data__value__descriptor
.decode_text(text_buf
);
2958 field_data__value
.decode_text(text_buf
);
2961 void EMBEDDED_PDV::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
2964 va_start(pvar
, 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
);
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
);
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
);
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);
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
);
2995 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3000 void EMBEDDED_PDV::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3003 va_start(pvar
, 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);
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());
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
);
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
);
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
)
3033 XER_decode(*p_td
.xer
, reader
, XER_coding
, 0);
3034 size_t bytes
= reader
.ByteConsumed();
3035 p_buf
.set_pos(bytes
);
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
);
3043 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3048 ASN_BER_TLV_t
* EMBEDDED_PDV::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
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
);
3064 boolean
EMBEDDED_PDV::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
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
);
3072 ASN_BER_TLV_t tmp_tlv
;
3073 boolean tlv_present
=FALSE
;
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
);
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
;
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
;
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
);
3095 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
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 {
3102 TTCN_EncDec_ErrorContext::error
3103 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
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
);
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
]);
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");
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);
3122 if (indenting
) do_indent(p_buf
, --indent
);
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
;
3130 int EMBEDDED_PDV::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
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();
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");
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
);
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
;
3167 void EMBEDDED_PDV_template::clean_up()
3169 switch (template_selection
) {
3170 case SPECIFIC_VALUE
:
3171 delete single_value
;
3174 case COMPLEMENTED_LIST
:
3175 delete [] value_list
.list_value
;
3180 template_selection
= UNINITIALIZED_TEMPLATE
;
3183 void EMBEDDED_PDV_template::set_specific()
3185 if (template_selection
!= SPECIFIC_VALUE
) {
3186 template_sel old_selection
= template_selection
;
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
;
3198 void EMBEDDED_PDV_template::copy_value(const EMBEDDED_PDV
& other_value
)
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
);
3208 void EMBEDDED_PDV_template::copy_template(const EMBEDDED_PDV_template
& other_value
)
3210 switch (other_value
.template_selection
) {
3211 case SPECIFIC_VALUE
:
3212 single_value
= new single_value_struct(*other_value
.single_value
);
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
]);
3226 TTCN_error("Copying an uninitialized/unsupported template of type EMBEDDED PDV.");
3228 set_selection(other_value
);
3231 EMBEDDED_PDV_template::EMBEDDED_PDV_template()
3235 EMBEDDED_PDV_template::EMBEDDED_PDV_template(template_sel other_value
)
3236 : Base_Template(other_value
)
3238 check_single_selection(other_value
);
3241 EMBEDDED_PDV_template::EMBEDDED_PDV_template(const EMBEDDED_PDV
& other_value
)
3243 copy_value(other_value
);
3246 EMBEDDED_PDV_template::EMBEDDED_PDV_template(const OPTIONAL
<EMBEDDED_PDV
>& other_value
)
3248 switch (other_value
.get_selection()) {
3249 case OPTIONAL_PRESENT
:
3250 copy_value((const EMBEDDED_PDV
&)other_value
);
3253 set_selection(OMIT_VALUE
);
3256 TTCN_error("Creating a template of type EMBEDDED PDV from an unbound optional field.");
3260 EMBEDDED_PDV_template::EMBEDDED_PDV_template(const EMBEDDED_PDV_template
& other_value
)
3263 copy_template(other_value
);
3266 EMBEDDED_PDV_template::~EMBEDDED_PDV_template()
3271 EMBEDDED_PDV_template
& EMBEDDED_PDV_template::operator=(template_sel other_value
)
3273 check_single_selection(other_value
);
3275 set_selection(other_value
);
3279 EMBEDDED_PDV_template
& EMBEDDED_PDV_template::operator=(const EMBEDDED_PDV
& other_value
)
3282 copy_value(other_value
);
3286 EMBEDDED_PDV_template
& EMBEDDED_PDV_template::operator=(const OPTIONAL
<EMBEDDED_PDV
>& other_value
)
3289 switch (other_value
.get_selection()) {
3290 case OPTIONAL_PRESENT
:
3291 copy_value((const EMBEDDED_PDV
&)other_value
);
3294 set_selection(OMIT_VALUE
);
3297 TTCN_error("Assignment of an unbound optional field to a template of type EMBEDDED PDV.");
3302 EMBEDDED_PDV_template
& EMBEDDED_PDV_template::operator=(const EMBEDDED_PDV_template
& other_value
)
3304 if (&other_value
!= this) {
3306 copy_template(other_value
);
3311 boolean
EMBEDDED_PDV_template::match(const EMBEDDED_PDV
& other_value
) const
3313 switch (template_selection
) {
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
;
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
;
3333 TTCN_error("Matching an uninitialized/unsupported template of type EMBEDDED PDV.");
3338 EMBEDDED_PDV
EMBEDDED_PDV_template::valueof() const
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();
3350 void EMBEDDED_PDV_template::set_type(template_sel template_type
, unsigned int list_length
)
3352 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3353 TTCN_error("Setting an invalid list for a template of type EMBEDDED PDV.");
3355 set_selection(template_type
);
3356 value_list
.n_values
= list_length
;
3357 value_list
.list_value
= new EMBEDDED_PDV_template
[list_length
];
3360 EMBEDDED_PDV_template
& EMBEDDED_PDV_template::list_item(unsigned int list_index
) const
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
];
3369 EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_template::identification()
3372 return single_value
->field_identification
;
3375 const EMBEDDED_PDV_identification_template
& EMBEDDED_PDV_template::identification() const
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
;
3382 UNIVERSAL_CHARSTRING_template
& EMBEDDED_PDV_template::data__value__descriptor()
3385 return single_value
->field_data__value__descriptor
;
3388 const UNIVERSAL_CHARSTRING_template
& EMBEDDED_PDV_template::data__value__descriptor() const
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
;
3395 OCTETSTRING_template
& EMBEDDED_PDV_template::data__value()
3398 return single_value
->field_data__value
;
3401 const OCTETSTRING_template
& EMBEDDED_PDV_template::data__value() const
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
;
3408 int EMBEDDED_PDV_template::size_of() const
3410 switch (template_selection
)
3412 case SPECIFIC_VALUE
:
3415 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
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
++)
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.");
3431 TTCN_error("Performing sizeof() operation on a template of type EMBEDDED PDV containing omit value.");
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.");
3438 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EMBEDDED PDV.");
3443 void EMBEDDED_PDV_template::log() const
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(" }");
3455 case COMPLEMENTED_LIST
:
3456 TTCN_Logger::log_event_str("complement ");
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();
3464 TTCN_Logger::log_char(')');
3473 void EMBEDDED_PDV_template::log_match(const EMBEDDED_PDV
& match_value
) const
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());
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");
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(" }");
3491 TTCN_Logger::log_event_str(" with ");
3493 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3494 else TTCN_Logger::log_event_str(" unmatched");
3498 void EMBEDDED_PDV_template::encode_text(Text_Buf
& text_buf
) const
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
);
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
);
3518 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EMBEDDED PDV.");
3522 void EMBEDDED_PDV_template::decode_text(Text_Buf
& text_buf
)
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
);
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
);
3545 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EMBEDDED PDV.");
3549 boolean
EMBEDDED_PDV_template::is_present() const
3551 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3552 return !match_omit();
3555 boolean
EMBEDDED_PDV_template::match_omit() const
3557 if (is_ifpresent
) return TRUE
;
3558 switch (template_selection
) {
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
;
3574 #ifndef TITAN_RUNTIME_2
3575 void EMBEDDED_PDV_template::check_restriction(template_res t_res
, const char* t_name
) const
3577 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3578 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3580 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3583 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3584 template_selection
==SPECIFIC_VALUE
)) return;
3587 if (!match_omit()) return;
3592 TTCN_error("Restriction `%s' on template of type %s violated.",
3593 get_res_name(t_res
), t_name
? t_name
: "EMBEDDED PDV");