1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 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 ///////////////////////////////////////////////////////////////////////////////
10 #include "ASN_External.hh"
13 #include "ASN_Null.hh"
14 #include "Bitstring.hh"
17 #include "Octetstring.hh"
18 #include "Universal_charstring.hh"
20 #include "Parameters.h"
21 #include "Param_Types.hh"
28 #include "../common/dbgnew.hh"
31 * This type is used to BER encode/decode the EXTERNAL type.
32 * For details, see X.690 8.18.
37 to do when regenerating:
41 add __SUNPRO_CC ifdefs for single_value_struct
43 delete encode/decode members except for EXTERNAL
47 leave transfer syntax in anonymous namespace
49 delete encode/decode members except for EXTERNAL
50 leave EXTERNAL::BER_encode_TLV() -- written by hand
51 leave EXTERNAL::BER_decode_TLV() -- written by hand
53 replace '@EXTERNAL' with 'EXTERNAL'
55 remove RAW and TEXT enc/dec functions
59 namespace { /* anonymous namespace */
61 class EXTERNALtransfer_encoding
;
62 class EXTERNALtransfer
;
64 class EXTERNALtransfer_encoding
: public Base_Type
{
66 enum union_selection_type
{ UNBOUND_VALUE
= 0, ALT_single__ASN1__type
= 1, ALT_octet__aligned
= 2, ALT_arbitrary
= 3 };
68 union_selection_type union_selection
;
70 ASN_ANY
*field_single__ASN1__type
;
71 OCTETSTRING
*field_octet__aligned
;
72 BITSTRING
*field_arbitrary
;
75 void copy_value(const EXTERNALtransfer_encoding
& other_value
);
78 EXTERNALtransfer_encoding()
79 { union_selection
= UNBOUND_VALUE
; }
80 EXTERNALtransfer_encoding(const EXTERNALtransfer_encoding
& other_value
)
81 : Base_Type(other_value
)
82 { copy_value(other_value
); }
83 ~EXTERNALtransfer_encoding() { clean_up(); }
84 EXTERNALtransfer_encoding
& operator=(const EXTERNALtransfer_encoding
& other_value
);
85 ASN_ANY
& single__ASN1__type();
86 const ASN_ANY
& single__ASN1__type() const;
87 OCTETSTRING
& octet__aligned();
88 const OCTETSTRING
& octet__aligned() const;
89 BITSTRING
& arbitrary();
90 const BITSTRING
& arbitrary() const;
91 inline union_selection_type
get_selection() const { return union_selection
; }
92 #ifdef TITAN_RUNTIME_2
93 void set_param(Module_Param
& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_param() called."); }
94 Module_Param
* get_param(Module_Param_Name
& param_name
) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_param() called."); }
95 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::encode_text() called."); }
96 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::decode_text() called."); }
97 boolean
is_bound() const { return union_selection
!=UNBOUND_VALUE
; }
98 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::is_equal() called."); }
99 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_value() called."); }
100 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::clone() called."); }
101 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_descriptor() called."); }
103 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
104 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
105 int XER_encode(const XERdescriptor_t
& p_td
,
106 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const;
107 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
108 unsigned int flavor
, embed_values_dec_struct_t
*);
110 boolean
BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
);
112 boolean
BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
);
115 /** This class is used to encode/decode the EXTERNAL type.
117 * The sequence type used for encoding/decoding the EXTERNAL type
118 * differs from the associated type of EXTERNAL. See
119 * = X.690 (BER), 8.18.1 ;
120 * = X.691 (PER), 26.1 ;
123 * The actual encoding/decoding is performed by this class and its members.
124 * Data is transferred to/from an object of class EXTERNAL. */
125 class EXTERNALtransfer
: public Base_Type
{
126 OPTIONAL
<OBJID
> field_direct__reference
;
127 OPTIONAL
<INTEGER
> field_indirect__reference
;
128 OPTIONAL
<ObjectDescriptor
> field_data__value__descriptor
;
129 EXTERNALtransfer_encoding field_encoding
;
131 void load(const EXTERNAL
& ex
);
132 inline OPTIONAL
<OBJID
>& direct__reference()
133 {return field_direct__reference
;}
134 inline const OPTIONAL
<OBJID
>& direct__reference() const
135 {return field_direct__reference
;}
136 inline OPTIONAL
<INTEGER
>& indirect__reference()
137 {return field_indirect__reference
;}
138 inline const OPTIONAL
<INTEGER
>& indirect__reference() const
139 {return field_indirect__reference
;}
140 inline OPTIONAL
<ObjectDescriptor
>& data__value__descriptor()
141 {return field_data__value__descriptor
;}
142 inline const OPTIONAL
<ObjectDescriptor
>& data__value__descriptor() const
143 {return field_data__value__descriptor
;}
144 inline EXTERNALtransfer_encoding
& encoding()
145 {return field_encoding
;}
146 inline const EXTERNALtransfer_encoding
& encoding() const
147 {return field_encoding
;}
148 #ifdef TITAN_RUNTIME_2
149 void set_param(Module_Param
& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer::set_param() called."); }
150 Module_Param
* get_param(Module_Param_Name
& param_name
) const { TTCN_error("Internal error: EXTERNALtransfer::get_param() called."); }
151 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer::encode_text() called."); }
152 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer::decode_text() called."); }
153 boolean
is_bound() const { TTCN_error("Internal error: EXTERNALtransfer::is_bound() called."); }
154 boolean
is_value() const { TTCN_error("Internal error: EXTERNALtransfer::is_value() called."); }
155 void clean_up() { TTCN_error("Internal error: EXTERNALtransfer::clean_up() called."); }
156 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer::is_equal() called."); }
157 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer::set_value() called."); }
158 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer::clone() called."); }
159 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer::get_descriptor() called."); }
161 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
162 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
163 int XER_encode(const XERdescriptor_t
& p_td
,
164 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const;
165 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
166 unsigned int flavor
, embed_values_dec_struct_t
*);
169 /** Transform the information from the visible format to the encoding format
171 * Called from EXTERNAL::XER_encode() */
172 void EXTERNALtransfer::load(const EXTERNAL
& ex
)
174 // ALT_syntaxes, ALT_transfer__syntax and ALT_fixed do not appear below.
175 // These are forbidden for the EXTERNAL type.
176 switch(ex
.identification().get_selection()) {
177 case EXTERNAL_identification::ALT_syntax
:
178 field_direct__reference
=ex
.identification().syntax();
180 case EXTERNAL_identification::ALT_context__negotiation
:
181 field_direct__reference
=ex
.identification().context__negotiation().transfer__syntax();
184 field_direct__reference
=OMIT_VALUE
;
187 switch(ex
.identification().get_selection()) {
188 case EXTERNAL_identification::ALT_presentation__context__id
:
189 field_indirect__reference
=ex
.identification().presentation__context__id();
191 case EXTERNAL_identification::ALT_context__negotiation
:
192 field_indirect__reference
=ex
.identification().context__negotiation().presentation__context__id();
195 field_indirect__reference
=OMIT_VALUE
;
198 field_data__value__descriptor
=ex
.data__value__descriptor();
199 field_encoding
.octet__aligned()=ex
.data__value();
202 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_descr_
= { "EXTERNALtransfer.encoding", &CHOICE_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
204 static const ASN_Tag_t EXTERNALtransfer_encoding_single__ASN1__type_tag_
[] = { { ASN_TAG_CONT
, 0u } };
205 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_ber_
= { 1u, EXTERNALtransfer_encoding_single__ASN1__type_tag_
};
206 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_descr_
= { "EXTERNALtransfer.encoding.single-ASN1-type", &EXTERNALtransfer_encoding_single__ASN1__type_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
208 static const ASN_Tag_t EXTERNALtransfer_encoding_octet__aligned_tag_
[] = { { ASN_TAG_CONT
, 1u } };
209 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_octet__aligned_ber_
= { 1u, EXTERNALtransfer_encoding_octet__aligned_tag_
};
210 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_octet__aligned_descr_
= { "EXTERNALtransfer.encoding.octet-aligned", &EXTERNALtransfer_encoding_octet__aligned_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
212 static const ASN_Tag_t EXTERNALtransfer_encoding_arbitrary_tag_
[] = { { ASN_TAG_CONT
, 2u } };
213 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_arbitrary_ber_
= { 1u, EXTERNALtransfer_encoding_arbitrary_tag_
};
214 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_arbitrary_descr_
= { "EXTERNALtransfer.encoding.arbitrary", &EXTERNALtransfer_encoding_arbitrary_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
216 /* Member functions of C++ classes */
218 void EXTERNALtransfer_encoding::clean_up()
220 switch (union_selection
) {
221 case ALT_single__ASN1__type
:
222 delete field_single__ASN1__type
;
224 case ALT_octet__aligned
:
225 delete field_octet__aligned
;
228 delete field_arbitrary
;
233 union_selection
= UNBOUND_VALUE
;
236 void EXTERNALtransfer_encoding::copy_value(const EXTERNALtransfer_encoding
& other_value
)
238 switch (other_value
.union_selection
) {
239 case ALT_single__ASN1__type
:
240 field_single__ASN1__type
= new ASN_ANY(*other_value
.field_single__ASN1__type
);
242 case ALT_octet__aligned
:
243 field_octet__aligned
= new OCTETSTRING(*other_value
.field_octet__aligned
);
246 field_arbitrary
= new BITSTRING(*other_value
.field_arbitrary
);
249 TTCN_error("Assignment of an unbound union value of type EXTERNALtransfer.encoding.");
251 union_selection
= other_value
.union_selection
;
254 EXTERNALtransfer_encoding
& EXTERNALtransfer_encoding::operator=(const EXTERNALtransfer_encoding
& other_value
)
256 if(this != &other_value
) {
258 copy_value(other_value
);
263 ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type()
265 if (union_selection
!= ALT_single__ASN1__type
) {
267 field_single__ASN1__type
= new ASN_ANY
;
268 union_selection
= ALT_single__ASN1__type
;
270 return *field_single__ASN1__type
;
273 const ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type() const
275 if (union_selection
!= ALT_single__ASN1__type
) TTCN_error("Using non-selected field single-ASN1-type in a value of union type EXTERNALtransfer.encoding.");
276 return *field_single__ASN1__type
;
279 OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned()
281 if (union_selection
!= ALT_octet__aligned
) {
283 field_octet__aligned
= new OCTETSTRING
;
284 union_selection
= ALT_octet__aligned
;
286 return *field_octet__aligned
;
289 const OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned() const
291 if (union_selection
!= ALT_octet__aligned
) TTCN_error("Using non-selected field octet-aligned in a value of union type EXTERNALtransfer.encoding.");
292 return *field_octet__aligned
;
295 BITSTRING
& EXTERNALtransfer_encoding::arbitrary()
297 if (union_selection
!= ALT_arbitrary
) {
299 field_arbitrary
= new BITSTRING
;
300 union_selection
= ALT_arbitrary
;
302 return *field_arbitrary
;
305 const BITSTRING
& EXTERNALtransfer_encoding::arbitrary() const
307 if (union_selection
!= ALT_arbitrary
) TTCN_error("Using non-selected field arbitrary in a value of union type EXTERNALtransfer.encoding.");
308 return *field_arbitrary
;
311 ASN_BER_TLV_t
* EXTERNALtransfer_encoding::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
314 ASN_BER_TLV_t
*new_tlv
;
315 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
316 TTCN_EncDec_ErrorContext ec_1
;
317 switch (union_selection
) {
318 case ALT_single__ASN1__type
:
319 ec_1
.set_msg("single-ASN1-type': ");
320 new_tlv
=field_single__ASN1__type
->BER_encode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_coding
);
322 case ALT_octet__aligned
:
323 ec_1
.set_msg("octet-aligned': ");
324 new_tlv
=field_octet__aligned
->BER_encode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_coding
);
327 ec_1
.set_msg("arbitrary': ");
328 new_tlv
=field_arbitrary
->BER_encode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, p_coding
);
331 new_tlv
=BER_encode_chk_bound(FALSE
);
334 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
338 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
341 boolean
EXTERNALtransfer_encoding::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
344 union_selection
=ALT_single__ASN1__type
;
345 field_single__ASN1__type
=new ASN_ANY
;
346 if(field_single__ASN1__type
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_tlv
))
348 delete field_single__ASN1__type
;
349 union_selection
=ALT_octet__aligned
;
350 field_octet__aligned
=new OCTETSTRING
;
351 if(field_octet__aligned
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_tlv
))
353 delete field_octet__aligned
;
354 union_selection
=ALT_arbitrary
;
355 field_arbitrary
=new BITSTRING
;
356 if(field_arbitrary
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_arbitrary_descr_
, p_tlv
))
358 delete field_arbitrary
;
359 union_selection
=UNBOUND_VALUE
;
363 boolean
EXTERNALtransfer_encoding::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
365 if(p_td
.ber
->n_tags
==0) {
366 EXTERNALtransfer_encoding tmp_type
;
367 return tmp_type
.BER_decode_set_selection(p_tlv
);
369 else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
372 boolean
EXTERNALtransfer_encoding::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
375 ASN_BER_TLV_t stripped_tlv
;
376 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
377 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer.encoding' type: ");
378 ASN_BER_TLV_t tmp_tlv
;
379 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
))
381 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
382 TTCN_EncDec_ErrorContext ec_2
;
383 switch (union_selection
) {
384 case ALT_single__ASN1__type
:
385 ec_2
.set_msg("single-ASN1-type': ");
386 field_single__ASN1__type
->BER_decode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, tmp_tlv
, L_form
);
388 case ALT_octet__aligned
:
389 ec_2
.set_msg("octet-aligned': ");
390 field_octet__aligned
->BER_decode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, tmp_tlv
, L_form
);
393 ec_2
.set_msg("arbitrary': ");
394 field_arbitrary
->BER_decode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, tmp_tlv
, L_form
);
402 int EXTERNALtransfer_encoding::XER_encode(const XERdescriptor_t
& p_td
,
403 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
405 int indenting
= !is_canonical(flavor
);
406 int exer
= is_exer(flavor
);
407 int encoded_length
=(int)p_buf
.get_len();
408 if (indenting
) do_indent(p_buf
, indent
);
410 if (exer
) write_ns_prefix(p_td
, p_buf
);
411 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
414 switch (union_selection
) {
415 case ALT_single__ASN1__type
:
416 field_single__ASN1__type
->XER_encode(EXTERNAL_encoding_singleASN_xer_
, p_buf
, flavor
, indent
, 0);
418 case ALT_octet__aligned
:
419 field_octet__aligned
->XER_encode(EXTERNAL_encoding_octet_aligned_xer_
, p_buf
, flavor
, indent
, 0);
422 field_arbitrary
->XER_encode(EXTERNAL_encoding_arbitrary_xer_
, p_buf
, flavor
, indent
, 0);
425 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND
,
426 "Encoding an unbound value");
429 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
430 // TODO something at all ?
434 if (indenting
) do_indent(p_buf
, --indent
);
437 if (exer
) write_ns_prefix(p_td
, p_buf
);
438 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
439 return (int)p_buf
.get_len() - encoded_length
;
442 int EXTERNALtransfer_encoding::XER_decode(const XERdescriptor_t
& p_td
,
443 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
445 int exer
= is_exer(flavor
);
446 int success
= reader
.Ok(), type
, depth
= -1;
447 for (; success
==1; success
= reader
.Read()) {
448 type
= reader
.NodeType();
449 if (type
== XML_READER_TYPE_ELEMENT
) {
450 verify_name(reader
, p_td
, exer
);
451 depth
= reader
.Depth();
456 const char * name
= 0;
457 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
458 type
= reader
.NodeType();
459 if (XML_READER_TYPE_ELEMENT
== type
) break;
460 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
462 name
= (const char*)reader
.Name();
465 case 's': // single-ASN1-type
466 single__ASN1__type().XER_decode(EXTERNAL_encoding_singleASN_xer_
, reader
, flavor
, 0);
469 case 'o': // octet-aligned
470 octet__aligned().XER_decode(EXTERNAL_encoding_octet_aligned_xer_
, reader
, flavor
, 0);
473 case 'a': // arbitrary
474 arbitrary().XER_decode(EXTERNAL_encoding_arbitrary_xer_
, reader
, flavor
, 0);
478 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
479 "Doh!"); // FIXME error method and text
483 for (success
= reader
.Read(); success
==1; success
= reader
.Read()) {
484 type
= reader
.NodeType();
485 if (XML_READER_TYPE_END_ELEMENT
== type
) {
486 verify_end(reader
, p_td
, depth
, exer
);
487 reader
.Read(); // one last time
492 return 0; // FIXME return value
495 /******************** EXTERNALtransfer class ********************/
497 ASN_BER_TLV_t
* EXTERNALtransfer::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
500 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
501 TTCN_EncDec_ErrorContext
ec_0("Component '");
502 TTCN_EncDec_ErrorContext ec_1
;
503 ec_1
.set_msg("direct-reference': ");
504 new_tlv
->add_TLV(field_direct__reference
.BER_encode_TLV(OBJID_descr_
, p_coding
));
505 ec_1
.set_msg("indirect-reference': ");
506 new_tlv
->add_TLV(field_indirect__reference
.BER_encode_TLV(INTEGER_descr_
, p_coding
));
507 ec_1
.set_msg("data-value-descriptor': ");
508 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(ObjectDescriptor_descr_
, p_coding
));
509 ec_1
.set_msg("encoding': ");
510 new_tlv
->add_TLV(field_encoding
.BER_encode_TLV(EXTERNALtransfer_encoding_descr_
, p_coding
));
511 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
515 boolean
EXTERNALtransfer::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
518 ASN_BER_TLV_t stripped_tlv
;
519 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
520 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer' type: ");
521 stripped_tlv
.chk_constructed_flag(TRUE
);
523 ASN_BER_TLV_t tmp_tlv
;
524 boolean tlv_present
=FALSE
;
526 TTCN_EncDec_ErrorContext
ec_1("Component '");
527 TTCN_EncDec_ErrorContext ec_2
;
528 ec_2
.set_msg("direct-reference': ");
529 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
530 if(!tlv_present
) field_direct__reference
=OMIT_VALUE
;
532 field_direct__reference
.BER_decode_TLV(OBJID_descr_
, tmp_tlv
, L_form
);
533 if(field_direct__reference
.ispresent()) tlv_present
=FALSE
;
535 ec_2
.set_msg("indirect-reference': ");
536 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
537 if(!tlv_present
) field_indirect__reference
=OMIT_VALUE
;
539 field_indirect__reference
.BER_decode_TLV(INTEGER_descr_
, tmp_tlv
, L_form
);
540 if(field_indirect__reference
.ispresent()) tlv_present
=FALSE
;
542 ec_2
.set_msg("data-value-descriptor': ");
543 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
544 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
546 field_data__value__descriptor
.BER_decode_TLV(ObjectDescriptor_descr_
, tmp_tlv
, L_form
);
547 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
549 ec_2
.set_msg("encoding': ");
550 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
551 if(!tlv_present
) return FALSE
;
552 field_encoding
.BER_decode_TLV(EXTERNALtransfer_encoding_descr_
, tmp_tlv
, L_form
);
555 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
559 int EXTERNALtransfer::XER_encode(const XERdescriptor_t
& p_td
,
560 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
562 int indenting
= !is_canonical(flavor
);
563 int exer
= is_exer(flavor
);
564 int encoded_length
=(int)p_buf
.get_len();
565 if (indenting
) do_indent(p_buf
, indent
);
567 if (exer
) write_ns_prefix(p_td
, p_buf
);
568 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
571 field_direct__reference
.XER_encode(EXTERNAL_direct_reference_xer_
, p_buf
, flavor
, indent
, 0);
572 field_indirect__reference
.XER_encode(EXTERNAL_indirect_reference_xer_
, p_buf
, flavor
, indent
, 0);
573 field_data__value__descriptor
.XER_encode(EXTERNAL_data_value_descriptor_xer_
, p_buf
, flavor
, indent
, 0);
574 field_encoding
.XER_encode(EXTERNAL_encoding_xer_
, p_buf
, flavor
, indent
, 0);
576 if (indenting
) do_indent(p_buf
, --indent
);
579 if (exer
) write_ns_prefix(p_td
, p_buf
);
580 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
581 return (int)p_buf
.get_len() - encoded_length
;
584 int EXTERNALtransfer::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
585 unsigned int flavor
, embed_values_dec_struct_t
*)
587 int exer
= is_exer(flavor
);
588 int success
= reader
.Ok(), depth
= -1;
589 for (; success
== 1; success
= reader
.Read()) {
590 int type
= reader
.NodeType();
591 if (XML_READER_TYPE_ELEMENT
== type
) {
592 verify_name(reader
, p_td
, exer
);
593 depth
= reader
.Depth();
599 field_direct__reference
.XER_decode(EXTERNAL_direct_reference_xer_
, reader
, flavor
, 0);
600 field_indirect__reference
.XER_decode(EXTERNAL_indirect_reference_xer_
, reader
, flavor
, 0);
601 field_data__value__descriptor
.XER_decode(EXTERNAL_data_value_descriptor_xer_
, reader
, flavor
, 0);
602 field_encoding
.XER_decode(EXTERNAL_encoding_xer_
, reader
, flavor
, 0);
604 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
605 int type
= reader
.NodeType();
606 if (XML_READER_TYPE_END_ELEMENT
== type
) {
607 verify_end(reader
, p_td
, depth
, exer
);
608 reader
.Read(); // one more time
612 return 1; // decode successful
614 } // end of anonymous namespace
617 * And this is the EXTERNAL type stuff.
621 * This is written by hand, do not delete it! :)
623 ASN_BER_TLV_t
* EXTERNAL::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
625 EXTERNALtransfer v_tmpmfr
;
626 v_tmpmfr
.load(*this);
627 return v_tmpmfr
.BER_encode_TLV(p_td
, p_coding
);
630 /** Load information from an EXTERNALtransfer
632 * @param x pointer to an EXTERNALtransfer. It is of type void* because
633 * <anonymous-namespace>::EXTERNALtransfer can not appear in the header.
635 * Called by XER_decode() */
636 void EXTERNAL::transfer(void *x
)
638 EXTERNALtransfer
& v_tmpmfr
= *(EXTERNALtransfer
*)x
;
639 if (v_tmpmfr
.direct__reference().ispresent()) {
640 if (v_tmpmfr
.indirect__reference().ispresent()) {
641 EXTERNAL_identification_context__negotiation
& v_tmpjsz
=
642 field_identification
.context__negotiation();
643 v_tmpjsz
.presentation__context__id() = v_tmpmfr
.indirect__reference()();
644 v_tmpjsz
.transfer__syntax() = v_tmpmfr
.direct__reference()();
646 field_identification
.syntax() = v_tmpmfr
.direct__reference()();
649 if (v_tmpmfr
.indirect__reference().ispresent()) {
650 field_identification
.presentation__context__id() =
651 v_tmpmfr
.indirect__reference()();
653 TTCN_EncDec_ErrorContext::warning("Neither direct-reference nor "
654 "indirect-reference is present.");
657 switch (field_identification
.get_selection()) {
658 case EXTERNAL_identification::ALT_syntaxes
:
659 case EXTERNAL_identification::ALT_transfer__syntax
:
660 case EXTERNAL_identification::ALT_fixed
:
661 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
662 "EXTERNAL type does not allow the syntaxes, transfer-syntax or fixed");
666 break; // rest are OK
669 field_data__value__descriptor
= v_tmpmfr
.data__value__descriptor();
670 const EXTERNALtransfer_encoding
& v_tmpjsz
= v_tmpmfr
.encoding();
671 switch (v_tmpjsz
.get_selection()) {
672 case EXTERNALtransfer_encoding::ALT_single__ASN1__type
:
673 field_data__value
= v_tmpjsz
.single__ASN1__type();
675 case EXTERNALtransfer_encoding::ALT_octet__aligned
:
676 field_data__value
= v_tmpjsz
.octet__aligned();
678 case EXTERNALtransfer_encoding::ALT_arbitrary
:
679 field_data__value
= bit2oct(v_tmpjsz
.arbitrary());
682 TTCN_EncDec_ErrorContext::error_internal("Unknown selection for field "
683 "`encoding' in EXTERNAL type.");
688 * This is written by hand, do not delete it! :)
690 boolean
EXTERNAL::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
692 EXTERNALtransfer v_tmpmfr
;
693 if(!v_tmpmfr
.BER_decode_TLV(p_td
, p_tlv
, L_form
))
699 int EXTERNAL::XER_encode(const XERdescriptor_t
& p_td
,
700 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
703 TTCN_EncDec_ErrorContext::error
704 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
706 EXTERNALtransfer xfer
;
708 return xfer
.XER_encode(p_td
, p_buf
, flavor
, indent
, 0);
711 int EXTERNAL::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
712 unsigned int flavor
, embed_values_dec_struct_t
*)
714 EXTERNALtransfer xfer
;
715 xfer
.XER_decode(p_td
, reader
, flavor
, 0);
717 return 1; // decode successful
720 /* generated stuff */
722 void EXTERNAL_identification::clean_up()
724 switch (union_selection
) {
726 delete field_syntaxes
;
731 case ALT_presentation__context__id
:
732 delete field_presentation__context__id
;
734 case ALT_context__negotiation
:
735 delete field_context__negotiation
;
737 case ALT_transfer__syntax
:
738 delete field_transfer__syntax
;
746 union_selection
= UNBOUND_VALUE
;
749 void EXTERNAL_identification::copy_value(const EXTERNAL_identification
& other_value
)
751 switch (other_value
.union_selection
) {
753 field_syntaxes
= new EXTERNAL_identification_syntaxes(*other_value
.field_syntaxes
);
756 field_syntax
= new OBJID(*other_value
.field_syntax
);
758 case ALT_presentation__context__id
:
759 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
761 case ALT_context__negotiation
:
762 field_context__negotiation
= new EXTERNAL_identification_context__negotiation(*other_value
.field_context__negotiation
);
764 case ALT_transfer__syntax
:
765 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
768 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
771 TTCN_error("Assignment of an unbound union value of type EXTERNAL.identification.");
773 union_selection
= other_value
.union_selection
;
776 EXTERNAL_identification::EXTERNAL_identification()
778 union_selection
= UNBOUND_VALUE
;
781 EXTERNAL_identification::EXTERNAL_identification(const EXTERNAL_identification
& other_value
)
782 : Base_Type(other_value
)
784 copy_value(other_value
);
787 EXTERNAL_identification::~EXTERNAL_identification()
792 EXTERNAL_identification
& EXTERNAL_identification::operator=(const EXTERNAL_identification
& other_value
)
794 if (this != &other_value
) {
796 copy_value(other_value
);
801 boolean
EXTERNAL_identification::operator==(const EXTERNAL_identification
& other_value
) const
803 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type EXTERNAL.identification.");
804 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type EXTERNAL.identification.");
805 if (union_selection
!= other_value
.union_selection
) return FALSE
;
806 switch (union_selection
) {
808 return *field_syntaxes
== *other_value
.field_syntaxes
;
810 return *field_syntax
== *other_value
.field_syntax
;
811 case ALT_presentation__context__id
:
812 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
813 case ALT_context__negotiation
:
814 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
815 case ALT_transfer__syntax
:
816 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
818 return *field_fixed
== *other_value
.field_fixed
;
824 EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes()
826 if (union_selection
!= ALT_syntaxes
) {
828 field_syntaxes
= new EXTERNAL_identification_syntaxes
;
829 union_selection
= ALT_syntaxes
;
831 return *field_syntaxes
;
834 const EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes() const
836 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type EXTERNAL.identification.");
837 return *field_syntaxes
;
840 OBJID
& EXTERNAL_identification::syntax()
842 if (union_selection
!= ALT_syntax
) {
844 field_syntax
= new OBJID
;
845 union_selection
= ALT_syntax
;
847 return *field_syntax
;
850 const OBJID
& EXTERNAL_identification::syntax() const
852 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type EXTERNAL.identification.");
853 return *field_syntax
;
856 INTEGER
& EXTERNAL_identification::presentation__context__id()
858 if (union_selection
!= ALT_presentation__context__id
) {
860 field_presentation__context__id
= new INTEGER
;
861 union_selection
= ALT_presentation__context__id
;
863 return *field_presentation__context__id
;
866 const INTEGER
& EXTERNAL_identification::presentation__context__id() const
868 if (union_selection
!= ALT_presentation__context__id
) TTCN_error("Using non-selected field presentation_context_id in a value of union type EXTERNAL.identification.");
869 return *field_presentation__context__id
;
872 EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation()
874 if (union_selection
!= ALT_context__negotiation
) {
876 field_context__negotiation
= new EXTERNAL_identification_context__negotiation
;
877 union_selection
= ALT_context__negotiation
;
879 return *field_context__negotiation
;
882 const EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation() const
884 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type EXTERNAL.identification.");
885 return *field_context__negotiation
;
888 OBJID
& EXTERNAL_identification::transfer__syntax()
890 if (union_selection
!= ALT_transfer__syntax
) {
892 field_transfer__syntax
= new OBJID
;
893 union_selection
= ALT_transfer__syntax
;
895 return *field_transfer__syntax
;
898 const OBJID
& EXTERNAL_identification::transfer__syntax() const
900 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type EXTERNAL.identification.");
901 return *field_transfer__syntax
;
904 ASN_NULL
& EXTERNAL_identification::fixed()
906 if (union_selection
!= ALT_fixed
) {
908 field_fixed
= new ASN_NULL
;
909 union_selection
= ALT_fixed
;
914 const ASN_NULL
& EXTERNAL_identification::fixed() const
916 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type EXTERNAL.identification.");
920 boolean
EXTERNAL_identification::ischosen(union_selection_type checked_selection
) const
922 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
923 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type EXTERNAL.identification.");
924 return union_selection
== checked_selection
;
927 boolean
EXTERNAL_identification::is_value() const
929 switch (union_selection
) {
931 return field_syntaxes
->is_value();
933 return field_syntax
->is_value();
934 case ALT_presentation__context__id
:
935 return field_presentation__context__id
->is_value();
936 case ALT_context__negotiation
:
937 return field_context__negotiation
->is_value();
938 case ALT_transfer__syntax
:
939 return field_transfer__syntax
->is_value();
941 return field_fixed
->is_value();
947 void EXTERNAL_identification::log() const
949 switch (union_selection
) {
951 TTCN_Logger::log_event_str("{ syntaxes := ");
952 field_syntaxes
->log();
953 TTCN_Logger::log_event_str(" }");
956 TTCN_Logger::log_event_str("{ syntax := ");
958 TTCN_Logger::log_event_str(" }");
960 case ALT_presentation__context__id
:
961 TTCN_Logger::log_event_str("{ presentation_context_id := ");
962 field_presentation__context__id
->log();
963 TTCN_Logger::log_event_str(" }");
965 case ALT_context__negotiation
:
966 TTCN_Logger::log_event_str("{ context_negotiation := ");
967 field_context__negotiation
->log();
968 TTCN_Logger::log_event_str(" }");
970 case ALT_transfer__syntax
:
971 TTCN_Logger::log_event_str("{ transfer_syntax := ");
972 field_transfer__syntax
->log();
973 TTCN_Logger::log_event_str(" }");
976 TTCN_Logger::log_event_str("{ fixed := ");
978 TTCN_Logger::log_event_str(" }");
981 TTCN_Logger::log_event_str("<unbound>");
986 void EXTERNAL_identification::set_param(Module_Param
& param
) {
987 param
.basic_check(Module_Param::BC_VALUE
, "union value");
988 Module_Param_Ptr mp
= ¶m
;
989 if (param
.get_type() == Module_Param::MP_Reference
) {
990 mp
= param
.get_referenced_param();
992 if (mp
->get_type()==Module_Param::MP_Value_List
&& mp
->get_size()==0) return;
993 if (mp
->get_type()!=Module_Param::MP_Assignment_List
) {
994 param
.error("union value with field name was expected");
996 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
997 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
998 syntaxes().set_param(*mp_last
);
1001 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
1002 syntax().set_param(*mp_last
);
1005 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
1006 presentation__context__id().set_param(*mp_last
);
1009 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1010 context__negotiation().set_param(*mp_last
);
1013 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1014 transfer__syntax().set_param(*mp_last
);
1017 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1018 fixed().set_param(*mp_last
);
1021 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1024 Module_Param
* EXTERNAL_identification::get_param(Module_Param_Name
& param_name
) const
1027 return new Module_Param_Unbound();
1029 Module_Param
* mp_field
= NULL
;
1031 switch(get_selection()) {
1033 mp_field
= field_syntaxes
->get_param(param_name
);
1034 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
1037 mp_field
= field_syntax
->get_param(param_name
);
1038 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
1040 case ALT_presentation__context__id
:
1041 mp_field
= field_presentation__context__id
->get_param(param_name
);
1042 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
1044 case ALT_context__negotiation
:
1045 mp_field
= field_context__negotiation
->get_param(param_name
);
1046 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
1048 case ALT_transfer__syntax
:
1049 mp_field
= field_transfer__syntax
->get_param(param_name
);
1050 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
1053 mp_field
= field_fixed
->get_param(param_name
);
1054 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
1059 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
1060 mp
->add_elem(mp_field
);
1064 void EXTERNAL_identification_template::set_param(Module_Param
& param
)
1066 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
1067 Module_Param_Ptr mp
= ¶m
;
1068 if (param
.get_type() == Module_Param::MP_Reference
) {
1069 mp
= param
.get_referenced_param();
1071 switch (mp
->get_type()) {
1072 case Module_Param::MP_Omit
:
1075 case Module_Param::MP_Any
:
1078 case Module_Param::MP_AnyOrNone
:
1079 *this = ANY_OR_OMIT
;
1081 case Module_Param::MP_List_Template
:
1082 case Module_Param::MP_ComplementList_Template
: {
1083 EXTERNAL_identification_template temp
;
1084 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
1085 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
1086 for (size_t i
=0; i
<mp
->get_size(); i
++) {
1087 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
1091 case Module_Param::MP_Value_List
:
1092 if (mp
->get_size()==0) break;
1093 param
.type_error("union template", "EXTERNAL.identification");
1095 case Module_Param::MP_Assignment_List
: {
1096 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
1097 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
1098 syntaxes().set_param(*mp_last
);
1101 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
1102 syntax().set_param(*mp_last
);
1105 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
1106 presentation__context__id().set_param(*mp_last
);
1109 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1110 context__negotiation().set_param(*mp_last
);
1113 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1114 transfer__syntax().set_param(*mp_last
);
1117 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1118 fixed().set_param(*mp_last
);
1121 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1124 param
.type_error("union template", "EXTERNAL.identification");
1126 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
1129 Module_Param
* EXTERNAL_identification_template::get_param(Module_Param_Name
& param_name
) const
1131 Module_Param
* mp
= NULL
;
1132 switch (template_selection
) {
1133 case UNINITIALIZED_TEMPLATE
:
1134 mp
= new Module_Param_Unbound();
1137 mp
= new Module_Param_Omit();
1140 mp
= new Module_Param_Any();
1143 mp
= new Module_Param_AnyOrNone();
1145 case SPECIFIC_VALUE
: {
1146 Module_Param
* mp_field
= NULL
;
1147 switch(single_value
.union_selection
) {
1148 case EXTERNAL_identification::ALT_syntaxes
:
1149 mp_field
= single_value
.field_syntaxes
->get_param(param_name
);
1150 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
1152 case EXTERNAL_identification::ALT_syntax
:
1153 mp_field
= single_value
.field_syntax
->get_param(param_name
);
1154 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
1156 case EXTERNAL_identification::ALT_presentation__context__id
:
1157 mp_field
= single_value
.field_presentation__context__id
->get_param(param_name
);
1158 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
1160 case EXTERNAL_identification::ALT_context__negotiation
:
1161 mp_field
= single_value
.field_context__negotiation
->get_param(param_name
);
1162 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
1164 case EXTERNAL_identification::ALT_transfer__syntax
:
1165 mp_field
= single_value
.field_transfer__syntax
->get_param(param_name
);
1166 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
1168 case EXTERNAL_identification::ALT_fixed
:
1169 mp_field
= single_value
.field_fixed
->get_param(param_name
);
1170 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
1175 mp
= new Module_Param_Assignment_List();
1176 mp
->add_elem(mp_field
);
1179 case COMPLEMENTED_LIST
: {
1180 if (template_selection
== VALUE_LIST
) {
1181 mp
= new Module_Param_List_Template();
1184 mp
= new Module_Param_ComplementList_Template();
1186 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
1187 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
1194 mp
->set_ifpresent();
1199 void EXTERNAL_identification::encode_text(Text_Buf
& text_buf
) const
1201 text_buf
.push_int(union_selection
);
1202 switch (union_selection
) {
1204 field_syntaxes
->encode_text(text_buf
);
1207 field_syntax
->encode_text(text_buf
);
1209 case ALT_presentation__context__id
:
1210 field_presentation__context__id
->encode_text(text_buf
);
1212 case ALT_context__negotiation
:
1213 field_context__negotiation
->encode_text(text_buf
);
1215 case ALT_transfer__syntax
:
1216 field_transfer__syntax
->encode_text(text_buf
);
1219 field_fixed
->encode_text(text_buf
);
1222 TTCN_error("Text encoder: Encoding an unbound value of union type EXTERNAL.identification.");
1226 void EXTERNAL_identification::decode_text(Text_Buf
& text_buf
)
1228 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
1230 syntaxes().decode_text(text_buf
);
1233 syntax().decode_text(text_buf
);
1235 case ALT_presentation__context__id
:
1236 presentation__context__id().decode_text(text_buf
);
1238 case ALT_context__negotiation
:
1239 context__negotiation().decode_text(text_buf
);
1241 case ALT_transfer__syntax
:
1242 transfer__syntax().decode_text(text_buf
);
1245 fixed().decode_text(text_buf
);
1248 TTCN_error("Text decoder: Unrecognized union selector was received for type EXTERNAL.identification.");
1253 void EXTERNAL_identification_template::clean_up()
1255 switch (template_selection
) {
1256 case SPECIFIC_VALUE
:
1257 switch (single_value
.union_selection
) {
1258 case EXTERNAL_identification::ALT_syntaxes
:
1259 delete single_value
.field_syntaxes
;
1261 case EXTERNAL_identification::ALT_syntax
:
1262 delete single_value
.field_syntax
;
1264 case EXTERNAL_identification::ALT_presentation__context__id
:
1265 delete single_value
.field_presentation__context__id
;
1267 case EXTERNAL_identification::ALT_context__negotiation
:
1268 delete single_value
.field_context__negotiation
;
1270 case EXTERNAL_identification::ALT_transfer__syntax
:
1271 delete single_value
.field_transfer__syntax
;
1273 case EXTERNAL_identification::ALT_fixed
:
1274 delete single_value
.field_fixed
;
1281 case COMPLEMENTED_LIST
:
1282 delete [] value_list
.list_value
;
1287 template_selection
= UNINITIALIZED_TEMPLATE
;
1290 void EXTERNAL_identification_template::copy_value(const EXTERNAL_identification
& other_value
)
1292 single_value
.union_selection
= other_value
.get_selection();
1293 switch (single_value
.union_selection
) {
1294 case EXTERNAL_identification::ALT_syntaxes
:
1295 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(other_value
.syntaxes());
1297 case EXTERNAL_identification::ALT_syntax
:
1298 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
1300 case EXTERNAL_identification::ALT_presentation__context__id
:
1301 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
1303 case EXTERNAL_identification::ALT_context__negotiation
:
1304 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(other_value
.context__negotiation());
1306 case EXTERNAL_identification::ALT_transfer__syntax
:
1307 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
1309 case EXTERNAL_identification::ALT_fixed
:
1310 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
1313 TTCN_error("Initializing a template with an unbound value of type EXTERNAL.identification.");
1315 set_selection(SPECIFIC_VALUE
);
1318 void EXTERNAL_identification_template::copy_template(const EXTERNAL_identification_template
& other_value
)
1320 switch (other_value
.template_selection
) {
1321 case SPECIFIC_VALUE
:
1322 single_value
.union_selection
= other_value
.single_value
.union_selection
;
1323 switch (single_value
.union_selection
) {
1324 case EXTERNAL_identification::ALT_syntaxes
:
1325 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
1327 case EXTERNAL_identification::ALT_syntax
:
1328 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
1330 case EXTERNAL_identification::ALT_presentation__context__id
:
1331 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
1333 case EXTERNAL_identification::ALT_context__negotiation
:
1334 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
1336 case EXTERNAL_identification::ALT_transfer__syntax
:
1337 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
1339 case EXTERNAL_identification::ALT_fixed
:
1340 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
1343 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EXTERNAL.identification.");
1351 case COMPLEMENTED_LIST
:
1352 value_list
.n_values
= other_value
.value_list
.n_values
;
1353 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1354 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1355 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1358 TTCN_error("Copying an uninitialized template of union type EXTERNAL.identification.");
1360 set_selection(other_value
);
1363 EXTERNAL_identification_template::EXTERNAL_identification_template()
1367 EXTERNAL_identification_template::EXTERNAL_identification_template(template_sel other_value
)
1368 : Base_Template(other_value
)
1370 check_single_selection(other_value
);
1373 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification
& other_value
)
1375 copy_value(other_value
);
1378 EXTERNAL_identification_template::EXTERNAL_identification_template(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1380 switch (other_value
.get_selection()) {
1381 case OPTIONAL_PRESENT
:
1382 copy_value((const EXTERNAL_identification
&)other_value
);
1385 set_selection(OMIT_VALUE
);
1388 TTCN_error("Creating a template of union type EXTERNAL.identification from an unbound optional field.");
1392 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification_template
& other_value
)
1395 copy_template(other_value
);
1398 EXTERNAL_identification_template::~EXTERNAL_identification_template()
1403 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(template_sel other_value
)
1405 check_single_selection(other_value
);
1407 set_selection(other_value
);
1411 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification
& other_value
)
1414 copy_value(other_value
);
1418 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1421 switch (other_value
.get_selection()) {
1422 case OPTIONAL_PRESENT
:
1423 copy_value((const EXTERNAL_identification
&)other_value
);
1426 set_selection(OMIT_VALUE
);
1429 TTCN_error("Assignment of an unbound optional field to a template of union type EXTERNAL.identification.");
1434 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification_template
& other_value
)
1436 if (&other_value
!= this) {
1438 copy_template(other_value
);
1443 boolean
EXTERNAL_identification_template::match(const EXTERNAL_identification
& other_value
,
1444 boolean
/* legacy */) const
1446 switch (template_selection
) {
1452 case SPECIFIC_VALUE
:
1454 EXTERNAL_identification::union_selection_type value_selection
= other_value
.get_selection();
1455 if (value_selection
== EXTERNAL_identification::UNBOUND_VALUE
) return FALSE
;
1456 if (value_selection
!= single_value
.union_selection
) return FALSE
;
1457 switch (value_selection
) {
1458 case EXTERNAL_identification::ALT_syntaxes
:
1459 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
1460 case EXTERNAL_identification::ALT_syntax
:
1461 return single_value
.field_syntax
->match(other_value
.syntax());
1462 case EXTERNAL_identification::ALT_presentation__context__id
:
1463 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
1464 case EXTERNAL_identification::ALT_context__negotiation
:
1465 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
1466 case EXTERNAL_identification::ALT_transfer__syntax
:
1467 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
1468 case EXTERNAL_identification::ALT_fixed
:
1469 return single_value
.field_fixed
->match(other_value
.fixed());
1471 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EXTERNAL.identification.");
1474 break; // should never get here
1476 case COMPLEMENTED_LIST
:
1477 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1478 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1479 return template_selection
== COMPLEMENTED_LIST
;
1481 TTCN_error ("Matching an uninitialized template of union type EXTERNAL.identification.");
1486 EXTERNAL_identification
EXTERNAL_identification_template::valueof() const
1488 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1489 TTCN_error("Performing valueof or send operation on a non-specific template of union type EXTERNAL.identification.");
1490 EXTERNAL_identification ret_val
;
1491 switch (single_value
.union_selection
) {
1492 case EXTERNAL_identification::ALT_syntaxes
:
1493 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
1495 case EXTERNAL_identification::ALT_syntax
:
1496 ret_val
.syntax() = single_value
.field_syntax
->valueof();
1498 case EXTERNAL_identification::ALT_presentation__context__id
:
1499 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
1501 case EXTERNAL_identification::ALT_context__negotiation
:
1502 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
1504 case EXTERNAL_identification::ALT_transfer__syntax
:
1505 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1507 case EXTERNAL_identification::ALT_fixed
:
1508 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1511 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EXTERNAL.identification.");
1516 EXTERNAL_identification_template
& EXTERNAL_identification_template::list_item(unsigned int list_index
) const
1518 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 EXTERNAL.identification.");
1519 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type EXTERNAL.identification.");
1520 return value_list
.list_value
[list_index
];
1522 void EXTERNAL_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1524 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
) TTCN_error ("Internal error: Setting an invalid list for a template of union type EXTERNAL.identification.");
1526 set_selection(template_type
);
1527 value_list
.n_values
= list_length
;
1528 value_list
.list_value
= new EXTERNAL_identification_template
[list_length
];
1531 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes()
1533 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) {
1534 template_sel old_selection
= template_selection
;
1536 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(ANY_VALUE
);
1537 else single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1538 single_value
.union_selection
= EXTERNAL_identification::ALT_syntaxes
;
1539 set_selection(SPECIFIC_VALUE
);
1541 return *single_value
.field_syntaxes
;
1544 const EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes() const
1546 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type EXTERNAL.identification.");
1547 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) TTCN_error("Accessing non-selected field syntaxes in a template of union type EXTERNAL.identification.");
1548 return *single_value
.field_syntaxes
;
1551 OBJID_template
& EXTERNAL_identification_template::syntax()
1553 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) {
1554 template_sel old_selection
= template_selection
;
1556 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1557 else single_value
.field_syntax
= new OBJID_template
;
1558 single_value
.union_selection
= EXTERNAL_identification::ALT_syntax
;
1559 set_selection(SPECIFIC_VALUE
);
1561 return *single_value
.field_syntax
;
1564 const OBJID_template
& EXTERNAL_identification_template::syntax() const
1566 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type EXTERNAL.identification.");
1567 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) TTCN_error("Accessing non-selected field syntax in a template of union type EXTERNAL.identification.");
1568 return *single_value
.field_syntax
;
1571 INTEGER_template
& EXTERNAL_identification_template::presentation__context__id()
1573 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_presentation__context__id
) {
1574 template_sel old_selection
= template_selection
;
1576 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1577 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1578 single_value
.union_selection
= EXTERNAL_identification::ALT_presentation__context__id
;
1579 set_selection(SPECIFIC_VALUE
);
1581 return *single_value
.field_presentation__context__id
;
1584 const INTEGER_template
& EXTERNAL_identification_template::presentation__context__id() const
1586 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type EXTERNAL.identification.");
1587 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_presentation__context__id
) TTCN_error("Accessing non-selected field presentation_context_id in a template of union type EXTERNAL.identification.");
1588 return *single_value
.field_presentation__context__id
;
1591 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation()
1593 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_context__negotiation
) {
1594 template_sel old_selection
= template_selection
;
1596 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(ANY_VALUE
);
1597 else single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1598 single_value
.union_selection
= EXTERNAL_identification::ALT_context__negotiation
;
1599 set_selection(SPECIFIC_VALUE
);
1601 return *single_value
.field_context__negotiation
;
1604 const EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation() const
1606 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type EXTERNAL.identification.");
1607 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_context__negotiation
) TTCN_error("Accessing non-selected field context_negotiation in a template of union type EXTERNAL.identification.");
1608 return *single_value
.field_context__negotiation
;
1611 OBJID_template
& EXTERNAL_identification_template::transfer__syntax()
1613 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_transfer__syntax
) {
1614 template_sel old_selection
= template_selection
;
1616 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1617 else single_value
.field_transfer__syntax
= new OBJID_template
;
1618 single_value
.union_selection
= EXTERNAL_identification::ALT_transfer__syntax
;
1619 set_selection(SPECIFIC_VALUE
);
1621 return *single_value
.field_transfer__syntax
;
1624 const OBJID_template
& EXTERNAL_identification_template::transfer__syntax() const
1626 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type EXTERNAL.identification.");
1627 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_transfer__syntax
) TTCN_error("Accessing non-selected field transfer_syntax in a template of union type EXTERNAL.identification.");
1628 return *single_value
.field_transfer__syntax
;
1631 ASN_NULL_template
& EXTERNAL_identification_template::fixed()
1633 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) {
1634 template_sel old_selection
= template_selection
;
1636 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1637 else single_value
.field_fixed
= new ASN_NULL_template
;
1638 single_value
.union_selection
= EXTERNAL_identification::ALT_fixed
;
1639 set_selection(SPECIFIC_VALUE
);
1641 return *single_value
.field_fixed
;
1644 const ASN_NULL_template
& EXTERNAL_identification_template::fixed() const
1646 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type EXTERNAL.identification.");
1647 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) TTCN_error("Accessing non-selected field fixed in a template of union type EXTERNAL.identification.");
1648 return *single_value
.field_fixed
;
1651 boolean
EXTERNAL_identification_template::ischosen(EXTERNAL_identification::union_selection_type checked_selection
) const
1653 if (checked_selection
== EXTERNAL_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
1654 switch (template_selection
) {
1655 case SPECIFIC_VALUE
:
1656 if (single_value
.union_selection
== EXTERNAL_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type EXTERNAL.identification.");
1657 return single_value
.union_selection
== checked_selection
;
1660 if (value_list
.n_values
< 1)
1661 TTCN_error("Internal error: Performing ischosen() operation on a template of union type EXTERNAL.identification containing an empty list.");
1662 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1663 boolean all_same
= TRUE
;
1664 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1665 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1670 if (all_same
) return ret_val
;
1672 // FIXME really no break?
1676 case COMPLEMENTED_LIST
:
1677 TTCN_error("Performing ischosen() operation on a template of union type EXTERNAL.identification, which does not determine unambiguously the chosen field of the matching values.");
1679 TTCN_error("Performing ischosen() operation on an uninitialized template of union type EXTERNAL.identification");
1684 void EXTERNAL_identification_template::log() const
1686 switch (template_selection
) {
1687 case SPECIFIC_VALUE
:
1688 switch (single_value
.union_selection
) {
1689 case EXTERNAL_identification::ALT_syntaxes
:
1690 TTCN_Logger::log_event_str("{ syntaxes := ");
1691 single_value
.field_syntaxes
->log();
1692 TTCN_Logger::log_event_str(" }");
1694 case EXTERNAL_identification::ALT_syntax
:
1695 TTCN_Logger::log_event_str("{ syntax := ");
1696 single_value
.field_syntax
->log();
1697 TTCN_Logger::log_event_str(" }");
1699 case EXTERNAL_identification::ALT_presentation__context__id
:
1700 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1701 single_value
.field_presentation__context__id
->log();
1702 TTCN_Logger::log_event_str(" }");
1704 case EXTERNAL_identification::ALT_context__negotiation
:
1705 TTCN_Logger::log_event_str("{ context_negotiation := ");
1706 single_value
.field_context__negotiation
->log();
1707 TTCN_Logger::log_event_str(" }");
1709 case EXTERNAL_identification::ALT_transfer__syntax
:
1710 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1711 single_value
.field_transfer__syntax
->log();
1712 TTCN_Logger::log_event_str(" }");
1714 case EXTERNAL_identification::ALT_fixed
:
1715 TTCN_Logger::log_event_str("{ fixed := ");
1716 single_value
.field_fixed
->log();
1717 TTCN_Logger::log_event_str(" }");
1720 TTCN_Logger::log_event_str("<invalid selector>");
1724 case COMPLEMENTED_LIST
:
1725 TTCN_Logger::log_event_str("complement ");
1728 TTCN_Logger::log_char('(');
1729 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1730 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1731 value_list
.list_value
[list_count
].log();
1733 TTCN_Logger::log_char(')');
1742 void EXTERNAL_identification_template::log_match(const EXTERNAL_identification
& match_value
,
1743 boolean
/* legacy */) const
1745 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1746 if(match(match_value
)){
1747 TTCN_Logger::print_logmatch_buffer();
1748 TTCN_Logger::log_event_str(" matched ");
1752 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1753 switch (single_value
.union_selection
) {
1754 case EXTERNAL_identification::ALT_syntaxes
:
1755 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1756 TTCN_Logger::log_logmatch_info(".syntaxes");
1757 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1759 TTCN_Logger::log_event_str("{ syntaxes := ");
1760 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1761 TTCN_Logger::log_event_str(" }");
1764 case EXTERNAL_identification::ALT_syntax
:
1765 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1766 TTCN_Logger::log_logmatch_info(".syntax");
1767 single_value
.field_syntax
->log_match(match_value
.syntax());
1769 TTCN_Logger::log_event_str("{ syntax := ");
1770 single_value
.field_syntax
->log_match(match_value
.syntax());
1771 TTCN_Logger::log_event_str(" }");
1774 case EXTERNAL_identification::ALT_presentation__context__id
:
1775 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1776 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1777 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1779 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1780 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1781 TTCN_Logger::log_event_str(" }");
1784 case EXTERNAL_identification::ALT_context__negotiation
:
1785 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1786 TTCN_Logger::log_logmatch_info(".context_negotiation");
1787 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1789 TTCN_Logger::log_event_str("{ context_negotiation := ");
1790 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1791 TTCN_Logger::log_event_str(" }");
1794 case EXTERNAL_identification::ALT_transfer__syntax
:
1795 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1796 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1797 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1799 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1800 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1801 TTCN_Logger::log_event_str(" }");
1804 case EXTERNAL_identification::ALT_fixed
:
1805 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1806 TTCN_Logger::log_logmatch_info(".fixed");
1807 single_value
.field_fixed
->log_match(match_value
.fixed());
1809 TTCN_Logger::log_event_str("{ fixed := ");
1810 single_value
.field_fixed
->log_match(match_value
.fixed());
1811 TTCN_Logger::log_event_str(" }");
1815 TTCN_Logger::print_logmatch_buffer();
1816 TTCN_Logger::log_event_str("<invalid selector>");
1820 TTCN_Logger::print_logmatch_buffer();
1822 TTCN_Logger::log_event_str(" with ");
1824 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1825 else TTCN_Logger::log_event_str(" unmatched");
1829 void EXTERNAL_identification_template::encode_text(Text_Buf
& text_buf
) const
1831 encode_text_base(text_buf
);
1832 switch (template_selection
) {
1833 case SPECIFIC_VALUE
:
1834 text_buf
.push_int(single_value
.union_selection
);
1835 switch (single_value
.union_selection
) {
1836 case EXTERNAL_identification::ALT_syntaxes
:
1837 single_value
.field_syntaxes
->encode_text(text_buf
);
1839 case EXTERNAL_identification::ALT_syntax
:
1840 single_value
.field_syntax
->encode_text(text_buf
);
1842 case EXTERNAL_identification::ALT_presentation__context__id
:
1843 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1845 case EXTERNAL_identification::ALT_context__negotiation
:
1846 single_value
.field_context__negotiation
->encode_text(text_buf
);
1848 case EXTERNAL_identification::ALT_transfer__syntax
:
1849 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1851 case EXTERNAL_identification::ALT_fixed
:
1852 single_value
.field_fixed
->encode_text(text_buf
);
1855 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EXTERNAL.identification.");
1863 case COMPLEMENTED_LIST
:
1864 text_buf
.push_int(value_list
.n_values
);
1865 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1866 value_list
.list_value
[list_count
].encode_text(text_buf
);
1869 TTCN_error("Text encoder: Encoding an uninitialized template of type EXTERNAL.identification.");
1873 void EXTERNAL_identification_template::decode_text(Text_Buf
& text_buf
)
1876 decode_text_base(text_buf
);
1877 switch (template_selection
) {
1878 case SPECIFIC_VALUE
:
1880 single_value
.union_selection
= EXTERNAL_identification::UNBOUND_VALUE
;
1881 EXTERNAL_identification::union_selection_type new_selection
= (EXTERNAL_identification::union_selection_type
)text_buf
.pull_int().get_val();
1882 switch (new_selection
) {
1883 case EXTERNAL_identification::ALT_syntaxes
:
1884 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1885 single_value
.field_syntaxes
->decode_text(text_buf
);
1887 case EXTERNAL_identification::ALT_syntax
:
1888 single_value
.field_syntax
= new OBJID_template
;
1889 single_value
.field_syntax
->decode_text(text_buf
);
1891 case EXTERNAL_identification::ALT_presentation__context__id
:
1892 single_value
.field_presentation__context__id
= new INTEGER_template
;
1893 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1895 case EXTERNAL_identification::ALT_context__negotiation
:
1896 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1897 single_value
.field_context__negotiation
->decode_text(text_buf
);
1899 case EXTERNAL_identification::ALT_transfer__syntax
:
1900 single_value
.field_transfer__syntax
= new OBJID_template
;
1901 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1903 case EXTERNAL_identification::ALT_fixed
:
1904 single_value
.field_fixed
= new ASN_NULL_template
;
1905 single_value
.field_fixed
->decode_text(text_buf
);
1908 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EXTERNAL.identification.");
1910 single_value
.union_selection
= new_selection
;
1918 case COMPLEMENTED_LIST
:
1919 value_list
.n_values
= text_buf
.pull_int().get_val();
1920 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1921 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1922 value_list
.list_value
[list_count
].decode_text(text_buf
);
1925 TTCN_error("Text decoder: Unrecognized selector was received in a template of type EXTERNAL.identification.");
1929 boolean
EXTERNAL_identification_template::is_present(boolean legacy
/* = FALSE */) const
1931 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1932 return !match_omit(legacy
);
1935 boolean
EXTERNAL_identification_template::match_omit(boolean legacy
/* = FALSE */) const
1937 if (is_ifpresent
) return TRUE
;
1938 switch (template_selection
) {
1943 case COMPLEMENTED_LIST
:
1945 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1946 if (value_list
.list_value
[i
].match_omit())
1947 return template_selection
==VALUE_LIST
;
1948 return template_selection
==COMPLEMENTED_LIST
;
1949 } // else fall through
1956 #ifndef TITAN_RUNTIME_2
1957 void EXTERNAL_identification_template::check_restriction(template_res t_res
, const char* t_name
,
1958 boolean legacy
/* = FALSE */) const
1960 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1961 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1963 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1966 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1967 template_selection
==SPECIFIC_VALUE
)) return;
1970 if (!match_omit(legacy
)) return;
1975 TTCN_error("Restriction `%s' on template of type %s violated.",
1976 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification");
1980 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes()
1984 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes(const OBJID
& par_abstract
,
1985 const OBJID
& par_transfer
)
1986 : field_abstract(par_abstract
),
1987 field_transfer(par_transfer
)
1991 boolean
EXTERNAL_identification_syntaxes::operator==(const EXTERNAL_identification_syntaxes
& other_value
) const
1993 return field_abstract
==other_value
.field_abstract
1994 && field_transfer
==other_value
.field_transfer
;
1997 int EXTERNAL_identification_syntaxes::size_of() const
2003 void EXTERNAL_identification_syntaxes::log() const
2005 TTCN_Logger::log_event_str("{ abstract := ");
2006 field_abstract
.log();
2007 TTCN_Logger::log_event_str(", transfer := ");
2008 field_transfer
.log();
2009 TTCN_Logger::log_event_str(" }");
2012 boolean
EXTERNAL_identification_syntaxes::is_bound() const
2014 if(field_abstract
.is_bound()) return TRUE
;
2015 if(field_transfer
.is_bound()) return TRUE
;
2019 boolean
EXTERNAL_identification_syntaxes::is_value() const
2021 if(!field_abstract
.is_value()) return FALSE
;
2022 if(!field_transfer
.is_value()) return FALSE
;
2026 void EXTERNAL_identification_syntaxes::clean_up()
2028 field_abstract
.clean_up();
2029 field_transfer
.clean_up();
2032 void EXTERNAL_identification_syntaxes::set_param(Module_Param
& param
)
2034 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2035 Module_Param_Ptr mp
= ¶m
;
2036 if (param
.get_type() == Module_Param::MP_Reference
) {
2037 mp
= param
.get_referenced_param();
2039 switch (mp
->get_type()) {
2040 case Module_Param::MP_Value_List
:
2041 if (mp
->get_size()==0) return;
2042 if (2!=mp
->get_size()) {
2043 param
.error("record value of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
2045 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
2046 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
2048 case Module_Param::MP_Assignment_List
: {
2049 Vector
<bool> value_used(mp
->get_size());
2050 value_used
.resize(mp
->get_size(), false);
2051 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2052 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2053 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
2054 abstract().set_param(*curr_param
);
2055 value_used
[val_idx
]=true;
2058 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2059 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2060 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
2061 transfer().set_param(*curr_param
);
2062 value_used
[val_idx
]=true;
2065 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2066 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2071 param
.type_error("record value", "EXTERNAL.identification.syntaxes");
2075 Module_Param
* EXTERNAL_identification_syntaxes::get_param(Module_Param_Name
& param_name
) const
2078 return new Module_Param_Unbound();
2080 Module_Param
* mp_field_abstract
= field_abstract
.get_param(param_name
);
2081 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
2082 Module_Param
* mp_field_transfer
= field_transfer
.get_param(param_name
);
2083 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
2084 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2085 mp
->add_elem(mp_field_abstract
);
2086 mp
->add_elem(mp_field_transfer
);
2090 void EXTERNAL_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
2092 field_abstract
.encode_text(text_buf
);
2093 field_transfer
.encode_text(text_buf
);
2096 void EXTERNAL_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
2098 field_abstract
.decode_text(text_buf
);
2099 field_transfer
.decode_text(text_buf
);
2102 struct EXTERNAL_identification_syntaxes_template::single_value_struct
{
2103 OBJID_template field_abstract
;
2104 OBJID_template field_transfer
;
2107 void EXTERNAL_identification_syntaxes_template::set_param(Module_Param
& param
)
2109 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2110 Module_Param_Ptr mp
= ¶m
;
2111 if (param
.get_type() == Module_Param::MP_Reference
) {
2112 mp
= param
.get_referenced_param();
2114 switch (mp
->get_type()) {
2115 case Module_Param::MP_Omit
:
2118 case Module_Param::MP_Any
:
2121 case Module_Param::MP_AnyOrNone
:
2122 *this = ANY_OR_OMIT
;
2124 case Module_Param::MP_List_Template
:
2125 case Module_Param::MP_ComplementList_Template
: {
2126 EXTERNAL_identification_syntaxes_template temp
;
2127 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2128 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2129 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2130 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2134 case Module_Param::MP_Value_List
:
2135 if (mp
->get_size()==0) break;
2136 if (2!=mp
->get_size()) {
2137 param
.error("record template of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
2139 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
2140 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
2142 case Module_Param::MP_Assignment_List
: {
2143 Vector
<bool> value_used(mp
->get_size());
2144 value_used
.resize(mp
->get_size(), false);
2145 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2146 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2147 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
2148 abstract().set_param(*curr_param
);
2149 value_used
[val_idx
]=true;
2152 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2153 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2154 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
2155 transfer().set_param(*curr_param
);
2156 value_used
[val_idx
]=true;
2159 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2160 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2165 param
.type_error("record template", "EXTERNAL.identification.syntaxes");
2167 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2170 Module_Param
* EXTERNAL_identification_syntaxes_template::get_param(Module_Param_Name
& param_name
) const
2172 Module_Param
* mp
= NULL
;
2173 switch (template_selection
) {
2174 case UNINITIALIZED_TEMPLATE
:
2175 mp
= new Module_Param_Unbound();
2178 mp
= new Module_Param_Omit();
2181 mp
= new Module_Param_Any();
2184 mp
= new Module_Param_AnyOrNone();
2186 case SPECIFIC_VALUE
: {
2187 Module_Param
* mp_field_abstract
= single_value
->field_abstract
.get_param(param_name
);
2188 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
2189 Module_Param
* mp_field_transfer
= single_value
->field_transfer
.get_param(param_name
);
2190 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
2191 mp
= new Module_Param_Assignment_List();
2192 mp
->add_elem(mp_field_abstract
);
2193 mp
->add_elem(mp_field_transfer
);
2196 case COMPLEMENTED_LIST
: {
2197 if (template_selection
== VALUE_LIST
) {
2198 mp
= new Module_Param_List_Template();
2201 mp
= new Module_Param_ComplementList_Template();
2203 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2204 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2211 mp
->set_ifpresent();
2216 void EXTERNAL_identification_syntaxes_template::clean_up()
2218 switch (template_selection
) {
2219 case SPECIFIC_VALUE
:
2220 delete single_value
;
2223 case COMPLEMENTED_LIST
:
2224 delete [] value_list
.list_value
;
2229 template_selection
= UNINITIALIZED_TEMPLATE
;
2232 void EXTERNAL_identification_syntaxes_template::set_specific()
2234 if (template_selection
!= SPECIFIC_VALUE
) {
2235 template_sel old_selection
= template_selection
;
2237 single_value
= new single_value_struct
;
2238 set_selection(SPECIFIC_VALUE
);
2239 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2240 single_value
->field_abstract
= ANY_VALUE
;
2241 single_value
->field_transfer
= ANY_VALUE
;
2246 void EXTERNAL_identification_syntaxes_template::copy_value(const EXTERNAL_identification_syntaxes
& other_value
)
2248 single_value
= new single_value_struct
;
2249 single_value
->field_abstract
= other_value
.abstract();
2250 single_value
->field_transfer
= other_value
.transfer();
2251 set_selection(SPECIFIC_VALUE
);
2254 void EXTERNAL_identification_syntaxes_template::copy_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2256 switch (other_value
.template_selection
) {
2257 case SPECIFIC_VALUE
:
2258 single_value
= new single_value_struct(*other_value
.single_value
);
2265 case COMPLEMENTED_LIST
:
2266 value_list
.n_values
= other_value
.value_list
.n_values
;
2267 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2268 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2269 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2272 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2274 set_selection(other_value
);
2277 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template()
2281 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(template_sel other_value
)
2282 : Base_Template(other_value
)
2284 check_single_selection(other_value
);
2287 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes
& other_value
)
2289 copy_value(other_value
);
2292 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2294 switch (other_value
.get_selection()) {
2295 case OPTIONAL_PRESENT
:
2296 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2299 set_selection(OMIT_VALUE
);
2302 TTCN_error("Creating a template of type EXTERNAL.identification.syntaxes from an unbound optional field.");
2306 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2309 copy_template(other_value
);
2312 EXTERNAL_identification_syntaxes_template::~EXTERNAL_identification_syntaxes_template()
2317 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(template_sel other_value
)
2319 check_single_selection(other_value
);
2321 set_selection(other_value
);
2325 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes
& other_value
)
2328 copy_value(other_value
);
2332 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2335 switch (other_value
.get_selection()) {
2336 case OPTIONAL_PRESENT
:
2337 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2340 set_selection(OMIT_VALUE
);
2343 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.syntaxes.");
2348 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes_template
& other_value
)
2350 if (&other_value
!= this) {
2352 copy_template(other_value
);
2357 boolean
EXTERNAL_identification_syntaxes_template::match(const EXTERNAL_identification_syntaxes
& other_value
,
2358 boolean
/* legacy */) const
2360 switch (template_selection
) {
2366 case SPECIFIC_VALUE
:
2367 if (!other_value
.abstract().is_bound()) return FALSE
;
2368 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
2369 if (!other_value
.transfer().is_bound()) return FALSE
;
2370 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
2373 case COMPLEMENTED_LIST
:
2374 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2375 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2376 return template_selection
== COMPLEMENTED_LIST
;
2378 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2383 EXTERNAL_identification_syntaxes
EXTERNAL_identification_syntaxes_template::valueof() const
2385 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2386 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.syntaxes.");
2387 EXTERNAL_identification_syntaxes ret_val
;
2388 ret_val
.abstract() = single_value
->field_abstract
.valueof();
2389 ret_val
.transfer() = single_value
->field_transfer
.valueof();
2393 void EXTERNAL_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
2395 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2396 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.syntaxes.");
2398 set_selection(template_type
);
2399 value_list
.n_values
= list_length
;
2400 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[list_length
];
2403 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::list_item(unsigned int list_index
) const
2405 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2406 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.syntaxes.");
2407 if (list_index
>= value_list
.n_values
)
2408 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.syntaxes.");
2409 return value_list
.list_value
[list_index
];
2412 OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract()
2415 return single_value
->field_abstract
;
2418 const OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract() const
2420 if (template_selection
!= SPECIFIC_VALUE
)
2421 TTCN_error("Accessing field abstract of a non-specific template of type EXTERNAL.identification.syntaxes.");
2422 return single_value
->field_abstract
;
2425 OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer()
2428 return single_value
->field_transfer
;
2431 const OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer() const
2433 if (template_selection
!= SPECIFIC_VALUE
)
2434 TTCN_error("Accessing field transfer of a non-specific template of type EXTERNAL.identification.syntaxes.");
2435 return single_value
->field_transfer
;
2438 int EXTERNAL_identification_syntaxes_template::size_of() const
2440 switch (template_selection
)
2442 case SPECIFIC_VALUE
:
2449 if (value_list
.n_values
<1)
2450 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing an empty list.");
2451 int item_size
= value_list
.list_value
[0].size_of();
2452 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2454 if (value_list
.list_value
[i
].size_of()!=item_size
)
2455 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing a value list with different sizes.");
2460 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing omit value.");
2463 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing */? value.");
2464 case COMPLEMENTED_LIST
:
2465 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing complemented list.");
2467 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2472 void EXTERNAL_identification_syntaxes_template::log() const
2474 switch (template_selection
) {
2475 case SPECIFIC_VALUE
:
2476 TTCN_Logger::log_event_str("{ abstract := ");
2477 single_value
->field_abstract
.log();
2478 TTCN_Logger::log_event_str(", transfer := ");
2479 single_value
->field_transfer
.log();
2480 TTCN_Logger::log_event_str(" }");
2482 case COMPLEMENTED_LIST
:
2483 TTCN_Logger::log_event_str("complement ");
2486 TTCN_Logger::log_char('(');
2487 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2488 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2489 value_list
.list_value
[list_count
].log();
2491 TTCN_Logger::log_char(')');
2500 void EXTERNAL_identification_syntaxes_template::log_match(const EXTERNAL_identification_syntaxes
& match_value
,
2501 boolean
/* legacy */) const
2503 if (template_selection
== SPECIFIC_VALUE
) {
2504 TTCN_Logger::log_event_str("{ abstract := ");
2505 single_value
->field_abstract
.log_match(match_value
.abstract());
2506 TTCN_Logger::log_event_str(", transfer := ");
2507 single_value
->field_transfer
.log_match(match_value
.transfer());
2508 TTCN_Logger::log_event_str(" }");
2511 TTCN_Logger::log_event_str(" with ");
2513 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2514 else TTCN_Logger::log_event_str(" unmatched");
2518 void EXTERNAL_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2520 encode_text_base(text_buf
);
2521 switch (template_selection
) {
2522 case SPECIFIC_VALUE
:
2523 single_value
->field_abstract
.encode_text(text_buf
);
2524 single_value
->field_transfer
.encode_text(text_buf
);
2531 case COMPLEMENTED_LIST
:
2532 text_buf
.push_int(value_list
.n_values
);
2533 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2534 value_list
.list_value
[list_count
].encode_text(text_buf
);
2537 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2541 void EXTERNAL_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2544 decode_text_base(text_buf
);
2545 switch (template_selection
) {
2546 case SPECIFIC_VALUE
:
2547 single_value
= new single_value_struct
;
2548 single_value
->field_abstract
.decode_text(text_buf
);
2549 single_value
->field_transfer
.decode_text(text_buf
);
2556 case COMPLEMENTED_LIST
:
2557 value_list
.n_values
= text_buf
.pull_int().get_val();
2558 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2559 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2560 value_list
.list_value
[list_count
].decode_text(text_buf
);
2563 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.syntaxes.");
2567 boolean
EXTERNAL_identification_syntaxes_template::is_present(boolean legacy
/* = FALSE */) const
2569 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2570 return !match_omit(legacy
);
2573 boolean
EXTERNAL_identification_syntaxes_template::match_omit(boolean legacy
/* = FALSE */) const
2575 if (is_ifpresent
) return TRUE
;
2576 switch (template_selection
) {
2581 case COMPLEMENTED_LIST
:
2583 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2584 if (value_list
.list_value
[i
].match_omit())
2585 return template_selection
==VALUE_LIST
;
2586 return template_selection
==COMPLEMENTED_LIST
;
2587 } // else fall through
2594 #ifndef TITAN_RUNTIME_2
2595 void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
,
2596 boolean legacy
/* = FALSE */) const
2598 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2599 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2601 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2604 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2605 template_selection
==SPECIFIC_VALUE
)) return;
2608 if (!match_omit(legacy
)) return;
2613 TTCN_error("Restriction `%s' on template of type %s violated.",
2614 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.syntaxes");
2618 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation()
2622 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2623 const OBJID
& par_transfer__syntax
)
2624 : field_presentation__context__id(par_presentation__context__id
),
2625 field_transfer__syntax(par_transfer__syntax
)
2629 boolean
EXTERNAL_identification_context__negotiation::operator==(const EXTERNAL_identification_context__negotiation
& other_value
) const
2631 return field_presentation__context__id
==other_value
.field_presentation__context__id
2632 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2635 int EXTERNAL_identification_context__negotiation::size_of() const
2641 void EXTERNAL_identification_context__negotiation::log() const
2643 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2644 field_presentation__context__id
.log();
2645 TTCN_Logger::log_event_str(", transfer_syntax := ");
2646 field_transfer__syntax
.log();
2647 TTCN_Logger::log_event_str(" }");
2650 boolean
EXTERNAL_identification_context__negotiation::is_bound() const
2652 if(field_presentation__context__id
.is_bound()) return TRUE
;
2653 if(field_transfer__syntax
.is_bound()) return TRUE
;
2657 boolean
EXTERNAL_identification_context__negotiation::is_value() const
2659 if(!field_presentation__context__id
.is_value()) return FALSE
;
2660 if(!field_transfer__syntax
.is_value()) return FALSE
;
2664 void EXTERNAL_identification_context__negotiation::clean_up()
2666 field_presentation__context__id
.clean_up();
2667 field_transfer__syntax
.clean_up();
2670 void EXTERNAL_identification_context__negotiation::set_param(Module_Param
& param
)
2672 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2673 Module_Param_Ptr mp
= ¶m
;
2674 if (param
.get_type() == Module_Param::MP_Reference
) {
2675 mp
= param
.get_referenced_param();
2677 switch (mp
->get_type()) {
2678 case Module_Param::MP_Value_List
:
2679 if (mp
->get_size()==0) return;
2680 if (2!=mp
->get_size()) {
2681 param
.error("record value of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2683 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2684 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2686 case Module_Param::MP_Assignment_List
: {
2687 Vector
<bool> value_used(mp
->get_size());
2688 value_used
.resize(mp
->get_size(), false);
2689 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2690 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2691 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2692 presentation__context__id().set_param(*curr_param
);
2693 value_used
[val_idx
]=true;
2696 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2697 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2698 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2699 transfer__syntax().set_param(*curr_param
);
2700 value_used
[val_idx
]=true;
2703 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2704 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2709 param
.type_error("record value", "EXTERNAL.identification.context-negotiation");
2713 Module_Param
* EXTERNAL_identification_context__negotiation::get_param(Module_Param_Name
& param_name
) const
2716 return new Module_Param_Unbound();
2718 Module_Param
* mp_field_presentation_context_id
= field_presentation__context__id
.get_param(param_name
);
2719 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2720 Module_Param
* mp_field_transfer_syntax
= field_transfer__syntax
.get_param(param_name
);
2721 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2722 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2723 mp
->add_elem(mp_field_presentation_context_id
);
2724 mp
->add_elem(mp_field_transfer_syntax
);
2728 void EXTERNAL_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2730 field_presentation__context__id
.encode_text(text_buf
);
2731 field_transfer__syntax
.encode_text(text_buf
);
2734 void EXTERNAL_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2736 field_presentation__context__id
.decode_text(text_buf
);
2737 field_transfer__syntax
.decode_text(text_buf
);
2740 struct EXTERNAL_identification_context__negotiation_template::single_value_struct
{
2741 INTEGER_template field_presentation__context__id
;
2742 OBJID_template field_transfer__syntax
;
2745 void EXTERNAL_identification_context__negotiation_template::set_param(Module_Param
& param
)
2747 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2748 Module_Param_Ptr mp
= ¶m
;
2749 if (param
.get_type() == Module_Param::MP_Reference
) {
2750 mp
= param
.get_referenced_param();
2752 switch (mp
->get_type()) {
2753 case Module_Param::MP_Omit
:
2756 case Module_Param::MP_Any
:
2759 case Module_Param::MP_AnyOrNone
:
2760 *this = ANY_OR_OMIT
;
2762 case Module_Param::MP_List_Template
:
2763 case Module_Param::MP_ComplementList_Template
: {
2764 EXTERNAL_identification_context__negotiation_template temp
;
2765 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2766 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2767 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2768 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2772 case Module_Param::MP_Value_List
:
2773 if (mp
->get_size()==0) break;
2774 if (2!=mp
->get_size()) {
2775 param
.error("record template of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2777 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2778 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2780 case Module_Param::MP_Assignment_List
: {
2781 Vector
<bool> value_used(mp
->get_size());
2782 value_used
.resize(mp
->get_size(), false);
2783 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2784 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2785 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2786 presentation__context__id().set_param(*curr_param
);
2787 value_used
[val_idx
]=true;
2790 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2791 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2792 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2793 transfer__syntax().set_param(*curr_param
);
2794 value_used
[val_idx
]=true;
2797 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2798 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2803 param
.type_error("record template", "EXTERNAL.identification.context-negotiation");
2805 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2808 Module_Param
* EXTERNAL_identification_context__negotiation_template::get_param(Module_Param_Name
& param_name
) const
2810 Module_Param
* mp
= NULL
;
2811 switch (template_selection
) {
2812 case UNINITIALIZED_TEMPLATE
:
2813 mp
= new Module_Param_Unbound();
2816 mp
= new Module_Param_Omit();
2819 mp
= new Module_Param_Any();
2822 mp
= new Module_Param_AnyOrNone();
2824 case SPECIFIC_VALUE
: {
2825 Module_Param
* mp_field_presentation_context_id
= single_value
->field_presentation__context__id
.get_param(param_name
);
2826 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2827 Module_Param
* mp_field_transfer_syntax
= single_value
->field_transfer__syntax
.get_param(param_name
);
2828 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2829 mp
= new Module_Param_Assignment_List();
2830 mp
->add_elem(mp_field_presentation_context_id
);
2831 mp
->add_elem(mp_field_transfer_syntax
);
2834 case COMPLEMENTED_LIST
: {
2835 if (template_selection
== VALUE_LIST
) {
2836 mp
= new Module_Param_List_Template();
2839 mp
= new Module_Param_ComplementList_Template();
2841 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2842 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2849 mp
->set_ifpresent();
2854 void EXTERNAL_identification_context__negotiation_template::clean_up()
2856 switch (template_selection
) {
2857 case SPECIFIC_VALUE
:
2858 delete single_value
;
2861 case COMPLEMENTED_LIST
:
2862 delete [] value_list
.list_value
;
2867 template_selection
= UNINITIALIZED_TEMPLATE
;
2870 void EXTERNAL_identification_context__negotiation_template::set_specific()
2872 if (template_selection
!= SPECIFIC_VALUE
) {
2873 template_sel old_selection
= template_selection
;
2875 single_value
= new single_value_struct
;
2876 set_selection(SPECIFIC_VALUE
);
2877 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2878 single_value
->field_presentation__context__id
= ANY_VALUE
;
2879 single_value
->field_transfer__syntax
= ANY_VALUE
;
2884 void EXTERNAL_identification_context__negotiation_template::copy_value(const EXTERNAL_identification_context__negotiation
& other_value
)
2886 single_value
= new single_value_struct
;
2887 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2888 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2889 set_selection(SPECIFIC_VALUE
);
2892 void EXTERNAL_identification_context__negotiation_template::copy_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2894 switch (other_value
.template_selection
) {
2895 case SPECIFIC_VALUE
:
2896 single_value
= new single_value_struct(*other_value
.single_value
);
2903 case COMPLEMENTED_LIST
:
2904 value_list
.n_values
= other_value
.value_list
.n_values
;
2905 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
2906 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2907 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2910 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2912 set_selection(other_value
);
2915 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template()
2919 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(template_sel other_value
)
2920 : Base_Template(other_value
)
2922 check_single_selection(other_value
);
2925 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation
& other_value
)
2927 copy_value(other_value
);
2930 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2932 switch (other_value
.get_selection()) {
2933 case OPTIONAL_PRESENT
:
2934 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2937 set_selection(OMIT_VALUE
);
2940 TTCN_error("Creating a template of type EXTERNAL.identification.context-negotiation from an unbound optional field.");
2944 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2947 copy_template(other_value
);
2950 EXTERNAL_identification_context__negotiation_template::~EXTERNAL_identification_context__negotiation_template()
2955 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(template_sel other_value
)
2957 check_single_selection(other_value
);
2959 set_selection(other_value
);
2963 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation
& other_value
)
2966 copy_value(other_value
);
2970 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2973 switch (other_value
.get_selection()) {
2974 case OPTIONAL_PRESENT
:
2975 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2978 set_selection(OMIT_VALUE
);
2981 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.context-negotiation.");
2986 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2988 if (&other_value
!= this) {
2990 copy_template(other_value
);
2995 boolean
EXTERNAL_identification_context__negotiation_template::match(const EXTERNAL_identification_context__negotiation
& other_value
,
2996 boolean
/* legacy */) const
2998 switch (template_selection
) {
3004 case SPECIFIC_VALUE
:
3005 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
3006 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
3007 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
3008 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
3011 case COMPLEMENTED_LIST
:
3012 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3013 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3014 return template_selection
== COMPLEMENTED_LIST
;
3016 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3021 EXTERNAL_identification_context__negotiation
EXTERNAL_identification_context__negotiation_template::valueof() const
3023 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3024 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.context-negotiation.");
3025 EXTERNAL_identification_context__negotiation ret_val
;
3026 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
3027 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
3031 void EXTERNAL_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
3033 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3034 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.context-negotiation.");
3036 set_selection(template_type
);
3037 value_list
.n_values
= list_length
;
3038 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[list_length
];
3041 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::list_item(unsigned int list_index
) const
3043 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3044 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.context-negotiation.");
3045 if (list_index
>= value_list
.n_values
)
3046 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.context-negotiation.");
3047 return value_list
.list_value
[list_index
];
3050 INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id()
3053 return single_value
->field_presentation__context__id
;
3056 const INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id() const
3058 if (template_selection
!= SPECIFIC_VALUE
)
3059 TTCN_error("Accessing field presentation_context_id of a non-specific template of type EXTERNAL.identification.context-negotiation.");
3060 return single_value
->field_presentation__context__id
;
3063 OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax()
3066 return single_value
->field_transfer__syntax
;
3069 const OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax() const
3071 if (template_selection
!= SPECIFIC_VALUE
)
3072 TTCN_error("Accessing field transfer_syntax of a non-specific template of type EXTERNAL.identification.context-negotiation.");
3073 return single_value
->field_transfer__syntax
;
3076 int EXTERNAL_identification_context__negotiation_template::size_of() const
3078 switch (template_selection
)
3080 case SPECIFIC_VALUE
:
3087 if (value_list
.n_values
<1)
3088 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing an empty list.");
3089 int item_size
= value_list
.list_value
[0].size_of();
3090 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3092 if (value_list
.list_value
[i
].size_of()!=item_size
)
3093 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing a value list with different sizes.");
3098 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing omit value.");
3101 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing */? value.");
3102 case COMPLEMENTED_LIST
:
3103 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing complemented list.");
3105 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3110 void EXTERNAL_identification_context__negotiation_template::log() const
3112 switch (template_selection
) {
3113 case SPECIFIC_VALUE
:
3114 TTCN_Logger::log_event_str("{ presentation_context_id := ");
3115 single_value
->field_presentation__context__id
.log();
3116 TTCN_Logger::log_event_str(", transfer_syntax := ");
3117 single_value
->field_transfer__syntax
.log();
3118 TTCN_Logger::log_event_str(" }");
3120 case COMPLEMENTED_LIST
:
3121 TTCN_Logger::log_event_str("complement ");
3124 TTCN_Logger::log_char('(');
3125 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3126 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3127 value_list
.list_value
[list_count
].log();
3129 TTCN_Logger::log_char(')');
3138 void EXTERNAL_identification_context__negotiation_template::log_match(const EXTERNAL_identification_context__negotiation
& match_value
,
3139 boolean
/* legacy */) const
3141 if (template_selection
== SPECIFIC_VALUE
) {
3142 TTCN_Logger::log_event_str("{ presentation_context_id := ");
3143 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
3144 TTCN_Logger::log_event_str(", transfer_syntax := ");
3145 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
3146 TTCN_Logger::log_event_str(" }");
3149 TTCN_Logger::log_event_str(" with ");
3151 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3152 else TTCN_Logger::log_event_str(" unmatched");
3156 void EXTERNAL_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
3158 encode_text_base(text_buf
);
3159 switch (template_selection
) {
3160 case SPECIFIC_VALUE
:
3161 single_value
->field_presentation__context__id
.encode_text(text_buf
);
3162 single_value
->field_transfer__syntax
.encode_text(text_buf
);
3169 case COMPLEMENTED_LIST
:
3170 text_buf
.push_int(value_list
.n_values
);
3171 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3172 value_list
.list_value
[list_count
].encode_text(text_buf
);
3175 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3179 void EXTERNAL_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
3182 decode_text_base(text_buf
);
3183 switch (template_selection
) {
3184 case SPECIFIC_VALUE
:
3185 single_value
= new single_value_struct
;
3186 single_value
->field_presentation__context__id
.decode_text(text_buf
);
3187 single_value
->field_transfer__syntax
.decode_text(text_buf
);
3194 case COMPLEMENTED_LIST
:
3195 value_list
.n_values
= text_buf
.pull_int().get_val();
3196 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
3197 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3198 value_list
.list_value
[list_count
].decode_text(text_buf
);
3201 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.context-negotiation.");
3205 boolean
EXTERNAL_identification_context__negotiation_template::is_present(boolean legacy
/* = FALSE */) const
3207 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3208 return !match_omit(legacy
);
3211 boolean
EXTERNAL_identification_context__negotiation_template::match_omit(boolean legacy
/* = FALSE */) const
3213 if (is_ifpresent
) return TRUE
;
3214 switch (template_selection
) {
3219 case COMPLEMENTED_LIST
:
3221 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3222 if (value_list
.list_value
[i
].match_omit())
3223 return template_selection
==VALUE_LIST
;
3224 return template_selection
==COMPLEMENTED_LIST
;
3225 } // else fall through
3232 #ifndef TITAN_RUNTIME_2
3233 void EXTERNAL_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
,
3234 boolean legacy
/* = FALSE */) const
3236 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3237 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3239 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3242 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3243 template_selection
==SPECIFIC_VALUE
)) return;
3246 if (!match_omit(legacy
)) return;
3251 TTCN_error("Restriction `%s' on template of type %s violated.",
3252 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.context-negotiation");
3256 EXTERNAL::EXTERNAL()
3260 EXTERNAL::EXTERNAL(const EXTERNAL_identification
& par_identification
,
3261 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
3262 const OCTETSTRING
& par_data__value
)
3263 : field_identification(par_identification
),
3264 field_data__value__descriptor(par_data__value__descriptor
),
3265 field_data__value(par_data__value
)
3269 boolean
EXTERNAL::operator==(const EXTERNAL
& other_value
) const
3271 return field_identification
==other_value
.field_identification
3272 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
3273 && field_data__value
==other_value
.field_data__value
;
3276 int EXTERNAL::size_of() const
3279 if (field_data__value__descriptor
.ispresent()) ret_val
++;
3283 void EXTERNAL::log() const
3285 TTCN_Logger::log_event_str("{ identification := ");
3286 field_identification
.log();
3287 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3288 field_data__value__descriptor
.log();
3289 TTCN_Logger::log_event_str(", data_value := ");
3290 field_data__value
.log();
3291 TTCN_Logger::log_event_str(" }");
3294 boolean
EXTERNAL::is_bound() const
3296 if(field_identification
.is_bound()) return TRUE
;
3297 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
3298 if(field_data__value
.is_bound()) return TRUE
;
3302 boolean
EXTERNAL::is_value() const
3304 if(!field_identification
.is_value()) return FALSE
;
3305 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
3306 if(!field_data__value
.is_value()) return FALSE
;
3310 void EXTERNAL::clean_up()
3312 field_identification
.clean_up();
3313 field_data__value__descriptor
.clean_up();
3314 field_data__value
.clean_up();
3317 void EXTERNAL::set_param(Module_Param
& param
)
3319 param
.basic_check(Module_Param::BC_VALUE
, "record value");
3320 Module_Param_Ptr mp
= ¶m
;
3321 if (param
.get_type() == Module_Param::MP_Reference
) {
3322 mp
= param
.get_referenced_param();
3324 switch (mp
->get_type()) {
3325 case Module_Param::MP_Value_List
:
3326 if (mp
->get_size()==0) return;
3327 if (3!=mp
->get_size()) {
3328 param
.error("record value of type EXTERNAL has 3 fields but list value has %d fields", (int)mp
->get_size());
3330 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3331 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3332 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*mp
->get_elem(2));
3334 case Module_Param::MP_Assignment_List
: {
3335 Vector
<bool> value_used(mp
->get_size());
3336 value_used
.resize(mp
->get_size(), false);
3337 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3338 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3339 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3340 identification().set_param(*curr_param
);
3341 value_used
[val_idx
]=true;
3344 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3345 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3346 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3347 data__value__descriptor().set_param(*curr_param
);
3348 value_used
[val_idx
]=true;
3351 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3352 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3353 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3354 data__value().set_param(*curr_param
);
3355 value_used
[val_idx
]=true;
3358 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3359 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3364 param
.type_error("record value", "EXTERNAL");
3368 Module_Param
* EXTERNAL::get_param(Module_Param_Name
& param_name
) const
3371 return new Module_Param_Unbound();
3373 Module_Param
* mp_field_identification
= field_identification
.get_param(param_name
);
3374 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3375 Module_Param
* mp_field_data_value_descriptor
= field_data__value__descriptor
.get_param(param_name
);
3376 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3377 Module_Param
* mp_field_data_value
= field_data__value
.get_param(param_name
);
3378 mp_field_data_value
->set_id(new Module_Param_FieldName(mcopystr("data_value")));
3379 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
3380 mp
->add_elem(mp_field_identification
);
3381 mp
->add_elem(mp_field_data_value_descriptor
);
3382 mp
->add_elem(mp_field_data_value
);
3386 void EXTERNAL::encode_text(Text_Buf
& text_buf
) const
3388 field_identification
.encode_text(text_buf
);
3389 field_data__value__descriptor
.encode_text(text_buf
);
3390 field_data__value
.encode_text(text_buf
);
3393 void EXTERNAL::decode_text(Text_Buf
& text_buf
)
3395 field_identification
.decode_text(text_buf
);
3396 field_data__value__descriptor
.decode_text(text_buf
);
3397 field_data__value
.decode_text(text_buf
);
3400 void EXTERNAL::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
3403 va_start(pvar
, p_coding
);
3405 case TTCN_EncDec::CT_BER
: {
3406 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
3407 unsigned BER_coding
=va_arg(pvar
, unsigned);
3408 BER_encode_chk_coding(BER_coding
);
3409 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
3410 tlv
->put_in_buffer(p_buf
);
3411 ASN_BER_TLV_t::destruct(tlv
);
3413 case TTCN_EncDec::CT_RAW
: {
3414 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
3415 TTCN_EncDec_ErrorContext::error_internal
3416 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3418 case TTCN_EncDec::CT_TEXT
: {
3419 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
3420 TTCN_EncDec_ErrorContext::error_internal
3421 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3423 case TTCN_EncDec::CT_XER
: {
3424 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
3425 unsigned XER_coding
=va_arg(pvar
, unsigned);
3426 XER_encode(*p_td
.xer
, p_buf
, XER_coding
, 0, 0);
3428 case TTCN_EncDec::CT_JSON
: {
3429 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
3430 TTCN_EncDec_ErrorContext::error_internal
3431 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3434 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3439 void EXTERNAL::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3442 va_start(pvar
, p_coding
);
3444 case TTCN_EncDec::CT_BER
: {
3445 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
3446 unsigned L_form
=va_arg(pvar
, unsigned);
3448 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
3449 BER_decode_TLV(p_td
, tlv
, L_form
);
3450 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3452 case TTCN_EncDec::CT_RAW
: {
3453 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3454 TTCN_EncDec_ErrorContext::error_internal
3455 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3457 case TTCN_EncDec::CT_TEXT
: {
3458 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3459 TTCN_EncDec_ErrorContext::error_internal
3460 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3462 case TTCN_EncDec::CT_XER
: {
3463 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3464 unsigned XER_coding
=va_arg(pvar
, unsigned);
3465 XmlReaderWrap
reader(p_buf
);
3466 int success
= reader
.Read();
3467 for (; success
==1; success
=reader
.Read()) {
3468 int type
= reader
.NodeType();
3469 if (type
==XML_READER_TYPE_ELEMENT
)
3472 XER_decode(*p_td
.xer
, reader
, XER_coding
, 0);
3473 size_t bytes
= reader
.ByteConsumed();
3474 p_buf
.set_pos(bytes
);
3476 case TTCN_EncDec::CT_JSON
: {
3477 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3478 TTCN_EncDec_ErrorContext::error_internal
3479 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3482 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3487 struct EXTERNAL_template::single_value_struct
{
3488 EXTERNAL_identification_template field_identification
;
3489 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3490 OCTETSTRING_template field_data__value
;
3493 void EXTERNAL_template::set_param(Module_Param
& param
)
3495 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
3496 Module_Param_Ptr mp
= ¶m
;
3497 if (param
.get_type() == Module_Param::MP_Reference
) {
3498 mp
= param
.get_referenced_param();
3500 switch (mp
->get_type()) {
3501 case Module_Param::MP_Omit
:
3504 case Module_Param::MP_Any
:
3507 case Module_Param::MP_AnyOrNone
:
3508 *this = ANY_OR_OMIT
;
3510 case Module_Param::MP_List_Template
:
3511 case Module_Param::MP_ComplementList_Template
: {
3512 EXTERNAL_template temp
;
3513 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
3514 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
3515 for (size_t i
=0; i
<mp
->get_size(); i
++) {
3516 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
3520 case Module_Param::MP_Value_List
:
3521 if (mp
->get_size()==0) break;
3522 if (3!=mp
->get_size()) {
3523 param
.error("record template of type EXTERNAL has 3 fields but list value has %d fields", (int)mp
->get_size());
3525 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3526 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3527 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*mp
->get_elem(2));
3529 case Module_Param::MP_Assignment_List
: {
3530 Vector
<bool> value_used(mp
->get_size());
3531 value_used
.resize(mp
->get_size(), false);
3532 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3533 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3534 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3535 identification().set_param(*curr_param
);
3536 value_used
[val_idx
]=true;
3539 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3540 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3541 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3542 data__value__descriptor().set_param(*curr_param
);
3543 value_used
[val_idx
]=true;
3546 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3547 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3548 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3549 data__value().set_param(*curr_param
);
3550 value_used
[val_idx
]=true;
3553 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3554 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3559 param
.type_error("record template", "EXTERNAL");
3561 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
3564 Module_Param
* EXTERNAL_template::get_param(Module_Param_Name
& param_name
) const
3566 Module_Param
* mp
= NULL
;
3567 switch (template_selection
) {
3568 case UNINITIALIZED_TEMPLATE
:
3569 mp
= new Module_Param_Unbound();
3572 mp
= new Module_Param_Omit();
3575 mp
= new Module_Param_Any();
3578 mp
= new Module_Param_AnyOrNone();
3580 case SPECIFIC_VALUE
: {
3581 Module_Param
* mp_field_identification
= single_value
->field_identification
.get_param(param_name
);
3582 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3583 Module_Param
* mp_field_data_value_descriptor
= single_value
->field_data__value__descriptor
.get_param(param_name
);
3584 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3585 Module_Param
* mp_field_string_value
= single_value
->field_data__value
.get_param(param_name
);
3586 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("data_value")));
3587 mp
= new Module_Param_Assignment_List();
3588 mp
->add_elem(mp_field_identification
);
3589 mp
->add_elem(mp_field_data_value_descriptor
);
3590 mp
->add_elem(mp_field_string_value
);
3593 case COMPLEMENTED_LIST
: {
3594 if (template_selection
== VALUE_LIST
) {
3595 mp
= new Module_Param_List_Template();
3598 mp
= new Module_Param_ComplementList_Template();
3600 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
3601 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
3608 mp
->set_ifpresent();
3613 void EXTERNAL_template::clean_up()
3615 switch (template_selection
) {
3616 case SPECIFIC_VALUE
:
3617 delete single_value
;
3620 case COMPLEMENTED_LIST
:
3621 delete [] value_list
.list_value
;
3626 template_selection
= UNINITIALIZED_TEMPLATE
;
3629 void EXTERNAL_template::set_specific()
3631 if (template_selection
!= SPECIFIC_VALUE
) {
3632 template_sel old_selection
= template_selection
;
3634 single_value
= new single_value_struct
;
3635 set_selection(SPECIFIC_VALUE
);
3636 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3637 single_value
->field_identification
= ANY_VALUE
;
3638 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3639 single_value
->field_data__value
= ANY_VALUE
;
3644 void EXTERNAL_template::copy_value(const EXTERNAL
& other_value
)
3646 single_value
= new single_value_struct
;
3647 single_value
->field_identification
= other_value
.identification();
3648 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3649 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3650 single_value
->field_data__value
= other_value
.data__value();
3651 set_selection(SPECIFIC_VALUE
);
3654 void EXTERNAL_template::copy_template(const EXTERNAL_template
& other_value
)
3656 switch (other_value
.template_selection
) {
3657 case SPECIFIC_VALUE
:
3658 single_value
= new single_value_struct(*other_value
.single_value
);
3665 case COMPLEMENTED_LIST
:
3666 value_list
.n_values
= other_value
.value_list
.n_values
;
3667 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
3668 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3669 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3672 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.");
3674 set_selection(other_value
);
3677 EXTERNAL_template::EXTERNAL_template()
3681 EXTERNAL_template::EXTERNAL_template(template_sel other_value
)
3682 : Base_Template(other_value
)
3684 check_single_selection(other_value
);
3687 EXTERNAL_template::EXTERNAL_template(const EXTERNAL
& other_value
)
3689 copy_value(other_value
);
3692 EXTERNAL_template::EXTERNAL_template(const OPTIONAL
<EXTERNAL
>& other_value
)
3694 switch (other_value
.get_selection()) {
3695 case OPTIONAL_PRESENT
:
3696 copy_value((const EXTERNAL
&)other_value
);
3699 set_selection(OMIT_VALUE
);
3702 TTCN_error("Creating a template of type EXTERNAL from an unbound optional field.");
3706 EXTERNAL_template::EXTERNAL_template(const EXTERNAL_template
& other_value
)
3709 copy_template(other_value
);
3712 EXTERNAL_template::~EXTERNAL_template()
3717 EXTERNAL_template
& EXTERNAL_template::operator=(template_sel other_value
)
3719 check_single_selection(other_value
);
3721 set_selection(other_value
);
3725 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL
& other_value
)
3728 copy_value(other_value
);
3732 EXTERNAL_template
& EXTERNAL_template::operator=(const OPTIONAL
<EXTERNAL
>& other_value
)
3735 switch (other_value
.get_selection()) {
3736 case OPTIONAL_PRESENT
:
3737 copy_value((const EXTERNAL
&)other_value
);
3740 set_selection(OMIT_VALUE
);
3743 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.");
3748 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL_template
& other_value
)
3750 if (&other_value
!= this) {
3752 copy_template(other_value
);
3757 boolean
EXTERNAL_template::match(const EXTERNAL
& other_value
,
3758 boolean
/* legacy */) const
3760 switch (template_selection
) {
3766 case SPECIFIC_VALUE
:
3767 if (!other_value
.identification().is_bound()) return FALSE
;
3768 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3769 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3770 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
;
3771 if (!other_value
.data__value().is_bound()) return FALSE
;
3772 if (!single_value
->field_data__value
.match(other_value
.data__value())) return FALSE
;
3775 case COMPLEMENTED_LIST
:
3776 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3777 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3778 return template_selection
== COMPLEMENTED_LIST
;
3780 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.");
3785 EXTERNAL
EXTERNAL_template::valueof() const
3787 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3788 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.");
3790 ret_val
.identification() = single_value
->field_identification
.valueof();
3791 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3792 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3793 ret_val
.data__value() = single_value
->field_data__value
.valueof();
3797 void EXTERNAL_template::set_type(template_sel template_type
, unsigned int list_length
)
3799 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3800 TTCN_error("Setting an invalid list for a template of type EXTERNAL.");
3802 set_selection(template_type
);
3803 value_list
.n_values
= list_length
;
3804 value_list
.list_value
= new EXTERNAL_template
[list_length
];
3807 EXTERNAL_template
& EXTERNAL_template::list_item(unsigned int list_index
) const
3809 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3810 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.");
3811 if (list_index
>= value_list
.n_values
)
3812 TTCN_error("Index overflow in a value list template of type EXTERNAL.");
3813 return value_list
.list_value
[list_index
];
3816 EXTERNAL_identification_template
& EXTERNAL_template::identification()
3819 return single_value
->field_identification
;
3822 const EXTERNAL_identification_template
& EXTERNAL_template::identification() const
3824 if (template_selection
!= SPECIFIC_VALUE
)
3825 TTCN_error("Accessing field identification of a non-specific template of type EXTERNAL.");
3826 return single_value
->field_identification
;
3829 UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor()
3832 return single_value
->field_data__value__descriptor
;
3835 const UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor() const
3837 if (template_selection
!= SPECIFIC_VALUE
)
3838 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type EXTERNAL.");
3839 return single_value
->field_data__value__descriptor
;
3842 OCTETSTRING_template
& EXTERNAL_template::data__value()
3845 return single_value
->field_data__value
;
3848 const OCTETSTRING_template
& EXTERNAL_template::data__value() const
3850 if (template_selection
!= SPECIFIC_VALUE
)
3851 TTCN_error("Accessing field data_value of a non-specific template of type EXTERNAL.");
3852 return single_value
->field_data__value
;
3855 int EXTERNAL_template::size_of() const
3857 switch (template_selection
)
3859 case SPECIFIC_VALUE
:
3862 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3867 if (value_list
.n_values
<1)
3868 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL containing an empty list.");
3869 int item_size
= value_list
.list_value
[0].size_of();
3870 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3872 if (value_list
.list_value
[i
].size_of()!=item_size
)
3873 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing a value list with different sizes.");
3878 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing omit value.");
3881 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing */? value.");
3882 case COMPLEMENTED_LIST
:
3883 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing complemented list.");
3885 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.");
3890 void EXTERNAL_template::log() const
3892 switch (template_selection
) {
3893 case SPECIFIC_VALUE
:
3894 TTCN_Logger::log_event_str("{ identification := ");
3895 single_value
->field_identification
.log();
3896 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3897 single_value
->field_data__value__descriptor
.log();
3898 TTCN_Logger::log_event_str(", data_value := ");
3899 single_value
->field_data__value
.log();
3900 TTCN_Logger::log_event_str(" }");
3902 case COMPLEMENTED_LIST
:
3903 TTCN_Logger::log_event_str("complement ");
3906 TTCN_Logger::log_char('(');
3907 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3908 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3909 value_list
.list_value
[list_count
].log();
3911 TTCN_Logger::log_char(')');
3920 void EXTERNAL_template::log_match(const EXTERNAL
& match_value
,
3921 boolean
/* legacy */) const
3923 if (template_selection
== SPECIFIC_VALUE
) {
3924 TTCN_Logger::log_event_str("{ identification := ");
3925 single_value
->field_identification
.log_match(match_value
.identification());
3926 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3927 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3929 single_value
->field_data__value__descriptor
.log();
3930 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3931 else TTCN_Logger::log_event_str(" unmatched");
3933 TTCN_Logger::log_event_str(", data_value := ");
3934 single_value
->field_data__value
.log_match(match_value
.data__value());
3935 TTCN_Logger::log_event_str(" }");
3938 TTCN_Logger::log_event_str(" with ");
3940 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3941 else TTCN_Logger::log_event_str(" unmatched");
3945 void EXTERNAL_template::encode_text(Text_Buf
& text_buf
) const
3947 encode_text_base(text_buf
);
3948 switch (template_selection
) {
3949 case SPECIFIC_VALUE
:
3950 single_value
->field_identification
.encode_text(text_buf
);
3951 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3952 single_value
->field_data__value
.encode_text(text_buf
);
3959 case COMPLEMENTED_LIST
:
3960 text_buf
.push_int(value_list
.n_values
);
3961 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3962 value_list
.list_value
[list_count
].encode_text(text_buf
);
3965 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.");
3969 void EXTERNAL_template::decode_text(Text_Buf
& text_buf
)
3972 decode_text_base(text_buf
);
3973 switch (template_selection
) {
3974 case SPECIFIC_VALUE
:
3975 single_value
= new single_value_struct
;
3976 single_value
->field_identification
.decode_text(text_buf
);
3977 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3978 single_value
->field_data__value
.decode_text(text_buf
);
3985 case COMPLEMENTED_LIST
:
3986 value_list
.n_values
= text_buf
.pull_int().get_val();
3987 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
3988 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3989 value_list
.list_value
[list_count
].decode_text(text_buf
);
3992 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.");
3996 boolean
EXTERNAL_template::is_present(boolean legacy
/* = FALSE */) const
3998 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3999 return !match_omit(legacy
);
4002 boolean
EXTERNAL_template::match_omit(boolean legacy
/* = FALSE */) const
4004 if (is_ifpresent
) return TRUE
;
4005 switch (template_selection
) {
4010 case COMPLEMENTED_LIST
:
4012 // legacy behavior: 'omit' can appear in the value/complement list
4013 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
4014 if (value_list
.list_value
[i
].match_omit())
4015 return template_selection
==VALUE_LIST
;
4016 return template_selection
==COMPLEMENTED_LIST
;
4018 // else fall through
4025 #ifndef TITAN_RUNTIME_2
4026 void EXTERNAL_template::check_restriction(template_res t_res
, const char* t_name
,
4027 boolean legacy
/* = FALSE */) const
4029 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
4030 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
4032 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
4035 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
4036 template_selection
==SPECIFIC_VALUE
)) return;
4039 if (!match_omit(legacy
)) return;
4044 TTCN_error("Restriction `%s' on template of type %s violated.",
4045 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL");