1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
18 * Szabo, Janos Zoltan – initial implementation
21 ******************************************************************************/
24 #include "ASN_External.hh"
27 #include "ASN_Null.hh"
28 #include "Bitstring.hh"
31 #include "Octetstring.hh"
32 #include "Universal_charstring.hh"
34 #include "Parameters.h"
35 #include "Param_Types.hh"
42 #include "../common/dbgnew.hh"
45 * This type is used to BER encode/decode the EXTERNAL type.
46 * For details, see X.690 8.18.
51 to do when regenerating:
55 add __SUNPRO_CC ifdefs for single_value_struct
57 delete encode/decode members except for EXTERNAL
61 leave transfer syntax in anonymous namespace
63 delete encode/decode members except for EXTERNAL
64 leave EXTERNAL::BER_encode_TLV() -- written by hand
65 leave EXTERNAL::BER_decode_TLV() -- written by hand
67 replace '@EXTERNAL' with 'EXTERNAL'
69 remove RAW and TEXT enc/dec functions
73 namespace { /* anonymous namespace */
75 class EXTERNALtransfer_encoding
;
76 class EXTERNALtransfer
;
78 class EXTERNALtransfer_encoding
: public Base_Type
{
80 enum union_selection_type
{ UNBOUND_VALUE
= 0, ALT_single__ASN1__type
= 1, ALT_octet__aligned
= 2, ALT_arbitrary
= 3 };
82 union_selection_type union_selection
;
84 ASN_ANY
*field_single__ASN1__type
;
85 OCTETSTRING
*field_octet__aligned
;
86 BITSTRING
*field_arbitrary
;
89 void copy_value(const EXTERNALtransfer_encoding
& other_value
);
92 EXTERNALtransfer_encoding()
93 { union_selection
= UNBOUND_VALUE
; }
94 EXTERNALtransfer_encoding(const EXTERNALtransfer_encoding
& other_value
)
95 : Base_Type(other_value
)
96 { copy_value(other_value
); }
97 ~EXTERNALtransfer_encoding() { clean_up(); }
98 EXTERNALtransfer_encoding
& operator=(const EXTERNALtransfer_encoding
& other_value
);
99 ASN_ANY
& single__ASN1__type();
100 const ASN_ANY
& single__ASN1__type() const;
101 OCTETSTRING
& octet__aligned();
102 const OCTETSTRING
& octet__aligned() const;
103 BITSTRING
& arbitrary();
104 const BITSTRING
& arbitrary() const;
105 inline union_selection_type
get_selection() const { return union_selection
; }
106 #ifdef TITAN_RUNTIME_2
107 void set_param(Module_Param
& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_param() called."); }
108 Module_Param
* get_param(Module_Param_Name
& param_name
) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_param() called."); }
109 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::encode_text() called."); }
110 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::decode_text() called."); }
111 boolean
is_bound() const { return union_selection
!=UNBOUND_VALUE
; }
112 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::is_equal() called."); }
113 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_value() called."); }
114 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::clone() called."); }
115 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_descriptor() called."); }
117 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
118 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
119 int XER_encode(const XERdescriptor_t
& p_td
,
120 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const;
121 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
122 unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*);
124 boolean
BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
);
126 boolean
BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
);
129 /** This class is used to encode/decode the EXTERNAL type.
131 * The sequence type used for encoding/decoding the EXTERNAL type
132 * differs from the associated type of EXTERNAL. See
133 * = X.690 (BER), 8.18.1 ;
134 * = X.691 (PER), 26.1 ;
137 * The actual encoding/decoding is performed by this class and its members.
138 * Data is transferred to/from an object of class EXTERNAL. */
139 class EXTERNALtransfer
: public Base_Type
{
140 OPTIONAL
<OBJID
> field_direct__reference
;
141 OPTIONAL
<INTEGER
> field_indirect__reference
;
142 OPTIONAL
<ObjectDescriptor
> field_data__value__descriptor
;
143 EXTERNALtransfer_encoding field_encoding
;
145 void load(const EXTERNAL
& ex
);
146 inline OPTIONAL
<OBJID
>& direct__reference()
147 {return field_direct__reference
;}
148 inline const OPTIONAL
<OBJID
>& direct__reference() const
149 {return field_direct__reference
;}
150 inline OPTIONAL
<INTEGER
>& indirect__reference()
151 {return field_indirect__reference
;}
152 inline const OPTIONAL
<INTEGER
>& indirect__reference() const
153 {return field_indirect__reference
;}
154 inline OPTIONAL
<ObjectDescriptor
>& data__value__descriptor()
155 {return field_data__value__descriptor
;}
156 inline const OPTIONAL
<ObjectDescriptor
>& data__value__descriptor() const
157 {return field_data__value__descriptor
;}
158 inline EXTERNALtransfer_encoding
& encoding()
159 {return field_encoding
;}
160 inline const EXTERNALtransfer_encoding
& encoding() const
161 {return field_encoding
;}
162 #ifdef TITAN_RUNTIME_2
163 void set_param(Module_Param
& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer::set_param() called."); }
164 Module_Param
* get_param(Module_Param_Name
& param_name
) const { TTCN_error("Internal error: EXTERNALtransfer::get_param() called."); }
165 void encode_text(Text_Buf
& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer::encode_text() called."); }
166 void decode_text(Text_Buf
& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer::decode_text() called."); }
167 boolean
is_bound() const { TTCN_error("Internal error: EXTERNALtransfer::is_bound() called."); }
168 boolean
is_value() const { TTCN_error("Internal error: EXTERNALtransfer::is_value() called."); }
169 void clean_up() { TTCN_error("Internal error: EXTERNALtransfer::clean_up() called."); }
170 boolean
is_equal(const Base_Type
* /*other_value*/) const { TTCN_error("Internal error: EXTERNALtransfer::is_equal() called."); }
171 void set_value(const Base_Type
* /*other_value*/) { TTCN_error("Internal error: EXTERNALtransfer::set_value() called."); }
172 Base_Type
* clone() const { TTCN_error("Internal error: EXTERNALtransfer::clone() called."); }
173 const TTCN_Typedescriptor_t
* get_descriptor() const { TTCN_error("Internal error: EXTERNALtransfer::get_descriptor() called."); }
175 ASN_BER_TLV_t
* BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const;
176 boolean
BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
);
177 int XER_encode(const XERdescriptor_t
& p_td
,
178 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const;
179 int XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
180 unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*);
183 /** Transform the information from the visible format to the encoding format
185 * Called from EXTERNAL::XER_encode() */
186 void EXTERNALtransfer::load(const EXTERNAL
& ex
)
188 // ALT_syntaxes, ALT_transfer__syntax and ALT_fixed do not appear below.
189 // These are forbidden for the EXTERNAL type.
190 switch(ex
.identification().get_selection()) {
191 case EXTERNAL_identification::ALT_syntax
:
192 field_direct__reference
=ex
.identification().syntax();
194 case EXTERNAL_identification::ALT_context__negotiation
:
195 field_direct__reference
=ex
.identification().context__negotiation().transfer__syntax();
198 field_direct__reference
=OMIT_VALUE
;
201 switch(ex
.identification().get_selection()) {
202 case EXTERNAL_identification::ALT_presentation__context__id
:
203 field_indirect__reference
=ex
.identification().presentation__context__id();
205 case EXTERNAL_identification::ALT_context__negotiation
:
206 field_indirect__reference
=ex
.identification().context__negotiation().presentation__context__id();
209 field_indirect__reference
=OMIT_VALUE
;
212 field_data__value__descriptor
=ex
.data__value__descriptor();
213 field_encoding
.octet__aligned()=ex
.data__value();
216 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_descr_
= { "EXTERNALtransfer.encoding", &CHOICE_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
218 static const ASN_Tag_t EXTERNALtransfer_encoding_single__ASN1__type_tag_
[] = { { ASN_TAG_CONT
, 0u } };
219 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_ber_
= { 1u, EXTERNALtransfer_encoding_single__ASN1__type_tag_
};
220 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_descr_
= { "EXTERNALtransfer.encoding.single-ASN1-type", &EXTERNALtransfer_encoding_single__ASN1__type_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
222 static const ASN_Tag_t EXTERNALtransfer_encoding_octet__aligned_tag_
[] = { { ASN_TAG_CONT
, 1u } };
223 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_octet__aligned_ber_
= { 1u, EXTERNALtransfer_encoding_octet__aligned_tag_
};
224 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_octet__aligned_descr_
= { "EXTERNALtransfer.encoding.octet-aligned", &EXTERNALtransfer_encoding_octet__aligned_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
226 static const ASN_Tag_t EXTERNALtransfer_encoding_arbitrary_tag_
[] = { { ASN_TAG_CONT
, 2u } };
227 static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_arbitrary_ber_
= { 1u, EXTERNALtransfer_encoding_arbitrary_tag_
};
228 static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_arbitrary_descr_
= { "EXTERNALtransfer.encoding.arbitrary", &EXTERNALtransfer_encoding_arbitrary_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
230 /* Member functions of C++ classes */
232 void EXTERNALtransfer_encoding::clean_up()
234 switch (union_selection
) {
235 case ALT_single__ASN1__type
:
236 delete field_single__ASN1__type
;
238 case ALT_octet__aligned
:
239 delete field_octet__aligned
;
242 delete field_arbitrary
;
247 union_selection
= UNBOUND_VALUE
;
250 void EXTERNALtransfer_encoding::copy_value(const EXTERNALtransfer_encoding
& other_value
)
252 switch (other_value
.union_selection
) {
253 case ALT_single__ASN1__type
:
254 field_single__ASN1__type
= new ASN_ANY(*other_value
.field_single__ASN1__type
);
256 case ALT_octet__aligned
:
257 field_octet__aligned
= new OCTETSTRING(*other_value
.field_octet__aligned
);
260 field_arbitrary
= new BITSTRING(*other_value
.field_arbitrary
);
263 TTCN_error("Assignment of an unbound union value of type EXTERNALtransfer.encoding.");
265 union_selection
= other_value
.union_selection
;
268 EXTERNALtransfer_encoding
& EXTERNALtransfer_encoding::operator=(const EXTERNALtransfer_encoding
& other_value
)
270 if(this != &other_value
) {
272 copy_value(other_value
);
277 ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type()
279 if (union_selection
!= ALT_single__ASN1__type
) {
281 field_single__ASN1__type
= new ASN_ANY
;
282 union_selection
= ALT_single__ASN1__type
;
284 return *field_single__ASN1__type
;
287 const ASN_ANY
& EXTERNALtransfer_encoding::single__ASN1__type() const
289 if (union_selection
!= ALT_single__ASN1__type
) TTCN_error("Using non-selected field single-ASN1-type in a value of union type EXTERNALtransfer.encoding.");
290 return *field_single__ASN1__type
;
293 OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned()
295 if (union_selection
!= ALT_octet__aligned
) {
297 field_octet__aligned
= new OCTETSTRING
;
298 union_selection
= ALT_octet__aligned
;
300 return *field_octet__aligned
;
303 const OCTETSTRING
& EXTERNALtransfer_encoding::octet__aligned() const
305 if (union_selection
!= ALT_octet__aligned
) TTCN_error("Using non-selected field octet-aligned in a value of union type EXTERNALtransfer.encoding.");
306 return *field_octet__aligned
;
309 BITSTRING
& EXTERNALtransfer_encoding::arbitrary()
311 if (union_selection
!= ALT_arbitrary
) {
313 field_arbitrary
= new BITSTRING
;
314 union_selection
= ALT_arbitrary
;
316 return *field_arbitrary
;
319 const BITSTRING
& EXTERNALtransfer_encoding::arbitrary() const
321 if (union_selection
!= ALT_arbitrary
) TTCN_error("Using non-selected field arbitrary in a value of union type EXTERNALtransfer.encoding.");
322 return *field_arbitrary
;
325 ASN_BER_TLV_t
* EXTERNALtransfer_encoding::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
328 ASN_BER_TLV_t
*new_tlv
;
329 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
330 TTCN_EncDec_ErrorContext ec_1
;
331 switch (union_selection
) {
332 case ALT_single__ASN1__type
:
333 ec_1
.set_msg("single-ASN1-type': ");
334 new_tlv
=field_single__ASN1__type
->BER_encode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_coding
);
336 case ALT_octet__aligned
:
337 ec_1
.set_msg("octet-aligned': ");
338 new_tlv
=field_octet__aligned
->BER_encode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_coding
);
341 ec_1
.set_msg("arbitrary': ");
342 new_tlv
=field_arbitrary
->BER_encode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, p_coding
);
345 new_tlv
=BER_encode_chk_bound(FALSE
);
348 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
352 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
355 boolean
EXTERNALtransfer_encoding::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
358 union_selection
=ALT_single__ASN1__type
;
359 field_single__ASN1__type
=new ASN_ANY
;
360 if(field_single__ASN1__type
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, p_tlv
))
362 delete field_single__ASN1__type
;
363 union_selection
=ALT_octet__aligned
;
364 field_octet__aligned
=new OCTETSTRING
;
365 if(field_octet__aligned
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_octet__aligned_descr_
, p_tlv
))
367 delete field_octet__aligned
;
368 union_selection
=ALT_arbitrary
;
369 field_arbitrary
=new BITSTRING
;
370 if(field_arbitrary
->BER_decode_isMyMsg(EXTERNALtransfer_encoding_arbitrary_descr_
, p_tlv
))
372 delete field_arbitrary
;
373 union_selection
=UNBOUND_VALUE
;
377 boolean
EXTERNALtransfer_encoding::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
379 if(p_td
.ber
->n_tags
==0) {
380 EXTERNALtransfer_encoding tmp_type
;
381 return tmp_type
.BER_decode_set_selection(p_tlv
);
383 else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
386 boolean
EXTERNALtransfer_encoding::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
389 ASN_BER_TLV_t stripped_tlv
;
390 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
391 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer.encoding' type: ");
392 ASN_BER_TLV_t tmp_tlv
;
393 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
))
395 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
396 TTCN_EncDec_ErrorContext ec_2
;
397 switch (union_selection
) {
398 case ALT_single__ASN1__type
:
399 ec_2
.set_msg("single-ASN1-type': ");
400 field_single__ASN1__type
->BER_decode_TLV(EXTERNALtransfer_encoding_single__ASN1__type_descr_
, tmp_tlv
, L_form
);
402 case ALT_octet__aligned
:
403 ec_2
.set_msg("octet-aligned': ");
404 field_octet__aligned
->BER_decode_TLV(EXTERNALtransfer_encoding_octet__aligned_descr_
, tmp_tlv
, L_form
);
407 ec_2
.set_msg("arbitrary': ");
408 field_arbitrary
->BER_decode_TLV(EXTERNALtransfer_encoding_arbitrary_descr_
, tmp_tlv
, L_form
);
416 int EXTERNALtransfer_encoding::XER_encode(const XERdescriptor_t
& p_td
,
417 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
419 int indenting
= !is_canonical(flavor
);
420 int exer
= is_exer(flavor
);
421 int encoded_length
=(int)p_buf
.get_len();
422 if (indenting
) do_indent(p_buf
, indent
);
424 if (exer
) write_ns_prefix(p_td
, p_buf
);
425 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
428 switch (union_selection
) {
429 case ALT_single__ASN1__type
:
430 field_single__ASN1__type
->XER_encode(EXTERNAL_encoding_singleASN_xer_
, p_buf
, flavor
, indent
, 0);
432 case ALT_octet__aligned
:
433 field_octet__aligned
->XER_encode(EXTERNAL_encoding_octet_aligned_xer_
, p_buf
, flavor
, indent
, 0);
436 field_arbitrary
->XER_encode(EXTERNAL_encoding_arbitrary_xer_
, p_buf
, flavor
, indent
, 0);
439 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND
,
440 "Encoding an unbound value");
443 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
444 // TODO something at all ?
448 if (indenting
) do_indent(p_buf
, --indent
);
451 if (exer
) write_ns_prefix(p_td
, p_buf
);
452 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
453 return (int)p_buf
.get_len() - encoded_length
;
456 int EXTERNALtransfer_encoding::XER_decode(const XERdescriptor_t
& p_td
,
457 XmlReaderWrap
& reader
, unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
459 int exer
= is_exer(flavor
);
460 int success
= reader
.Ok(), type
, depth
= -1;
461 for (; success
==1; success
= reader
.Read()) {
462 type
= reader
.NodeType();
463 if (type
== XML_READER_TYPE_ELEMENT
) {
464 verify_name(reader
, p_td
, exer
);
465 depth
= reader
.Depth();
470 const char * name
= 0;
471 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
472 type
= reader
.NodeType();
473 if (XML_READER_TYPE_ELEMENT
== type
) break;
474 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
476 name
= (const char*)reader
.Name();
479 case 's': // single-ASN1-type
480 single__ASN1__type().XER_decode(EXTERNAL_encoding_singleASN_xer_
, reader
, flavor
, flavor2
, 0);
483 case 'o': // octet-aligned
484 octet__aligned().XER_decode(EXTERNAL_encoding_octet_aligned_xer_
, reader
, flavor
, flavor2
, 0);
487 case 'a': // arbitrary
488 arbitrary().XER_decode(EXTERNAL_encoding_arbitrary_xer_
, reader
, flavor
, flavor2
, 0);
492 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
493 "Doh!"); // FIXME error method and text
497 for (success
= reader
.Read(); success
==1; success
= reader
.Read()) {
498 type
= reader
.NodeType();
499 if (XML_READER_TYPE_END_ELEMENT
== type
) {
500 verify_end(reader
, p_td
, depth
, exer
);
501 reader
.Read(); // one last time
506 return 0; // FIXME return value
509 /******************** EXTERNALtransfer class ********************/
511 ASN_BER_TLV_t
* EXTERNALtransfer::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
514 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
515 TTCN_EncDec_ErrorContext
ec_0("Component '");
516 TTCN_EncDec_ErrorContext ec_1
;
517 ec_1
.set_msg("direct-reference': ");
518 new_tlv
->add_TLV(field_direct__reference
.BER_encode_TLV(OBJID_descr_
, p_coding
));
519 ec_1
.set_msg("indirect-reference': ");
520 new_tlv
->add_TLV(field_indirect__reference
.BER_encode_TLV(INTEGER_descr_
, p_coding
));
521 ec_1
.set_msg("data-value-descriptor': ");
522 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(ObjectDescriptor_descr_
, p_coding
));
523 ec_1
.set_msg("encoding': ");
524 new_tlv
->add_TLV(field_encoding
.BER_encode_TLV(EXTERNALtransfer_encoding_descr_
, p_coding
));
525 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
529 boolean
EXTERNALtransfer::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
532 ASN_BER_TLV_t stripped_tlv
;
533 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
534 TTCN_EncDec_ErrorContext
ec_0("While decoding 'EXTERNALtransfer' type: ");
535 stripped_tlv
.chk_constructed_flag(TRUE
);
537 ASN_BER_TLV_t tmp_tlv
;
538 boolean tlv_present
=FALSE
;
540 TTCN_EncDec_ErrorContext
ec_1("Component '");
541 TTCN_EncDec_ErrorContext ec_2
;
542 ec_2
.set_msg("direct-reference': ");
543 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
544 if(!tlv_present
) field_direct__reference
=OMIT_VALUE
;
546 field_direct__reference
.BER_decode_TLV(OBJID_descr_
, tmp_tlv
, L_form
);
547 if(field_direct__reference
.ispresent()) tlv_present
=FALSE
;
549 ec_2
.set_msg("indirect-reference': ");
550 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
551 if(!tlv_present
) field_indirect__reference
=OMIT_VALUE
;
553 field_indirect__reference
.BER_decode_TLV(INTEGER_descr_
, tmp_tlv
, L_form
);
554 if(field_indirect__reference
.ispresent()) tlv_present
=FALSE
;
556 ec_2
.set_msg("data-value-descriptor': ");
557 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
558 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
560 field_data__value__descriptor
.BER_decode_TLV(ObjectDescriptor_descr_
, tmp_tlv
, L_form
);
561 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
563 ec_2
.set_msg("encoding': ");
564 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
565 if(!tlv_present
) return FALSE
;
566 field_encoding
.BER_decode_TLV(EXTERNALtransfer_encoding_descr_
, tmp_tlv
, L_form
);
569 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
573 int EXTERNALtransfer::XER_encode(const XERdescriptor_t
& p_td
,
574 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
576 int indenting
= !is_canonical(flavor
);
577 int exer
= is_exer(flavor
);
578 int encoded_length
=(int)p_buf
.get_len();
579 if (indenting
) do_indent(p_buf
, indent
);
581 if (exer
) write_ns_prefix(p_td
, p_buf
);
582 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
585 field_direct__reference
.XER_encode(EXTERNAL_direct_reference_xer_
, p_buf
, flavor
, indent
, 0);
586 field_indirect__reference
.XER_encode(EXTERNAL_indirect_reference_xer_
, p_buf
, flavor
, indent
, 0);
587 field_data__value__descriptor
.XER_encode(EXTERNAL_data_value_descriptor_xer_
, p_buf
, flavor
, indent
, 0);
588 field_encoding
.XER_encode(EXTERNAL_encoding_xer_
, p_buf
, flavor
, indent
, 0);
590 if (indenting
) do_indent(p_buf
, --indent
);
593 if (exer
) write_ns_prefix(p_td
, p_buf
);
594 p_buf
.put_s((size_t)p_td
.namelens
[exer
] - 1 + indenting
, (const unsigned char*)p_td
.names
[exer
]);
595 return (int)p_buf
.get_len() - encoded_length
;
598 int EXTERNALtransfer::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
599 unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
601 int exer
= is_exer(flavor
);
602 int success
= reader
.Ok(), depth
= -1;
603 for (; success
== 1; success
= reader
.Read()) {
604 int type
= reader
.NodeType();
605 if (XML_READER_TYPE_ELEMENT
== type
) {
606 verify_name(reader
, p_td
, exer
);
607 depth
= reader
.Depth();
613 field_direct__reference
.XER_decode(EXTERNAL_direct_reference_xer_
, reader
, flavor
, flavor2
, 0);
614 field_indirect__reference
.XER_decode(EXTERNAL_indirect_reference_xer_
, reader
, flavor
, flavor2
, 0);
615 field_data__value__descriptor
.XER_decode(EXTERNAL_data_value_descriptor_xer_
, reader
, flavor
, flavor2
, 0);
616 field_encoding
.XER_decode(EXTERNAL_encoding_xer_
, reader
, flavor
, flavor2
, 0);
618 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
619 int type
= reader
.NodeType();
620 if (XML_READER_TYPE_END_ELEMENT
== type
) {
621 verify_end(reader
, p_td
, depth
, exer
);
622 reader
.Read(); // one more time
626 return 1; // decode successful
628 } // end of anonymous namespace
631 * And this is the EXTERNAL type stuff.
635 * This is written by hand, do not delete it! :)
637 ASN_BER_TLV_t
* EXTERNAL::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
639 EXTERNALtransfer v_tmpmfr
;
640 v_tmpmfr
.load(*this);
641 return v_tmpmfr
.BER_encode_TLV(p_td
, p_coding
);
644 /** Load information from an EXTERNALtransfer
646 * @param x pointer to an EXTERNALtransfer. It is of type void* because
647 * <anonymous-namespace>::EXTERNALtransfer can not appear in the header.
649 * Called by XER_decode() */
650 void EXTERNAL::transfer(void *x
)
652 EXTERNALtransfer
& v_tmpmfr
= *(EXTERNALtransfer
*)x
;
653 if (v_tmpmfr
.direct__reference().ispresent()) {
654 if (v_tmpmfr
.indirect__reference().ispresent()) {
655 EXTERNAL_identification_context__negotiation
& v_tmpjsz
=
656 field_identification
.context__negotiation();
657 v_tmpjsz
.presentation__context__id() = v_tmpmfr
.indirect__reference()();
658 v_tmpjsz
.transfer__syntax() = v_tmpmfr
.direct__reference()();
660 field_identification
.syntax() = v_tmpmfr
.direct__reference()();
663 if (v_tmpmfr
.indirect__reference().ispresent()) {
664 field_identification
.presentation__context__id() =
665 v_tmpmfr
.indirect__reference()();
667 TTCN_EncDec_ErrorContext::warning("Neither direct-reference nor "
668 "indirect-reference is present.");
671 switch (field_identification
.get_selection()) {
672 case EXTERNAL_identification::ALT_syntaxes
:
673 case EXTERNAL_identification::ALT_transfer__syntax
:
674 case EXTERNAL_identification::ALT_fixed
:
675 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
676 "EXTERNAL type does not allow the syntaxes, transfer-syntax or fixed");
680 break; // rest are OK
683 field_data__value__descriptor
= v_tmpmfr
.data__value__descriptor();
684 const EXTERNALtransfer_encoding
& v_tmpjsz
= v_tmpmfr
.encoding();
685 switch (v_tmpjsz
.get_selection()) {
686 case EXTERNALtransfer_encoding::ALT_single__ASN1__type
:
687 field_data__value
= v_tmpjsz
.single__ASN1__type();
689 case EXTERNALtransfer_encoding::ALT_octet__aligned
:
690 field_data__value
= v_tmpjsz
.octet__aligned();
692 case EXTERNALtransfer_encoding::ALT_arbitrary
:
693 field_data__value
= bit2oct(v_tmpjsz
.arbitrary());
696 TTCN_EncDec_ErrorContext::error_internal("Unknown selection for field "
697 "`encoding' in EXTERNAL type.");
702 * This is written by hand, do not delete it! :)
704 boolean
EXTERNAL::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
706 EXTERNALtransfer v_tmpmfr
;
707 if(!v_tmpmfr
.BER_decode_TLV(p_td
, p_tlv
, L_form
))
713 int EXTERNAL::XER_encode(const XERdescriptor_t
& p_td
,
714 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
717 TTCN_EncDec_ErrorContext::error
718 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
720 EXTERNALtransfer xfer
;
722 return xfer
.XER_encode(p_td
, p_buf
, flavor
, indent
, 0);
725 int EXTERNAL::XER_decode(const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
,
726 unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
728 EXTERNALtransfer xfer
;
729 xfer
.XER_decode(p_td
, reader
, flavor
, flavor2
, 0);
731 return 1; // decode successful
734 /* generated stuff */
736 void EXTERNAL_identification::clean_up()
738 switch (union_selection
) {
740 delete field_syntaxes
;
745 case ALT_presentation__context__id
:
746 delete field_presentation__context__id
;
748 case ALT_context__negotiation
:
749 delete field_context__negotiation
;
751 case ALT_transfer__syntax
:
752 delete field_transfer__syntax
;
760 union_selection
= UNBOUND_VALUE
;
763 void EXTERNAL_identification::copy_value(const EXTERNAL_identification
& other_value
)
765 switch (other_value
.union_selection
) {
767 field_syntaxes
= new EXTERNAL_identification_syntaxes(*other_value
.field_syntaxes
);
770 field_syntax
= new OBJID(*other_value
.field_syntax
);
772 case ALT_presentation__context__id
:
773 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
775 case ALT_context__negotiation
:
776 field_context__negotiation
= new EXTERNAL_identification_context__negotiation(*other_value
.field_context__negotiation
);
778 case ALT_transfer__syntax
:
779 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
782 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
785 TTCN_error("Assignment of an unbound union value of type EXTERNAL.identification.");
787 union_selection
= other_value
.union_selection
;
790 EXTERNAL_identification::EXTERNAL_identification()
792 union_selection
= UNBOUND_VALUE
;
795 EXTERNAL_identification::EXTERNAL_identification(const EXTERNAL_identification
& other_value
)
796 : Base_Type(other_value
)
798 copy_value(other_value
);
801 EXTERNAL_identification::~EXTERNAL_identification()
806 EXTERNAL_identification
& EXTERNAL_identification::operator=(const EXTERNAL_identification
& other_value
)
808 if (this != &other_value
) {
810 copy_value(other_value
);
815 boolean
EXTERNAL_identification::operator==(const EXTERNAL_identification
& other_value
) const
817 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type EXTERNAL.identification.");
818 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type EXTERNAL.identification.");
819 if (union_selection
!= other_value
.union_selection
) return FALSE
;
820 switch (union_selection
) {
822 return *field_syntaxes
== *other_value
.field_syntaxes
;
824 return *field_syntax
== *other_value
.field_syntax
;
825 case ALT_presentation__context__id
:
826 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
827 case ALT_context__negotiation
:
828 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
829 case ALT_transfer__syntax
:
830 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
832 return *field_fixed
== *other_value
.field_fixed
;
838 EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes()
840 if (union_selection
!= ALT_syntaxes
) {
842 field_syntaxes
= new EXTERNAL_identification_syntaxes
;
843 union_selection
= ALT_syntaxes
;
845 return *field_syntaxes
;
848 const EXTERNAL_identification_syntaxes
& EXTERNAL_identification::syntaxes() const
850 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type EXTERNAL.identification.");
851 return *field_syntaxes
;
854 OBJID
& EXTERNAL_identification::syntax()
856 if (union_selection
!= ALT_syntax
) {
858 field_syntax
= new OBJID
;
859 union_selection
= ALT_syntax
;
861 return *field_syntax
;
864 const OBJID
& EXTERNAL_identification::syntax() const
866 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type EXTERNAL.identification.");
867 return *field_syntax
;
870 INTEGER
& EXTERNAL_identification::presentation__context__id()
872 if (union_selection
!= ALT_presentation__context__id
) {
874 field_presentation__context__id
= new INTEGER
;
875 union_selection
= ALT_presentation__context__id
;
877 return *field_presentation__context__id
;
880 const INTEGER
& EXTERNAL_identification::presentation__context__id() const
882 if (union_selection
!= ALT_presentation__context__id
) TTCN_error("Using non-selected field presentation_context_id in a value of union type EXTERNAL.identification.");
883 return *field_presentation__context__id
;
886 EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation()
888 if (union_selection
!= ALT_context__negotiation
) {
890 field_context__negotiation
= new EXTERNAL_identification_context__negotiation
;
891 union_selection
= ALT_context__negotiation
;
893 return *field_context__negotiation
;
896 const EXTERNAL_identification_context__negotiation
& EXTERNAL_identification::context__negotiation() const
898 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type EXTERNAL.identification.");
899 return *field_context__negotiation
;
902 OBJID
& EXTERNAL_identification::transfer__syntax()
904 if (union_selection
!= ALT_transfer__syntax
) {
906 field_transfer__syntax
= new OBJID
;
907 union_selection
= ALT_transfer__syntax
;
909 return *field_transfer__syntax
;
912 const OBJID
& EXTERNAL_identification::transfer__syntax() const
914 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type EXTERNAL.identification.");
915 return *field_transfer__syntax
;
918 ASN_NULL
& EXTERNAL_identification::fixed()
920 if (union_selection
!= ALT_fixed
) {
922 field_fixed
= new ASN_NULL
;
923 union_selection
= ALT_fixed
;
928 const ASN_NULL
& EXTERNAL_identification::fixed() const
930 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type EXTERNAL.identification.");
934 boolean
EXTERNAL_identification::ischosen(union_selection_type checked_selection
) const
936 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
937 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type EXTERNAL.identification.");
938 return union_selection
== checked_selection
;
941 boolean
EXTERNAL_identification::is_value() const
943 switch (union_selection
) {
945 return field_syntaxes
->is_value();
947 return field_syntax
->is_value();
948 case ALT_presentation__context__id
:
949 return field_presentation__context__id
->is_value();
950 case ALT_context__negotiation
:
951 return field_context__negotiation
->is_value();
952 case ALT_transfer__syntax
:
953 return field_transfer__syntax
->is_value();
955 return field_fixed
->is_value();
961 void EXTERNAL_identification::log() const
963 switch (union_selection
) {
965 TTCN_Logger::log_event_str("{ syntaxes := ");
966 field_syntaxes
->log();
967 TTCN_Logger::log_event_str(" }");
970 TTCN_Logger::log_event_str("{ syntax := ");
972 TTCN_Logger::log_event_str(" }");
974 case ALT_presentation__context__id
:
975 TTCN_Logger::log_event_str("{ presentation_context_id := ");
976 field_presentation__context__id
->log();
977 TTCN_Logger::log_event_str(" }");
979 case ALT_context__negotiation
:
980 TTCN_Logger::log_event_str("{ context_negotiation := ");
981 field_context__negotiation
->log();
982 TTCN_Logger::log_event_str(" }");
984 case ALT_transfer__syntax
:
985 TTCN_Logger::log_event_str("{ transfer_syntax := ");
986 field_transfer__syntax
->log();
987 TTCN_Logger::log_event_str(" }");
990 TTCN_Logger::log_event_str("{ fixed := ");
992 TTCN_Logger::log_event_str(" }");
995 TTCN_Logger::log_event_str("<unbound>");
1000 void EXTERNAL_identification::set_param(Module_Param
& param
) {
1001 param
.basic_check(Module_Param::BC_VALUE
, "union value");
1002 Module_Param_Ptr mp
= ¶m
;
1003 if (param
.get_type() == Module_Param::MP_Reference
) {
1004 mp
= param
.get_referenced_param();
1006 if (mp
->get_type()==Module_Param::MP_Value_List
&& mp
->get_size()==0) return;
1007 if (mp
->get_type()!=Module_Param::MP_Assignment_List
) {
1008 param
.error("union value with field name was expected");
1010 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
1011 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
1012 syntaxes().set_param(*mp_last
);
1015 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
1016 syntax().set_param(*mp_last
);
1019 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
1020 presentation__context__id().set_param(*mp_last
);
1023 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1024 context__negotiation().set_param(*mp_last
);
1027 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1028 transfer__syntax().set_param(*mp_last
);
1031 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1032 fixed().set_param(*mp_last
);
1035 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1038 Module_Param
* EXTERNAL_identification::get_param(Module_Param_Name
& param_name
) const
1041 return new Module_Param_Unbound();
1043 Module_Param
* mp_field
= NULL
;
1045 switch(get_selection()) {
1047 mp_field
= field_syntaxes
->get_param(param_name
);
1048 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
1051 mp_field
= field_syntax
->get_param(param_name
);
1052 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
1054 case ALT_presentation__context__id
:
1055 mp_field
= field_presentation__context__id
->get_param(param_name
);
1056 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
1058 case ALT_context__negotiation
:
1059 mp_field
= field_context__negotiation
->get_param(param_name
);
1060 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
1062 case ALT_transfer__syntax
:
1063 mp_field
= field_transfer__syntax
->get_param(param_name
);
1064 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
1067 mp_field
= field_fixed
->get_param(param_name
);
1068 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
1073 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
1074 mp
->add_elem(mp_field
);
1078 void EXTERNAL_identification_template::set_param(Module_Param
& param
)
1080 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
1081 Module_Param_Ptr mp
= ¶m
;
1082 if (param
.get_type() == Module_Param::MP_Reference
) {
1083 mp
= param
.get_referenced_param();
1085 switch (mp
->get_type()) {
1086 case Module_Param::MP_Omit
:
1089 case Module_Param::MP_Any
:
1092 case Module_Param::MP_AnyOrNone
:
1093 *this = ANY_OR_OMIT
;
1095 case Module_Param::MP_List_Template
:
1096 case Module_Param::MP_ComplementList_Template
: {
1097 EXTERNAL_identification_template temp
;
1098 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
1099 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
1100 for (size_t i
=0; i
<mp
->get_size(); i
++) {
1101 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
1105 case Module_Param::MP_Value_List
:
1106 if (mp
->get_size()==0) break;
1107 param
.type_error("union template", "EXTERNAL.identification");
1109 case Module_Param::MP_Assignment_List
: {
1110 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
1111 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
1112 syntaxes().set_param(*mp_last
);
1115 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
1116 syntax().set_param(*mp_last
);
1119 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
1120 presentation__context__id().set_param(*mp_last
);
1123 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
1124 context__negotiation().set_param(*mp_last
);
1127 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
1128 transfer__syntax().set_param(*mp_last
);
1131 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
1132 fixed().set_param(*mp_last
);
1135 mp_last
->error("Field %s does not exist in type EXTERNAL.identification.", mp_last
->get_id()->get_name());
1138 param
.type_error("union template", "EXTERNAL.identification");
1140 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
1143 Module_Param
* EXTERNAL_identification_template::get_param(Module_Param_Name
& param_name
) const
1145 Module_Param
* mp
= NULL
;
1146 switch (template_selection
) {
1147 case UNINITIALIZED_TEMPLATE
:
1148 mp
= new Module_Param_Unbound();
1151 mp
= new Module_Param_Omit();
1154 mp
= new Module_Param_Any();
1157 mp
= new Module_Param_AnyOrNone();
1159 case SPECIFIC_VALUE
: {
1160 Module_Param
* mp_field
= NULL
;
1161 switch(single_value
.union_selection
) {
1162 case EXTERNAL_identification::ALT_syntaxes
:
1163 mp_field
= single_value
.field_syntaxes
->get_param(param_name
);
1164 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
1166 case EXTERNAL_identification::ALT_syntax
:
1167 mp_field
= single_value
.field_syntax
->get_param(param_name
);
1168 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
1170 case EXTERNAL_identification::ALT_presentation__context__id
:
1171 mp_field
= single_value
.field_presentation__context__id
->get_param(param_name
);
1172 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
1174 case EXTERNAL_identification::ALT_context__negotiation
:
1175 mp_field
= single_value
.field_context__negotiation
->get_param(param_name
);
1176 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
1178 case EXTERNAL_identification::ALT_transfer__syntax
:
1179 mp_field
= single_value
.field_transfer__syntax
->get_param(param_name
);
1180 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
1182 case EXTERNAL_identification::ALT_fixed
:
1183 mp_field
= single_value
.field_fixed
->get_param(param_name
);
1184 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
1189 mp
= new Module_Param_Assignment_List();
1190 mp
->add_elem(mp_field
);
1193 case COMPLEMENTED_LIST
: {
1194 if (template_selection
== VALUE_LIST
) {
1195 mp
= new Module_Param_List_Template();
1198 mp
= new Module_Param_ComplementList_Template();
1200 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
1201 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
1208 mp
->set_ifpresent();
1213 void EXTERNAL_identification::encode_text(Text_Buf
& text_buf
) const
1215 text_buf
.push_int(union_selection
);
1216 switch (union_selection
) {
1218 field_syntaxes
->encode_text(text_buf
);
1221 field_syntax
->encode_text(text_buf
);
1223 case ALT_presentation__context__id
:
1224 field_presentation__context__id
->encode_text(text_buf
);
1226 case ALT_context__negotiation
:
1227 field_context__negotiation
->encode_text(text_buf
);
1229 case ALT_transfer__syntax
:
1230 field_transfer__syntax
->encode_text(text_buf
);
1233 field_fixed
->encode_text(text_buf
);
1236 TTCN_error("Text encoder: Encoding an unbound value of union type EXTERNAL.identification.");
1240 void EXTERNAL_identification::decode_text(Text_Buf
& text_buf
)
1242 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
1244 syntaxes().decode_text(text_buf
);
1247 syntax().decode_text(text_buf
);
1249 case ALT_presentation__context__id
:
1250 presentation__context__id().decode_text(text_buf
);
1252 case ALT_context__negotiation
:
1253 context__negotiation().decode_text(text_buf
);
1255 case ALT_transfer__syntax
:
1256 transfer__syntax().decode_text(text_buf
);
1259 fixed().decode_text(text_buf
);
1262 TTCN_error("Text decoder: Unrecognized union selector was received for type EXTERNAL.identification.");
1267 void EXTERNAL_identification_template::clean_up()
1269 switch (template_selection
) {
1270 case SPECIFIC_VALUE
:
1271 switch (single_value
.union_selection
) {
1272 case EXTERNAL_identification::ALT_syntaxes
:
1273 delete single_value
.field_syntaxes
;
1275 case EXTERNAL_identification::ALT_syntax
:
1276 delete single_value
.field_syntax
;
1278 case EXTERNAL_identification::ALT_presentation__context__id
:
1279 delete single_value
.field_presentation__context__id
;
1281 case EXTERNAL_identification::ALT_context__negotiation
:
1282 delete single_value
.field_context__negotiation
;
1284 case EXTERNAL_identification::ALT_transfer__syntax
:
1285 delete single_value
.field_transfer__syntax
;
1287 case EXTERNAL_identification::ALT_fixed
:
1288 delete single_value
.field_fixed
;
1295 case COMPLEMENTED_LIST
:
1296 delete [] value_list
.list_value
;
1301 template_selection
= UNINITIALIZED_TEMPLATE
;
1304 void EXTERNAL_identification_template::copy_value(const EXTERNAL_identification
& other_value
)
1306 single_value
.union_selection
= other_value
.get_selection();
1307 switch (single_value
.union_selection
) {
1308 case EXTERNAL_identification::ALT_syntaxes
:
1309 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(other_value
.syntaxes());
1311 case EXTERNAL_identification::ALT_syntax
:
1312 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
1314 case EXTERNAL_identification::ALT_presentation__context__id
:
1315 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
1317 case EXTERNAL_identification::ALT_context__negotiation
:
1318 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(other_value
.context__negotiation());
1320 case EXTERNAL_identification::ALT_transfer__syntax
:
1321 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
1323 case EXTERNAL_identification::ALT_fixed
:
1324 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
1327 TTCN_error("Initializing a template with an unbound value of type EXTERNAL.identification.");
1329 set_selection(SPECIFIC_VALUE
);
1332 void EXTERNAL_identification_template::copy_template(const EXTERNAL_identification_template
& other_value
)
1334 switch (other_value
.template_selection
) {
1335 case SPECIFIC_VALUE
:
1336 single_value
.union_selection
= other_value
.single_value
.union_selection
;
1337 switch (single_value
.union_selection
) {
1338 case EXTERNAL_identification::ALT_syntaxes
:
1339 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
1341 case EXTERNAL_identification::ALT_syntax
:
1342 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
1344 case EXTERNAL_identification::ALT_presentation__context__id
:
1345 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
1347 case EXTERNAL_identification::ALT_context__negotiation
:
1348 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
1350 case EXTERNAL_identification::ALT_transfer__syntax
:
1351 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
1353 case EXTERNAL_identification::ALT_fixed
:
1354 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
1357 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type EXTERNAL.identification.");
1365 case COMPLEMENTED_LIST
:
1366 value_list
.n_values
= other_value
.value_list
.n_values
;
1367 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1368 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1369 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1372 TTCN_error("Copying an uninitialized template of union type EXTERNAL.identification.");
1374 set_selection(other_value
);
1377 EXTERNAL_identification_template::EXTERNAL_identification_template()
1381 EXTERNAL_identification_template::EXTERNAL_identification_template(template_sel other_value
)
1382 : Base_Template(other_value
)
1384 check_single_selection(other_value
);
1387 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification
& other_value
)
1389 copy_value(other_value
);
1392 EXTERNAL_identification_template::EXTERNAL_identification_template(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1394 switch (other_value
.get_selection()) {
1395 case OPTIONAL_PRESENT
:
1396 copy_value((const EXTERNAL_identification
&)other_value
);
1399 set_selection(OMIT_VALUE
);
1402 TTCN_error("Creating a template of union type EXTERNAL.identification from an unbound optional field.");
1406 EXTERNAL_identification_template::EXTERNAL_identification_template(const EXTERNAL_identification_template
& other_value
)
1409 copy_template(other_value
);
1412 EXTERNAL_identification_template::~EXTERNAL_identification_template()
1417 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(template_sel other_value
)
1419 check_single_selection(other_value
);
1421 set_selection(other_value
);
1425 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification
& other_value
)
1428 copy_value(other_value
);
1432 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const OPTIONAL
<EXTERNAL_identification
>& other_value
)
1435 switch (other_value
.get_selection()) {
1436 case OPTIONAL_PRESENT
:
1437 copy_value((const EXTERNAL_identification
&)other_value
);
1440 set_selection(OMIT_VALUE
);
1443 TTCN_error("Assignment of an unbound optional field to a template of union type EXTERNAL.identification.");
1448 EXTERNAL_identification_template
& EXTERNAL_identification_template::operator=(const EXTERNAL_identification_template
& other_value
)
1450 if (&other_value
!= this) {
1452 copy_template(other_value
);
1457 boolean
EXTERNAL_identification_template::match(const EXTERNAL_identification
& other_value
,
1458 boolean
/* legacy */) const
1460 switch (template_selection
) {
1466 case SPECIFIC_VALUE
:
1468 EXTERNAL_identification::union_selection_type value_selection
= other_value
.get_selection();
1469 if (value_selection
== EXTERNAL_identification::UNBOUND_VALUE
) return FALSE
;
1470 if (value_selection
!= single_value
.union_selection
) return FALSE
;
1471 switch (value_selection
) {
1472 case EXTERNAL_identification::ALT_syntaxes
:
1473 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
1474 case EXTERNAL_identification::ALT_syntax
:
1475 return single_value
.field_syntax
->match(other_value
.syntax());
1476 case EXTERNAL_identification::ALT_presentation__context__id
:
1477 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
1478 case EXTERNAL_identification::ALT_context__negotiation
:
1479 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
1480 case EXTERNAL_identification::ALT_transfer__syntax
:
1481 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
1482 case EXTERNAL_identification::ALT_fixed
:
1483 return single_value
.field_fixed
->match(other_value
.fixed());
1485 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type EXTERNAL.identification.");
1488 break; // should never get here
1490 case COMPLEMENTED_LIST
:
1491 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1492 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1493 return template_selection
== COMPLEMENTED_LIST
;
1495 TTCN_error ("Matching an uninitialized template of union type EXTERNAL.identification.");
1500 EXTERNAL_identification
EXTERNAL_identification_template::valueof() const
1502 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1503 TTCN_error("Performing valueof or send operation on a non-specific template of union type EXTERNAL.identification.");
1504 EXTERNAL_identification ret_val
;
1505 switch (single_value
.union_selection
) {
1506 case EXTERNAL_identification::ALT_syntaxes
:
1507 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
1509 case EXTERNAL_identification::ALT_syntax
:
1510 ret_val
.syntax() = single_value
.field_syntax
->valueof();
1512 case EXTERNAL_identification::ALT_presentation__context__id
:
1513 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
1515 case EXTERNAL_identification::ALT_context__negotiation
:
1516 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
1518 case EXTERNAL_identification::ALT_transfer__syntax
:
1519 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1521 case EXTERNAL_identification::ALT_fixed
:
1522 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1525 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type EXTERNAL.identification.");
1530 EXTERNAL_identification_template
& EXTERNAL_identification_template::list_item(unsigned int list_index
) const
1532 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.");
1533 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type EXTERNAL.identification.");
1534 return value_list
.list_value
[list_index
];
1536 void EXTERNAL_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1538 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.");
1540 set_selection(template_type
);
1541 value_list
.n_values
= list_length
;
1542 value_list
.list_value
= new EXTERNAL_identification_template
[list_length
];
1545 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes()
1547 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) {
1548 template_sel old_selection
= template_selection
;
1550 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template(ANY_VALUE
);
1551 else single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1552 single_value
.union_selection
= EXTERNAL_identification::ALT_syntaxes
;
1553 set_selection(SPECIFIC_VALUE
);
1555 return *single_value
.field_syntaxes
;
1558 const EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_template::syntaxes() const
1560 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type EXTERNAL.identification.");
1561 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntaxes
) TTCN_error("Accessing non-selected field syntaxes in a template of union type EXTERNAL.identification.");
1562 return *single_value
.field_syntaxes
;
1565 OBJID_template
& EXTERNAL_identification_template::syntax()
1567 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) {
1568 template_sel old_selection
= template_selection
;
1570 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1571 else single_value
.field_syntax
= new OBJID_template
;
1572 single_value
.union_selection
= EXTERNAL_identification::ALT_syntax
;
1573 set_selection(SPECIFIC_VALUE
);
1575 return *single_value
.field_syntax
;
1578 const OBJID_template
& EXTERNAL_identification_template::syntax() const
1580 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type EXTERNAL.identification.");
1581 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_syntax
) TTCN_error("Accessing non-selected field syntax in a template of union type EXTERNAL.identification.");
1582 return *single_value
.field_syntax
;
1585 INTEGER_template
& EXTERNAL_identification_template::presentation__context__id()
1587 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_presentation__context__id
) {
1588 template_sel old_selection
= template_selection
;
1590 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1591 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1592 single_value
.union_selection
= EXTERNAL_identification::ALT_presentation__context__id
;
1593 set_selection(SPECIFIC_VALUE
);
1595 return *single_value
.field_presentation__context__id
;
1598 const INTEGER_template
& EXTERNAL_identification_template::presentation__context__id() const
1600 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type EXTERNAL.identification.");
1601 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.");
1602 return *single_value
.field_presentation__context__id
;
1605 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation()
1607 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_context__negotiation
) {
1608 template_sel old_selection
= template_selection
;
1610 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template(ANY_VALUE
);
1611 else single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1612 single_value
.union_selection
= EXTERNAL_identification::ALT_context__negotiation
;
1613 set_selection(SPECIFIC_VALUE
);
1615 return *single_value
.field_context__negotiation
;
1618 const EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_template::context__negotiation() const
1620 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type EXTERNAL.identification.");
1621 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.");
1622 return *single_value
.field_context__negotiation
;
1625 OBJID_template
& EXTERNAL_identification_template::transfer__syntax()
1627 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_transfer__syntax
) {
1628 template_sel old_selection
= template_selection
;
1630 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1631 else single_value
.field_transfer__syntax
= new OBJID_template
;
1632 single_value
.union_selection
= EXTERNAL_identification::ALT_transfer__syntax
;
1633 set_selection(SPECIFIC_VALUE
);
1635 return *single_value
.field_transfer__syntax
;
1638 const OBJID_template
& EXTERNAL_identification_template::transfer__syntax() const
1640 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type EXTERNAL.identification.");
1641 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.");
1642 return *single_value
.field_transfer__syntax
;
1645 ASN_NULL_template
& EXTERNAL_identification_template::fixed()
1647 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) {
1648 template_sel old_selection
= template_selection
;
1650 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1651 else single_value
.field_fixed
= new ASN_NULL_template
;
1652 single_value
.union_selection
= EXTERNAL_identification::ALT_fixed
;
1653 set_selection(SPECIFIC_VALUE
);
1655 return *single_value
.field_fixed
;
1658 const ASN_NULL_template
& EXTERNAL_identification_template::fixed() const
1660 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type EXTERNAL.identification.");
1661 if (single_value
.union_selection
!= EXTERNAL_identification::ALT_fixed
) TTCN_error("Accessing non-selected field fixed in a template of union type EXTERNAL.identification.");
1662 return *single_value
.field_fixed
;
1665 boolean
EXTERNAL_identification_template::ischosen(EXTERNAL_identification::union_selection_type checked_selection
) const
1667 if (checked_selection
== EXTERNAL_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type EXTERNAL.identification.");
1668 switch (template_selection
) {
1669 case SPECIFIC_VALUE
:
1670 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.");
1671 return single_value
.union_selection
== checked_selection
;
1674 if (value_list
.n_values
< 1)
1675 TTCN_error("Internal error: Performing ischosen() operation on a template of union type EXTERNAL.identification containing an empty list.");
1676 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1677 boolean all_same
= TRUE
;
1678 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1679 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1684 if (all_same
) return ret_val
;
1686 // FIXME really no break?
1690 case COMPLEMENTED_LIST
:
1691 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.");
1693 TTCN_error("Performing ischosen() operation on an uninitialized template of union type EXTERNAL.identification");
1698 void EXTERNAL_identification_template::log() const
1700 switch (template_selection
) {
1701 case SPECIFIC_VALUE
:
1702 switch (single_value
.union_selection
) {
1703 case EXTERNAL_identification::ALT_syntaxes
:
1704 TTCN_Logger::log_event_str("{ syntaxes := ");
1705 single_value
.field_syntaxes
->log();
1706 TTCN_Logger::log_event_str(" }");
1708 case EXTERNAL_identification::ALT_syntax
:
1709 TTCN_Logger::log_event_str("{ syntax := ");
1710 single_value
.field_syntax
->log();
1711 TTCN_Logger::log_event_str(" }");
1713 case EXTERNAL_identification::ALT_presentation__context__id
:
1714 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1715 single_value
.field_presentation__context__id
->log();
1716 TTCN_Logger::log_event_str(" }");
1718 case EXTERNAL_identification::ALT_context__negotiation
:
1719 TTCN_Logger::log_event_str("{ context_negotiation := ");
1720 single_value
.field_context__negotiation
->log();
1721 TTCN_Logger::log_event_str(" }");
1723 case EXTERNAL_identification::ALT_transfer__syntax
:
1724 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1725 single_value
.field_transfer__syntax
->log();
1726 TTCN_Logger::log_event_str(" }");
1728 case EXTERNAL_identification::ALT_fixed
:
1729 TTCN_Logger::log_event_str("{ fixed := ");
1730 single_value
.field_fixed
->log();
1731 TTCN_Logger::log_event_str(" }");
1734 TTCN_Logger::log_event_str("<invalid selector>");
1738 case COMPLEMENTED_LIST
:
1739 TTCN_Logger::log_event_str("complement ");
1742 TTCN_Logger::log_char('(');
1743 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1744 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1745 value_list
.list_value
[list_count
].log();
1747 TTCN_Logger::log_char(')');
1756 void EXTERNAL_identification_template::log_match(const EXTERNAL_identification
& match_value
,
1757 boolean
/* legacy */) const
1759 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1760 if(match(match_value
)){
1761 TTCN_Logger::print_logmatch_buffer();
1762 TTCN_Logger::log_event_str(" matched ");
1766 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1767 switch (single_value
.union_selection
) {
1768 case EXTERNAL_identification::ALT_syntaxes
:
1769 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1770 TTCN_Logger::log_logmatch_info(".syntaxes");
1771 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1773 TTCN_Logger::log_event_str("{ syntaxes := ");
1774 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1775 TTCN_Logger::log_event_str(" }");
1778 case EXTERNAL_identification::ALT_syntax
:
1779 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1780 TTCN_Logger::log_logmatch_info(".syntax");
1781 single_value
.field_syntax
->log_match(match_value
.syntax());
1783 TTCN_Logger::log_event_str("{ syntax := ");
1784 single_value
.field_syntax
->log_match(match_value
.syntax());
1785 TTCN_Logger::log_event_str(" }");
1788 case EXTERNAL_identification::ALT_presentation__context__id
:
1789 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1790 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1791 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1793 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1794 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1795 TTCN_Logger::log_event_str(" }");
1798 case EXTERNAL_identification::ALT_context__negotiation
:
1799 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1800 TTCN_Logger::log_logmatch_info(".context_negotiation");
1801 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1803 TTCN_Logger::log_event_str("{ context_negotiation := ");
1804 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1805 TTCN_Logger::log_event_str(" }");
1808 case EXTERNAL_identification::ALT_transfer__syntax
:
1809 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1810 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1811 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1813 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1814 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1815 TTCN_Logger::log_event_str(" }");
1818 case EXTERNAL_identification::ALT_fixed
:
1819 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1820 TTCN_Logger::log_logmatch_info(".fixed");
1821 single_value
.field_fixed
->log_match(match_value
.fixed());
1823 TTCN_Logger::log_event_str("{ fixed := ");
1824 single_value
.field_fixed
->log_match(match_value
.fixed());
1825 TTCN_Logger::log_event_str(" }");
1829 TTCN_Logger::print_logmatch_buffer();
1830 TTCN_Logger::log_event_str("<invalid selector>");
1834 TTCN_Logger::print_logmatch_buffer();
1836 TTCN_Logger::log_event_str(" with ");
1838 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1839 else TTCN_Logger::log_event_str(" unmatched");
1843 void EXTERNAL_identification_template::encode_text(Text_Buf
& text_buf
) const
1845 encode_text_base(text_buf
);
1846 switch (template_selection
) {
1847 case SPECIFIC_VALUE
:
1848 text_buf
.push_int(single_value
.union_selection
);
1849 switch (single_value
.union_selection
) {
1850 case EXTERNAL_identification::ALT_syntaxes
:
1851 single_value
.field_syntaxes
->encode_text(text_buf
);
1853 case EXTERNAL_identification::ALT_syntax
:
1854 single_value
.field_syntax
->encode_text(text_buf
);
1856 case EXTERNAL_identification::ALT_presentation__context__id
:
1857 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1859 case EXTERNAL_identification::ALT_context__negotiation
:
1860 single_value
.field_context__negotiation
->encode_text(text_buf
);
1862 case EXTERNAL_identification::ALT_transfer__syntax
:
1863 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1865 case EXTERNAL_identification::ALT_fixed
:
1866 single_value
.field_fixed
->encode_text(text_buf
);
1869 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type EXTERNAL.identification.");
1877 case COMPLEMENTED_LIST
:
1878 text_buf
.push_int(value_list
.n_values
);
1879 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1880 value_list
.list_value
[list_count
].encode_text(text_buf
);
1883 TTCN_error("Text encoder: Encoding an uninitialized template of type EXTERNAL.identification.");
1887 void EXTERNAL_identification_template::decode_text(Text_Buf
& text_buf
)
1890 decode_text_base(text_buf
);
1891 switch (template_selection
) {
1892 case SPECIFIC_VALUE
:
1894 single_value
.union_selection
= EXTERNAL_identification::UNBOUND_VALUE
;
1895 EXTERNAL_identification::union_selection_type new_selection
= (EXTERNAL_identification::union_selection_type
)text_buf
.pull_int().get_val();
1896 switch (new_selection
) {
1897 case EXTERNAL_identification::ALT_syntaxes
:
1898 single_value
.field_syntaxes
= new EXTERNAL_identification_syntaxes_template
;
1899 single_value
.field_syntaxes
->decode_text(text_buf
);
1901 case EXTERNAL_identification::ALT_syntax
:
1902 single_value
.field_syntax
= new OBJID_template
;
1903 single_value
.field_syntax
->decode_text(text_buf
);
1905 case EXTERNAL_identification::ALT_presentation__context__id
:
1906 single_value
.field_presentation__context__id
= new INTEGER_template
;
1907 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1909 case EXTERNAL_identification::ALT_context__negotiation
:
1910 single_value
.field_context__negotiation
= new EXTERNAL_identification_context__negotiation_template
;
1911 single_value
.field_context__negotiation
->decode_text(text_buf
);
1913 case EXTERNAL_identification::ALT_transfer__syntax
:
1914 single_value
.field_transfer__syntax
= new OBJID_template
;
1915 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1917 case EXTERNAL_identification::ALT_fixed
:
1918 single_value
.field_fixed
= new ASN_NULL_template
;
1919 single_value
.field_fixed
->decode_text(text_buf
);
1922 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type EXTERNAL.identification.");
1924 single_value
.union_selection
= new_selection
;
1932 case COMPLEMENTED_LIST
:
1933 value_list
.n_values
= text_buf
.pull_int().get_val();
1934 value_list
.list_value
= new EXTERNAL_identification_template
[value_list
.n_values
];
1935 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1936 value_list
.list_value
[list_count
].decode_text(text_buf
);
1939 TTCN_error("Text decoder: Unrecognized selector was received in a template of type EXTERNAL.identification.");
1943 boolean
EXTERNAL_identification_template::is_present(boolean legacy
/* = FALSE */) const
1945 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1946 return !match_omit(legacy
);
1949 boolean
EXTERNAL_identification_template::match_omit(boolean legacy
/* = FALSE */) const
1951 if (is_ifpresent
) return TRUE
;
1952 switch (template_selection
) {
1957 case COMPLEMENTED_LIST
:
1959 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1960 if (value_list
.list_value
[i
].match_omit())
1961 return template_selection
==VALUE_LIST
;
1962 return template_selection
==COMPLEMENTED_LIST
;
1963 } // else fall through
1970 #ifndef TITAN_RUNTIME_2
1971 void EXTERNAL_identification_template::check_restriction(template_res t_res
, const char* t_name
,
1972 boolean legacy
/* = FALSE */) const
1974 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1975 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1977 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1980 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1981 template_selection
==SPECIFIC_VALUE
)) return;
1984 if (!match_omit(legacy
)) return;
1989 TTCN_error("Restriction `%s' on template of type %s violated.",
1990 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification");
1994 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes()
1998 EXTERNAL_identification_syntaxes::EXTERNAL_identification_syntaxes(const OBJID
& par_abstract
,
1999 const OBJID
& par_transfer
)
2000 : field_abstract(par_abstract
),
2001 field_transfer(par_transfer
)
2005 boolean
EXTERNAL_identification_syntaxes::operator==(const EXTERNAL_identification_syntaxes
& other_value
) const
2007 return field_abstract
==other_value
.field_abstract
2008 && field_transfer
==other_value
.field_transfer
;
2011 int EXTERNAL_identification_syntaxes::size_of() const
2017 void EXTERNAL_identification_syntaxes::log() const
2019 TTCN_Logger::log_event_str("{ abstract := ");
2020 field_abstract
.log();
2021 TTCN_Logger::log_event_str(", transfer := ");
2022 field_transfer
.log();
2023 TTCN_Logger::log_event_str(" }");
2026 boolean
EXTERNAL_identification_syntaxes::is_bound() const
2028 if(field_abstract
.is_bound()) return TRUE
;
2029 if(field_transfer
.is_bound()) return TRUE
;
2033 boolean
EXTERNAL_identification_syntaxes::is_value() const
2035 if(!field_abstract
.is_value()) return FALSE
;
2036 if(!field_transfer
.is_value()) return FALSE
;
2040 void EXTERNAL_identification_syntaxes::clean_up()
2042 field_abstract
.clean_up();
2043 field_transfer
.clean_up();
2046 void EXTERNAL_identification_syntaxes::set_param(Module_Param
& param
)
2048 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2049 Module_Param_Ptr mp
= ¶m
;
2050 if (param
.get_type() == Module_Param::MP_Reference
) {
2051 mp
= param
.get_referenced_param();
2053 switch (mp
->get_type()) {
2054 case Module_Param::MP_Value_List
:
2055 if (mp
->get_size()==0) return;
2056 if (2!=mp
->get_size()) {
2057 param
.error("record value of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
2059 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
2060 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
2062 case Module_Param::MP_Assignment_List
: {
2063 Vector
<bool> value_used(mp
->get_size());
2064 value_used
.resize(mp
->get_size(), false);
2065 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2066 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2067 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
2068 abstract().set_param(*curr_param
);
2069 value_used
[val_idx
]=true;
2072 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2073 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2074 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
2075 transfer().set_param(*curr_param
);
2076 value_used
[val_idx
]=true;
2079 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2080 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2085 param
.type_error("record value", "EXTERNAL.identification.syntaxes");
2089 Module_Param
* EXTERNAL_identification_syntaxes::get_param(Module_Param_Name
& param_name
) const
2092 return new Module_Param_Unbound();
2094 Module_Param
* mp_field_abstract
= field_abstract
.get_param(param_name
);
2095 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
2096 Module_Param
* mp_field_transfer
= field_transfer
.get_param(param_name
);
2097 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
2098 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2099 mp
->add_elem(mp_field_abstract
);
2100 mp
->add_elem(mp_field_transfer
);
2104 void EXTERNAL_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
2106 field_abstract
.encode_text(text_buf
);
2107 field_transfer
.encode_text(text_buf
);
2110 void EXTERNAL_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
2112 field_abstract
.decode_text(text_buf
);
2113 field_transfer
.decode_text(text_buf
);
2116 struct EXTERNAL_identification_syntaxes_template::single_value_struct
{
2117 OBJID_template field_abstract
;
2118 OBJID_template field_transfer
;
2121 void EXTERNAL_identification_syntaxes_template::set_param(Module_Param
& param
)
2123 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2124 Module_Param_Ptr mp
= ¶m
;
2125 if (param
.get_type() == Module_Param::MP_Reference
) {
2126 mp
= param
.get_referenced_param();
2128 switch (mp
->get_type()) {
2129 case Module_Param::MP_Omit
:
2132 case Module_Param::MP_Any
:
2135 case Module_Param::MP_AnyOrNone
:
2136 *this = ANY_OR_OMIT
;
2138 case Module_Param::MP_List_Template
:
2139 case Module_Param::MP_ComplementList_Template
: {
2140 EXTERNAL_identification_syntaxes_template temp
;
2141 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2142 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2143 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2144 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2148 case Module_Param::MP_Value_List
:
2149 if (mp
->get_size()==0) break;
2150 if (2!=mp
->get_size()) {
2151 param
.error("record template of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
2153 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
2154 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
2156 case Module_Param::MP_Assignment_List
: {
2157 Vector
<bool> value_used(mp
->get_size());
2158 value_used
.resize(mp
->get_size(), false);
2159 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2160 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2161 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
2162 abstract().set_param(*curr_param
);
2163 value_used
[val_idx
]=true;
2166 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2167 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2168 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
2169 transfer().set_param(*curr_param
);
2170 value_used
[val_idx
]=true;
2173 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2174 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2179 param
.type_error("record template", "EXTERNAL.identification.syntaxes");
2181 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2184 Module_Param
* EXTERNAL_identification_syntaxes_template::get_param(Module_Param_Name
& param_name
) const
2186 Module_Param
* mp
= NULL
;
2187 switch (template_selection
) {
2188 case UNINITIALIZED_TEMPLATE
:
2189 mp
= new Module_Param_Unbound();
2192 mp
= new Module_Param_Omit();
2195 mp
= new Module_Param_Any();
2198 mp
= new Module_Param_AnyOrNone();
2200 case SPECIFIC_VALUE
: {
2201 Module_Param
* mp_field_abstract
= single_value
->field_abstract
.get_param(param_name
);
2202 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
2203 Module_Param
* mp_field_transfer
= single_value
->field_transfer
.get_param(param_name
);
2204 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
2205 mp
= new Module_Param_Assignment_List();
2206 mp
->add_elem(mp_field_abstract
);
2207 mp
->add_elem(mp_field_transfer
);
2210 case COMPLEMENTED_LIST
: {
2211 if (template_selection
== VALUE_LIST
) {
2212 mp
= new Module_Param_List_Template();
2215 mp
= new Module_Param_ComplementList_Template();
2217 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2218 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2225 mp
->set_ifpresent();
2230 void EXTERNAL_identification_syntaxes_template::clean_up()
2232 switch (template_selection
) {
2233 case SPECIFIC_VALUE
:
2234 delete single_value
;
2237 case COMPLEMENTED_LIST
:
2238 delete [] value_list
.list_value
;
2243 template_selection
= UNINITIALIZED_TEMPLATE
;
2246 void EXTERNAL_identification_syntaxes_template::set_specific()
2248 if (template_selection
!= SPECIFIC_VALUE
) {
2249 template_sel old_selection
= template_selection
;
2251 single_value
= new single_value_struct
;
2252 set_selection(SPECIFIC_VALUE
);
2253 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2254 single_value
->field_abstract
= ANY_VALUE
;
2255 single_value
->field_transfer
= ANY_VALUE
;
2260 void EXTERNAL_identification_syntaxes_template::copy_value(const EXTERNAL_identification_syntaxes
& other_value
)
2262 single_value
= new single_value_struct
;
2263 single_value
->field_abstract
= other_value
.abstract();
2264 single_value
->field_transfer
= other_value
.transfer();
2265 set_selection(SPECIFIC_VALUE
);
2268 void EXTERNAL_identification_syntaxes_template::copy_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2270 switch (other_value
.template_selection
) {
2271 case SPECIFIC_VALUE
:
2272 single_value
= new single_value_struct(*other_value
.single_value
);
2279 case COMPLEMENTED_LIST
:
2280 value_list
.n_values
= other_value
.value_list
.n_values
;
2281 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2282 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2283 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2286 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2288 set_selection(other_value
);
2291 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template()
2295 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(template_sel other_value
)
2296 : Base_Template(other_value
)
2298 check_single_selection(other_value
);
2301 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes
& other_value
)
2303 copy_value(other_value
);
2306 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2308 switch (other_value
.get_selection()) {
2309 case OPTIONAL_PRESENT
:
2310 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2313 set_selection(OMIT_VALUE
);
2316 TTCN_error("Creating a template of type EXTERNAL.identification.syntaxes from an unbound optional field.");
2320 EXTERNAL_identification_syntaxes_template::EXTERNAL_identification_syntaxes_template(const EXTERNAL_identification_syntaxes_template
& other_value
)
2323 copy_template(other_value
);
2326 EXTERNAL_identification_syntaxes_template::~EXTERNAL_identification_syntaxes_template()
2331 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(template_sel other_value
)
2333 check_single_selection(other_value
);
2335 set_selection(other_value
);
2339 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes
& other_value
)
2342 copy_value(other_value
);
2346 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const OPTIONAL
<EXTERNAL_identification_syntaxes
>& other_value
)
2349 switch (other_value
.get_selection()) {
2350 case OPTIONAL_PRESENT
:
2351 copy_value((const EXTERNAL_identification_syntaxes
&)other_value
);
2354 set_selection(OMIT_VALUE
);
2357 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.syntaxes.");
2362 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::operator=(const EXTERNAL_identification_syntaxes_template
& other_value
)
2364 if (&other_value
!= this) {
2366 copy_template(other_value
);
2371 boolean
EXTERNAL_identification_syntaxes_template::match(const EXTERNAL_identification_syntaxes
& other_value
,
2372 boolean
/* legacy */) const
2374 switch (template_selection
) {
2380 case SPECIFIC_VALUE
:
2381 if (!other_value
.abstract().is_bound()) return FALSE
;
2382 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
2383 if (!other_value
.transfer().is_bound()) return FALSE
;
2384 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
2387 case COMPLEMENTED_LIST
:
2388 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2389 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2390 return template_selection
== COMPLEMENTED_LIST
;
2392 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2397 EXTERNAL_identification_syntaxes
EXTERNAL_identification_syntaxes_template::valueof() const
2399 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2400 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.syntaxes.");
2401 EXTERNAL_identification_syntaxes ret_val
;
2402 ret_val
.abstract() = single_value
->field_abstract
.valueof();
2403 ret_val
.transfer() = single_value
->field_transfer
.valueof();
2407 void EXTERNAL_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
2409 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2410 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.syntaxes.");
2412 set_selection(template_type
);
2413 value_list
.n_values
= list_length
;
2414 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[list_length
];
2417 EXTERNAL_identification_syntaxes_template
& EXTERNAL_identification_syntaxes_template::list_item(unsigned int list_index
) const
2419 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2420 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.syntaxes.");
2421 if (list_index
>= value_list
.n_values
)
2422 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.syntaxes.");
2423 return value_list
.list_value
[list_index
];
2426 OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract()
2429 return single_value
->field_abstract
;
2432 const OBJID_template
& EXTERNAL_identification_syntaxes_template::abstract() const
2434 if (template_selection
!= SPECIFIC_VALUE
)
2435 TTCN_error("Accessing field abstract of a non-specific template of type EXTERNAL.identification.syntaxes.");
2436 return single_value
->field_abstract
;
2439 OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer()
2442 return single_value
->field_transfer
;
2445 const OBJID_template
& EXTERNAL_identification_syntaxes_template::transfer() const
2447 if (template_selection
!= SPECIFIC_VALUE
)
2448 TTCN_error("Accessing field transfer of a non-specific template of type EXTERNAL.identification.syntaxes.");
2449 return single_value
->field_transfer
;
2452 int EXTERNAL_identification_syntaxes_template::size_of() const
2454 switch (template_selection
)
2456 case SPECIFIC_VALUE
:
2463 if (value_list
.n_values
<1)
2464 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing an empty list.");
2465 int item_size
= value_list
.list_value
[0].size_of();
2466 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2468 if (value_list
.list_value
[i
].size_of()!=item_size
)
2469 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing a value list with different sizes.");
2474 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing omit value.");
2477 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing */? value.");
2478 case COMPLEMENTED_LIST
:
2479 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.syntaxes containing complemented list.");
2481 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2486 void EXTERNAL_identification_syntaxes_template::log() const
2488 switch (template_selection
) {
2489 case SPECIFIC_VALUE
:
2490 TTCN_Logger::log_event_str("{ abstract := ");
2491 single_value
->field_abstract
.log();
2492 TTCN_Logger::log_event_str(", transfer := ");
2493 single_value
->field_transfer
.log();
2494 TTCN_Logger::log_event_str(" }");
2496 case COMPLEMENTED_LIST
:
2497 TTCN_Logger::log_event_str("complement ");
2500 TTCN_Logger::log_char('(');
2501 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2502 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2503 value_list
.list_value
[list_count
].log();
2505 TTCN_Logger::log_char(')');
2514 void EXTERNAL_identification_syntaxes_template::log_match(const EXTERNAL_identification_syntaxes
& match_value
,
2515 boolean
/* legacy */) const
2517 if (template_selection
== SPECIFIC_VALUE
) {
2518 TTCN_Logger::log_event_str("{ abstract := ");
2519 single_value
->field_abstract
.log_match(match_value
.abstract());
2520 TTCN_Logger::log_event_str(", transfer := ");
2521 single_value
->field_transfer
.log_match(match_value
.transfer());
2522 TTCN_Logger::log_event_str(" }");
2525 TTCN_Logger::log_event_str(" with ");
2527 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2528 else TTCN_Logger::log_event_str(" unmatched");
2532 void EXTERNAL_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2534 encode_text_base(text_buf
);
2535 switch (template_selection
) {
2536 case SPECIFIC_VALUE
:
2537 single_value
->field_abstract
.encode_text(text_buf
);
2538 single_value
->field_transfer
.encode_text(text_buf
);
2545 case COMPLEMENTED_LIST
:
2546 text_buf
.push_int(value_list
.n_values
);
2547 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2548 value_list
.list_value
[list_count
].encode_text(text_buf
);
2551 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.syntaxes.");
2555 void EXTERNAL_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2558 decode_text_base(text_buf
);
2559 switch (template_selection
) {
2560 case SPECIFIC_VALUE
:
2561 single_value
= new single_value_struct
;
2562 single_value
->field_abstract
.decode_text(text_buf
);
2563 single_value
->field_transfer
.decode_text(text_buf
);
2570 case COMPLEMENTED_LIST
:
2571 value_list
.n_values
= text_buf
.pull_int().get_val();
2572 value_list
.list_value
= new EXTERNAL_identification_syntaxes_template
[value_list
.n_values
];
2573 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2574 value_list
.list_value
[list_count
].decode_text(text_buf
);
2577 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.syntaxes.");
2581 boolean
EXTERNAL_identification_syntaxes_template::is_present(boolean legacy
/* = FALSE */) const
2583 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2584 return !match_omit(legacy
);
2587 boolean
EXTERNAL_identification_syntaxes_template::match_omit(boolean legacy
/* = FALSE */) const
2589 if (is_ifpresent
) return TRUE
;
2590 switch (template_selection
) {
2595 case COMPLEMENTED_LIST
:
2597 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2598 if (value_list
.list_value
[i
].match_omit())
2599 return template_selection
==VALUE_LIST
;
2600 return template_selection
==COMPLEMENTED_LIST
;
2601 } // else fall through
2608 #ifndef TITAN_RUNTIME_2
2609 void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
,
2610 boolean legacy
/* = FALSE */) const
2612 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2613 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2615 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2618 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2619 template_selection
==SPECIFIC_VALUE
)) return;
2622 if (!match_omit(legacy
)) return;
2627 TTCN_error("Restriction `%s' on template of type %s violated.",
2628 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.syntaxes");
2632 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation()
2636 EXTERNAL_identification_context__negotiation::EXTERNAL_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2637 const OBJID
& par_transfer__syntax
)
2638 : field_presentation__context__id(par_presentation__context__id
),
2639 field_transfer__syntax(par_transfer__syntax
)
2643 boolean
EXTERNAL_identification_context__negotiation::operator==(const EXTERNAL_identification_context__negotiation
& other_value
) const
2645 return field_presentation__context__id
==other_value
.field_presentation__context__id
2646 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2649 int EXTERNAL_identification_context__negotiation::size_of() const
2655 void EXTERNAL_identification_context__negotiation::log() const
2657 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2658 field_presentation__context__id
.log();
2659 TTCN_Logger::log_event_str(", transfer_syntax := ");
2660 field_transfer__syntax
.log();
2661 TTCN_Logger::log_event_str(" }");
2664 boolean
EXTERNAL_identification_context__negotiation::is_bound() const
2666 if(field_presentation__context__id
.is_bound()) return TRUE
;
2667 if(field_transfer__syntax
.is_bound()) return TRUE
;
2671 boolean
EXTERNAL_identification_context__negotiation::is_value() const
2673 if(!field_presentation__context__id
.is_value()) return FALSE
;
2674 if(!field_transfer__syntax
.is_value()) return FALSE
;
2678 void EXTERNAL_identification_context__negotiation::clean_up()
2680 field_presentation__context__id
.clean_up();
2681 field_transfer__syntax
.clean_up();
2684 void EXTERNAL_identification_context__negotiation::set_param(Module_Param
& param
)
2686 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2687 Module_Param_Ptr mp
= ¶m
;
2688 if (param
.get_type() == Module_Param::MP_Reference
) {
2689 mp
= param
.get_referenced_param();
2691 switch (mp
->get_type()) {
2692 case Module_Param::MP_Value_List
:
2693 if (mp
->get_size()==0) return;
2694 if (2!=mp
->get_size()) {
2695 param
.error("record value of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2697 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2698 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2700 case Module_Param::MP_Assignment_List
: {
2701 Vector
<bool> value_used(mp
->get_size());
2702 value_used
.resize(mp
->get_size(), false);
2703 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2704 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2705 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2706 presentation__context__id().set_param(*curr_param
);
2707 value_used
[val_idx
]=true;
2710 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2711 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2712 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2713 transfer__syntax().set_param(*curr_param
);
2714 value_used
[val_idx
]=true;
2717 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2718 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2723 param
.type_error("record value", "EXTERNAL.identification.context-negotiation");
2727 Module_Param
* EXTERNAL_identification_context__negotiation::get_param(Module_Param_Name
& param_name
) const
2730 return new Module_Param_Unbound();
2732 Module_Param
* mp_field_presentation_context_id
= field_presentation__context__id
.get_param(param_name
);
2733 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2734 Module_Param
* mp_field_transfer_syntax
= field_transfer__syntax
.get_param(param_name
);
2735 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2736 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2737 mp
->add_elem(mp_field_presentation_context_id
);
2738 mp
->add_elem(mp_field_transfer_syntax
);
2742 void EXTERNAL_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2744 field_presentation__context__id
.encode_text(text_buf
);
2745 field_transfer__syntax
.encode_text(text_buf
);
2748 void EXTERNAL_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2750 field_presentation__context__id
.decode_text(text_buf
);
2751 field_transfer__syntax
.decode_text(text_buf
);
2754 struct EXTERNAL_identification_context__negotiation_template::single_value_struct
{
2755 INTEGER_template field_presentation__context__id
;
2756 OBJID_template field_transfer__syntax
;
2759 void EXTERNAL_identification_context__negotiation_template::set_param(Module_Param
& param
)
2761 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2762 Module_Param_Ptr mp
= ¶m
;
2763 if (param
.get_type() == Module_Param::MP_Reference
) {
2764 mp
= param
.get_referenced_param();
2766 switch (mp
->get_type()) {
2767 case Module_Param::MP_Omit
:
2770 case Module_Param::MP_Any
:
2773 case Module_Param::MP_AnyOrNone
:
2774 *this = ANY_OR_OMIT
;
2776 case Module_Param::MP_List_Template
:
2777 case Module_Param::MP_ComplementList_Template
: {
2778 EXTERNAL_identification_context__negotiation_template temp
;
2779 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2780 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2781 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2782 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2786 case Module_Param::MP_Value_List
:
2787 if (mp
->get_size()==0) break;
2788 if (2!=mp
->get_size()) {
2789 param
.error("record template of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2791 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2792 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2794 case Module_Param::MP_Assignment_List
: {
2795 Vector
<bool> value_used(mp
->get_size());
2796 value_used
.resize(mp
->get_size(), false);
2797 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2798 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2799 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2800 presentation__context__id().set_param(*curr_param
);
2801 value_used
[val_idx
]=true;
2804 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2805 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2806 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2807 transfer__syntax().set_param(*curr_param
);
2808 value_used
[val_idx
]=true;
2811 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2812 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2817 param
.type_error("record template", "EXTERNAL.identification.context-negotiation");
2819 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2822 Module_Param
* EXTERNAL_identification_context__negotiation_template::get_param(Module_Param_Name
& param_name
) const
2824 Module_Param
* mp
= NULL
;
2825 switch (template_selection
) {
2826 case UNINITIALIZED_TEMPLATE
:
2827 mp
= new Module_Param_Unbound();
2830 mp
= new Module_Param_Omit();
2833 mp
= new Module_Param_Any();
2836 mp
= new Module_Param_AnyOrNone();
2838 case SPECIFIC_VALUE
: {
2839 Module_Param
* mp_field_presentation_context_id
= single_value
->field_presentation__context__id
.get_param(param_name
);
2840 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2841 Module_Param
* mp_field_transfer_syntax
= single_value
->field_transfer__syntax
.get_param(param_name
);
2842 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2843 mp
= new Module_Param_Assignment_List();
2844 mp
->add_elem(mp_field_presentation_context_id
);
2845 mp
->add_elem(mp_field_transfer_syntax
);
2848 case COMPLEMENTED_LIST
: {
2849 if (template_selection
== VALUE_LIST
) {
2850 mp
= new Module_Param_List_Template();
2853 mp
= new Module_Param_ComplementList_Template();
2855 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2856 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2863 mp
->set_ifpresent();
2868 void EXTERNAL_identification_context__negotiation_template::clean_up()
2870 switch (template_selection
) {
2871 case SPECIFIC_VALUE
:
2872 delete single_value
;
2875 case COMPLEMENTED_LIST
:
2876 delete [] value_list
.list_value
;
2881 template_selection
= UNINITIALIZED_TEMPLATE
;
2884 void EXTERNAL_identification_context__negotiation_template::set_specific()
2886 if (template_selection
!= SPECIFIC_VALUE
) {
2887 template_sel old_selection
= template_selection
;
2889 single_value
= new single_value_struct
;
2890 set_selection(SPECIFIC_VALUE
);
2891 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2892 single_value
->field_presentation__context__id
= ANY_VALUE
;
2893 single_value
->field_transfer__syntax
= ANY_VALUE
;
2898 void EXTERNAL_identification_context__negotiation_template::copy_value(const EXTERNAL_identification_context__negotiation
& other_value
)
2900 single_value
= new single_value_struct
;
2901 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2902 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2903 set_selection(SPECIFIC_VALUE
);
2906 void EXTERNAL_identification_context__negotiation_template::copy_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2908 switch (other_value
.template_selection
) {
2909 case SPECIFIC_VALUE
:
2910 single_value
= new single_value_struct(*other_value
.single_value
);
2917 case COMPLEMENTED_LIST
:
2918 value_list
.n_values
= other_value
.value_list
.n_values
;
2919 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
2920 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2921 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2924 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
2926 set_selection(other_value
);
2929 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template()
2933 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(template_sel other_value
)
2934 : Base_Template(other_value
)
2936 check_single_selection(other_value
);
2939 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation
& other_value
)
2941 copy_value(other_value
);
2944 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2946 switch (other_value
.get_selection()) {
2947 case OPTIONAL_PRESENT
:
2948 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2951 set_selection(OMIT_VALUE
);
2954 TTCN_error("Creating a template of type EXTERNAL.identification.context-negotiation from an unbound optional field.");
2958 EXTERNAL_identification_context__negotiation_template::EXTERNAL_identification_context__negotiation_template(const EXTERNAL_identification_context__negotiation_template
& other_value
)
2961 copy_template(other_value
);
2964 EXTERNAL_identification_context__negotiation_template::~EXTERNAL_identification_context__negotiation_template()
2969 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(template_sel other_value
)
2971 check_single_selection(other_value
);
2973 set_selection(other_value
);
2977 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation
& other_value
)
2980 copy_value(other_value
);
2984 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const OPTIONAL
<EXTERNAL_identification_context__negotiation
>& other_value
)
2987 switch (other_value
.get_selection()) {
2988 case OPTIONAL_PRESENT
:
2989 copy_value((const EXTERNAL_identification_context__negotiation
&)other_value
);
2992 set_selection(OMIT_VALUE
);
2995 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.identification.context-negotiation.");
3000 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::operator=(const EXTERNAL_identification_context__negotiation_template
& other_value
)
3002 if (&other_value
!= this) {
3004 copy_template(other_value
);
3009 boolean
EXTERNAL_identification_context__negotiation_template::match(const EXTERNAL_identification_context__negotiation
& other_value
,
3010 boolean
/* legacy */) const
3012 switch (template_selection
) {
3018 case SPECIFIC_VALUE
:
3019 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
3020 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
3021 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
3022 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
3025 case COMPLEMENTED_LIST
:
3026 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3027 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3028 return template_selection
== COMPLEMENTED_LIST
;
3030 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3035 EXTERNAL_identification_context__negotiation
EXTERNAL_identification_context__negotiation_template::valueof() const
3037 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3038 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.identification.context-negotiation.");
3039 EXTERNAL_identification_context__negotiation ret_val
;
3040 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
3041 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
3045 void EXTERNAL_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
3047 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3048 TTCN_error("Setting an invalid list for a template of type EXTERNAL.identification.context-negotiation.");
3050 set_selection(template_type
);
3051 value_list
.n_values
= list_length
;
3052 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[list_length
];
3055 EXTERNAL_identification_context__negotiation_template
& EXTERNAL_identification_context__negotiation_template::list_item(unsigned int list_index
) const
3057 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3058 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.identification.context-negotiation.");
3059 if (list_index
>= value_list
.n_values
)
3060 TTCN_error("Index overflow in a value list template of type EXTERNAL.identification.context-negotiation.");
3061 return value_list
.list_value
[list_index
];
3064 INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id()
3067 return single_value
->field_presentation__context__id
;
3070 const INTEGER_template
& EXTERNAL_identification_context__negotiation_template::presentation__context__id() const
3072 if (template_selection
!= SPECIFIC_VALUE
)
3073 TTCN_error("Accessing field presentation_context_id of a non-specific template of type EXTERNAL.identification.context-negotiation.");
3074 return single_value
->field_presentation__context__id
;
3077 OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax()
3080 return single_value
->field_transfer__syntax
;
3083 const OBJID_template
& EXTERNAL_identification_context__negotiation_template::transfer__syntax() const
3085 if (template_selection
!= SPECIFIC_VALUE
)
3086 TTCN_error("Accessing field transfer_syntax of a non-specific template of type EXTERNAL.identification.context-negotiation.");
3087 return single_value
->field_transfer__syntax
;
3090 int EXTERNAL_identification_context__negotiation_template::size_of() const
3092 switch (template_selection
)
3094 case SPECIFIC_VALUE
:
3101 if (value_list
.n_values
<1)
3102 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing an empty list.");
3103 int item_size
= value_list
.list_value
[0].size_of();
3104 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3106 if (value_list
.list_value
[i
].size_of()!=item_size
)
3107 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing a value list with different sizes.");
3112 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing omit value.");
3115 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing */? value.");
3116 case COMPLEMENTED_LIST
:
3117 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL.identification.context-negotiation containing complemented list.");
3119 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3124 void EXTERNAL_identification_context__negotiation_template::log() const
3126 switch (template_selection
) {
3127 case SPECIFIC_VALUE
:
3128 TTCN_Logger::log_event_str("{ presentation_context_id := ");
3129 single_value
->field_presentation__context__id
.log();
3130 TTCN_Logger::log_event_str(", transfer_syntax := ");
3131 single_value
->field_transfer__syntax
.log();
3132 TTCN_Logger::log_event_str(" }");
3134 case COMPLEMENTED_LIST
:
3135 TTCN_Logger::log_event_str("complement ");
3138 TTCN_Logger::log_char('(');
3139 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3140 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3141 value_list
.list_value
[list_count
].log();
3143 TTCN_Logger::log_char(')');
3152 void EXTERNAL_identification_context__negotiation_template::log_match(const EXTERNAL_identification_context__negotiation
& match_value
,
3153 boolean
/* legacy */) const
3155 if (template_selection
== SPECIFIC_VALUE
) {
3156 TTCN_Logger::log_event_str("{ presentation_context_id := ");
3157 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
3158 TTCN_Logger::log_event_str(", transfer_syntax := ");
3159 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
3160 TTCN_Logger::log_event_str(" }");
3163 TTCN_Logger::log_event_str(" with ");
3165 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3166 else TTCN_Logger::log_event_str(" unmatched");
3170 void EXTERNAL_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
3172 encode_text_base(text_buf
);
3173 switch (template_selection
) {
3174 case SPECIFIC_VALUE
:
3175 single_value
->field_presentation__context__id
.encode_text(text_buf
);
3176 single_value
->field_transfer__syntax
.encode_text(text_buf
);
3183 case COMPLEMENTED_LIST
:
3184 text_buf
.push_int(value_list
.n_values
);
3185 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3186 value_list
.list_value
[list_count
].encode_text(text_buf
);
3189 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation.");
3193 void EXTERNAL_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
3196 decode_text_base(text_buf
);
3197 switch (template_selection
) {
3198 case SPECIFIC_VALUE
:
3199 single_value
= new single_value_struct
;
3200 single_value
->field_presentation__context__id
.decode_text(text_buf
);
3201 single_value
->field_transfer__syntax
.decode_text(text_buf
);
3208 case COMPLEMENTED_LIST
:
3209 value_list
.n_values
= text_buf
.pull_int().get_val();
3210 value_list
.list_value
= new EXTERNAL_identification_context__negotiation_template
[value_list
.n_values
];
3211 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3212 value_list
.list_value
[list_count
].decode_text(text_buf
);
3215 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.identification.context-negotiation.");
3219 boolean
EXTERNAL_identification_context__negotiation_template::is_present(boolean legacy
/* = FALSE */) const
3221 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3222 return !match_omit(legacy
);
3225 boolean
EXTERNAL_identification_context__negotiation_template::match_omit(boolean legacy
/* = FALSE */) const
3227 if (is_ifpresent
) return TRUE
;
3228 switch (template_selection
) {
3233 case COMPLEMENTED_LIST
:
3235 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3236 if (value_list
.list_value
[i
].match_omit())
3237 return template_selection
==VALUE_LIST
;
3238 return template_selection
==COMPLEMENTED_LIST
;
3239 } // else fall through
3246 #ifndef TITAN_RUNTIME_2
3247 void EXTERNAL_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
,
3248 boolean legacy
/* = FALSE */) const
3250 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3251 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3253 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3256 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3257 template_selection
==SPECIFIC_VALUE
)) return;
3260 if (!match_omit(legacy
)) return;
3265 TTCN_error("Restriction `%s' on template of type %s violated.",
3266 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL.identification.context-negotiation");
3270 EXTERNAL::EXTERNAL()
3274 EXTERNAL::EXTERNAL(const EXTERNAL_identification
& par_identification
,
3275 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
3276 const OCTETSTRING
& par_data__value
)
3277 : field_identification(par_identification
),
3278 field_data__value__descriptor(par_data__value__descriptor
),
3279 field_data__value(par_data__value
)
3283 boolean
EXTERNAL::operator==(const EXTERNAL
& other_value
) const
3285 return field_identification
==other_value
.field_identification
3286 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
3287 && field_data__value
==other_value
.field_data__value
;
3290 int EXTERNAL::size_of() const
3293 if (field_data__value__descriptor
.ispresent()) ret_val
++;
3297 void EXTERNAL::log() const
3299 TTCN_Logger::log_event_str("{ identification := ");
3300 field_identification
.log();
3301 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3302 field_data__value__descriptor
.log();
3303 TTCN_Logger::log_event_str(", data_value := ");
3304 field_data__value
.log();
3305 TTCN_Logger::log_event_str(" }");
3308 boolean
EXTERNAL::is_bound() const
3310 if(field_identification
.is_bound()) return TRUE
;
3311 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
3312 if(field_data__value
.is_bound()) return TRUE
;
3316 boolean
EXTERNAL::is_value() const
3318 if(!field_identification
.is_value()) return FALSE
;
3319 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
3320 if(!field_data__value
.is_value()) return FALSE
;
3324 void EXTERNAL::clean_up()
3326 field_identification
.clean_up();
3327 field_data__value__descriptor
.clean_up();
3328 field_data__value
.clean_up();
3331 void EXTERNAL::set_param(Module_Param
& param
)
3333 param
.basic_check(Module_Param::BC_VALUE
, "record value");
3334 Module_Param_Ptr mp
= ¶m
;
3335 if (param
.get_type() == Module_Param::MP_Reference
) {
3336 mp
= param
.get_referenced_param();
3338 switch (mp
->get_type()) {
3339 case Module_Param::MP_Value_List
:
3340 if (mp
->get_size()==0) return;
3341 if (3!=mp
->get_size()) {
3342 param
.error("record value of type EXTERNAL has 3 fields but list value has %d fields", (int)mp
->get_size());
3344 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3345 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3346 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*mp
->get_elem(2));
3348 case Module_Param::MP_Assignment_List
: {
3349 Vector
<bool> value_used(mp
->get_size());
3350 value_used
.resize(mp
->get_size(), false);
3351 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3352 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3353 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3354 identification().set_param(*curr_param
);
3355 value_used
[val_idx
]=true;
3358 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3359 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3360 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3361 data__value__descriptor().set_param(*curr_param
);
3362 value_used
[val_idx
]=true;
3365 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3366 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3367 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3368 data__value().set_param(*curr_param
);
3369 value_used
[val_idx
]=true;
3372 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3373 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3378 param
.type_error("record value", "EXTERNAL");
3382 Module_Param
* EXTERNAL::get_param(Module_Param_Name
& param_name
) const
3385 return new Module_Param_Unbound();
3387 Module_Param
* mp_field_identification
= field_identification
.get_param(param_name
);
3388 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3389 Module_Param
* mp_field_data_value_descriptor
= field_data__value__descriptor
.get_param(param_name
);
3390 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3391 Module_Param
* mp_field_data_value
= field_data__value
.get_param(param_name
);
3392 mp_field_data_value
->set_id(new Module_Param_FieldName(mcopystr("data_value")));
3393 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
3394 mp
->add_elem(mp_field_identification
);
3395 mp
->add_elem(mp_field_data_value_descriptor
);
3396 mp
->add_elem(mp_field_data_value
);
3400 void EXTERNAL::encode_text(Text_Buf
& text_buf
) const
3402 field_identification
.encode_text(text_buf
);
3403 field_data__value__descriptor
.encode_text(text_buf
);
3404 field_data__value
.encode_text(text_buf
);
3407 void EXTERNAL::decode_text(Text_Buf
& text_buf
)
3409 field_identification
.decode_text(text_buf
);
3410 field_data__value__descriptor
.decode_text(text_buf
);
3411 field_data__value
.decode_text(text_buf
);
3414 void EXTERNAL::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
3417 va_start(pvar
, p_coding
);
3419 case TTCN_EncDec::CT_BER
: {
3420 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
3421 unsigned BER_coding
=va_arg(pvar
, unsigned);
3422 BER_encode_chk_coding(BER_coding
);
3423 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
3424 tlv
->put_in_buffer(p_buf
);
3425 ASN_BER_TLV_t::destruct(tlv
);
3427 case TTCN_EncDec::CT_RAW
: {
3428 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
3429 TTCN_EncDec_ErrorContext::error_internal
3430 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3432 case TTCN_EncDec::CT_TEXT
: {
3433 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
3434 TTCN_EncDec_ErrorContext::error_internal
3435 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3437 case TTCN_EncDec::CT_XER
: {
3438 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
3439 unsigned XER_coding
=va_arg(pvar
, unsigned);
3440 XER_encode(*p_td
.xer
, p_buf
, XER_coding
, 0, 0);
3442 case TTCN_EncDec::CT_JSON
: {
3443 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
3444 TTCN_EncDec_ErrorContext::error_internal
3445 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3448 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3453 void EXTERNAL::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3456 va_start(pvar
, p_coding
);
3458 case TTCN_EncDec::CT_BER
: {
3459 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
3460 unsigned L_form
=va_arg(pvar
, unsigned);
3462 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
3463 BER_decode_TLV(p_td
, tlv
, L_form
);
3464 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3466 case TTCN_EncDec::CT_RAW
: {
3467 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3468 TTCN_EncDec_ErrorContext::error_internal
3469 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3471 case TTCN_EncDec::CT_TEXT
: {
3472 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3473 TTCN_EncDec_ErrorContext::error_internal
3474 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3476 case TTCN_EncDec::CT_XER
: {
3477 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3478 unsigned XER_coding
=va_arg(pvar
, unsigned);
3479 XmlReaderWrap
reader(p_buf
);
3480 int success
= reader
.Read();
3481 for (; success
==1; success
=reader
.Read()) {
3482 int type
= reader
.NodeType();
3483 if (type
==XML_READER_TYPE_ELEMENT
)
3486 XER_decode(*p_td
.xer
, reader
, XER_coding
, XER_NONE
, 0);
3487 size_t bytes
= reader
.ByteConsumed();
3488 p_buf
.set_pos(bytes
);
3490 case TTCN_EncDec::CT_JSON
: {
3491 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3492 TTCN_EncDec_ErrorContext::error_internal
3493 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3496 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3501 struct EXTERNAL_template::single_value_struct
{
3502 EXTERNAL_identification_template field_identification
;
3503 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3504 OCTETSTRING_template field_data__value
;
3507 void EXTERNAL_template::set_param(Module_Param
& param
)
3509 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
3510 Module_Param_Ptr mp
= ¶m
;
3511 if (param
.get_type() == Module_Param::MP_Reference
) {
3512 mp
= param
.get_referenced_param();
3514 switch (mp
->get_type()) {
3515 case Module_Param::MP_Omit
:
3518 case Module_Param::MP_Any
:
3521 case Module_Param::MP_AnyOrNone
:
3522 *this = ANY_OR_OMIT
;
3524 case Module_Param::MP_List_Template
:
3525 case Module_Param::MP_ComplementList_Template
: {
3526 EXTERNAL_template temp
;
3527 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
3528 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
3529 for (size_t i
=0; i
<mp
->get_size(); i
++) {
3530 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
3534 case Module_Param::MP_Value_List
:
3535 if (mp
->get_size()==0) break;
3536 if (3!=mp
->get_size()) {
3537 param
.error("record template of type EXTERNAL has 3 fields but list value has %d fields", (int)mp
->get_size());
3539 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3540 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3541 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) data__value().set_param(*mp
->get_elem(2));
3543 case Module_Param::MP_Assignment_List
: {
3544 Vector
<bool> value_used(mp
->get_size());
3545 value_used
.resize(mp
->get_size(), false);
3546 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3547 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3548 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3549 identification().set_param(*curr_param
);
3550 value_used
[val_idx
]=true;
3553 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3554 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3555 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3556 data__value__descriptor().set_param(*curr_param
);
3557 value_used
[val_idx
]=true;
3560 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3561 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3562 if (!strcmp(curr_param
->get_id()->get_name(), "data_value")) {
3563 data__value().set_param(*curr_param
);
3564 value_used
[val_idx
]=true;
3567 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3568 mp
->get_elem(val_idx
)->error("Non existent field name in type EXTERNAL: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3573 param
.type_error("record template", "EXTERNAL");
3575 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
3578 Module_Param
* EXTERNAL_template::get_param(Module_Param_Name
& param_name
) const
3580 Module_Param
* mp
= NULL
;
3581 switch (template_selection
) {
3582 case UNINITIALIZED_TEMPLATE
:
3583 mp
= new Module_Param_Unbound();
3586 mp
= new Module_Param_Omit();
3589 mp
= new Module_Param_Any();
3592 mp
= new Module_Param_AnyOrNone();
3594 case SPECIFIC_VALUE
: {
3595 Module_Param
* mp_field_identification
= single_value
->field_identification
.get_param(param_name
);
3596 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3597 Module_Param
* mp_field_data_value_descriptor
= single_value
->field_data__value__descriptor
.get_param(param_name
);
3598 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3599 Module_Param
* mp_field_string_value
= single_value
->field_data__value
.get_param(param_name
);
3600 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("data_value")));
3601 mp
= new Module_Param_Assignment_List();
3602 mp
->add_elem(mp_field_identification
);
3603 mp
->add_elem(mp_field_data_value_descriptor
);
3604 mp
->add_elem(mp_field_string_value
);
3607 case COMPLEMENTED_LIST
: {
3608 if (template_selection
== VALUE_LIST
) {
3609 mp
= new Module_Param_List_Template();
3612 mp
= new Module_Param_ComplementList_Template();
3614 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
3615 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
3622 mp
->set_ifpresent();
3627 void EXTERNAL_template::clean_up()
3629 switch (template_selection
) {
3630 case SPECIFIC_VALUE
:
3631 delete single_value
;
3634 case COMPLEMENTED_LIST
:
3635 delete [] value_list
.list_value
;
3640 template_selection
= UNINITIALIZED_TEMPLATE
;
3643 void EXTERNAL_template::set_specific()
3645 if (template_selection
!= SPECIFIC_VALUE
) {
3646 template_sel old_selection
= template_selection
;
3648 single_value
= new single_value_struct
;
3649 set_selection(SPECIFIC_VALUE
);
3650 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3651 single_value
->field_identification
= ANY_VALUE
;
3652 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3653 single_value
->field_data__value
= ANY_VALUE
;
3658 void EXTERNAL_template::copy_value(const EXTERNAL
& other_value
)
3660 single_value
= new single_value_struct
;
3661 single_value
->field_identification
= other_value
.identification();
3662 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3663 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3664 single_value
->field_data__value
= other_value
.data__value();
3665 set_selection(SPECIFIC_VALUE
);
3668 void EXTERNAL_template::copy_template(const EXTERNAL_template
& other_value
)
3670 switch (other_value
.template_selection
) {
3671 case SPECIFIC_VALUE
:
3672 single_value
= new single_value_struct(*other_value
.single_value
);
3679 case COMPLEMENTED_LIST
:
3680 value_list
.n_values
= other_value
.value_list
.n_values
;
3681 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
3682 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3683 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3686 TTCN_error("Copying an uninitialized/unsupported template of type EXTERNAL.");
3688 set_selection(other_value
);
3691 EXTERNAL_template::EXTERNAL_template()
3695 EXTERNAL_template::EXTERNAL_template(template_sel other_value
)
3696 : Base_Template(other_value
)
3698 check_single_selection(other_value
);
3701 EXTERNAL_template::EXTERNAL_template(const EXTERNAL
& other_value
)
3703 copy_value(other_value
);
3706 EXTERNAL_template::EXTERNAL_template(const OPTIONAL
<EXTERNAL
>& other_value
)
3708 switch (other_value
.get_selection()) {
3709 case OPTIONAL_PRESENT
:
3710 copy_value((const EXTERNAL
&)other_value
);
3713 set_selection(OMIT_VALUE
);
3716 TTCN_error("Creating a template of type EXTERNAL from an unbound optional field.");
3720 EXTERNAL_template::EXTERNAL_template(const EXTERNAL_template
& other_value
)
3723 copy_template(other_value
);
3726 EXTERNAL_template::~EXTERNAL_template()
3731 EXTERNAL_template
& EXTERNAL_template::operator=(template_sel other_value
)
3733 check_single_selection(other_value
);
3735 set_selection(other_value
);
3739 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL
& other_value
)
3742 copy_value(other_value
);
3746 EXTERNAL_template
& EXTERNAL_template::operator=(const OPTIONAL
<EXTERNAL
>& other_value
)
3749 switch (other_value
.get_selection()) {
3750 case OPTIONAL_PRESENT
:
3751 copy_value((const EXTERNAL
&)other_value
);
3754 set_selection(OMIT_VALUE
);
3757 TTCN_error("Assignment of an unbound optional field to a template of type EXTERNAL.");
3762 EXTERNAL_template
& EXTERNAL_template::operator=(const EXTERNAL_template
& other_value
)
3764 if (&other_value
!= this) {
3766 copy_template(other_value
);
3771 boolean
EXTERNAL_template::match(const EXTERNAL
& other_value
,
3772 boolean
/* legacy */) const
3774 switch (template_selection
) {
3780 case SPECIFIC_VALUE
:
3781 if (!other_value
.identification().is_bound()) return FALSE
;
3782 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3783 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3784 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
;
3785 if (!other_value
.data__value().is_bound()) return FALSE
;
3786 if (!single_value
->field_data__value
.match(other_value
.data__value())) return FALSE
;
3789 case COMPLEMENTED_LIST
:
3790 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3791 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3792 return template_selection
== COMPLEMENTED_LIST
;
3794 TTCN_error("Matching an uninitialized/unsupported template of type EXTERNAL.");
3799 EXTERNAL
EXTERNAL_template::valueof() const
3801 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3802 TTCN_error("Performing valueof or send operation on a non-specific template of type EXTERNAL.");
3804 ret_val
.identification() = single_value
->field_identification
.valueof();
3805 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3806 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3807 ret_val
.data__value() = single_value
->field_data__value
.valueof();
3811 void EXTERNAL_template::set_type(template_sel template_type
, unsigned int list_length
)
3813 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3814 TTCN_error("Setting an invalid list for a template of type EXTERNAL.");
3816 set_selection(template_type
);
3817 value_list
.n_values
= list_length
;
3818 value_list
.list_value
= new EXTERNAL_template
[list_length
];
3821 EXTERNAL_template
& EXTERNAL_template::list_item(unsigned int list_index
) const
3823 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3824 TTCN_error("Accessing a list element of a non-list template of type EXTERNAL.");
3825 if (list_index
>= value_list
.n_values
)
3826 TTCN_error("Index overflow in a value list template of type EXTERNAL.");
3827 return value_list
.list_value
[list_index
];
3830 EXTERNAL_identification_template
& EXTERNAL_template::identification()
3833 return single_value
->field_identification
;
3836 const EXTERNAL_identification_template
& EXTERNAL_template::identification() const
3838 if (template_selection
!= SPECIFIC_VALUE
)
3839 TTCN_error("Accessing field identification of a non-specific template of type EXTERNAL.");
3840 return single_value
->field_identification
;
3843 UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor()
3846 return single_value
->field_data__value__descriptor
;
3849 const UNIVERSAL_CHARSTRING_template
& EXTERNAL_template::data__value__descriptor() const
3851 if (template_selection
!= SPECIFIC_VALUE
)
3852 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type EXTERNAL.");
3853 return single_value
->field_data__value__descriptor
;
3856 OCTETSTRING_template
& EXTERNAL_template::data__value()
3859 return single_value
->field_data__value
;
3862 const OCTETSTRING_template
& EXTERNAL_template::data__value() const
3864 if (template_selection
!= SPECIFIC_VALUE
)
3865 TTCN_error("Accessing field data_value of a non-specific template of type EXTERNAL.");
3866 return single_value
->field_data__value
;
3869 int EXTERNAL_template::size_of() const
3871 switch (template_selection
)
3873 case SPECIFIC_VALUE
:
3876 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3881 if (value_list
.n_values
<1)
3882 TTCN_error("Internal error: Performing sizeof() operation on a template of type EXTERNAL containing an empty list.");
3883 int item_size
= value_list
.list_value
[0].size_of();
3884 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3886 if (value_list
.list_value
[i
].size_of()!=item_size
)
3887 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing a value list with different sizes.");
3892 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing omit value.");
3895 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing */? value.");
3896 case COMPLEMENTED_LIST
:
3897 TTCN_error("Performing sizeof() operation on a template of type EXTERNAL containing complemented list.");
3899 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type EXTERNAL.");
3904 void EXTERNAL_template::log() const
3906 switch (template_selection
) {
3907 case SPECIFIC_VALUE
:
3908 TTCN_Logger::log_event_str("{ identification := ");
3909 single_value
->field_identification
.log();
3910 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3911 single_value
->field_data__value__descriptor
.log();
3912 TTCN_Logger::log_event_str(", data_value := ");
3913 single_value
->field_data__value
.log();
3914 TTCN_Logger::log_event_str(" }");
3916 case COMPLEMENTED_LIST
:
3917 TTCN_Logger::log_event_str("complement ");
3920 TTCN_Logger::log_char('(');
3921 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3922 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3923 value_list
.list_value
[list_count
].log();
3925 TTCN_Logger::log_char(')');
3934 void EXTERNAL_template::log_match(const EXTERNAL
& match_value
,
3935 boolean
/* legacy */) const
3937 if (template_selection
== SPECIFIC_VALUE
) {
3938 TTCN_Logger::log_event_str("{ identification := ");
3939 single_value
->field_identification
.log_match(match_value
.identification());
3940 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3941 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3943 single_value
->field_data__value__descriptor
.log();
3944 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3945 else TTCN_Logger::log_event_str(" unmatched");
3947 TTCN_Logger::log_event_str(", data_value := ");
3948 single_value
->field_data__value
.log_match(match_value
.data__value());
3949 TTCN_Logger::log_event_str(" }");
3952 TTCN_Logger::log_event_str(" with ");
3954 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3955 else TTCN_Logger::log_event_str(" unmatched");
3959 void EXTERNAL_template::encode_text(Text_Buf
& text_buf
) const
3961 encode_text_base(text_buf
);
3962 switch (template_selection
) {
3963 case SPECIFIC_VALUE
:
3964 single_value
->field_identification
.encode_text(text_buf
);
3965 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3966 single_value
->field_data__value
.encode_text(text_buf
);
3973 case COMPLEMENTED_LIST
:
3974 text_buf
.push_int(value_list
.n_values
);
3975 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3976 value_list
.list_value
[list_count
].encode_text(text_buf
);
3979 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type EXTERNAL.");
3983 void EXTERNAL_template::decode_text(Text_Buf
& text_buf
)
3986 decode_text_base(text_buf
);
3987 switch (template_selection
) {
3988 case SPECIFIC_VALUE
:
3989 single_value
= new single_value_struct
;
3990 single_value
->field_identification
.decode_text(text_buf
);
3991 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3992 single_value
->field_data__value
.decode_text(text_buf
);
3999 case COMPLEMENTED_LIST
:
4000 value_list
.n_values
= text_buf
.pull_int().get_val();
4001 value_list
.list_value
= new EXTERNAL_template
[value_list
.n_values
];
4002 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
4003 value_list
.list_value
[list_count
].decode_text(text_buf
);
4006 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type EXTERNAL.");
4010 boolean
EXTERNAL_template::is_present(boolean legacy
/* = FALSE */) const
4012 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
4013 return !match_omit(legacy
);
4016 boolean
EXTERNAL_template::match_omit(boolean legacy
/* = FALSE */) const
4018 if (is_ifpresent
) return TRUE
;
4019 switch (template_selection
) {
4024 case COMPLEMENTED_LIST
:
4026 // legacy behavior: 'omit' can appear in the value/complement list
4027 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
4028 if (value_list
.list_value
[i
].match_omit())
4029 return template_selection
==VALUE_LIST
;
4030 return template_selection
==COMPLEMENTED_LIST
;
4032 // else fall through
4039 #ifndef TITAN_RUNTIME_2
4040 void EXTERNAL_template::check_restriction(template_res t_res
, const char* t_name
,
4041 boolean legacy
/* = FALSE */) const
4043 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
4044 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
4046 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
4049 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
4050 template_selection
==SPECIFIC_VALUE
)) return;
4053 if (!match_omit(legacy
)) return;
4058 TTCN_error("Restriction `%s' on template of type %s violated.",
4059 get_res_name(t_res
), t_name
? t_name
: "EXTERNAL");