1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
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 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::encode_text() called."); }
95 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::decode_text() called."); }
96 boolean
is_bound() const { return union_selection
!=UNBOUND_VALUE
; }
97 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::is_equal() called."); }
98 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_value() called."); }
99 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::clone() called."); }
100 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_descriptor() called."); }
102 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
103 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
104 int XER_encode(const XERdescriptor_t
& p_td
,
105 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
) const;
106 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
107 unsigned int flavor
);
109 boolean
BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
);
111 boolean
BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
);
114 /** This class is used to encode/decode the EXTERNAL type.
116 * The sequence type used for encoding/decoding the EXTERNAL type
117 * differs from the associated type of EXTERNAL. See
118 * = X.690 (BER), 8.18.1 ;
119 * = X.691 (PER), 26.1 ;
122 * The actual encoding/decoding is performed by this class and its members.
123 * Data is transferred to/from an object of class EXTERNAL. */
124 class EXTERNALtransfer
: public Base_Type
{
125 OPTIONAL
<OBJID
> field_direct__reference
;
126 OPTIONAL
<INTEGER
> field_indirect__reference
;
127 OPTIONAL
<ObjectDescriptor
> field_data__value__descriptor
;
128 EXTERNALtransfer_encoding field_encoding
;
130 void load(const EXTERNAL
& ex
);
131 inline OPTIONAL
<OBJID
>& direct__reference()
132 {return field_direct__reference
;}
133 inline const OPTIONAL
<OBJID
>& direct__reference() const
134 {return field_direct__reference
;}
135 inline OPTIONAL
<INTEGER
>& indirect__reference()
136 {return field_indirect__reference
;}
137 inline const OPTIONAL
<INTEGER
>& indirect__reference() const
138 {return field_indirect__reference
;}
139 inline OPTIONAL
<ObjectDescriptor
>& data__value__descriptor()
140 {return field_data__value__descriptor
;}
141 inline const OPTIONAL
<ObjectDescriptor
>& data__value__descriptor() const
142 {return field_data__value__descriptor
;}
143 inline EXTERNALtransfer_encoding
& encoding()
144 {return field_encoding
;}
145 inline const EXTERNALtransfer_encoding
& encoding() const
146 {return field_encoding
;}
147 #ifdef TITAN_RUNTIME_2
148 void set_param(Module_Param
& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer::set_param() called."); }
149 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer::encode_text() called."); }
150 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer::decode_text() called."); }
151 boolean
is_bound() const { TTCN_error("Internal error: EXTERNALtransfer::is_bound() called."); }
152 boolean
is_value() const { TTCN_error("Internal error: EXTERNALtransfer::is_value() called."); }
153 void clean_up() { TTCN_error("Internal error: EXTERNALtransfer::clean_up() called."); }
154 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer::is_equal() called."); }
155 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer::set_value() called."); }
156 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer::clone() called."); }
157 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer::get_descriptor() called."); }
159 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
160 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
161 int XER_encode(const XERdescriptor_t
& p_td
,
162 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
) const;
163 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
164 unsigned int flavor
);
167 /** Transform the information from the visible format to the encoding format
169 * Called from EXTERNAL::XER_encode() */
170 void EXTERNALtransfer::load(const EXTERNAL
& ex
)
172 // ALT_syntaxes, ALT_transfer__syntax and ALT_fixed do not appear below.
173 // These are forbidden for the EXTERNAL type.
174 switch(ex
.identification().get_selection()) {
175 case EXTERNAL_identification::ALT_syntax
:
176 field_direct__reference
=ex
.identification().syntax();
178 case EXTERNAL_identification::ALT_context__negotiation
:
179 field_direct__reference
=ex
.identification().context__negotiation().transfer__syntax();
182 field_direct__reference
=OMIT_VALUE
;
185 switch(ex
.identification().get_selection()) {
186 case EXTERNAL_identification::ALT_presentation__context__id
:
187 field_indirect__reference
=ex
.identification().presentation__context__id();
189 case EXTERNAL_identification::ALT_context__negotiation
:
190 field_indirect__reference
=ex
.identification().context__negotiation().presentation__context__id();
193 field_indirect__reference
=OMIT_VALUE
;
196 field_data__value__descriptor
=ex
.data__value__descriptor();
197 field_encoding
.octet__aligned()=ex
.data__value();
200 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_descr_
= { "EXTERNALtransfer.encoding", &CHOICE_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
202 static const ASN_Tag_t EXTERNALtransfer_encoding_single__ASN1__type_tag_
[] = { { ASN_TAG_CONT
, 0u } };
203 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_ber_
= { 1u, EXTERNALtransfer_encoding_single__ASN1__type_tag_
};
204 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
, TTCN_Typedescriptor_t::DONTCARE
};
206 static const ASN_Tag_t EXTERNALtransfer_encoding_octet__aligned_tag_
[] = { { ASN_TAG_CONT
, 1u } };
207 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_octet__aligned_ber_
= { 1u, EXTERNALtransfer_encoding_octet__aligned_tag_
};
208 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_octet__aligned_descr_
= { "EXTERNALtransfer.encoding.octet-aligned", &EXTERNALtransfer_encoding_octet__aligned_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
210 static const ASN_Tag_t EXTERNALtransfer_encoding_arbitrary_tag_
[] = { { ASN_TAG_CONT
, 2u } };
211 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_arbitrary_ber_
= { 1u, EXTERNALtransfer_encoding_arbitrary_tag_
};
212 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_arbitrary_descr_
= { "EXTERNALtransfer.encoding.arbitrary", &EXTERNALtransfer_encoding_arbitrary_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
214 /* Member functions of C++ classes */
216 void EXTERNALtransfer_encoding::clean_up()
218 switch (union_selection
) {
219 case ALT_single__ASN1__type
:
220 delete field_single__ASN1__type
;
222 case ALT_octet__aligned
:
223 delete field_octet__aligned
;
226 delete field_arbitrary
;
231 union_selection
= UNBOUND_VALUE
;
234 void EXTERNALtransfer_encoding::copy_value(const EXTERNALtransfer_encoding
& other_value
)
236 switch (other_value
.union_selection
) {
237 case ALT_single__ASN1__type
:
238 field_single__ASN1__type
= new ASN_ANY(*other_value
.field_single__ASN1__type
);
240 case ALT_octet__aligned
:
241 field_octet__aligned
= new OCTETSTRING(*other_value
.field_octet__aligned
);
244 field_arbitrary
= new BITSTRING(*other_value
.field_arbitrary
);
247 TTCN_error("Assignment of an unbound union value of type EXTERNALtransfer.encoding.");
249 union_selection
= other_value
.union_selection
;
252 EXTERNALtransfer_encoding
& EXTERNALtransfer_encoding::operator=(const EXTERNALtransfer_encoding
& other_value
)
254 if(this != &other_value
) {
256 copy_value(other_value
);
261 ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type()
263 if (union_selection
!= ALT_single__ASN1__type
) {
265 field_single__ASN1__type
= new ASN_ANY
;
266 union_selection
= ALT_single__ASN1__type
;
268 return *field_single__ASN1__type
;
271 const ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type() const
273 if (union_selection
!= ALT_single__ASN1__type
) TTCN_error("Using non-selected field single-ASN1-type in a value of union type EXTERNALtransfer.encoding.");
274 return *field_single__ASN1__type
;
277 OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned()
279 if (union_selection
!= ALT_octet__aligned
) {
281 field_octet__aligned
= new OCTETSTRING
;
282 union_selection
= ALT_octet__aligned
;
284 return *field_octet__aligned
;
287 const OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned() const
289 if (union_selection
!= ALT_octet__aligned
) TTCN_error("Using non-selected field octet-aligned in a value of union type EXTERNALtransfer.encoding.");
290 return *field_octet__aligned
;
293 BITSTRING
& EXTERNALtransfer_encoding::arbitrary()
295 if (union_selection
!= ALT_arbitrary
) {
297 field_arbitrary
= new BITSTRING
;
298 union_selection
= ALT_arbitrary
;
300 return *field_arbitrary
;
303 const BITSTRING
& EXTERNALtransfer_encoding::arbitrary() const
305 if (union_selection
!= ALT_arbitrary
) TTCN_error("Using non-selected field arbitrary in a value of union type EXTERNALtransfer.encoding.");
306 return *field_arbitrary
;
309 ASN_BER_TLV_t
* EXTERNALtransfer_encoding::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
312 ASN_BER_TLV_t
*new_tlv
;
313 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
314 TTCN_EncDec_ErrorContext ec_1
;
315 switch (union_selection
) {
316 case ALT_single__ASN1__type
:
317 ec_1
.set_msg("single-ASN1-type': ");
318 new_tlv
=field_single__ASN1__type
->BER_encode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_coding
);
320 case ALT_octet__aligned
:
321 ec_1
.set_msg("octet-aligned': ");
322 new_tlv
=field_octet__aligned
->BER_encode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_coding
);
325 ec_1
.set_msg("arbitrary': ");
326 new_tlv
=field_arbitrary
->BER_encode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, p_coding
);
329 new_tlv
=BER_encode_chk_bound(FALSE
);
332 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
336 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
339 boolean
EXTERNALtransfer_encoding::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
342 union_selection
=ALT_single__ASN1__type
;
343 field_single__ASN1__type
=new ASN_ANY
;
344 if(field_single__ASN1__type
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_tlv
))
346 delete field_single__ASN1__type
;
347 union_selection
=ALT_octet__aligned
;
348 field_octet__aligned
=new OCTETSTRING
;
349 if(field_octet__aligned
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_tlv
))
351 delete field_octet__aligned
;
352 union_selection
=ALT_arbitrary
;
353 field_arbitrary
=new BITSTRING
;
354 if(field_arbitrary
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_arbitrary_descr_
, p_tlv
))
356 delete field_arbitrary
;
357 union_selection
=UNBOUND_VALUE
;
361 boolean
EXTERNALtransfer_encoding::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
363 if(p_td
.ber
->n_tags
==0) {
364 EXTERNALtransfer_encoding tmp_type
;
365 return tmp_type
.BER_decode_set_selection(p_tlv
);
367 else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
370 boolean
EXTERNALtransfer_encoding::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
373 ASN_BER_TLV_t stripped_tlv
;
374 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
375 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer.encoding' type: ");
376 ASN_BER_TLV_t tmp_tlv
;
377 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
))
379 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
380 TTCN_EncDec_ErrorContext ec_2
;
381 switch (union_selection
) {
382 case ALT_single__ASN1__type
:
383 ec_2
.set_msg("single-ASN1-type': ");
384 field_single__ASN1__type
->BER_decode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, tmp_tlv
, L_form
);
386 case ALT_octet__aligned
:
387 ec_2
.set_msg("octet-aligned': ");
388 field_octet__aligned
->BER_decode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, tmp_tlv
, L_form
);
391 ec_2
.set_msg("arbitrary': ");
392 field_arbitrary
->BER_decode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, tmp_tlv
, L_form
);
400 int EXTERNALtransfer_encoding::XER_encode(const XERdescriptor_t
& p_td
,
401 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
) const
403 int indenting
= !is_canonical(flavor
);
404 int exer
= is_exer(flavor
);
405 int encoded_length
=(int)p_buf
.get_len();
406 if (indenting
) do_indent(p_buf
, indent
);
408 if (exer
) write_ns_prefix(p_td
, p_buf
);
409 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
412 switch (union_selection
) {
413 case ALT_single__ASN1__type
:
414 field_single__ASN1__type
->XER_encode(EXTERNAL_encoding_singleASN_xer_
, p_buf
, flavor
, indent
);
416 case ALT_octet__aligned
:
417 field_octet__aligned
->XER_encode(EXTERNAL_encoding_octet_aligned_xer_
, p_buf
, flavor
, indent
);
420 field_arbitrary
->XER_encode(EXTERNAL_encoding_arbitrary_xer_
, p_buf
, flavor
, indent
);
423 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND
,
424 "Encoding an unbound value");
427 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
428 // TODO something at all ?
432 if (indenting
) do_indent(p_buf
, --indent
);
435 if (exer
) write_ns_prefix(p_td
, p_buf
);
436 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
437 return (int)p_buf
.get_len() - encoded_length
;
440 int EXTERNALtransfer_encoding::XER_decode(const XERdescriptor_t
& p_td
,
441 XmlReaderWrap
& reader
, unsigned int flavor
)
443 int exer
= is_exer(flavor
);
444 int success
= reader
.Ok(), type
, depth
= -1;
445 for (; success
==1; success
= reader
.Read()) {
446 type
= reader
.NodeType();
447 if (type
== XML_READER_TYPE_ELEMENT
) {
448 verify_name(reader
, p_td
, exer
);
449 depth
= reader
.Depth();
454 const char * name
= 0;
455 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
456 type
= reader
.NodeType();
457 if (XML_READER_TYPE_ELEMENT
== type
) break;
458 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
460 name
= (const char*)reader
.Name();
463 case 's': // single-ASN1-type
464 single__ASN1__type().XER_decode(EXTERNAL_encoding_singleASN_xer_
, reader
, flavor
);
467 case 'o': // octet-aligned
468 octet__aligned().XER_decode(EXTERNAL_encoding_octet_aligned_xer_
, reader
, flavor
);
471 case 'a': // arbitrary
472 arbitrary().XER_decode(EXTERNAL_encoding_arbitrary_xer_
, reader
, flavor
);
476 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
477 "Doh!"); // FIXME error method and text
481 for (success
= reader
.Read(); success
==1; success
= reader
.Read()) {
482 type
= reader
.NodeType();
483 if (XML_READER_TYPE_END_ELEMENT
== type
) {
484 verify_end(reader
, p_td
, depth
, exer
);
485 reader
.Read(); // one last time
490 return 0; // FIXME return value
493 /******************** EXTERNALtransfer class ********************/
495 ASN_BER_TLV_t
* EXTERNALtransfer::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
498 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
499 TTCN_EncDec_ErrorContext
ec_0("Component '");
500 TTCN_EncDec_ErrorContext ec_1
;
501 ec_1
.set_msg("direct-reference': ");
502 new_tlv
->add_TLV(field_direct__reference
.BER_encode_TLV(OBJID_descr_
, p_coding
));
503 ec_1
.set_msg("indirect-reference': ");
504 new_tlv
->add_TLV(field_indirect__reference
.BER_encode_TLV(INTEGER_descr_
, p_coding
));
505 ec_1
.set_msg("data-value-descriptor': ");
506 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(ObjectDescriptor_descr_
, p_coding
));
507 ec_1
.set_msg("encoding': ");
508 new_tlv
->add_TLV(field_encoding
.BER_encode_TLV(EXTERNALtransfer_encoding_descr_
, p_coding
));
509 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
513 boolean
EXTERNALtransfer::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
516 ASN_BER_TLV_t stripped_tlv
;
517 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
518 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer' type: ");
519 stripped_tlv
.chk_constructed_flag(TRUE
);
521 ASN_BER_TLV_t tmp_tlv
;
522 boolean tlv_present
=FALSE
;
524 TTCN_EncDec_ErrorContext
ec_1("Component '");
525 TTCN_EncDec_ErrorContext ec_2
;
526 ec_2
.set_msg("direct-reference': ");
527 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
528 if(!tlv_present
) field_direct__reference
=OMIT_VALUE
;
530 field_direct__reference
.BER_decode_TLV(OBJID_descr_
, tmp_tlv
, L_form
);
531 if(field_direct__reference
.ispresent()) tlv_present
=FALSE
;
533 ec_2
.set_msg("indirect-reference': ");
534 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
535 if(!tlv_present
) field_indirect__reference
=OMIT_VALUE
;
537 field_indirect__reference
.BER_decode_TLV(INTEGER_descr_
, tmp_tlv
, L_form
);
538 if(field_indirect__reference
.ispresent()) tlv_present
=FALSE
;
540 ec_2
.set_msg("data-value-descriptor': ");
541 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
542 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
544 field_data__value__descriptor
.BER_decode_TLV(ObjectDescriptor_descr_
, tmp_tlv
, L_form
);
545 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
547 ec_2
.set_msg("encoding': ");
548 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
549 if(!tlv_present
) return FALSE
;
550 field_encoding
.BER_decode_TLV(EXTERNALtransfer_encoding_descr_
, tmp_tlv
, L_form
);
553 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
557 int EXTERNALtransfer::XER_encode(const XERdescriptor_t
& p_td
,
558 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
) const
560 int indenting
= !is_canonical(flavor
);
561 int exer
= is_exer(flavor
);
562 int encoded_length
=(int)p_buf
.get_len();
563 if (indenting
) do_indent(p_buf
, indent
);
565 if (exer
) write_ns_prefix(p_td
, p_buf
);
566 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
569 field_direct__reference
.XER_encode(EXTERNAL_direct_reference_xer_
, p_buf
, flavor
, indent
);
570 field_indirect__reference
.XER_encode(EXTERNAL_indirect_reference_xer_
, p_buf
, flavor
, indent
);
571 field_data__value__descriptor
.XER_encode(EXTERNAL_data_value_descriptor_xer_
, p_buf
, flavor
, indent
);
572 field_encoding
.XER_encode(EXTERNAL_encoding_xer_
, p_buf
, flavor
, indent
);
574 if (indenting
) do_indent(p_buf
, --indent
);
577 if (exer
) write_ns_prefix(p_td
, p_buf
);
578 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
579 return (int)p_buf
.get_len() - encoded_length
;
582 int EXTERNALtransfer::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
, unsigned int flavor
)
584 int exer
= is_exer(flavor
);
585 int success
= reader
.Ok(), depth
= -1;
586 for (; success
== 1; success
= reader
.Read()) {
587 int type
= reader
.NodeType();
588 if (XML_READER_TYPE_ELEMENT
== type
) {
589 verify_name(reader
, p_td
, exer
);
590 depth
= reader
.Depth();
596 field_direct__reference
.XER_decode(EXTERNAL_direct_reference_xer_
, reader
, flavor
);
597 field_indirect__reference
.XER_decode(EXTERNAL_indirect_reference_xer_
, reader
, flavor
);
598 field_data__value__descriptor
.XER_decode(EXTERNAL_data_value_descriptor_xer_
, reader
, flavor
);
599 field_encoding
.XER_decode(EXTERNAL_encoding_xer_
, reader
, flavor
);
601 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
602 int type
= reader
.NodeType();
603 if (XML_READER_TYPE_END_ELEMENT
== type
) {
604 verify_end(reader
, p_td
, depth
, exer
);
605 reader
.Read(); // one more time
609 return 1; // decode successful
611 } // end of anonymous namespace
614 * And this is the EXTERNAL type stuff.
618 * This is written by hand, do not delete it! :)
620 ASN_BER_TLV_t
* EXTERNAL::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
622 EXTERNALtransfer v_tmpmfr
;
623 v_tmpmfr
.load(*this);
624 return v_tmpmfr
.BER_encode_TLV(p_td
, p_coding
);
627 /** Load information from an EXTERNALtransfer
629 * @param x pointer to an EXTERNALtransfer. It is of type void* because
630 * <anonymous-namespace>::EXTERNALtransfer can not appear in the header.
632 * Called by XER_decode() */
633 void EXTERNAL::transfer(void *x
)
635 EXTERNALtransfer
& v_tmpmfr
= *(EXTERNALtransfer
*)x
;
636 if (v_tmpmfr
.direct__reference().ispresent()) {
637 if (v_tmpmfr
.indirect__reference().ispresent()) {
638 EXTERNAL_identification_context__negotiation
& v_tmpjsz
=
639 field_identification
.context__negotiation();
640 v_tmpjsz
.presentation__context__id() = v_tmpmfr
.indirect__reference()();
641 v_tmpjsz
.transfer__syntax() = v_tmpmfr
.direct__reference()();
643 field_identification
.syntax() = v_tmpmfr
.direct__reference()();
646 if (v_tmpmfr
.indirect__reference().ispresent()) {
647 field_identification
.presentation__context__id() =
648 v_tmpmfr
.indirect__reference()();
650 TTCN_EncDec_ErrorContext::warning("Neither direct-reference nor "
651 "indirect-reference is present.");
654 switch (field_identification
.get_selection()) {
655 case EXTERNAL_identification::ALT_syntaxes
:
656 case EXTERNAL_identification::ALT_transfer__syntax
:
657 case EXTERNAL_identification::ALT_fixed
:
658 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
659 "EXTERNAL type does not allow the syntaxes, transfer-syntax or fixed");
663 break; // rest are OK
666 field_data__value__descriptor
= v_tmpmfr
.data__value__descriptor();
667 const EXTERNALtransfer_encoding
& v_tmpjsz
= v_tmpmfr
.encoding();
668 switch (v_tmpjsz
.get_selection()) {
669 case EXTERNALtransfer_encoding::ALT_single__ASN1__type
:
670 field_data__value
= v_tmpjsz
.single__ASN1__type();
672 case EXTERNALtransfer_encoding::ALT_octet__aligned
:
673 field_data__value
= v_tmpjsz
.octet__aligned();
675 case EXTERNALtransfer_encoding::ALT_arbitrary
:
676 field_data__value
= bit2oct(v_tmpjsz
.arbitrary());
679 TTCN_EncDec_ErrorContext::error_internal("Unknown selection for field "
680 "`encoding' in EXTERNAL type.");
685 * This is written by hand, do not delete it! :)
687 boolean
EXTERNAL::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
689 EXTERNALtransfer v_tmpmfr
;
690 if(!v_tmpmfr
.BER_decode_TLV(p_td
, p_tlv
, L_form
))
696 int EXTERNAL::XER_encode(const XERdescriptor_t
& p_td
,
697 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
) const
700 TTCN_EncDec_ErrorContext::error
701 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
703 EXTERNALtransfer xfer
;
705 return xfer
.XER_encode(p_td
, p_buf
, flavor
, indent
);
708 int EXTERNAL::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
711 EXTERNALtransfer xfer
;
712 xfer
.XER_decode(p_td
, reader
, flavor
);
714 return 1; // decode successful
717 /* generated stuff */
719 void EXTERNAL_identification::clean_up()
721 switch (union_selection
) {
723 delete field_syntaxes
;
728 case ALT_presentation__context__id
:
729 delete field_presentation__context__id
;
731 case ALT_context__negotiation
:
732 delete field_context__negotiation
;
734 case ALT_transfer__syntax
:
735 delete field_transfer__syntax
;
743 union_selection
= UNBOUND_VALUE
;
746 void EXTERNAL_identification::copy_value(const EXTERNAL_identification
& other_value
)
748 switch (other_value
.union_selection
) {
750 field_syntaxes
= new EXTERNAL_identification_syntaxes(*other_value
.field_syntaxes
);
753 field_syntax
= new OBJID(*other_value
.field_syntax
);
755 case ALT_presentation__context__id
:
756 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
758 case ALT_context__negotiation
:
759 field_context__negotiation
= new EXTERNAL_identification_context__negotiation(*other_value
.field_context__negotiation
);
761 case ALT_transfer__syntax
:
762 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
765 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
768 TTCN_error("Assignment of an unbound union value of type EXTERNAL.identification.");
770 union_selection
= other_value
.union_selection
;
773 EXTERNAL_identification::EXTERNAL_identification()
775 union_selection
= UNBOUND_VALUE
;
778 EXTERNAL_identification::EXTERNAL_identification(const EXTERNAL_identification
& other_value
)
779 : Base_Type(other_value
)
781 copy_value(other_value
);
784 EXTERNAL_identification::~EXTERNAL_identification()
789 EXTERNAL_identification
& EXTERNAL_identification::operator=(const EXTERNAL_identification
& other_value
)
791 if (this != &other_value
) {
793 copy_value(other_value
);
798 boolean
EXTERNAL_identification::operator==(const EXTERNAL_identification
& other_value
) const
800 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type EXTERNAL.identification.");
801 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type EXTERNAL.identification.");
802 if (union_selection
!= other_value
.union_selection
) return FALSE
;
803 switch (union_selection
) {
805 return *field_syntaxes
== *other_value
.field_syntaxes
;
807 return *field_syntax
== *other_value
.field_syntax
;
808 case ALT_presentation__context__id
:
809 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
810 case ALT_context__negotiation
:
811 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
812 case ALT_transfer__syntax
:
813 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
815 return *field_fixed
== *other_value
.field_fixed
;
821 EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes()
823 if (union_selection
!= ALT_syntaxes
) {
825 field_syntaxes
= new EXTERNAL_identification_syntaxes
;
826 union_selection
= ALT_syntaxes
;
828 return *field_syntaxes
;
831 const EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes() const
833 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type EXTERNAL.identification.");
834 return *field_syntaxes
;
837 OBJID
& EXTERNAL_identification::syntax()
839 if (union_selection
!= ALT_syntax
) {
841 field_syntax
= new OBJID
;
842 union_selection
= ALT_syntax
;
844 return *field_syntax
;
847 const OBJID
& EXTERNAL_identification::syntax() const
849 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type EXTERNAL.identification.");
850 return *field_syntax
;
853 INTEGER
& EXTERNAL_identification::presentation__context__id()
855 if (union_selection
!= ALT_presentation__context__id
) {
857 field_presentation__context__id
= new INTEGER
;
858 union_selection
= ALT_presentation__context__id
;
860 return *field_presentation__context__id
;
863 const INTEGER
& EXTERNAL_identification::presentation__context__id() const
865 if (union_selection
!= ALT_presentation__context__id
) TTCN_error("Using non-selected field presentation_context_id in a value of union type EXTERNAL.identification.");
866 return *field_presentation__context__id
;
869 EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation()
871 if (union_selection
!= ALT_context__negotiation
) {
873 field_context__negotiation
= new EXTERNAL_identification_context__negotiation
;
874 union_selection
= ALT_context__negotiation
;
876 return *field_context__negotiation
;
879 const EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation() const
881 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type EXTERNAL.identification.");
882 return *field_context__negotiation
;
885 OBJID
& EXTERNAL_identification::transfer__syntax()
887 if (union_selection
!= ALT_transfer__syntax
) {
889 field_transfer__syntax
= new OBJID
;
890 union_selection
= ALT_transfer__syntax
;
892 return *field_transfer__syntax
;
895 const OBJID
& EXTERNAL_identification::transfer__syntax() const
897 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type EXTERNAL.identification.");
898 return *field_transfer__syntax
;
901 ASN_NULL
& EXTERNAL_identification::fixed()
903 if (union_selection
!= ALT_fixed
) {
905 field_fixed
= new ASN_NULL
;
906 union_selection
= ALT_fixed
;
911 const ASN_NULL
& EXTERNAL_identification::fixed() const
913 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type EXTERNAL.identification.");
917 boolean
EXTERNAL_identification::ischosen(union_selection_type checked_selection
) const
919 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
920 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type EXTERNAL.identification.");
921 return union_selection
== checked_selection
;
924 boolean
EXTERNAL_identification::is_value() const
926 switch (union_selection
) {
928 return field_syntaxes
->is_value();
930 return field_syntax
->is_value();
931 case ALT_presentation__context__id
:
932 return field_presentation__context__id
->is_value();
933 case ALT_context__negotiation
:
934 return field_context__negotiation
->is_value();
935 case ALT_transfer__syntax
:
936 return field_transfer__syntax
->is_value();
938 return field_fixed
->is_value();
944 void EXTERNAL_identification::log() const
946 switch (union_selection
) {
948 TTCN_Logger::log_event_str("{ syntaxes := ");
949 field_syntaxes
->log();
950 TTCN_Logger::log_event_str(" }");
953 TTCN_Logger::log_event_str("{ syntax := ");
955 TTCN_Logger::log_event_str(" }");
957 case ALT_presentation__context__id
:
958 TTCN_Logger::log_event_str("{ presentation_context_id := ");
959 field_presentation__context__id
->log();
960 TTCN_Logger::log_event_str(" }");
962 case ALT_context__negotiation
:
963 TTCN_Logger::log_event_str("{ context_negotiation := ");
964 field_context__negotiation
->log();
965 TTCN_Logger::log_event_str(" }");
967 case ALT_transfer__syntax
:
968 TTCN_Logger::log_event_str("{ transfer_syntax := ");
969 field_transfer__syntax
->log();
970 TTCN_Logger::log_event_str(" }");
973 TTCN_Logger::log_event_str("{ fixed := ");
975 TTCN_Logger::log_event_str(" }");
978 TTCN_Logger::log_event_str("<unbound>");
983 void EXTERNAL_identification::set_param(Module_Param
& param
) {
984 param
.basic_check(Module_Param::BC_VALUE
, "union value");
985 if (param
.get_type()==Module_Param::MP_Value_List
&& param
.get_size()==0) return;
986 if (param
.get_type()!=Module_Param::MP_Assignment_List
) {
987 param
.error("union value with field name was expected");
989 Module_Param
* mp_last
= param
.get_elem(param
.get_size()-1);
990 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
991 syntaxes().set_param(*mp_last
);
994 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
995 syntax().set_param(*mp_last
);
998 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
999 presentation__context__id().set_param(*mp_last
);
1002 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1003 context__negotiation().set_param(*mp_last
);
1006 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1007 transfer__syntax().set_param(*mp_last
);
1010 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1011 fixed().set_param(*mp_last
);
1014 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1017 void EXTERNAL_identification_template::set_param(Module_Param
& param
)
1019 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
1020 switch (param
.get_type()) {
1021 case Module_Param::MP_Omit
:
1024 case Module_Param::MP_Any
:
1027 case Module_Param::MP_AnyOrNone
:
1028 *this = ANY_OR_OMIT
;
1030 case Module_Param::MP_List_Template
:
1031 case Module_Param::MP_ComplementList_Template
:
1032 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
1033 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
1034 list_item(p_i
).set_param(*param
.get_elem(p_i
));
1037 case Module_Param::MP_Value_List
:
1038 if (param
.get_size()==0) break;
1039 param
.type_error("union template", "EXTERNAL.identification");
1041 case Module_Param::MP_Assignment_List
: {
1042 Module_Param
* mp_last
= param
.get_elem(param
.get_size()-1);
1043 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
1044 syntaxes().set_param(*mp_last
);
1047 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
1048 syntax().set_param(*mp_last
);
1051 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
1052 presentation__context__id().set_param(*mp_last
);
1055 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1056 context__negotiation().set_param(*mp_last
);
1059 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1060 transfer__syntax().set_param(*mp_last
);
1063 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1064 fixed().set_param(*mp_last
);
1067 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1070 param
.type_error("union template", "EXTERNAL.identification");
1072 is_ifpresent
= param
.get_ifpresent();
1075 void EXTERNAL_identification::encode_text(Text_Buf
& text_buf
) const
1077 text_buf
.push_int(union_selection
);
1078 switch (union_selection
) {
1080 field_syntaxes
->encode_text(text_buf
);
1083 field_syntax
->encode_text(text_buf
);
1085 case ALT_presentation__context__id
:
1086 field_presentation__context__id
->encode_text(text_buf
);
1088 case ALT_context__negotiation
:
1089 field_context__negotiation
->encode_text(text_buf
);
1091 case ALT_transfer__syntax
:
1092 field_transfer__syntax
->encode_text(text_buf
);
1095 field_fixed
->encode_text(text_buf
);
1098 TTCN_error("Text encoder: Encoding an unbound value of union type EXTERNAL.identification.");
1102 void EXTERNAL_identification::decode_text(Text_Buf
& text_buf
)
1104 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
1106 syntaxes().decode_text(text_buf
);
1109 syntax().decode_text(text_buf
);
1111 case ALT_presentation__context__id
:
1112 presentation__context__id().decode_text(text_buf
);
1114 case ALT_context__negotiation
:
1115 context__negotiation().decode_text(text_buf
);
1117 case ALT_transfer__syntax
:
1118 transfer__syntax().decode_text(text_buf
);
1121 fixed().decode_text(text_buf
);
1124 TTCN_error("Text decoder: Unrecognized union selector was received for type EXTERNAL.identification.");
1129 void EXTERNAL_identification_template::clean_up()
1131 switch (template_selection
) {
1132 case SPECIFIC_VALUE
:
1133 switch (single_value
.union_selection
) {
1134 case EXTERNAL_identification::ALT_syntaxes
:
1135 delete single_value
.field_syntaxes
;
1137 case EXTERNAL_identification::ALT_syntax
:
1138 delete single_value
.field_syntax
;
1140 case EXTERNAL_identification::ALT_presentation__context__id
:
1141 delete single_value
.field_presentation__context__id
;
1143 case EXTERNAL_identification::ALT_context__negotiation
:
1144 delete single_value
.field_context__negotiation
;
1146 case EXTERNAL_identification::ALT_transfer__syntax
:
1147 delete single_value
.field_transfer__syntax
;
1149 case EXTERNAL_identification::ALT_fixed
:
1150 delete single_value
.field_fixed
;
1157 case COMPLEMENTED_LIST
:
1158 delete [] value_list
.list_value
;
1163 template_selection
= UNINITIALIZED_TEMPLATE
;
1166 void EXTERNAL_identification_template::copy_value(const EXTERNAL_identification
& other_value
)
1168 single_value
.union_selection
= other_value
.get_selection();
1169 switch (single_value
.union_selection
) {
1170 case EXTERNAL_identification::ALT_syntaxes
:
1171 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(other_value
.syntaxes());
1173 case EXTERNAL_identification::ALT_syntax
:
1174 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
1176 case EXTERNAL_identification::ALT_presentation__context__id
:
1177 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
1179 case EXTERNAL_identification::ALT_context__negotiation
:
1180 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(other_value
.context__negotiation());
1182 case EXTERNAL_identification::ALT_transfer__syntax
:
1183 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
1185 case EXTERNAL_identification::ALT_fixed
:
1186 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
1189 TTCN_error("Initializing a template with an unbound value of type EXTERNAL.identification.");
1191 set_selection(SPECIFIC_VALUE
);
1194 void EXTERNAL_identification_template::copy_template(const EXTERNAL_identification_template
& other_value
)
1196 switch (other_value
.template_selection
) {
1197 case SPECIFIC_VALUE
:
1198 single_value
.union_selection
= other_value
.single_value
.union_selection
;
1199 switch (single_value
.union_selection
) {
1200 case EXTERNAL_identification::ALT_syntaxes
:
1201 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
1203 case EXTERNAL_identification::ALT_syntax
:
1204 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
1206 case EXTERNAL_identification::ALT_presentation__context__id
:
1207 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
1209 case EXTERNAL_identification::ALT_context__negotiation
:
1210 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
1212 case EXTERNAL_identification::ALT_transfer__syntax
:
1213 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
1215 case EXTERNAL_identification::ALT_fixed
:
1216 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
1219 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EXTERNAL.identification.");
1227 case COMPLEMENTED_LIST
:
1228 value_list
.n_values
= other_value
.value_list
.n_values
;
1229 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1230 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1231 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1234 TTCN_error("Copying an uninitialized template of union type EXTERNAL.identification.");
1236 set_selection(other_value
);
1239 EXTERNAL_identification_template::EXTERNAL_identification_template()
1243 EXTERNAL_identification_template::EXTERNAL_identification_template(template_sel other_value
)
1244 : Base_Template(other_value
)
1246 check_single_selection(other_value
);
1249 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification
& other_value
)
1251 copy_value(other_value
);
1254 EXTERNAL_identification_template::EXTERNAL_identification_template(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1256 switch (other_value
.get_selection()) {
1257 case OPTIONAL_PRESENT
:
1258 copy_value((const EXTERNAL_identification
&)other_value
);
1261 set_selection(OMIT_VALUE
);
1264 TTCN_error("Creating a template of union type EXTERNAL.identification from an unbound optional field.");
1268 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification_template
& other_value
)
1271 copy_template(other_value
);
1274 EXTERNAL_identification_template::~EXTERNAL_identification_template()
1279 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(template_sel other_value
)
1281 check_single_selection(other_value
);
1283 set_selection(other_value
);
1287 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification
& other_value
)
1290 copy_value(other_value
);
1294 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1297 switch (other_value
.get_selection()) {
1298 case OPTIONAL_PRESENT
:
1299 copy_value((const EXTERNAL_identification
&)other_value
);
1302 set_selection(OMIT_VALUE
);
1305 TTCN_error("Assignment of an unbound optional field to a template of union type EXTERNAL.identification.");
1310 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification_template
& other_value
)
1312 if (&other_value
!= this) {
1314 copy_template(other_value
);
1319 boolean
EXTERNAL_identification_template::match(const EXTERNAL_identification
& other_value
) const
1321 switch (template_selection
) {
1327 case SPECIFIC_VALUE
:
1329 EXTERNAL_identification::union_selection_type value_selection
= other_value
.get_selection();
1330 if (value_selection
== EXTERNAL_identification::UNBOUND_VALUE
) return FALSE
;
1331 if (value_selection
!= single_value
.union_selection
) return FALSE
;
1332 switch (value_selection
) {
1333 case EXTERNAL_identification::ALT_syntaxes
:
1334 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
1335 case EXTERNAL_identification::ALT_syntax
:
1336 return single_value
.field_syntax
->match(other_value
.syntax());
1337 case EXTERNAL_identification::ALT_presentation__context__id
:
1338 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
1339 case EXTERNAL_identification::ALT_context__negotiation
:
1340 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
1341 case EXTERNAL_identification::ALT_transfer__syntax
:
1342 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
1343 case EXTERNAL_identification::ALT_fixed
:
1344 return single_value
.field_fixed
->match(other_value
.fixed());
1346 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EXTERNAL.identification.");
1349 break; // should never get here
1351 case COMPLEMENTED_LIST
:
1352 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1353 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1354 return template_selection
== COMPLEMENTED_LIST
;
1356 TTCN_error ("Matching an uninitialized template of union type EXTERNAL.identification.");
1361 EXTERNAL_identification
EXTERNAL_identification_template::valueof() const
1363 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1364 TTCN_error("Performing valueof or send operation on a non-specific template of union type EXTERNAL.identification.");
1365 EXTERNAL_identification ret_val
;
1366 switch (single_value
.union_selection
) {
1367 case EXTERNAL_identification::ALT_syntaxes
:
1368 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
1370 case EXTERNAL_identification::ALT_syntax
:
1371 ret_val
.syntax() = single_value
.field_syntax
->valueof();
1373 case EXTERNAL_identification::ALT_presentation__context__id
:
1374 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
1376 case EXTERNAL_identification::ALT_context__negotiation
:
1377 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
1379 case EXTERNAL_identification::ALT_transfer__syntax
:
1380 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1382 case EXTERNAL_identification::ALT_fixed
:
1383 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1386 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EXTERNAL.identification.");
1391 EXTERNAL_identification_template
& EXTERNAL_identification_template::list_item(unsigned int list_index
) const
1393 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.");
1394 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type EXTERNAL.identification.");
1395 return value_list
.list_value
[list_index
];
1397 void EXTERNAL_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1399 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.");
1401 set_selection(template_type
);
1402 value_list
.n_values
= list_length
;
1403 value_list
.list_value
= new EXTERNAL_identification_template
[list_length
];
1406 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes()
1408 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) {
1409 template_sel old_selection
= template_selection
;
1411 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(ANY_VALUE
);
1412 else single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1413 single_value
.union_selection
= EXTERNAL_identification::ALT_syntaxes
;
1414 set_selection(SPECIFIC_VALUE
);
1416 return *single_value
.field_syntaxes
;
1419 const EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes() const
1421 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type EXTERNAL.identification.");
1422 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) TTCN_error("Accessing non-selected field syntaxes in a template of union type EXTERNAL.identification.");
1423 return *single_value
.field_syntaxes
;
1426 OBJID_template
& EXTERNAL_identification_template::syntax()
1428 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) {
1429 template_sel old_selection
= template_selection
;
1431 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1432 else single_value
.field_syntax
= new OBJID_template
;
1433 single_value
.union_selection
= EXTERNAL_identification::ALT_syntax
;
1434 set_selection(SPECIFIC_VALUE
);
1436 return *single_value
.field_syntax
;
1439 const OBJID_template
& EXTERNAL_identification_template::syntax() const
1441 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type EXTERNAL.identification.");
1442 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) TTCN_error("Accessing non-selected field syntax in a template of union type EXTERNAL.identification.");
1443 return *single_value
.field_syntax
;
1446 INTEGER_template
& EXTERNAL_identification_template::presentation__context__id()
1448 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_presentation__context__id
) {
1449 template_sel old_selection
= template_selection
;
1451 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1452 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1453 single_value
.union_selection
= EXTERNAL_identification::ALT_presentation__context__id
;
1454 set_selection(SPECIFIC_VALUE
);
1456 return *single_value
.field_presentation__context__id
;
1459 const INTEGER_template
& EXTERNAL_identification_template::presentation__context__id() const
1461 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type EXTERNAL.identification.");
1462 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.");
1463 return *single_value
.field_presentation__context__id
;
1466 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation()
1468 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_context__negotiation
) {
1469 template_sel old_selection
= template_selection
;
1471 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(ANY_VALUE
);
1472 else single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1473 single_value
.union_selection
= EXTERNAL_identification::ALT_context__negotiation
;
1474 set_selection(SPECIFIC_VALUE
);
1476 return *single_value
.field_context__negotiation
;
1479 const EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation() const
1481 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type EXTERNAL.identification.");
1482 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.");
1483 return *single_value
.field_context__negotiation
;
1486 OBJID_template
& EXTERNAL_identification_template::transfer__syntax()
1488 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_transfer__syntax
) {
1489 template_sel old_selection
= template_selection
;
1491 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1492 else single_value
.field_transfer__syntax
= new OBJID_template
;
1493 single_value
.union_selection
= EXTERNAL_identification::ALT_transfer__syntax
;
1494 set_selection(SPECIFIC_VALUE
);
1496 return *single_value
.field_transfer__syntax
;
1499 const OBJID_template
& EXTERNAL_identification_template::transfer__syntax() const
1501 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type EXTERNAL.identification.");
1502 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.");
1503 return *single_value
.field_transfer__syntax
;
1506 ASN_NULL_template
& EXTERNAL_identification_template::fixed()
1508 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) {
1509 template_sel old_selection
= template_selection
;
1511 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1512 else single_value
.field_fixed
= new ASN_NULL_template
;
1513 single_value
.union_selection
= EXTERNAL_identification::ALT_fixed
;
1514 set_selection(SPECIFIC_VALUE
);
1516 return *single_value
.field_fixed
;
1519 const ASN_NULL_template
& EXTERNAL_identification_template::fixed() const
1521 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type EXTERNAL.identification.");
1522 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) TTCN_error("Accessing non-selected field fixed in a template of union type EXTERNAL.identification.");
1523 return *single_value
.field_fixed
;
1526 boolean
EXTERNAL_identification_template::ischosen(EXTERNAL_identification::union_selection_type checked_selection
) const
1528 if (checked_selection
== EXTERNAL_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
1529 switch (template_selection
) {
1530 case SPECIFIC_VALUE
:
1531 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.");
1532 return single_value
.union_selection
== checked_selection
;
1535 if (value_list
.n_values
< 1)
1536 TTCN_error("Internal error: Performing ischosen() operation on a template of union type EXTERNAL.identification containing an empty list.");
1537 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1538 boolean all_same
= TRUE
;
1539 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1540 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1545 if (all_same
) return ret_val
;
1547 // FIXME really no break?
1551 case COMPLEMENTED_LIST
:
1552 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.");
1554 TTCN_error("Performing ischosen() operation on an uninitialized template of union type EXTERNAL.identification");
1559 void EXTERNAL_identification_template::log() const
1561 switch (template_selection
) {
1562 case SPECIFIC_VALUE
:
1563 switch (single_value
.union_selection
) {
1564 case EXTERNAL_identification::ALT_syntaxes
:
1565 TTCN_Logger::log_event_str("{ syntaxes := ");
1566 single_value
.field_syntaxes
->log();
1567 TTCN_Logger::log_event_str(" }");
1569 case EXTERNAL_identification::ALT_syntax
:
1570 TTCN_Logger::log_event_str("{ syntax := ");
1571 single_value
.field_syntax
->log();
1572 TTCN_Logger::log_event_str(" }");
1574 case EXTERNAL_identification::ALT_presentation__context__id
:
1575 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1576 single_value
.field_presentation__context__id
->log();
1577 TTCN_Logger::log_event_str(" }");
1579 case EXTERNAL_identification::ALT_context__negotiation
:
1580 TTCN_Logger::log_event_str("{ context_negotiation := ");
1581 single_value
.field_context__negotiation
->log();
1582 TTCN_Logger::log_event_str(" }");
1584 case EXTERNAL_identification::ALT_transfer__syntax
:
1585 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1586 single_value
.field_transfer__syntax
->log();
1587 TTCN_Logger::log_event_str(" }");
1589 case EXTERNAL_identification::ALT_fixed
:
1590 TTCN_Logger::log_event_str("{ fixed := ");
1591 single_value
.field_fixed
->log();
1592 TTCN_Logger::log_event_str(" }");
1595 TTCN_Logger::log_event_str("<invalid selector>");
1599 case COMPLEMENTED_LIST
:
1600 TTCN_Logger::log_event_str("complement ");
1603 TTCN_Logger::log_char('(');
1604 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1605 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1606 value_list
.list_value
[list_count
].log();
1608 TTCN_Logger::log_char(')');
1617 void EXTERNAL_identification_template::log_match(const EXTERNAL_identification
& match_value
) const
1619 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1620 if(match(match_value
)){
1621 TTCN_Logger::print_logmatch_buffer();
1622 TTCN_Logger::log_event_str(" matched ");
1626 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1627 switch (single_value
.union_selection
) {
1628 case EXTERNAL_identification::ALT_syntaxes
:
1629 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1630 TTCN_Logger::log_logmatch_info(".syntaxes");
1631 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1633 TTCN_Logger::log_event_str("{ syntaxes := ");
1634 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1635 TTCN_Logger::log_event_str(" }");
1638 case EXTERNAL_identification::ALT_syntax
:
1639 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1640 TTCN_Logger::log_logmatch_info(".syntax");
1641 single_value
.field_syntax
->log_match(match_value
.syntax());
1643 TTCN_Logger::log_event_str("{ syntax := ");
1644 single_value
.field_syntax
->log_match(match_value
.syntax());
1645 TTCN_Logger::log_event_str(" }");
1648 case EXTERNAL_identification::ALT_presentation__context__id
:
1649 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1650 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1651 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1653 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1654 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1655 TTCN_Logger::log_event_str(" }");
1658 case EXTERNAL_identification::ALT_context__negotiation
:
1659 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1660 TTCN_Logger::log_logmatch_info(".context_negotiation");
1661 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1663 TTCN_Logger::log_event_str("{ context_negotiation := ");
1664 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1665 TTCN_Logger::log_event_str(" }");
1668 case EXTERNAL_identification::ALT_transfer__syntax
:
1669 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1670 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1671 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1673 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1674 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1675 TTCN_Logger::log_event_str(" }");
1678 case EXTERNAL_identification::ALT_fixed
:
1679 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1680 TTCN_Logger::log_logmatch_info(".fixed");
1681 single_value
.field_fixed
->log_match(match_value
.fixed());
1683 TTCN_Logger::log_event_str("{ fixed := ");
1684 single_value
.field_fixed
->log_match(match_value
.fixed());
1685 TTCN_Logger::log_event_str(" }");
1689 TTCN_Logger::print_logmatch_buffer();
1690 TTCN_Logger::log_event_str("<invalid selector>");
1694 TTCN_Logger::print_logmatch_buffer();
1696 TTCN_Logger::log_event_str(" with ");
1698 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1699 else TTCN_Logger::log_event_str(" unmatched");
1703 void EXTERNAL_identification_template::encode_text(Text_Buf
& text_buf
) const
1705 encode_text_base(text_buf
);
1706 switch (template_selection
) {
1707 case SPECIFIC_VALUE
:
1708 text_buf
.push_int(single_value
.union_selection
);
1709 switch (single_value
.union_selection
) {
1710 case EXTERNAL_identification::ALT_syntaxes
:
1711 single_value
.field_syntaxes
->encode_text(text_buf
);
1713 case EXTERNAL_identification::ALT_syntax
:
1714 single_value
.field_syntax
->encode_text(text_buf
);
1716 case EXTERNAL_identification::ALT_presentation__context__id
:
1717 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1719 case EXTERNAL_identification::ALT_context__negotiation
:
1720 single_value
.field_context__negotiation
->encode_text(text_buf
);
1722 case EXTERNAL_identification::ALT_transfer__syntax
:
1723 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1725 case EXTERNAL_identification::ALT_fixed
:
1726 single_value
.field_fixed
->encode_text(text_buf
);
1729 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EXTERNAL.identification.");
1737 case COMPLEMENTED_LIST
:
1738 text_buf
.push_int(value_list
.n_values
);
1739 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1740 value_list
.list_value
[list_count
].encode_text(text_buf
);
1743 TTCN_error("Text encoder: Encoding an uninitialized template of type EXTERNAL.identification.");
1747 void EXTERNAL_identification_template::decode_text(Text_Buf
& text_buf
)
1750 decode_text_base(text_buf
);
1751 switch (template_selection
) {
1752 case SPECIFIC_VALUE
:
1754 single_value
.union_selection
= EXTERNAL_identification::UNBOUND_VALUE
;
1755 EXTERNAL_identification::union_selection_type new_selection
= (EXTERNAL_identification::union_selection_type
)text_buf
.pull_int().get_val();
1756 switch (new_selection
) {
1757 case EXTERNAL_identification::ALT_syntaxes
:
1758 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1759 single_value
.field_syntaxes
->decode_text(text_buf
);
1761 case EXTERNAL_identification::ALT_syntax
:
1762 single_value
.field_syntax
= new OBJID_template
;
1763 single_value
.field_syntax
->decode_text(text_buf
);
1765 case EXTERNAL_identification::ALT_presentation__context__id
:
1766 single_value
.field_presentation__context__id
= new INTEGER_template
;
1767 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1769 case EXTERNAL_identification::ALT_context__negotiation
:
1770 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1771 single_value
.field_context__negotiation
->decode_text(text_buf
);
1773 case EXTERNAL_identification::ALT_transfer__syntax
:
1774 single_value
.field_transfer__syntax
= new OBJID_template
;
1775 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1777 case EXTERNAL_identification::ALT_fixed
:
1778 single_value
.field_fixed
= new ASN_NULL_template
;
1779 single_value
.field_fixed
->decode_text(text_buf
);
1782 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EXTERNAL.identification.");
1784 single_value
.union_selection
= new_selection
;
1792 case COMPLEMENTED_LIST
:
1793 value_list
.n_values
= text_buf
.pull_int().get_val();
1794 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1795 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1796 value_list
.list_value
[list_count
].decode_text(text_buf
);
1799 TTCN_error("Text decoder: Unrecognized selector was received in a template of type EXTERNAL.identification.");
1803 boolean
EXTERNAL_identification_template::is_present() const
1805 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1806 return !match_omit();
1809 boolean
EXTERNAL_identification_template::match_omit() const
1811 if (is_ifpresent
) return TRUE
;
1812 switch (template_selection
) {
1817 case COMPLEMENTED_LIST
:
1818 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1819 if (value_list
.list_value
[i
].match_omit())
1820 return template_selection
==VALUE_LIST
;
1821 return template_selection
==COMPLEMENTED_LIST
;
1828 #ifndef TITAN_RUNTIME_2
1829 void EXTERNAL_identification_template::check_restriction(template_res t_res
, const char* t_name
) const
1831 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1832 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1834 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1837 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1838 template_selection
==SPECIFIC_VALUE
)) return;
1841 if (!match_omit()) return;
1846 TTCN_error("Restriction `%s' on template of type %s violated.",
1847 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification");
1851 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes()
1855 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes(const OBJID
& par_abstract
,
1856 const OBJID
& par_transfer
)
1857 : field_abstract(par_abstract
),
1858 field_transfer(par_transfer
)
1862 boolean
EXTERNAL_identification_syntaxes::operator==(const EXTERNAL_identification_syntaxes
& other_value
) const
1864 return field_abstract
==other_value
.field_abstract
1865 && field_transfer
==other_value
.field_transfer
;
1868 int EXTERNAL_identification_syntaxes::size_of() const
1874 void EXTERNAL_identification_syntaxes::log() const
1876 TTCN_Logger::log_event_str("{ abstract := ");
1877 field_abstract
.log();
1878 TTCN_Logger::log_event_str(", transfer := ");
1879 field_transfer
.log();
1880 TTCN_Logger::log_event_str(" }");
1883 boolean
EXTERNAL_identification_syntaxes::is_bound() const
1885 if(field_abstract
.is_bound()) return TRUE
;
1886 if(field_transfer
.is_bound()) return TRUE
;
1890 boolean
EXTERNAL_identification_syntaxes::is_value() const
1892 if(!field_abstract
.is_value()) return FALSE
;
1893 if(!field_transfer
.is_value()) return FALSE
;
1897 void EXTERNAL_identification_syntaxes::clean_up()
1899 field_abstract
.clean_up();
1900 field_transfer
.clean_up();
1903 void EXTERNAL_identification_syntaxes::set_param(Module_Param
& param
)
1905 param
.basic_check(Module_Param::BC_VALUE
, "record value");
1906 switch (param
.get_type()) {
1907 case Module_Param::MP_Value_List
:
1908 if (param
.get_size()==0) return;
1909 if (2!=param
.get_size()) {
1910 param
.error("record value of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)param
.get_size());
1912 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*param
.get_elem(0));
1913 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*param
.get_elem(1));
1915 case Module_Param::MP_Assignment_List
: {
1916 Vector
<bool> value_used(param
.get_size());
1917 value_used
.resize(param
.get_size(), false);
1918 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1919 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1920 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1921 abstract().set_param(*curr_param
);
1922 value_used
[val_idx
]=true;
1925 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1926 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1927 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1928 transfer().set_param(*curr_param
);
1929 value_used
[val_idx
]=true;
1932 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1933 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", param
.get_elem(val_idx
)->get_id()->get_name());
1938 param
.type_error("record value", "EXTERNAL.identification.syntaxes");
1942 void EXTERNAL_identification_syntaxes_template::set_param(Module_Param
& param
)
1944 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
1945 switch (param
.get_type()) {
1946 case Module_Param::MP_Omit
:
1949 case Module_Param::MP_Any
:
1952 case Module_Param::MP_AnyOrNone
:
1953 *this = ANY_OR_OMIT
;
1955 case Module_Param::MP_List_Template
:
1956 case Module_Param::MP_ComplementList_Template
:
1957 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
1958 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
1959 list_item(p_i
).set_param(*param
.get_elem(p_i
));
1962 case Module_Param::MP_Value_List
:
1963 if (param
.get_size()==0) break;
1964 if (2!=param
.get_size()) {
1965 param
.error("record template of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)param
.get_size());
1967 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*param
.get_elem(0));
1968 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*param
.get_elem(1));
1970 case Module_Param::MP_Assignment_List
: {
1971 Vector
<bool> value_used(param
.get_size());
1972 value_used
.resize(param
.get_size(), false);
1973 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1974 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1975 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1976 abstract().set_param(*curr_param
);
1977 value_used
[val_idx
]=true;
1980 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1981 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1982 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1983 transfer().set_param(*curr_param
);
1984 value_used
[val_idx
]=true;
1987 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1988 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", param
.get_elem(val_idx
)->get_id()->get_name());
1993 param
.type_error("record template", "EXTERNAL.identification.syntaxes");
1995 is_ifpresent
= param
.get_ifpresent();
1998 void EXTERNAL_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
2000 field_abstract
.encode_text(text_buf
);
2001 field_transfer
.encode_text(text_buf
);
2004 void EXTERNAL_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
2006 field_abstract
.decode_text(text_buf
);
2007 field_transfer
.decode_text(text_buf
);
2010 struct EXTERNAL_identification_syntaxes_template::single_value_struct
{
2011 OBJID_template field_abstract
;
2012 OBJID_template field_transfer
;
2015 void EXTERNAL_identification_syntaxes_template::clean_up()
2017 switch (template_selection
) {
2018 case SPECIFIC_VALUE
:
2019 delete single_value
;
2022 case COMPLEMENTED_LIST
:
2023 delete [] value_list
.list_value
;
2028 template_selection
= UNINITIALIZED_TEMPLATE
;
2031 void EXTERNAL_identification_syntaxes_template::set_specific()
2033 if (template_selection
!= SPECIFIC_VALUE
) {
2034 template_sel old_selection
= template_selection
;
2036 single_value
= new single_value_struct
;
2037 set_selection(SPECIFIC_VALUE
);
2038 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2039 single_value
->field_abstract
= ANY_VALUE
;
2040 single_value
->field_transfer
= ANY_VALUE
;
2045 void EXTERNAL_identification_syntaxes_template::copy_value(const EXTERNAL_identification_syntaxes
& other_value
)
2047 single_value
= new single_value_struct
;
2048 single_value
->field_abstract
= other_value
.abstract();
2049 single_value
->field_transfer
= other_value
.transfer();
2050 set_selection(SPECIFIC_VALUE
);
2053 void EXTERNAL_identification_syntaxes_template::copy_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2055 switch (other_value
.template_selection
) {
2056 case SPECIFIC_VALUE
:
2057 single_value
= new single_value_struct(*other_value
.single_value
);
2064 case COMPLEMENTED_LIST
:
2065 value_list
.n_values
= other_value
.value_list
.n_values
;
2066 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2067 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2068 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2071 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2073 set_selection(other_value
);
2076 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template()
2080 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(template_sel other_value
)
2081 : Base_Template(other_value
)
2083 check_single_selection(other_value
);
2086 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes
& other_value
)
2088 copy_value(other_value
);
2091 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2093 switch (other_value
.get_selection()) {
2094 case OPTIONAL_PRESENT
:
2095 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2098 set_selection(OMIT_VALUE
);
2101 TTCN_error("Creating a template of type EXTERNAL.identification.syntaxes from an unbound optional field.");
2105 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2108 copy_template(other_value
);
2111 EXTERNAL_identification_syntaxes_template::~EXTERNAL_identification_syntaxes_template()
2116 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(template_sel other_value
)
2118 check_single_selection(other_value
);
2120 set_selection(other_value
);
2124 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes
& other_value
)
2127 copy_value(other_value
);
2131 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2134 switch (other_value
.get_selection()) {
2135 case OPTIONAL_PRESENT
:
2136 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2139 set_selection(OMIT_VALUE
);
2142 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.syntaxes.");
2147 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes_template
& other_value
)
2149 if (&other_value
!= this) {
2151 copy_template(other_value
);
2156 boolean
EXTERNAL_identification_syntaxes_template::match(const EXTERNAL_identification_syntaxes
& other_value
) const
2158 switch (template_selection
) {
2164 case SPECIFIC_VALUE
:
2165 if (!other_value
.abstract().is_bound()) return FALSE
;
2166 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
2167 if (!other_value
.transfer().is_bound()) return FALSE
;
2168 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
2171 case COMPLEMENTED_LIST
:
2172 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2173 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2174 return template_selection
== COMPLEMENTED_LIST
;
2176 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2181 EXTERNAL_identification_syntaxes
EXTERNAL_identification_syntaxes_template::valueof() const
2183 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2184 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.syntaxes.");
2185 EXTERNAL_identification_syntaxes ret_val
;
2186 ret_val
.abstract() = single_value
->field_abstract
.valueof();
2187 ret_val
.transfer() = single_value
->field_transfer
.valueof();
2191 void EXTERNAL_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
2193 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2194 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.syntaxes.");
2196 set_selection(template_type
);
2197 value_list
.n_values
= list_length
;
2198 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[list_length
];
2201 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::list_item(unsigned int list_index
) const
2203 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2204 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.syntaxes.");
2205 if (list_index
>= value_list
.n_values
)
2206 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.syntaxes.");
2207 return value_list
.list_value
[list_index
];
2210 OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract()
2213 return single_value
->field_abstract
;
2216 const OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract() const
2218 if (template_selection
!= SPECIFIC_VALUE
)
2219 TTCN_error("Accessing field abstract of a non-specific template of type EXTERNAL.identification.syntaxes.");
2220 return single_value
->field_abstract
;
2223 OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer()
2226 return single_value
->field_transfer
;
2229 const OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer() const
2231 if (template_selection
!= SPECIFIC_VALUE
)
2232 TTCN_error("Accessing field transfer of a non-specific template of type EXTERNAL.identification.syntaxes.");
2233 return single_value
->field_transfer
;
2236 int EXTERNAL_identification_syntaxes_template::size_of() const
2238 switch (template_selection
)
2240 case SPECIFIC_VALUE
:
2247 if (value_list
.n_values
<1)
2248 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing an empty list.");
2249 int item_size
= value_list
.list_value
[0].size_of();
2250 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2252 if (value_list
.list_value
[i
].size_of()!=item_size
)
2253 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing a value list with different sizes.");
2258 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing omit value.");
2261 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing */? value.");
2262 case COMPLEMENTED_LIST
:
2263 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing complemented list.");
2265 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2270 void EXTERNAL_identification_syntaxes_template::log() const
2272 switch (template_selection
) {
2273 case SPECIFIC_VALUE
:
2274 TTCN_Logger::log_event_str("{ abstract := ");
2275 single_value
->field_abstract
.log();
2276 TTCN_Logger::log_event_str(", transfer := ");
2277 single_value
->field_transfer
.log();
2278 TTCN_Logger::log_event_str(" }");
2280 case COMPLEMENTED_LIST
:
2281 TTCN_Logger::log_event_str("complement ");
2284 TTCN_Logger::log_char('(');
2285 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2286 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2287 value_list
.list_value
[list_count
].log();
2289 TTCN_Logger::log_char(')');
2298 void EXTERNAL_identification_syntaxes_template::log_match(const EXTERNAL_identification_syntaxes
& match_value
) const
2300 if (template_selection
== SPECIFIC_VALUE
) {
2301 TTCN_Logger::log_event_str("{ abstract := ");
2302 single_value
->field_abstract
.log_match(match_value
.abstract());
2303 TTCN_Logger::log_event_str(", transfer := ");
2304 single_value
->field_transfer
.log_match(match_value
.transfer());
2305 TTCN_Logger::log_event_str(" }");
2308 TTCN_Logger::log_event_str(" with ");
2310 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2311 else TTCN_Logger::log_event_str(" unmatched");
2315 void EXTERNAL_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2317 encode_text_base(text_buf
);
2318 switch (template_selection
) {
2319 case SPECIFIC_VALUE
:
2320 single_value
->field_abstract
.encode_text(text_buf
);
2321 single_value
->field_transfer
.encode_text(text_buf
);
2328 case COMPLEMENTED_LIST
:
2329 text_buf
.push_int(value_list
.n_values
);
2330 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2331 value_list
.list_value
[list_count
].encode_text(text_buf
);
2334 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2338 void EXTERNAL_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2341 decode_text_base(text_buf
);
2342 switch (template_selection
) {
2343 case SPECIFIC_VALUE
:
2344 single_value
= new single_value_struct
;
2345 single_value
->field_abstract
.decode_text(text_buf
);
2346 single_value
->field_transfer
.decode_text(text_buf
);
2353 case COMPLEMENTED_LIST
:
2354 value_list
.n_values
= text_buf
.pull_int().get_val();
2355 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2356 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2357 value_list
.list_value
[list_count
].decode_text(text_buf
);
2360 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.syntaxes.");
2364 boolean
EXTERNAL_identification_syntaxes_template::is_present() const
2366 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2367 return !match_omit();
2370 boolean
EXTERNAL_identification_syntaxes_template::match_omit() const
2372 if (is_ifpresent
) return TRUE
;
2373 switch (template_selection
) {
2378 case COMPLEMENTED_LIST
:
2379 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2380 if (value_list
.list_value
[i
].match_omit())
2381 return template_selection
==VALUE_LIST
;
2382 return template_selection
==COMPLEMENTED_LIST
;
2389 #ifndef TITAN_RUNTIME_2
2390 void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
) const
2392 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2393 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2395 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2398 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2399 template_selection
==SPECIFIC_VALUE
)) return;
2402 if (!match_omit()) return;
2407 TTCN_error("Restriction `%s' on template of type %s violated.",
2408 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.syntaxes");
2412 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation()
2416 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2417 const OBJID
& par_transfer__syntax
)
2418 : field_presentation__context__id(par_presentation__context__id
),
2419 field_transfer__syntax(par_transfer__syntax
)
2423 boolean
EXTERNAL_identification_context__negotiation::operator==(const EXTERNAL_identification_context__negotiation
& other_value
) const
2425 return field_presentation__context__id
==other_value
.field_presentation__context__id
2426 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2429 int EXTERNAL_identification_context__negotiation::size_of() const
2435 void EXTERNAL_identification_context__negotiation::log() const
2437 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2438 field_presentation__context__id
.log();
2439 TTCN_Logger::log_event_str(", transfer_syntax := ");
2440 field_transfer__syntax
.log();
2441 TTCN_Logger::log_event_str(" }");
2444 boolean
EXTERNAL_identification_context__negotiation::is_bound() const
2446 if(field_presentation__context__id
.is_bound()) return TRUE
;
2447 if(field_transfer__syntax
.is_bound()) return TRUE
;
2451 boolean
EXTERNAL_identification_context__negotiation::is_value() const
2453 if(!field_presentation__context__id
.is_value()) return FALSE
;
2454 if(!field_transfer__syntax
.is_value()) return FALSE
;
2458 void EXTERNAL_identification_context__negotiation::clean_up()
2460 field_presentation__context__id
.clean_up();
2461 field_transfer__syntax
.clean_up();
2464 void EXTERNAL_identification_context__negotiation::set_param(Module_Param
& param
)
2466 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2467 switch (param
.get_type()) {
2468 case Module_Param::MP_Value_List
:
2469 if (param
.get_size()==0) return;
2470 if (2!=param
.get_size()) {
2471 param
.error("record value of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)param
.get_size());
2473 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*param
.get_elem(0));
2474 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*param
.get_elem(1));
2476 case Module_Param::MP_Assignment_List
: {
2477 Vector
<bool> value_used(param
.get_size());
2478 value_used
.resize(param
.get_size(), false);
2479 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2480 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2481 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2482 presentation__context__id().set_param(*curr_param
);
2483 value_used
[val_idx
]=true;
2486 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2487 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2488 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2489 transfer__syntax().set_param(*curr_param
);
2490 value_used
[val_idx
]=true;
2493 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2494 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2499 param
.type_error("record value", "EXTERNAL.identification.context-negotiation");
2503 void EXTERNAL_identification_context__negotiation_template::set_param(Module_Param
& param
)
2505 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2506 switch (param
.get_type()) {
2507 case Module_Param::MP_Omit
:
2510 case Module_Param::MP_Any
:
2513 case Module_Param::MP_AnyOrNone
:
2514 *this = ANY_OR_OMIT
;
2516 case Module_Param::MP_List_Template
:
2517 case Module_Param::MP_ComplementList_Template
:
2518 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
2519 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
2520 list_item(p_i
).set_param(*param
.get_elem(p_i
));
2523 case Module_Param::MP_Value_List
:
2524 if (param
.get_size()==0) break;
2525 if (2!=param
.get_size()) {
2526 param
.error("record template of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)param
.get_size());
2528 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*param
.get_elem(0));
2529 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*param
.get_elem(1));
2531 case Module_Param::MP_Assignment_List
: {
2532 Vector
<bool> value_used(param
.get_size());
2533 value_used
.resize(param
.get_size(), false);
2534 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2535 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2536 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2537 presentation__context__id().set_param(*curr_param
);
2538 value_used
[val_idx
]=true;
2541 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2542 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2543 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2544 transfer__syntax().set_param(*curr_param
);
2545 value_used
[val_idx
]=true;
2548 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2549 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2554 param
.type_error("record template", "EXTERNAL.identification.context-negotiation");
2556 is_ifpresent
= param
.get_ifpresent();
2559 void EXTERNAL_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2561 field_presentation__context__id
.encode_text(text_buf
);
2562 field_transfer__syntax
.encode_text(text_buf
);
2565 void EXTERNAL_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2567 field_presentation__context__id
.decode_text(text_buf
);
2568 field_transfer__syntax
.decode_text(text_buf
);
2571 struct EXTERNAL_identification_context__negotiation_template::single_value_struct
{
2572 INTEGER_template field_presentation__context__id
;
2573 OBJID_template field_transfer__syntax
;
2576 void EXTERNAL_identification_context__negotiation_template::clean_up()
2578 switch (template_selection
) {
2579 case SPECIFIC_VALUE
:
2580 delete single_value
;
2583 case COMPLEMENTED_LIST
:
2584 delete [] value_list
.list_value
;
2589 template_selection
= UNINITIALIZED_TEMPLATE
;
2592 void EXTERNAL_identification_context__negotiation_template::set_specific()
2594 if (template_selection
!= SPECIFIC_VALUE
) {
2595 template_sel old_selection
= template_selection
;
2597 single_value
= new single_value_struct
;
2598 set_selection(SPECIFIC_VALUE
);
2599 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2600 single_value
->field_presentation__context__id
= ANY_VALUE
;
2601 single_value
->field_transfer__syntax
= ANY_VALUE
;
2606 void EXTERNAL_identification_context__negotiation_template::copy_value(const EXTERNAL_identification_context__negotiation
& other_value
)
2608 single_value
= new single_value_struct
;
2609 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2610 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2611 set_selection(SPECIFIC_VALUE
);
2614 void EXTERNAL_identification_context__negotiation_template::copy_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2616 switch (other_value
.template_selection
) {
2617 case SPECIFIC_VALUE
:
2618 single_value
= new single_value_struct(*other_value
.single_value
);
2625 case COMPLEMENTED_LIST
:
2626 value_list
.n_values
= other_value
.value_list
.n_values
;
2627 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
2628 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2629 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2632 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2634 set_selection(other_value
);
2637 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template()
2641 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(template_sel other_value
)
2642 : Base_Template(other_value
)
2644 check_single_selection(other_value
);
2647 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation
& other_value
)
2649 copy_value(other_value
);
2652 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2654 switch (other_value
.get_selection()) {
2655 case OPTIONAL_PRESENT
:
2656 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2659 set_selection(OMIT_VALUE
);
2662 TTCN_error("Creating a template of type EXTERNAL.identification.context-negotiation from an unbound optional field.");
2666 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2669 copy_template(other_value
);
2672 EXTERNAL_identification_context__negotiation_template::~EXTERNAL_identification_context__negotiation_template()
2677 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(template_sel other_value
)
2679 check_single_selection(other_value
);
2681 set_selection(other_value
);
2685 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation
& other_value
)
2688 copy_value(other_value
);
2692 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2695 switch (other_value
.get_selection()) {
2696 case OPTIONAL_PRESENT
:
2697 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2700 set_selection(OMIT_VALUE
);
2703 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.context-negotiation.");
2708 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2710 if (&other_value
!= this) {
2712 copy_template(other_value
);
2717 boolean
EXTERNAL_identification_context__negotiation_template::match(const EXTERNAL_identification_context__negotiation
& other_value
) const
2719 switch (template_selection
) {
2725 case SPECIFIC_VALUE
:
2726 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
2727 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
2728 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
2729 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
2732 case COMPLEMENTED_LIST
:
2733 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2734 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2735 return template_selection
== COMPLEMENTED_LIST
;
2737 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2742 EXTERNAL_identification_context__negotiation
EXTERNAL_identification_context__negotiation_template::valueof() const
2744 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2745 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.context-negotiation.");
2746 EXTERNAL_identification_context__negotiation ret_val
;
2747 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
2748 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
2752 void EXTERNAL_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
2754 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2755 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.context-negotiation.");
2757 set_selection(template_type
);
2758 value_list
.n_values
= list_length
;
2759 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[list_length
];
2762 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::list_item(unsigned int list_index
) const
2764 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2765 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.context-negotiation.");
2766 if (list_index
>= value_list
.n_values
)
2767 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.context-negotiation.");
2768 return value_list
.list_value
[list_index
];
2771 INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id()
2774 return single_value
->field_presentation__context__id
;
2777 const INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id() const
2779 if (template_selection
!= SPECIFIC_VALUE
)
2780 TTCN_error("Accessing field presentation_context_id of a non-specific template of type EXTERNAL.identification.context-negotiation.");
2781 return single_value
->field_presentation__context__id
;
2784 OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax()
2787 return single_value
->field_transfer__syntax
;
2790 const OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax() const
2792 if (template_selection
!= SPECIFIC_VALUE
)
2793 TTCN_error("Accessing field transfer_syntax of a non-specific template of type EXTERNAL.identification.context-negotiation.");
2794 return single_value
->field_transfer__syntax
;
2797 int EXTERNAL_identification_context__negotiation_template::size_of() const
2799 switch (template_selection
)
2801 case SPECIFIC_VALUE
:
2808 if (value_list
.n_values
<1)
2809 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing an empty list.");
2810 int item_size
= value_list
.list_value
[0].size_of();
2811 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2813 if (value_list
.list_value
[i
].size_of()!=item_size
)
2814 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing a value list with different sizes.");
2819 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing omit value.");
2822 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing */? value.");
2823 case COMPLEMENTED_LIST
:
2824 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing complemented list.");
2826 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2831 void EXTERNAL_identification_context__negotiation_template::log() const
2833 switch (template_selection
) {
2834 case SPECIFIC_VALUE
:
2835 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2836 single_value
->field_presentation__context__id
.log();
2837 TTCN_Logger::log_event_str(", transfer_syntax := ");
2838 single_value
->field_transfer__syntax
.log();
2839 TTCN_Logger::log_event_str(" }");
2841 case COMPLEMENTED_LIST
:
2842 TTCN_Logger::log_event_str("complement ");
2845 TTCN_Logger::log_char('(');
2846 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2847 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2848 value_list
.list_value
[list_count
].log();
2850 TTCN_Logger::log_char(')');
2859 void EXTERNAL_identification_context__negotiation_template::log_match(const EXTERNAL_identification_context__negotiation
& match_value
) const
2861 if (template_selection
== SPECIFIC_VALUE
) {
2862 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2863 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
2864 TTCN_Logger::log_event_str(", transfer_syntax := ");
2865 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
2866 TTCN_Logger::log_event_str(" }");
2869 TTCN_Logger::log_event_str(" with ");
2871 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2872 else TTCN_Logger::log_event_str(" unmatched");
2876 void EXTERNAL_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
2878 encode_text_base(text_buf
);
2879 switch (template_selection
) {
2880 case SPECIFIC_VALUE
:
2881 single_value
->field_presentation__context__id
.encode_text(text_buf
);
2882 single_value
->field_transfer__syntax
.encode_text(text_buf
);
2889 case COMPLEMENTED_LIST
:
2890 text_buf
.push_int(value_list
.n_values
);
2891 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2892 value_list
.list_value
[list_count
].encode_text(text_buf
);
2895 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2899 void EXTERNAL_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
2902 decode_text_base(text_buf
);
2903 switch (template_selection
) {
2904 case SPECIFIC_VALUE
:
2905 single_value
= new single_value_struct
;
2906 single_value
->field_presentation__context__id
.decode_text(text_buf
);
2907 single_value
->field_transfer__syntax
.decode_text(text_buf
);
2914 case COMPLEMENTED_LIST
:
2915 value_list
.n_values
= text_buf
.pull_int().get_val();
2916 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
2917 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2918 value_list
.list_value
[list_count
].decode_text(text_buf
);
2921 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.context-negotiation.");
2925 boolean
EXTERNAL_identification_context__negotiation_template::is_present() const
2927 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2928 return !match_omit();
2931 boolean
EXTERNAL_identification_context__negotiation_template::match_omit() const
2933 if (is_ifpresent
) return TRUE
;
2934 switch (template_selection
) {
2939 case COMPLEMENTED_LIST
:
2940 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2941 if (value_list
.list_value
[i
].match_omit())
2942 return template_selection
==VALUE_LIST
;
2943 return template_selection
==COMPLEMENTED_LIST
;
2950 #ifndef TITAN_RUNTIME_2
2951 void EXTERNAL_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
) const
2953 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2954 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2956 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2959 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2960 template_selection
==SPECIFIC_VALUE
)) return;
2963 if (!match_omit()) return;
2968 TTCN_error("Restriction `%s' on template of type %s violated.",
2969 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.context-negotiation");
2973 EXTERNAL::EXTERNAL()
2977 EXTERNAL::EXTERNAL(const EXTERNAL_identification
& par_identification
,
2978 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
2979 const OCTETSTRING
& par_data__value
)
2980 : field_identification(par_identification
),
2981 field_data__value__descriptor(par_data__value__descriptor
),
2982 field_data__value(par_data__value
)
2986 boolean
EXTERNAL::operator==(const EXTERNAL
& other_value
) const
2988 return field_identification
==other_value
.field_identification
2989 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
2990 && field_data__value
==other_value
.field_data__value
;
2993 int EXTERNAL::size_of() const
2996 if (field_data__value__descriptor
.ispresent()) ret_val
++;
3000 void EXTERNAL::log() const
3002 TTCN_Logger::log_event_str("{ identification := ");
3003 field_identification
.log();
3004 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3005 field_data__value__descriptor
.log();
3006 TTCN_Logger::log_event_str(", data_value := ");
3007 field_data__value
.log();
3008 TTCN_Logger::log_event_str(" }");
3011 boolean
EXTERNAL::is_bound() const
3013 if(field_identification
.is_bound()) return TRUE
;
3014 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
3015 if(field_data__value
.is_bound()) return TRUE
;
3019 boolean
EXTERNAL::is_value() const
3021 if(!field_identification
.is_value()) return FALSE
;
3022 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
3023 if(!field_data__value
.is_value()) return FALSE
;
3027 void EXTERNAL::clean_up()
3029 field_identification
.clean_up();
3030 field_data__value__descriptor
.clean_up();
3031 field_data__value
.clean_up();
3034 void EXTERNAL::set_param(Module_Param
& param
)
3036 param
.basic_check(Module_Param::BC_VALUE
, "record value");
3037 switch (param
.get_type()) {
3038 case Module_Param::MP_Value_List
:
3039 if (param
.get_size()==0) return;
3040 if (3!=param
.get_size()) {
3041 param
.error("record value of type EXTERNAL has 3 fields but list value has %d fields", (int)param
.get_size());
3043 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*param
.get_elem(0));
3044 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*param
.get_elem(1));
3045 if (param
.get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*param
.get_elem(2));
3047 case Module_Param::MP_Assignment_List
: {
3048 Vector
<bool> value_used(param
.get_size());
3049 value_used
.resize(param
.get_size(), false);
3050 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3051 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3052 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3053 identification().set_param(*curr_param
);
3054 value_used
[val_idx
]=true;
3057 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3058 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3059 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3060 data__value__descriptor().set_param(*curr_param
);
3061 value_used
[val_idx
]=true;
3064 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3065 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3066 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3067 data__value().set_param(*curr_param
);
3068 value_used
[val_idx
]=true;
3071 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3072 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", param
.get_elem(val_idx
)->get_id()->get_name());
3077 param
.type_error("record value", "EXTERNAL");
3081 void EXTERNAL_template::set_param(Module_Param
& param
)
3083 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
3084 switch (param
.get_type()) {
3085 case Module_Param::MP_Omit
:
3088 case Module_Param::MP_Any
:
3091 case Module_Param::MP_AnyOrNone
:
3092 *this = ANY_OR_OMIT
;
3094 case Module_Param::MP_List_Template
:
3095 case Module_Param::MP_ComplementList_Template
:
3096 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
3097 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
3098 list_item(p_i
).set_param(*param
.get_elem(p_i
));
3101 case Module_Param::MP_Value_List
:
3102 if (param
.get_size()==0) break;
3103 if (3!=param
.get_size()) {
3104 param
.error("record template of type EXTERNAL has 3 fields but list value has %d fields", (int)param
.get_size());
3106 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*param
.get_elem(0));
3107 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*param
.get_elem(1));
3108 if (param
.get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*param
.get_elem(2));
3110 case Module_Param::MP_Assignment_List
: {
3111 Vector
<bool> value_used(param
.get_size());
3112 value_used
.resize(param
.get_size(), false);
3113 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3114 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3115 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3116 identification().set_param(*curr_param
);
3117 value_used
[val_idx
]=true;
3120 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3121 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3122 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3123 data__value__descriptor().set_param(*curr_param
);
3124 value_used
[val_idx
]=true;
3127 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
3128 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
3129 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3130 data__value().set_param(*curr_param
);
3131 value_used
[val_idx
]=true;
3134 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3135 param
.get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", param
.get_elem(val_idx
)->get_id()->get_name());
3140 param
.type_error("record template", "EXTERNAL");
3142 is_ifpresent
= param
.get_ifpresent();
3145 void EXTERNAL::encode_text(Text_Buf
& text_buf
) const
3147 field_identification
.encode_text(text_buf
);
3148 field_data__value__descriptor
.encode_text(text_buf
);
3149 field_data__value
.encode_text(text_buf
);
3152 void EXTERNAL::decode_text(Text_Buf
& text_buf
)
3154 field_identification
.decode_text(text_buf
);
3155 field_data__value__descriptor
.decode_text(text_buf
);
3156 field_data__value
.decode_text(text_buf
);
3159 void EXTERNAL::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
3162 va_start(pvar
, p_coding
);
3164 case TTCN_EncDec::CT_BER
: {
3165 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
3166 unsigned BER_coding
=va_arg(pvar
, unsigned);
3167 BER_encode_chk_coding(BER_coding
);
3168 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
3169 tlv
->put_in_buffer(p_buf
);
3170 ASN_BER_TLV_t::destruct(tlv
);
3172 case TTCN_EncDec::CT_RAW
: {
3173 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
3174 TTCN_EncDec_ErrorContext::error_internal
3175 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3177 case TTCN_EncDec::CT_TEXT
: {
3178 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
3179 TTCN_EncDec_ErrorContext::error_internal
3180 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3182 case TTCN_EncDec::CT_XER
: {
3183 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
3184 unsigned XER_coding
=va_arg(pvar
, unsigned);
3185 XER_encode(*p_td
.xer
, p_buf
, XER_coding
, 0);
3187 case TTCN_EncDec::CT_JSON
: {
3188 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
3189 TTCN_EncDec_ErrorContext::error_internal
3190 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3193 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3198 void EXTERNAL::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3201 va_start(pvar
, p_coding
);
3203 case TTCN_EncDec::CT_BER
: {
3204 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
3205 unsigned L_form
=va_arg(pvar
, unsigned);
3207 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
3208 BER_decode_TLV(p_td
, tlv
, L_form
);
3209 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3211 case TTCN_EncDec::CT_RAW
: {
3212 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3213 TTCN_EncDec_ErrorContext::error_internal
3214 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3216 case TTCN_EncDec::CT_TEXT
: {
3217 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3218 TTCN_EncDec_ErrorContext::error_internal
3219 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3221 case TTCN_EncDec::CT_XER
: {
3222 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3223 unsigned XER_coding
=va_arg(pvar
, unsigned);
3224 XmlReaderWrap
reader(p_buf
);
3225 int success
= reader
.Read();
3226 for (; success
==1; success
=reader
.Read()) {
3227 int type
= reader
.NodeType();
3228 if (type
==XML_READER_TYPE_ELEMENT
)
3231 XER_decode(*p_td
.xer
, reader
, XER_coding
);
3232 size_t bytes
= reader
.ByteConsumed();
3233 p_buf
.set_pos(bytes
);
3235 case TTCN_EncDec::CT_JSON
: {
3236 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3237 TTCN_EncDec_ErrorContext::error_internal
3238 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3241 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3246 struct EXTERNAL_template::single_value_struct
{
3247 EXTERNAL_identification_template field_identification
;
3248 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3249 OCTETSTRING_template field_data__value
;
3252 void EXTERNAL_template::clean_up()
3254 switch (template_selection
) {
3255 case SPECIFIC_VALUE
:
3256 delete single_value
;
3259 case COMPLEMENTED_LIST
:
3260 delete [] value_list
.list_value
;
3265 template_selection
= UNINITIALIZED_TEMPLATE
;
3268 void EXTERNAL_template::set_specific()
3270 if (template_selection
!= SPECIFIC_VALUE
) {
3271 template_sel old_selection
= template_selection
;
3273 single_value
= new single_value_struct
;
3274 set_selection(SPECIFIC_VALUE
);
3275 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3276 single_value
->field_identification
= ANY_VALUE
;
3277 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3278 single_value
->field_data__value
= ANY_VALUE
;
3283 void EXTERNAL_template::copy_value(const EXTERNAL
& other_value
)
3285 single_value
= new single_value_struct
;
3286 single_value
->field_identification
= other_value
.identification();
3287 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3288 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3289 single_value
->field_data__value
= other_value
.data__value();
3290 set_selection(SPECIFIC_VALUE
);
3293 void EXTERNAL_template::copy_template(const EXTERNAL_template
& other_value
)
3295 switch (other_value
.template_selection
) {
3296 case SPECIFIC_VALUE
:
3297 single_value
= new single_value_struct(*other_value
.single_value
);
3304 case COMPLEMENTED_LIST
:
3305 value_list
.n_values
= other_value
.value_list
.n_values
;
3306 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
3307 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3308 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3311 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.");
3313 set_selection(other_value
);
3316 EXTERNAL_template::EXTERNAL_template()
3320 EXTERNAL_template::EXTERNAL_template(template_sel other_value
)
3321 : Base_Template(other_value
)
3323 check_single_selection(other_value
);
3326 EXTERNAL_template::EXTERNAL_template(const EXTERNAL
& other_value
)
3328 copy_value(other_value
);
3331 EXTERNAL_template::EXTERNAL_template(const OPTIONAL
<EXTERNAL
>& other_value
)
3333 switch (other_value
.get_selection()) {
3334 case OPTIONAL_PRESENT
:
3335 copy_value((const EXTERNAL
&)other_value
);
3338 set_selection(OMIT_VALUE
);
3341 TTCN_error("Creating a template of type EXTERNAL from an unbound optional field.");
3345 EXTERNAL_template::EXTERNAL_template(const EXTERNAL_template
& other_value
)
3348 copy_template(other_value
);
3351 EXTERNAL_template::~EXTERNAL_template()
3356 EXTERNAL_template
& EXTERNAL_template::operator=(template_sel other_value
)
3358 check_single_selection(other_value
);
3360 set_selection(other_value
);
3364 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL
& other_value
)
3367 copy_value(other_value
);
3371 EXTERNAL_template
& EXTERNAL_template::operator=(const OPTIONAL
<EXTERNAL
>& other_value
)
3374 switch (other_value
.get_selection()) {
3375 case OPTIONAL_PRESENT
:
3376 copy_value((const EXTERNAL
&)other_value
);
3379 set_selection(OMIT_VALUE
);
3382 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.");
3387 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL_template
& other_value
)
3389 if (&other_value
!= this) {
3391 copy_template(other_value
);
3396 boolean
EXTERNAL_template::match(const EXTERNAL
& other_value
) const
3398 switch (template_selection
) {
3404 case SPECIFIC_VALUE
:
3405 if (!other_value
.identification().is_bound()) return FALSE
;
3406 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3407 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3408 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
;
3409 if (!other_value
.data__value().is_bound()) return FALSE
;
3410 if (!single_value
->field_data__value
.match(other_value
.data__value())) return FALSE
;
3413 case COMPLEMENTED_LIST
:
3414 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3415 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3416 return template_selection
== COMPLEMENTED_LIST
;
3418 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.");
3423 EXTERNAL
EXTERNAL_template::valueof() const
3425 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3426 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.");
3428 ret_val
.identification() = single_value
->field_identification
.valueof();
3429 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3430 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3431 ret_val
.data__value() = single_value
->field_data__value
.valueof();
3435 void EXTERNAL_template::set_type(template_sel template_type
, unsigned int list_length
)
3437 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3438 TTCN_error("Setting an invalid list for a template of type EXTERNAL.");
3440 set_selection(template_type
);
3441 value_list
.n_values
= list_length
;
3442 value_list
.list_value
= new EXTERNAL_template
[list_length
];
3445 EXTERNAL_template
& EXTERNAL_template::list_item(unsigned int list_index
) const
3447 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3448 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.");
3449 if (list_index
>= value_list
.n_values
)
3450 TTCN_error("Index overflow in a value list template of type EXTERNAL.");
3451 return value_list
.list_value
[list_index
];
3454 EXTERNAL_identification_template
& EXTERNAL_template::identification()
3457 return single_value
->field_identification
;
3460 const EXTERNAL_identification_template
& EXTERNAL_template::identification() const
3462 if (template_selection
!= SPECIFIC_VALUE
)
3463 TTCN_error("Accessing field identification of a non-specific template of type EXTERNAL.");
3464 return single_value
->field_identification
;
3467 UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor()
3470 return single_value
->field_data__value__descriptor
;
3473 const UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor() const
3475 if (template_selection
!= SPECIFIC_VALUE
)
3476 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type EXTERNAL.");
3477 return single_value
->field_data__value__descriptor
;
3480 OCTETSTRING_template
& EXTERNAL_template::data__value()
3483 return single_value
->field_data__value
;
3486 const OCTETSTRING_template
& EXTERNAL_template::data__value() const
3488 if (template_selection
!= SPECIFIC_VALUE
)
3489 TTCN_error("Accessing field data_value of a non-specific template of type EXTERNAL.");
3490 return single_value
->field_data__value
;
3493 int EXTERNAL_template::size_of() const
3495 switch (template_selection
)
3497 case SPECIFIC_VALUE
:
3500 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3505 if (value_list
.n_values
<1)
3506 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL containing an empty list.");
3507 int item_size
= value_list
.list_value
[0].size_of();
3508 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3510 if (value_list
.list_value
[i
].size_of()!=item_size
)
3511 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing a value list with different sizes.");
3516 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing omit value.");
3519 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing */? value.");
3520 case COMPLEMENTED_LIST
:
3521 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing complemented list.");
3523 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.");
3528 void EXTERNAL_template::log() const
3530 switch (template_selection
) {
3531 case SPECIFIC_VALUE
:
3532 TTCN_Logger::log_event_str("{ identification := ");
3533 single_value
->field_identification
.log();
3534 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3535 single_value
->field_data__value__descriptor
.log();
3536 TTCN_Logger::log_event_str(", data_value := ");
3537 single_value
->field_data__value
.log();
3538 TTCN_Logger::log_event_str(" }");
3540 case COMPLEMENTED_LIST
:
3541 TTCN_Logger::log_event_str("complement ");
3544 TTCN_Logger::log_char('(');
3545 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3546 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3547 value_list
.list_value
[list_count
].log();
3549 TTCN_Logger::log_char(')');
3558 void EXTERNAL_template::log_match(const EXTERNAL
& match_value
) const
3560 if (template_selection
== SPECIFIC_VALUE
) {
3561 TTCN_Logger::log_event_str("{ identification := ");
3562 single_value
->field_identification
.log_match(match_value
.identification());
3563 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3564 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3566 single_value
->field_data__value__descriptor
.log();
3567 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3568 else TTCN_Logger::log_event_str(" unmatched");
3570 TTCN_Logger::log_event_str(", data_value := ");
3571 single_value
->field_data__value
.log_match(match_value
.data__value());
3572 TTCN_Logger::log_event_str(" }");
3575 TTCN_Logger::log_event_str(" with ");
3577 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3578 else TTCN_Logger::log_event_str(" unmatched");
3582 void EXTERNAL_template::encode_text(Text_Buf
& text_buf
) const
3584 encode_text_base(text_buf
);
3585 switch (template_selection
) {
3586 case SPECIFIC_VALUE
:
3587 single_value
->field_identification
.encode_text(text_buf
);
3588 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3589 single_value
->field_data__value
.encode_text(text_buf
);
3596 case COMPLEMENTED_LIST
:
3597 text_buf
.push_int(value_list
.n_values
);
3598 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3599 value_list
.list_value
[list_count
].encode_text(text_buf
);
3602 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.");
3606 void EXTERNAL_template::decode_text(Text_Buf
& text_buf
)
3609 decode_text_base(text_buf
);
3610 switch (template_selection
) {
3611 case SPECIFIC_VALUE
:
3612 single_value
= new single_value_struct
;
3613 single_value
->field_identification
.decode_text(text_buf
);
3614 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3615 single_value
->field_data__value
.decode_text(text_buf
);
3622 case COMPLEMENTED_LIST
:
3623 value_list
.n_values
= text_buf
.pull_int().get_val();
3624 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
3625 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3626 value_list
.list_value
[list_count
].decode_text(text_buf
);
3629 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.");
3633 boolean
EXTERNAL_template::is_present() const
3635 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3636 return !match_omit();
3639 boolean
EXTERNAL_template::match_omit() const
3641 if (is_ifpresent
) return TRUE
;
3642 switch (template_selection
) {
3647 case COMPLEMENTED_LIST
:
3648 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3649 if (value_list
.list_value
[i
].match_omit())
3650 return template_selection
==VALUE_LIST
;
3651 return template_selection
==COMPLEMENTED_LIST
;
3658 #ifndef TITAN_RUNTIME_2
3659 void EXTERNAL_template::check_restriction(template_res t_res
, const char* t_name
) const
3661 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3662 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3664 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3667 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3668 template_selection
==SPECIFIC_VALUE
)) return;
3671 if (!match_omit()) return;
3676 TTCN_error("Restriction `%s' on template of type %s violated.",
3677 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL");