1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
14 #include "Param_Types.hh"
16 #include "ASN_CharacterString.hh"
18 #include "../common/dbgnew.hh"
22 to do when regenerating:
26 add __SUNPRO_CC ifdefs for single_value_struct
30 replace '@CHARACTER STRING' with 'CHARACTER STRING'
32 remove RAW and TEXT enc/dec functions
34 make the type descriptors of embedded types static
38 static const ASN_Tag_t CHARACTER_STRING_identification_tag_
[] = { { ASN_TAG_CONT
, 0u }};
39 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_ber_
= { 1u, CHARACTER_STRING_identification_tag_
};
40 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_descr_
= { "CHARACTER STRING.identification", &CHARACTER_STRING_identification_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
42 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_abstract_tag_
[] = { { ASN_TAG_CONT
, 0u }};
43 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_abstract_tag_
};
44 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_descr_
= { "CHARACTER STRING.identification.syntaxes.abstract", &CHARACTER_STRING_identification_syntaxes_abstract_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
46 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_transfer_tag_
[] = { { ASN_TAG_CONT
, 1u }};
47 const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_transfer_tag_
};
48 const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_descr_
= { "CHARACTER STRING.identification.syntaxes.transfer", &CHARACTER_STRING_identification_syntaxes_transfer_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
50 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_tag_
[] = { { ASN_TAG_CONT
, 0u }};
51 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_tag_
};
52 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_descr_
= { "CHARACTER STRING.identification.syntaxes", &CHARACTER_STRING_identification_syntaxes_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
54 static const ASN_Tag_t CHARACTER_STRING_identification_syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
55 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntax_ber_
= { 1u, CHARACTER_STRING_identification_syntax_tag_
};
56 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntax_descr_
= { "CHARACTER STRING.identification.syntax", &CHARACTER_STRING_identification_syntax_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
58 static const ASN_Tag_t CHARACTER_STRING_identification_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 2u }};
59 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_presentation__context__id_tag_
};
60 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_presentation__context__id_descr_
= { "CHARACTER STRING.identification.presentation-context-id", &CHARACTER_STRING_identification_presentation__context__id_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
62 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 0u }};
63 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
};
64 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
= { "CHARACTER STRING.identification.context-negotiation.presentation-context-id", &CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
66 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
67 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
};
68 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
= { "CHARACTER STRING.identification.context-negotiation.transfer-syntax", &CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
70 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_tag_
[] = { { ASN_TAG_CONT
, 3u }};
71 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_tag_
};
72 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_descr_
= { "CHARACTER STRING.identification.context-negotiation", &CHARACTER_STRING_identification_context__negotiation_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
74 static const ASN_Tag_t CHARACTER_STRING_identification_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 4u }};
75 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_transfer__syntax_tag_
};
76 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_transfer__syntax_descr_
= { "CHARACTER STRING.identification.transfer-syntax", &CHARACTER_STRING_identification_transfer__syntax_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
78 static const ASN_Tag_t CHARACTER_STRING_identification_fixed_tag_
[] = { { ASN_TAG_CONT
, 5u }};
79 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_fixed_ber_
= { 1u, CHARACTER_STRING_identification_fixed_tag_
};
80 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_fixed_descr_
= { "CHARACTER STRING.identification.fixed", &CHARACTER_STRING_identification_fixed_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
82 static const ASN_Tag_t CHARACTER_STRING_string__value_tag_
[] = { { ASN_TAG_CONT
, 2u }};
83 static const ASN_BERdescriptor_t CHARACTER_STRING_string__value_ber_
= { 1u, CHARACTER_STRING_string__value_tag_
};
84 static const TTCN_Typedescriptor_t CHARACTER_STRING_string__value_descr_
= { "CHARACTER STRING.string-value", &CHARACTER_STRING_string__value_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
86 static const ASN_Tag_t CHARACTER_STRING_data__value__descriptor_tag_
[] = { { ASN_TAG_CONT
, 1u }};
87 static const ASN_BERdescriptor_t CHARACTER_STRING_data__value__descriptor_ber_
= { 1u, CHARACTER_STRING_data__value__descriptor_tag_
};
88 static const TTCN_Typedescriptor_t CHARACTER_STRING_data__value__descriptor_descr_
= { "CHARACTER STRING.data-value-descriptor", &CHARACTER_STRING_data__value__descriptor_ber_
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::GRAPHICSTRING
};
90 void CHARACTER_STRING_identification::clean_up()
92 switch (union_selection
) {
94 delete field_syntaxes
;
99 case ALT_presentation__context__id
:
100 delete field_presentation__context__id
;
102 case ALT_context__negotiation
:
103 delete field_context__negotiation
;
105 case ALT_transfer__syntax
:
106 delete field_transfer__syntax
;
114 union_selection
= UNBOUND_VALUE
;
117 void CHARACTER_STRING_identification::copy_value(const CHARACTER_STRING_identification
& other_value
)
119 switch (other_value
.union_selection
) {
121 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes(*other_value
.field_syntaxes
);
124 field_syntax
= new OBJID(*other_value
.field_syntax
);
126 case ALT_presentation__context__id
:
127 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
129 case ALT_context__negotiation
:
130 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation(*other_value
.field_context__negotiation
);
132 case ALT_transfer__syntax
:
133 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
136 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
139 TTCN_error("Assignment of an unbound union value of type CHARACTER STRING.identification.");
141 union_selection
= other_value
.union_selection
;
144 CHARACTER_STRING_identification::CHARACTER_STRING_identification()
146 union_selection
= UNBOUND_VALUE
;
149 CHARACTER_STRING_identification::CHARACTER_STRING_identification(const CHARACTER_STRING_identification
& other_value
)
150 : Base_Type(other_value
)
152 copy_value(other_value
);
155 CHARACTER_STRING_identification::~CHARACTER_STRING_identification()
160 CHARACTER_STRING_identification
& CHARACTER_STRING_identification::operator=(const CHARACTER_STRING_identification
& other_value
)
162 if (this != &other_value
) {
164 copy_value(other_value
);
169 boolean
CHARACTER_STRING_identification::operator==(const CHARACTER_STRING_identification
& other_value
) const
171 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
172 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
173 if (union_selection
!= other_value
.union_selection
) return FALSE
;
174 switch (union_selection
) {
176 return *field_syntaxes
== *other_value
.field_syntaxes
;
178 return *field_syntax
== *other_value
.field_syntax
;
179 case ALT_presentation__context__id
:
180 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
181 case ALT_context__negotiation
:
182 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
183 case ALT_transfer__syntax
:
184 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
186 return *field_fixed
== *other_value
.field_fixed
;
192 CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes()
194 if (union_selection
!= ALT_syntaxes
) {
196 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
197 union_selection
= ALT_syntaxes
;
199 return *field_syntaxes
;
202 const CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes() const
204 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type CHARACTER STRING.identification.");
205 return *field_syntaxes
;
208 OBJID
& CHARACTER_STRING_identification::syntax()
210 if (union_selection
!= ALT_syntax
) {
212 field_syntax
= new OBJID
;
213 union_selection
= ALT_syntax
;
215 return *field_syntax
;
218 const OBJID
& CHARACTER_STRING_identification::syntax() const
220 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type CHARACTER STRING.identification.");
221 return *field_syntax
;
224 INTEGER
& CHARACTER_STRING_identification::presentation__context__id()
226 if (union_selection
!= ALT_presentation__context__id
) {
228 field_presentation__context__id
= new INTEGER
;
229 union_selection
= ALT_presentation__context__id
;
231 return *field_presentation__context__id
;
234 const INTEGER
& CHARACTER_STRING_identification::presentation__context__id() const
236 if (union_selection
!= ALT_presentation__context__id
) TTCN_error("Using non-selected field presentation_context_id in a value of union type CHARACTER STRING.identification.");
237 return *field_presentation__context__id
;
240 CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation()
242 if (union_selection
!= ALT_context__negotiation
) {
244 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
245 union_selection
= ALT_context__negotiation
;
247 return *field_context__negotiation
;
250 const CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation() const
252 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type CHARACTER STRING.identification.");
253 return *field_context__negotiation
;
256 OBJID
& CHARACTER_STRING_identification::transfer__syntax()
258 if (union_selection
!= ALT_transfer__syntax
) {
260 field_transfer__syntax
= new OBJID
;
261 union_selection
= ALT_transfer__syntax
;
263 return *field_transfer__syntax
;
266 const OBJID
& CHARACTER_STRING_identification::transfer__syntax() const
268 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type CHARACTER STRING.identification.");
269 return *field_transfer__syntax
;
272 ASN_NULL
& CHARACTER_STRING_identification::fixed()
274 if (union_selection
!= ALT_fixed
) {
276 field_fixed
= new ASN_NULL
;
277 union_selection
= ALT_fixed
;
282 const ASN_NULL
& CHARACTER_STRING_identification::fixed() const
284 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type CHARACTER STRING.identification.");
288 boolean
CHARACTER_STRING_identification::ischosen(union_selection_type checked_selection
) const
290 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification.");
291 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type CHARACTER STRING.identification.");
292 return union_selection
== checked_selection
;
295 boolean
CHARACTER_STRING_identification::is_bound() const
297 switch (union_selection
) {
299 return field_syntaxes
->is_bound();
301 return field_syntax
->is_bound();
302 case ALT_presentation__context__id
:
303 return field_presentation__context__id
->is_bound();
304 case ALT_context__negotiation
:
305 return field_context__negotiation
->is_bound();
306 case ALT_transfer__syntax
:
307 return field_transfer__syntax
->is_bound();
309 return field_fixed
->is_bound();
315 boolean
CHARACTER_STRING_identification::is_value() const
317 switch (union_selection
) {
319 return field_syntaxes
->is_value();
321 return field_syntax
->is_value();
322 case ALT_presentation__context__id
:
323 return field_presentation__context__id
->is_value();
324 case ALT_context__negotiation
:
325 return field_context__negotiation
->is_value();
326 case ALT_transfer__syntax
:
327 return field_transfer__syntax
->is_value();
329 return field_fixed
->is_value();
335 void CHARACTER_STRING_identification::log() const
337 switch (union_selection
) {
339 TTCN_Logger::log_event_str("{ syntaxes := ");
340 field_syntaxes
->log();
341 TTCN_Logger::log_event_str(" }");
344 TTCN_Logger::log_event_str("{ syntax := ");
346 TTCN_Logger::log_event_str(" }");
348 case ALT_presentation__context__id
:
349 TTCN_Logger::log_event_str("{ presentation_context_id := ");
350 field_presentation__context__id
->log();
351 TTCN_Logger::log_event_str(" }");
353 case ALT_context__negotiation
:
354 TTCN_Logger::log_event_str("{ context_negotiation := ");
355 field_context__negotiation
->log();
356 TTCN_Logger::log_event_str(" }");
358 case ALT_transfer__syntax
:
359 TTCN_Logger::log_event_str("{ transfer_syntax := ");
360 field_transfer__syntax
->log();
361 TTCN_Logger::log_event_str(" }");
364 TTCN_Logger::log_event_str("{ fixed := ");
366 TTCN_Logger::log_event_str(" }");
369 TTCN_Logger::log_event_str("<unbound>");
374 void CHARACTER_STRING_identification::set_param(Module_Param
& param
)
376 param
.basic_check(Module_Param::BC_VALUE
, "union value");
377 if (param
.get_type()==Module_Param::MP_Value_List
&& param
.get_size()==0) return;
378 if (param
.get_type()!=Module_Param::MP_Assignment_List
) {
379 param
.error("union value with field name was expected");
381 Module_Param
* mp_last
= param
.get_elem(param
.get_size()-1);
382 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
383 syntaxes().set_param(*mp_last
);
386 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
387 syntax().set_param(*mp_last
);
390 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
391 presentation__context__id().set_param(*mp_last
);
394 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
395 context__negotiation().set_param(*mp_last
);
398 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
399 transfer__syntax().set_param(*mp_last
);
402 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
403 fixed().set_param(*mp_last
);
406 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
409 void CHARACTER_STRING_identification_template::set_param(Module_Param
& param
)
411 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
412 switch (param
.get_type()) {
413 case Module_Param::MP_Omit
:
416 case Module_Param::MP_Any
:
419 case Module_Param::MP_AnyOrNone
:
422 case Module_Param::MP_List_Template
:
423 case Module_Param::MP_ComplementList_Template
:
424 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
425 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
426 list_item(p_i
).set_param(*param
.get_elem(p_i
));
429 case Module_Param::MP_Value_List
:
430 if (param
.get_size()==0) break;
431 param
.type_error("union template", "CHARACTER STRING.identification");
433 case Module_Param::MP_Assignment_List
: {
434 Module_Param
* mp_last
= param
.get_elem(param
.get_size()-1);
435 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
436 syntaxes().set_param(*mp_last
);
439 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
440 syntax().set_param(*mp_last
);
443 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
444 presentation__context__id().set_param(*mp_last
);
447 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
448 context__negotiation().set_param(*mp_last
);
451 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
452 transfer__syntax().set_param(*mp_last
);
455 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
456 fixed().set_param(*mp_last
);
459 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
462 param
.type_error("union template", "CHARACTER STRING.identification");
464 is_ifpresent
= param
.get_ifpresent();
467 void CHARACTER_STRING_identification::encode_text(Text_Buf
& text_buf
) const
469 text_buf
.push_int(union_selection
);
470 switch (union_selection
) {
472 field_syntaxes
->encode_text(text_buf
);
475 field_syntax
->encode_text(text_buf
);
477 case ALT_presentation__context__id
:
478 field_presentation__context__id
->encode_text(text_buf
);
480 case ALT_context__negotiation
:
481 field_context__negotiation
->encode_text(text_buf
);
483 case ALT_transfer__syntax
:
484 field_transfer__syntax
->encode_text(text_buf
);
487 field_fixed
->encode_text(text_buf
);
490 TTCN_error("Text encoder: Encoding an unbound value of union type CHARACTER STRING.identification.");
494 void CHARACTER_STRING_identification::decode_text(Text_Buf
& text_buf
)
496 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
498 syntaxes().decode_text(text_buf
);
501 syntax().decode_text(text_buf
);
503 case ALT_presentation__context__id
:
504 presentation__context__id().decode_text(text_buf
);
506 case ALT_context__negotiation
:
507 context__negotiation().decode_text(text_buf
);
509 case ALT_transfer__syntax
:
510 transfer__syntax().decode_text(text_buf
);
513 fixed().decode_text(text_buf
);
516 TTCN_error("Text decoder: Unrecognized union selector was received for type CHARACTER STRING.identification.");
521 void CHARACTER_STRING_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
522 void CHARACTER_STRING_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
525 ASN_BER_TLV_t
*CHARACTER_STRING_identification::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
528 ASN_BER_TLV_t
*new_tlv
;
529 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
530 TTCN_EncDec_ErrorContext ec_1
;
531 switch (union_selection
) {
533 ec_1
.set_msg("syntaxes': ");
534 new_tlv
= field_syntaxes
->BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, p_coding
);
537 ec_1
.set_msg("syntax': ");
538 new_tlv
= field_syntax
->BER_encode_TLV(CHARACTER_STRING_identification_syntax_descr_
, p_coding
);
540 case ALT_presentation__context__id
:
541 ec_1
.set_msg("presentation_context_id': ");
542 new_tlv
= field_presentation__context__id
->BER_encode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_coding
);
544 case ALT_context__negotiation
:
545 ec_1
.set_msg("context_negotiation': ");
546 new_tlv
= field_context__negotiation
->BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, p_coding
);
548 case ALT_transfer__syntax
:
549 ec_1
.set_msg("transfer_syntax': ");
550 new_tlv
= field_transfer__syntax
->BER_encode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_coding
);
553 ec_1
.set_msg("fixed': ");
554 new_tlv
= field_fixed
->BER_encode_TLV(CHARACTER_STRING_identification_fixed_descr_
, p_coding
);
557 new_tlv
= BER_encode_chk_bound(FALSE
);
560 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
563 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
566 boolean
CHARACTER_STRING_identification::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
569 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
570 union_selection
= ALT_syntaxes
;
571 if (field_syntaxes
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntaxes_descr_
, p_tlv
)) return TRUE
;
572 delete field_syntaxes
;
573 field_syntax
= new OBJID
;
574 union_selection
= ALT_syntax
;
575 if (field_syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntax_descr_
, p_tlv
)) return TRUE
;
577 field_presentation__context__id
= new INTEGER
;
578 union_selection
= ALT_presentation__context__id
;
579 if (field_presentation__context__id
->BER_decode_isMyMsg(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_tlv
)) return TRUE
;
580 delete field_presentation__context__id
;
581 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
582 union_selection
= ALT_context__negotiation
;
583 if (field_context__negotiation
->BER_decode_isMyMsg(CHARACTER_STRING_identification_context__negotiation_descr_
, p_tlv
)) return TRUE
;
584 delete field_context__negotiation
;
585 field_transfer__syntax
= new OBJID
;
586 union_selection
= ALT_transfer__syntax
;
587 if (field_transfer__syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_tlv
)) return TRUE
;
588 delete field_transfer__syntax
;
589 field_fixed
= new ASN_NULL
;
590 union_selection
= ALT_fixed
;
591 if (field_fixed
->BER_decode_isMyMsg(CHARACTER_STRING_identification_fixed_descr_
, p_tlv
)) return TRUE
;
593 union_selection
= UNBOUND_VALUE
;
597 boolean
CHARACTER_STRING_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
599 if (p_td
.ber
->n_tags
== 0) {
600 CHARACTER_STRING_identification tmp_type
;
601 return tmp_type
.BER_decode_set_selection(p_tlv
);
602 } else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
605 boolean
CHARACTER_STRING_identification::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
608 ASN_BER_TLV_t stripped_tlv
;
609 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
610 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification' type: ");
611 ASN_BER_TLV_t tmp_tlv
;
612 if (!BER_decode_TLV_CHOICE(*p_td
.ber
, stripped_tlv
, L_form
, tmp_tlv
) || !BER_decode_CHOICE_selection(BER_decode_set_selection(tmp_tlv
), tmp_tlv
)) return FALSE
;
613 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
614 TTCN_EncDec_ErrorContext ec_2
;
615 switch (union_selection
) {
617 ec_2
.set_msg("syntaxes': ");
618 field_syntaxes
->BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, tmp_tlv
, L_form
);
621 ec_2
.set_msg("syntax': ");
622 field_syntax
->BER_decode_TLV(CHARACTER_STRING_identification_syntax_descr_
, tmp_tlv
, L_form
);
624 case ALT_presentation__context__id
:
625 ec_2
.set_msg("presentation_context_id': ");
626 field_presentation__context__id
->BER_decode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, tmp_tlv
, L_form
);
628 case ALT_context__negotiation
:
629 ec_2
.set_msg("context_negotiation': ");
630 field_context__negotiation
->BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, tmp_tlv
, L_form
);
632 case ALT_transfer__syntax
:
633 ec_2
.set_msg("transfer_syntax': ");
634 field_transfer__syntax
->BER_decode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, tmp_tlv
, L_form
);
637 ec_2
.set_msg("fixed': ");
638 field_fixed
->BER_decode_TLV(CHARACTER_STRING_identification_fixed_descr_
, tmp_tlv
, L_form
);
646 // FIXME maybe: XER_encode and decode is virtually identical to EMBEDDED_PDV
648 int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t
& p_td
,
649 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
651 int encoded_length
=(int)p_buf
.get_len();
653 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
656 switch (union_selection
) {
658 field_syntaxes
->XER_encode(EMBEDDED_PDV_identification_sxs_xer_
, p_buf
, flavor
, indent
, 0);
661 field_syntax
->XER_encode(EMBEDDED_PDV_identification_sx_xer_
, p_buf
, flavor
, indent
, 0);
663 case ALT_presentation__context__id
:
664 field_presentation__context__id
->XER_encode(EMBEDDED_PDV_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
666 case ALT_context__negotiation
:
667 field_context__negotiation
->XER_encode(EMBEDDED_PDV_identification_cn_xer_
, p_buf
, flavor
, indent
, 0);
669 case ALT_transfer__syntax
:
670 field_transfer__syntax
->XER_encode(EMBEDDED_PDV_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
673 field_fixed
->XER_encode(EMBEDDED_PDV_identification_fix_xer_
, p_buf
, flavor
, indent
, 0);
676 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
680 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
682 return (int)p_buf
.get_len() - encoded_length
;
685 int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t
& p_td
,
686 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
688 int exer
= is_exer(flavor
);
689 // we are supposed to be parked on our element
690 for (int success
= 1; success
== 1; success
= reader
.Read()) {
691 int type
= reader
.NodeType();
693 case XML_READER_TYPE_ELEMENT
: {
694 if (verify_name(reader
, p_td
, exer
)) {
696 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
697 type
= reader
.NodeType();
698 if (XML_READER_TYPE_ELEMENT
== type
) break;
699 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
701 const char *name
= (const char*)reader
.Name();
702 // Avoid chained if-else on strcmp. Use the length as a hash
703 // (thankfully, they are all different).
704 size_t namelen
= strlen(name
);
707 syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_
, reader
, flavor
, 0);
711 syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_
, reader
, flavor
, 0);
714 case 23: // presentation-context-id
715 presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_
, reader
, flavor
, 0);
718 case 19: // context-negotiation
719 context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_
, reader
, flavor
, 0);
722 case 15: // transfer-syntax
723 transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_
, reader
, flavor
, 0);
727 fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_
, reader
, flavor
, 0);
734 else { // it belongs to somebody else
738 case XML_READER_TYPE_END_ELEMENT
: {
739 // advance to the next thing and bail
748 void CHARACTER_STRING_identification_template::clean_up()
750 switch (template_selection
) {
752 switch (single_value
.union_selection
) {
753 case CHARACTER_STRING_identification::ALT_syntaxes
:
754 delete single_value
.field_syntaxes
;
756 case CHARACTER_STRING_identification::ALT_syntax
:
757 delete single_value
.field_syntax
;
759 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
760 delete single_value
.field_presentation__context__id
;
762 case CHARACTER_STRING_identification::ALT_context__negotiation
:
763 delete single_value
.field_context__negotiation
;
765 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
766 delete single_value
.field_transfer__syntax
;
768 case CHARACTER_STRING_identification::ALT_fixed
:
769 delete single_value
.field_fixed
;
776 case COMPLEMENTED_LIST
:
777 delete [] value_list
.list_value
;
782 template_selection
= UNINITIALIZED_TEMPLATE
;
785 void CHARACTER_STRING_identification_template::copy_value(const CHARACTER_STRING_identification
& other_value
)
787 single_value
.union_selection
= other_value
.get_selection();
788 switch (single_value
.union_selection
) {
789 case CHARACTER_STRING_identification::ALT_syntaxes
:
790 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(other_value
.syntaxes());
792 case CHARACTER_STRING_identification::ALT_syntax
:
793 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
795 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
796 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
798 case CHARACTER_STRING_identification::ALT_context__negotiation
:
799 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(other_value
.context__negotiation());
801 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
802 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
804 case CHARACTER_STRING_identification::ALT_fixed
:
805 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
808 TTCN_error("Initializing a template with an unbound value of type CHARACTER STRING.identification.");
810 set_selection(SPECIFIC_VALUE
);
813 void CHARACTER_STRING_identification_template::copy_template(const CHARACTER_STRING_identification_template
& other_value
)
815 switch (other_value
.template_selection
) {
817 single_value
.union_selection
= other_value
.single_value
.union_selection
;
818 switch (single_value
.union_selection
) {
819 case CHARACTER_STRING_identification::ALT_syntaxes
:
820 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
822 case CHARACTER_STRING_identification::ALT_syntax
:
823 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
825 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
826 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
828 case CHARACTER_STRING_identification::ALT_context__negotiation
:
829 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
831 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
832 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
834 case CHARACTER_STRING_identification::ALT_fixed
:
835 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
838 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type CHARACTER STRING.identification.");
846 case COMPLEMENTED_LIST
:
847 value_list
.n_values
= other_value
.value_list
.n_values
;
848 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
849 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
850 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
853 TTCN_error("Copying an uninitialized template of union type CHARACTER STRING.identification.");
855 set_selection(other_value
);
858 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template()
862 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(template_sel other_value
)
863 : Base_Template(other_value
)
865 check_single_selection(other_value
);
868 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification
& other_value
)
870 copy_value(other_value
);
873 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
875 switch (other_value
.get_selection()) {
876 case OPTIONAL_PRESENT
:
877 copy_value((const CHARACTER_STRING_identification
&)other_value
);
880 set_selection(OMIT_VALUE
);
883 TTCN_error("Creating a template of union type CHARACTER STRING.identification from an unbound optional field.");
887 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification_template
& other_value
)
890 copy_template(other_value
);
893 CHARACTER_STRING_identification_template::~CHARACTER_STRING_identification_template()
898 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(template_sel other_value
)
900 check_single_selection(other_value
);
902 set_selection(other_value
);
906 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification
& other_value
)
909 copy_value(other_value
);
913 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
916 switch (other_value
.get_selection()) {
917 case OPTIONAL_PRESENT
:
918 copy_value((const CHARACTER_STRING_identification
&)other_value
);
921 set_selection(OMIT_VALUE
);
924 TTCN_error("Assignment of an unbound optional field to a template of union type CHARACTER STRING.identification.");
929 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification_template
& other_value
)
931 if (&other_value
!= this) {
933 copy_template(other_value
);
938 boolean
CHARACTER_STRING_identification_template::match(const CHARACTER_STRING_identification
& other_value
) const
940 switch (template_selection
) {
948 CHARACTER_STRING_identification::union_selection_type value_selection
= other_value
.get_selection();
949 if (value_selection
== CHARACTER_STRING_identification::UNBOUND_VALUE
) return FALSE
;
950 if (value_selection
!= single_value
.union_selection
) return FALSE
;
951 switch (value_selection
) {
952 case CHARACTER_STRING_identification::ALT_syntaxes
:
953 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
954 case CHARACTER_STRING_identification::ALT_syntax
:
955 return single_value
.field_syntax
->match(other_value
.syntax());
956 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
957 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
958 case CHARACTER_STRING_identification::ALT_context__negotiation
:
959 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
960 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
961 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
962 case CHARACTER_STRING_identification::ALT_fixed
:
963 return single_value
.field_fixed
->match(other_value
.fixed());
965 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type CHARACTER STRING.identification.");
969 case COMPLEMENTED_LIST
:
970 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
971 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
972 return template_selection
== COMPLEMENTED_LIST
;
974 TTCN_error ("Matching an uninitialized template of union type CHARACTER STRING.identification.");
979 CHARACTER_STRING_identification
CHARACTER_STRING_identification_template::valueof() const
981 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
982 TTCN_error("Performing valueof or send operation on a non-specific template of union type CHARACTER STRING.identification.");
983 CHARACTER_STRING_identification ret_val
;
984 switch (single_value
.union_selection
) {
985 case CHARACTER_STRING_identification::ALT_syntaxes
:
986 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
988 case CHARACTER_STRING_identification::ALT_syntax
:
989 ret_val
.syntax() = single_value
.field_syntax
->valueof();
991 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
992 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
994 case CHARACTER_STRING_identification::ALT_context__negotiation
:
995 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
997 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
998 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1000 case CHARACTER_STRING_identification::ALT_fixed
:
1001 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1004 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type CHARACTER STRING.identification.");
1009 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::list_item(unsigned int list_index
) const
1011 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 CHARACTER STRING.identification.");
1012 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type CHARACTER STRING.identification.");
1013 return value_list
.list_value
[list_index
];
1015 void CHARACTER_STRING_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1017 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
) TTCN_error ("Internal error: Setting an invalid list for a template of union type CHARACTER STRING.identification.");
1019 set_selection(template_type
);
1020 value_list
.n_values
= list_length
;
1021 value_list
.list_value
= new CHARACTER_STRING_identification_template
[list_length
];
1024 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes()
1026 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntaxes
) {
1027 template_sel old_selection
= template_selection
;
1029 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(ANY_VALUE
);
1030 else single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1031 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntaxes
;
1032 set_selection(SPECIFIC_VALUE
);
1034 return *single_value
.field_syntaxes
;
1037 const CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes() const
1039 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type CHARACTER STRING.identification.");
1040 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntaxes
) TTCN_error("Accessing non-selected field syntaxes in a template of union type CHARACTER STRING.identification.");
1041 return *single_value
.field_syntaxes
;
1044 OBJID_template
& CHARACTER_STRING_identification_template::syntax()
1046 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntax
) {
1047 template_sel old_selection
= template_selection
;
1049 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1050 else single_value
.field_syntax
= new OBJID_template
;
1051 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntax
;
1052 set_selection(SPECIFIC_VALUE
);
1054 return *single_value
.field_syntax
;
1057 const OBJID_template
& CHARACTER_STRING_identification_template::syntax() const
1059 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type CHARACTER STRING.identification.");
1060 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntax
) TTCN_error("Accessing non-selected field syntax in a template of union type CHARACTER STRING.identification.");
1061 return *single_value
.field_syntax
;
1064 INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id()
1066 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_presentation__context__id
) {
1067 template_sel old_selection
= template_selection
;
1069 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1070 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1071 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_presentation__context__id
;
1072 set_selection(SPECIFIC_VALUE
);
1074 return *single_value
.field_presentation__context__id
;
1077 const INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id() const
1079 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type CHARACTER STRING.identification.");
1080 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_presentation__context__id
) TTCN_error("Accessing non-selected field presentation_context_id in a template of union type CHARACTER STRING.identification.");
1081 return *single_value
.field_presentation__context__id
;
1084 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation()
1086 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_context__negotiation
) {
1087 template_sel old_selection
= template_selection
;
1089 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(ANY_VALUE
);
1090 else single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1091 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_context__negotiation
;
1092 set_selection(SPECIFIC_VALUE
);
1094 return *single_value
.field_context__negotiation
;
1097 const CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation() const
1099 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type CHARACTER STRING.identification.");
1100 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_context__negotiation
) TTCN_error("Accessing non-selected field context_negotiation in a template of union type CHARACTER STRING.identification.");
1101 return *single_value
.field_context__negotiation
;
1104 OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax()
1106 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_transfer__syntax
) {
1107 template_sel old_selection
= template_selection
;
1109 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1110 else single_value
.field_transfer__syntax
= new OBJID_template
;
1111 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_transfer__syntax
;
1112 set_selection(SPECIFIC_VALUE
);
1114 return *single_value
.field_transfer__syntax
;
1117 const OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax() const
1119 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type CHARACTER STRING.identification.");
1120 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_transfer__syntax
) TTCN_error("Accessing non-selected field transfer_syntax in a template of union type CHARACTER STRING.identification.");
1121 return *single_value
.field_transfer__syntax
;
1124 ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed()
1126 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_fixed
) {
1127 template_sel old_selection
= template_selection
;
1129 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1130 else single_value
.field_fixed
= new ASN_NULL_template
;
1131 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_fixed
;
1132 set_selection(SPECIFIC_VALUE
);
1134 return *single_value
.field_fixed
;
1137 const ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed() const
1139 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type CHARACTER STRING.identification.");
1140 if (single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_fixed
) TTCN_error("Accessing non-selected field fixed in a template of union type CHARACTER STRING.identification.");
1141 return *single_value
.field_fixed
;
1144 boolean
CHARACTER_STRING_identification_template::ischosen(CHARACTER_STRING_identification::union_selection_type checked_selection
) const
1146 if (checked_selection
== CHARACTER_STRING_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification.");
1147 switch (template_selection
) {
1148 case SPECIFIC_VALUE
:
1149 if (single_value
.union_selection
== CHARACTER_STRING_identification::UNBOUND_VALUE
) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type CHARACTER STRING.identification.");
1150 return single_value
.union_selection
== checked_selection
;
1153 if (value_list
.n_values
< 1)
1154 TTCN_error("Internal error: Performing ischosen() operation on a template of union type CHARACTER STRING.identification containing an empty list.");
1155 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1156 boolean all_same
= TRUE
;
1157 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1158 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1163 if (all_same
) return ret_val
;
1165 // FIXME really no break?
1169 case COMPLEMENTED_LIST
:
1170 TTCN_error("Performing ischosen() operation on a template of union type CHARACTER STRING.identification, which does not determine unambiguously the chosen field of the matching values.");
1172 TTCN_error("Performing ischosen() operation on an uninitialized template of union type CHARACTER STRING.identification");
1177 void CHARACTER_STRING_identification_template::log() const
1179 switch (template_selection
) {
1180 case SPECIFIC_VALUE
:
1181 switch (single_value
.union_selection
) {
1182 case CHARACTER_STRING_identification::ALT_syntaxes
:
1183 TTCN_Logger::log_event_str("{ syntaxes := ");
1184 single_value
.field_syntaxes
->log();
1185 TTCN_Logger::log_event_str(" }");
1187 case CHARACTER_STRING_identification::ALT_syntax
:
1188 TTCN_Logger::log_event_str("{ syntax := ");
1189 single_value
.field_syntax
->log();
1190 TTCN_Logger::log_event_str(" }");
1192 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1193 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1194 single_value
.field_presentation__context__id
->log();
1195 TTCN_Logger::log_event_str(" }");
1197 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1198 TTCN_Logger::log_event_str("{ context_negotiation := ");
1199 single_value
.field_context__negotiation
->log();
1200 TTCN_Logger::log_event_str(" }");
1202 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1203 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1204 single_value
.field_transfer__syntax
->log();
1205 TTCN_Logger::log_event_str(" }");
1207 case CHARACTER_STRING_identification::ALT_fixed
:
1208 TTCN_Logger::log_event_str("{ fixed := ");
1209 single_value
.field_fixed
->log();
1210 TTCN_Logger::log_event_str(" }");
1213 TTCN_Logger::log_event_str("<invalid selector>");
1217 case COMPLEMENTED_LIST
:
1218 TTCN_Logger::log_event_str("complement ");
1221 TTCN_Logger::log_char('(');
1222 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1223 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1224 value_list
.list_value
[list_count
].log();
1226 TTCN_Logger::log_char(')');
1235 void CHARACTER_STRING_identification_template::log_match(const CHARACTER_STRING_identification
& match_value
) const
1237 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1238 if(match(match_value
)){
1239 TTCN_Logger::print_logmatch_buffer();
1240 TTCN_Logger::log_event_str(" matched ");
1244 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1245 switch (single_value
.union_selection
) {
1246 case CHARACTER_STRING_identification::ALT_syntaxes
:
1247 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1248 TTCN_Logger::log_logmatch_info(".syntaxes");
1249 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1251 TTCN_Logger::log_event_str("{ syntaxes := ");
1252 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1253 TTCN_Logger::log_event_str(" }");
1256 case CHARACTER_STRING_identification::ALT_syntax
:
1257 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1258 TTCN_Logger::log_logmatch_info(".syntax");
1259 single_value
.field_syntax
->log_match(match_value
.syntax());
1261 TTCN_Logger::log_event_str("{ syntax := ");
1262 single_value
.field_syntax
->log_match(match_value
.syntax());
1263 TTCN_Logger::log_event_str(" }");
1266 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1267 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1268 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1269 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1271 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1272 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1273 TTCN_Logger::log_event_str(" }");
1276 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1277 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1278 TTCN_Logger::log_logmatch_info(".context_negotiation");
1279 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1281 TTCN_Logger::log_event_str("{ context_negotiation := ");
1282 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1283 TTCN_Logger::log_event_str(" }");
1286 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1287 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1288 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1289 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1291 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1292 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1293 TTCN_Logger::log_event_str(" }");
1296 case CHARACTER_STRING_identification::ALT_fixed
:
1297 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1298 TTCN_Logger::log_logmatch_info(".fixed");
1299 single_value
.field_fixed
->log_match(match_value
.fixed());
1301 TTCN_Logger::log_event_str("{ fixed := ");
1302 single_value
.field_fixed
->log_match(match_value
.fixed());
1303 TTCN_Logger::log_event_str(" }");
1307 TTCN_Logger::print_logmatch_buffer();
1308 TTCN_Logger::log_event_str("<invalid selector>");
1312 TTCN_Logger::print_logmatch_buffer();
1314 TTCN_Logger::log_event_str(" with ");
1316 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1317 else TTCN_Logger::log_event_str(" unmatched");
1321 void CHARACTER_STRING_identification_template::encode_text(Text_Buf
& text_buf
) const
1323 encode_text_base(text_buf
);
1324 switch (template_selection
) {
1325 case SPECIFIC_VALUE
:
1326 text_buf
.push_int(single_value
.union_selection
);
1327 switch (single_value
.union_selection
) {
1328 case CHARACTER_STRING_identification::ALT_syntaxes
:
1329 single_value
.field_syntaxes
->encode_text(text_buf
);
1331 case CHARACTER_STRING_identification::ALT_syntax
:
1332 single_value
.field_syntax
->encode_text(text_buf
);
1334 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1335 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1337 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1338 single_value
.field_context__negotiation
->encode_text(text_buf
);
1340 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1341 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1343 case CHARACTER_STRING_identification::ALT_fixed
:
1344 single_value
.field_fixed
->encode_text(text_buf
);
1347 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type CHARACTER STRING.identification.");
1355 case COMPLEMENTED_LIST
:
1356 text_buf
.push_int(value_list
.n_values
);
1357 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1358 value_list
.list_value
[list_count
].encode_text(text_buf
);
1361 TTCN_error("Text encoder: Encoding an uninitialized template of type CHARACTER STRING.identification.");
1365 void CHARACTER_STRING_identification_template::decode_text(Text_Buf
& text_buf
)
1368 decode_text_base(text_buf
);
1369 switch (template_selection
) {
1370 case SPECIFIC_VALUE
:
1372 single_value
.union_selection
= CHARACTER_STRING_identification::UNBOUND_VALUE
;
1373 CHARACTER_STRING_identification::union_selection_type new_selection
= (CHARACTER_STRING_identification::union_selection_type
)text_buf
.pull_int().get_val();
1374 switch (new_selection
) {
1375 case CHARACTER_STRING_identification::ALT_syntaxes
:
1376 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1377 single_value
.field_syntaxes
->decode_text(text_buf
);
1379 case CHARACTER_STRING_identification::ALT_syntax
:
1380 single_value
.field_syntax
= new OBJID_template
;
1381 single_value
.field_syntax
->decode_text(text_buf
);
1383 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1384 single_value
.field_presentation__context__id
= new INTEGER_template
;
1385 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1387 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1388 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1389 single_value
.field_context__negotiation
->decode_text(text_buf
);
1391 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1392 single_value
.field_transfer__syntax
= new OBJID_template
;
1393 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1395 case CHARACTER_STRING_identification::ALT_fixed
:
1396 single_value
.field_fixed
= new ASN_NULL_template
;
1397 single_value
.field_fixed
->decode_text(text_buf
);
1400 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type CHARACTER STRING.identification.");
1402 single_value
.union_selection
= new_selection
;
1410 case COMPLEMENTED_LIST
:
1411 value_list
.n_values
= text_buf
.pull_int().get_val();
1412 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
1413 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1414 value_list
.list_value
[list_count
].decode_text(text_buf
);
1417 TTCN_error("Text decoder: Unrecognized selector was received in a template of type CHARACTER STRING.identification.");
1421 boolean
CHARACTER_STRING_identification_template::is_present() const
1423 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1424 return !match_omit();
1427 boolean
CHARACTER_STRING_identification_template::match_omit() const
1429 if (is_ifpresent
) return TRUE
;
1430 switch (template_selection
) {
1435 case COMPLEMENTED_LIST
:
1436 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1437 if (value_list
.list_value
[i
].match_omit())
1438 return template_selection
==VALUE_LIST
;
1439 return template_selection
==COMPLEMENTED_LIST
;
1446 #ifndef TITAN_RUNTIME_2
1447 void CHARACTER_STRING_identification_template::check_restriction(template_res t_res
, const char* t_name
) const
1449 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1450 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1452 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1455 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1456 template_selection
==SPECIFIC_VALUE
)) return;
1459 if (!match_omit()) return;
1464 TTCN_error("Restriction `%s' on template of type %s violated.",
1465 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification");
1469 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes()
1473 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes(const OBJID
& par_abstract
,
1474 const OBJID
& par_transfer
)
1475 : field_abstract(par_abstract
),
1476 field_transfer(par_transfer
)
1480 boolean
CHARACTER_STRING_identification_syntaxes::operator==(const CHARACTER_STRING_identification_syntaxes
& other_value
) const
1482 return field_abstract
==other_value
.field_abstract
1483 && field_transfer
==other_value
.field_transfer
;
1486 int CHARACTER_STRING_identification_syntaxes::size_of() const
1492 void CHARACTER_STRING_identification_syntaxes::log() const
1494 TTCN_Logger::log_event_str("{ abstract := ");
1495 field_abstract
.log();
1496 TTCN_Logger::log_event_str(", transfer := ");
1497 field_transfer
.log();
1498 TTCN_Logger::log_event_str(" }");
1501 boolean
CHARACTER_STRING_identification_syntaxes::is_bound() const
1503 if(field_abstract
.is_bound()) return TRUE
;
1504 if(field_transfer
.is_bound()) return TRUE
;
1508 boolean
CHARACTER_STRING_identification_syntaxes::is_value() const
1510 if(!field_abstract
.is_value()) return FALSE
;
1511 if(!field_transfer
.is_value()) return FALSE
;
1515 void CHARACTER_STRING_identification_syntaxes::clean_up()
1517 field_abstract
.clean_up();
1518 field_transfer
.clean_up();
1521 void CHARACTER_STRING_identification_syntaxes::set_param(Module_Param
& param
)
1523 param
.basic_check(Module_Param::BC_VALUE
, "record value");
1524 switch (param
.get_type()) {
1525 case Module_Param::MP_Value_List
:
1526 if (param
.get_size()==0) return;
1527 if (2!=param
.get_size()) {
1528 param
.error("record value of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)param
.get_size());
1530 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*param
.get_elem(0));
1531 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*param
.get_elem(1));
1533 case Module_Param::MP_Assignment_List
: {
1534 Vector
<bool> value_used(param
.get_size());
1535 value_used
.resize(param
.get_size(), false);
1536 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1537 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1538 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1539 abstract().set_param(*curr_param
);
1540 value_used
[val_idx
]=true;
1543 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1544 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1545 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1546 transfer().set_param(*curr_param
);
1547 value_used
[val_idx
]=true;
1550 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1551 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", param
.get_elem(val_idx
)->get_id()->get_name());
1556 param
.type_error("record value", "CHARACTER STRING.identification.syntaxes");
1560 void CHARACTER_STRING_identification_syntaxes_template::set_param(Module_Param
& param
)
1562 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
1563 switch (param
.get_type()) {
1564 case Module_Param::MP_Omit
:
1567 case Module_Param::MP_Any
:
1570 case Module_Param::MP_AnyOrNone
:
1571 *this = ANY_OR_OMIT
;
1573 case Module_Param::MP_List_Template
:
1574 case Module_Param::MP_ComplementList_Template
:
1575 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
1576 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
1577 list_item(p_i
).set_param(*param
.get_elem(p_i
));
1580 case Module_Param::MP_Value_List
:
1581 if (param
.get_size()==0) break;
1582 if (2!=param
.get_size()) {
1583 param
.error("record template of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)param
.get_size());
1585 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*param
.get_elem(0));
1586 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*param
.get_elem(1));
1588 case Module_Param::MP_Assignment_List
: {
1589 Vector
<bool> value_used(param
.get_size());
1590 value_used
.resize(param
.get_size(), false);
1591 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1592 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1593 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1594 abstract().set_param(*curr_param
);
1595 value_used
[val_idx
]=true;
1598 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
1599 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
1600 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1601 transfer().set_param(*curr_param
);
1602 value_used
[val_idx
]=true;
1605 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1606 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", param
.get_elem(val_idx
)->get_id()->get_name());
1611 param
.type_error("record template", "CHARACTER STRING.identification.syntaxes");
1613 is_ifpresent
= param
.get_ifpresent();
1616 void CHARACTER_STRING_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
1618 field_abstract
.encode_text(text_buf
);
1619 field_transfer
.encode_text(text_buf
);
1622 void CHARACTER_STRING_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
1624 field_abstract
.decode_text(text_buf
);
1625 field_transfer
.decode_text(text_buf
);
1629 void CHARACTER_STRING_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
1630 void CHARACTER_STRING_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
1633 ASN_BER_TLV_t
* CHARACTER_STRING_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
1635 BER_chk_descr(p_td
);
1636 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
1637 TTCN_EncDec_ErrorContext
ec_0("Component '");
1638 TTCN_EncDec_ErrorContext ec_1
;
1639 ec_1
.set_msg("abstract': ");
1640 new_tlv
->add_TLV(field_abstract
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, p_coding
));
1641 ec_1
.set_msg("transfer': ");
1642 new_tlv
->add_TLV(field_transfer
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, p_coding
));
1643 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
1647 boolean
CHARACTER_STRING_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
1649 BER_chk_descr(p_td
);
1650 ASN_BER_TLV_t stripped_tlv
;
1651 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
1652 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.syntaxes' type: ");
1653 stripped_tlv
.chk_constructed_flag(TRUE
);
1655 ASN_BER_TLV_t tmp_tlv
;
1656 boolean tlv_present
=FALSE
;
1658 TTCN_EncDec_ErrorContext
ec_1("Component '");
1659 TTCN_EncDec_ErrorContext ec_2
;
1660 ec_2
.set_msg("abstract': ");
1661 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1662 if(!tlv_present
) return FALSE
;
1663 field_abstract
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, tmp_tlv
, L_form
);
1665 ec_2
.set_msg("transfer': ");
1666 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1667 if(!tlv_present
) return FALSE
;
1668 field_transfer
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, tmp_tlv
, L_form
);
1671 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
1675 int CHARACTER_STRING_identification_syntaxes::XER_encode(const XERdescriptor_t
& p_td
,
1676 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
1678 int encoded_length
=(int)p_buf
.get_len();
1680 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
1682 field_abstract
.XER_encode(CHARACTER_STRING_identification_sxs_abs_xer_
, p_buf
, flavor
, indent
, 0);
1683 field_transfer
.XER_encode(CHARACTER_STRING_identification_sxs_xfr_xer_
, p_buf
, flavor
, indent
, 0);
1685 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
1687 return p_buf
.get_len() - encoded_length
;
1690 int CHARACTER_STRING_identification_syntaxes::XER_decode(
1691 const XERdescriptor_t
& /*p_td*/, XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
1692 { // we stand on <syntaxes>, move ahead first
1693 for (int success
= reader
.Read(); success
== 1; success
= reader
.Read())
1695 int type
= reader
.NodeType();
1696 if (XML_READER_TYPE_ELEMENT
== type
)
1697 // no verify_name for a CHOICE
1700 // FIXME this assumes the right element
1701 field_abstract
.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_
, reader
, flavor
, 0);
1702 field_transfer
.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_
, reader
, flavor
, 0);
1703 for (int success
= 1; success
== 1; success
= reader
.Read())
1705 int type
= reader
.NodeType();
1706 if (XML_READER_TYPE_END_ELEMENT
== type
)
1709 return 0; // TODO maybe return proper value
1713 struct CHARACTER_STRING_identification_syntaxes_template::single_value_struct
{
1714 OBJID_template field_abstract
;
1715 OBJID_template field_transfer
;
1718 void CHARACTER_STRING_identification_syntaxes_template::clean_up()
1720 switch (template_selection
) {
1721 case SPECIFIC_VALUE
:
1722 delete single_value
;
1725 case COMPLEMENTED_LIST
:
1726 delete [] value_list
.list_value
;
1731 template_selection
= UNINITIALIZED_TEMPLATE
;
1734 void CHARACTER_STRING_identification_syntaxes_template::set_specific()
1736 if (template_selection
!= SPECIFIC_VALUE
) {
1737 template_sel old_selection
= template_selection
;
1739 single_value
= new single_value_struct
;
1740 set_selection(SPECIFIC_VALUE
);
1741 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
1742 single_value
->field_abstract
= ANY_VALUE
;
1743 single_value
->field_transfer
= ANY_VALUE
;
1748 void CHARACTER_STRING_identification_syntaxes_template::copy_value(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1750 single_value
= new single_value_struct
;
1751 single_value
->field_abstract
= other_value
.abstract();
1752 single_value
->field_transfer
= other_value
.transfer();
1753 set_selection(SPECIFIC_VALUE
);
1756 void CHARACTER_STRING_identification_syntaxes_template::copy_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
1758 switch (other_value
.template_selection
) {
1759 case SPECIFIC_VALUE
:
1760 single_value
= new single_value_struct(*other_value
.single_value
);
1767 case COMPLEMENTED_LIST
:
1768 value_list
.n_values
= other_value
.value_list
.n_values
;
1769 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
1770 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1771 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1774 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
1776 set_selection(other_value
);
1779 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template()
1783 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(template_sel other_value
)
1784 : Base_Template(other_value
)
1786 check_single_selection(other_value
);
1789 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1791 copy_value(other_value
);
1794 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
1796 switch (other_value
.get_selection()) {
1797 case OPTIONAL_PRESENT
:
1798 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
1801 set_selection(OMIT_VALUE
);
1804 TTCN_error("Creating a template of type CHARACTER STRING.identification.syntaxes from an unbound optional field.");
1808 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
1811 copy_template(other_value
);
1814 CHARACTER_STRING_identification_syntaxes_template::~CHARACTER_STRING_identification_syntaxes_template()
1819 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(template_sel other_value
)
1821 check_single_selection(other_value
);
1823 set_selection(other_value
);
1827 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1830 copy_value(other_value
);
1834 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
1837 switch (other_value
.get_selection()) {
1838 case OPTIONAL_PRESENT
:
1839 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
1842 set_selection(OMIT_VALUE
);
1845 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.syntaxes.");
1850 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
1852 if (&other_value
!= this) {
1854 copy_template(other_value
);
1859 boolean
CHARACTER_STRING_identification_syntaxes_template::match(const CHARACTER_STRING_identification_syntaxes
& other_value
) const
1861 switch (template_selection
) {
1867 case SPECIFIC_VALUE
:
1868 if (!other_value
.abstract().is_bound()) return FALSE
;
1869 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
1870 if (!other_value
.transfer().is_bound()) return FALSE
;
1871 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
1874 case COMPLEMENTED_LIST
:
1875 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1876 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1877 return template_selection
== COMPLEMENTED_LIST
;
1879 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
1884 CHARACTER_STRING_identification_syntaxes
CHARACTER_STRING_identification_syntaxes_template::valueof() const
1886 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1887 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.syntaxes.");
1888 CHARACTER_STRING_identification_syntaxes ret_val
;
1889 ret_val
.abstract() = single_value
->field_abstract
.valueof();
1890 ret_val
.transfer() = single_value
->field_transfer
.valueof();
1894 void CHARACTER_STRING_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
1896 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
1897 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.syntaxes.");
1899 set_selection(template_type
);
1900 value_list
.n_values
= list_length
;
1901 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[list_length
];
1904 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::list_item(unsigned int list_index
) const
1906 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
1907 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.syntaxes.");
1908 if (list_index
>= value_list
.n_values
)
1909 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.syntaxes.");
1910 return value_list
.list_value
[list_index
];
1913 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract()
1916 return single_value
->field_abstract
;
1919 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract() const
1921 if (template_selection
!= SPECIFIC_VALUE
)
1922 TTCN_error("Accessing field abstract of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
1923 return single_value
->field_abstract
;
1926 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer()
1929 return single_value
->field_transfer
;
1932 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer() const
1934 if (template_selection
!= SPECIFIC_VALUE
)
1935 TTCN_error("Accessing field transfer of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
1936 return single_value
->field_transfer
;
1939 int CHARACTER_STRING_identification_syntaxes_template::size_of() const
1941 switch (template_selection
)
1943 case SPECIFIC_VALUE
:
1950 if (value_list
.n_values
<1)
1951 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing an empty list.");
1952 int item_size
= value_list
.list_value
[0].size_of();
1953 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
1955 if (value_list
.list_value
[i
].size_of()!=item_size
)
1956 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing a value list with different sizes.");
1961 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing omit value.");
1964 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing */? value.");
1965 case COMPLEMENTED_LIST
:
1966 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing complemented list.");
1968 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
1973 void CHARACTER_STRING_identification_syntaxes_template::log() const
1975 switch (template_selection
) {
1976 case SPECIFIC_VALUE
:
1977 TTCN_Logger::log_event_str("{ abstract := ");
1978 single_value
->field_abstract
.log();
1979 TTCN_Logger::log_event_str(", transfer := ");
1980 single_value
->field_transfer
.log();
1981 TTCN_Logger::log_event_str(" }");
1983 case COMPLEMENTED_LIST
:
1984 TTCN_Logger::log_event_str("complement ");
1987 TTCN_Logger::log_char('(');
1988 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1989 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1990 value_list
.list_value
[list_count
].log();
1992 TTCN_Logger::log_char(')');
2001 void CHARACTER_STRING_identification_syntaxes_template::log_match(const CHARACTER_STRING_identification_syntaxes
& match_value
) const
2003 if (template_selection
== SPECIFIC_VALUE
) {
2004 TTCN_Logger::log_event_str("{ abstract := ");
2005 single_value
->field_abstract
.log_match(match_value
.abstract());
2006 TTCN_Logger::log_event_str(", transfer := ");
2007 single_value
->field_transfer
.log_match(match_value
.transfer());
2008 TTCN_Logger::log_event_str(" }");
2011 TTCN_Logger::log_event_str(" with ");
2013 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2014 else TTCN_Logger::log_event_str(" unmatched");
2018 void CHARACTER_STRING_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2020 encode_text_base(text_buf
);
2021 switch (template_selection
) {
2022 case SPECIFIC_VALUE
:
2023 single_value
->field_abstract
.encode_text(text_buf
);
2024 single_value
->field_transfer
.encode_text(text_buf
);
2031 case COMPLEMENTED_LIST
:
2032 text_buf
.push_int(value_list
.n_values
);
2033 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2034 value_list
.list_value
[list_count
].encode_text(text_buf
);
2037 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2041 void CHARACTER_STRING_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2044 decode_text_base(text_buf
);
2045 switch (template_selection
) {
2046 case SPECIFIC_VALUE
:
2047 single_value
= new single_value_struct
;
2048 single_value
->field_abstract
.decode_text(text_buf
);
2049 single_value
->field_transfer
.decode_text(text_buf
);
2056 case COMPLEMENTED_LIST
:
2057 value_list
.n_values
= text_buf
.pull_int().get_val();
2058 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
2059 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2060 value_list
.list_value
[list_count
].decode_text(text_buf
);
2063 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.syntaxes.");
2067 boolean
CHARACTER_STRING_identification_syntaxes_template::is_present() const
2069 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2070 return !match_omit();
2073 boolean
CHARACTER_STRING_identification_syntaxes_template::match_omit() const
2075 if (is_ifpresent
) return TRUE
;
2076 switch (template_selection
) {
2081 case COMPLEMENTED_LIST
:
2082 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2083 if (value_list
.list_value
[i
].match_omit())
2084 return template_selection
==VALUE_LIST
;
2085 return template_selection
==COMPLEMENTED_LIST
;
2092 #ifndef TITAN_RUNTIME_2
2093 void CHARACTER_STRING_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
) const
2095 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2096 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2098 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2101 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2102 template_selection
==SPECIFIC_VALUE
)) return;
2105 if (!match_omit()) return;
2110 TTCN_error("Restriction `%s' on template of type %s violated.",
2111 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.syntaxes");
2115 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation()
2119 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2120 const OBJID
& par_transfer__syntax
)
2121 : field_presentation__context__id(par_presentation__context__id
),
2122 field_transfer__syntax(par_transfer__syntax
)
2126 boolean
CHARACTER_STRING_identification_context__negotiation::operator==(const CHARACTER_STRING_identification_context__negotiation
& other_value
) const
2128 return field_presentation__context__id
==other_value
.field_presentation__context__id
2129 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2132 int CHARACTER_STRING_identification_context__negotiation::size_of() const
2138 void CHARACTER_STRING_identification_context__negotiation::log() const
2140 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2141 field_presentation__context__id
.log();
2142 TTCN_Logger::log_event_str(", transfer_syntax := ");
2143 field_transfer__syntax
.log();
2144 TTCN_Logger::log_event_str(" }");
2147 boolean
CHARACTER_STRING_identification_context__negotiation::is_bound() const
2149 if(field_presentation__context__id
.is_bound()) return TRUE
;
2150 if(field_transfer__syntax
.is_bound()) return TRUE
;
2154 boolean
CHARACTER_STRING_identification_context__negotiation::is_value() const
2156 if(!field_presentation__context__id
.is_value()) return FALSE
;
2157 if(!field_transfer__syntax
.is_value()) return FALSE
;
2161 void CHARACTER_STRING_identification_context__negotiation::clean_up()
2163 field_presentation__context__id
.clean_up();
2164 field_transfer__syntax
.clean_up();
2167 void CHARACTER_STRING_identification_context__negotiation::set_param(Module_Param
& param
)
2169 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2170 switch (param
.get_type()) {
2171 case Module_Param::MP_Value_List
:
2172 if (param
.get_size()==0) return;
2173 if (2!=param
.get_size()) {
2174 param
.error("record value of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)param
.get_size());
2176 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*param
.get_elem(0));
2177 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*param
.get_elem(1));
2179 case Module_Param::MP_Assignment_List
: {
2180 Vector
<bool> value_used(param
.get_size());
2181 value_used
.resize(param
.get_size(), false);
2182 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2183 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2184 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2185 presentation__context__id().set_param(*curr_param
);
2186 value_used
[val_idx
]=true;
2189 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2190 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2191 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2192 transfer__syntax().set_param(*curr_param
);
2193 value_used
[val_idx
]=true;
2196 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2197 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2202 param
.type_error("record value", "CHARACTER STRING.identification.context-negotiation");
2206 void CHARACTER_STRING_identification_context__negotiation_template::set_param(Module_Param
& param
)
2208 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2209 switch (param
.get_type()) {
2210 case Module_Param::MP_Omit
:
2213 case Module_Param::MP_Any
:
2216 case Module_Param::MP_AnyOrNone
:
2217 *this = ANY_OR_OMIT
;
2219 case Module_Param::MP_List_Template
:
2220 case Module_Param::MP_ComplementList_Template
:
2221 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
2222 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
2223 list_item(p_i
).set_param(*param
.get_elem(p_i
));
2226 case Module_Param::MP_Value_List
:
2227 if (param
.get_size()==0) break;
2228 if (2!=param
.get_size()) {
2229 param
.error("record template of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)param
.get_size());
2231 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*param
.get_elem(0));
2232 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*param
.get_elem(1));
2234 case Module_Param::MP_Assignment_List
: {
2235 Vector
<bool> value_used(param
.get_size());
2236 value_used
.resize(param
.get_size(), false);
2237 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2238 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2239 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2240 presentation__context__id().set_param(*curr_param
);
2241 value_used
[val_idx
]=true;
2244 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2245 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2246 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2247 transfer__syntax().set_param(*curr_param
);
2248 value_used
[val_idx
]=true;
2251 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2252 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2257 param
.type_error("record template", "CHARACTER STRING.identification.context-negotiation");
2259 is_ifpresent
= param
.get_ifpresent();
2262 void CHARACTER_STRING_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2264 field_presentation__context__id
.encode_text(text_buf
);
2265 field_transfer__syntax
.encode_text(text_buf
);
2268 void CHARACTER_STRING_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2270 field_presentation__context__id
.decode_text(text_buf
);
2271 field_transfer__syntax
.decode_text(text_buf
);
2275 void CHARACTER_STRING_identification_context__negotiation::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
2276 void CHARACTER_STRING_identification_context__negotiation::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
2279 ASN_BER_TLV_t
* CHARACTER_STRING_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
2281 BER_chk_descr(p_td
);
2282 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
2283 TTCN_EncDec_ErrorContext
ec_0("Component '");
2284 TTCN_EncDec_ErrorContext ec_1
;
2285 ec_1
.set_msg("presentation_context_id': ");
2286 new_tlv
->add_TLV(field_presentation__context__id
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, p_coding
));
2287 ec_1
.set_msg("transfer_syntax': ");
2288 new_tlv
->add_TLV(field_transfer__syntax
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, p_coding
));
2289 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
2293 boolean
CHARACTER_STRING_identification_context__negotiation::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
2295 BER_chk_descr(p_td
);
2296 ASN_BER_TLV_t stripped_tlv
;
2297 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
2298 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.context-negotiation' type: ");
2299 stripped_tlv
.chk_constructed_flag(TRUE
);
2301 ASN_BER_TLV_t tmp_tlv
;
2302 boolean tlv_present
=FALSE
;
2304 TTCN_EncDec_ErrorContext
ec_1("Component '");
2305 TTCN_EncDec_ErrorContext ec_2
;
2306 ec_2
.set_msg("presentation_context_id': ");
2307 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2308 if(!tlv_present
) return FALSE
;
2309 field_presentation__context__id
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, tmp_tlv
, L_form
);
2311 ec_2
.set_msg("transfer_syntax': ");
2312 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2313 if(!tlv_present
) return FALSE
;
2314 field_transfer__syntax
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, tmp_tlv
, L_form
);
2317 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
2321 int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERdescriptor_t
& p_td
,
2322 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
2324 int encoded_length
=(int)p_buf
.get_len();
2326 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
2328 field_presentation__context__id
.XER_encode(CHARACTER_STRING_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
2329 field_transfer__syntax
.XER_encode(CHARACTER_STRING_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
2331 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
2333 return p_buf
.get_len() - encoded_length
;
2336 int CHARACTER_STRING_identification_context__negotiation::XER_decode(
2337 const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
2339 int exer
= is_exer(flavor
);
2340 int type
= reader
.NodeType(), depth
= -1;
2341 const char* name
= (const char*)reader
.Name();
2342 int success
= reader
.Ok();
2343 if (type
==XML_READER_TYPE_ELEMENT
&& check_name(name
, p_td
, exer
)) {
2344 // we are in the right place
2345 depth
= reader
.Depth();
2346 success
= reader
.Read();
2348 field_presentation__context__id
.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_
, reader
, flavor
, 0);
2349 field_transfer__syntax
.XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_
, reader
, flavor
, 0);
2350 for (; success
== 1; success
= reader
.Read()) {
2351 type
= reader
.NodeType();
2352 if (XML_READER_TYPE_END_ELEMENT
== type
) {
2353 verify_end(reader
, p_td
, depth
, exer
);
2358 return 0; // TODO sensible return value
2361 struct CHARACTER_STRING_identification_context__negotiation_template::single_value_struct
{
2362 INTEGER_template field_presentation__context__id
;
2363 OBJID_template field_transfer__syntax
;
2366 void CHARACTER_STRING_identification_context__negotiation_template::clean_up()
2368 switch (template_selection
) {
2369 case SPECIFIC_VALUE
:
2370 delete single_value
;
2373 case COMPLEMENTED_LIST
:
2374 delete [] value_list
.list_value
;
2379 template_selection
= UNINITIALIZED_TEMPLATE
;
2382 void CHARACTER_STRING_identification_context__negotiation_template::set_specific()
2384 if (template_selection
!= SPECIFIC_VALUE
) {
2385 template_sel old_selection
= template_selection
;
2387 single_value
= new single_value_struct
;
2388 set_selection(SPECIFIC_VALUE
);
2389 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2390 single_value
->field_presentation__context__id
= ANY_VALUE
;
2391 single_value
->field_transfer__syntax
= ANY_VALUE
;
2396 void CHARACTER_STRING_identification_context__negotiation_template::copy_value(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2398 single_value
= new single_value_struct
;
2399 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2400 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2401 set_selection(SPECIFIC_VALUE
);
2404 void CHARACTER_STRING_identification_context__negotiation_template::copy_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2406 switch (other_value
.template_selection
) {
2407 case SPECIFIC_VALUE
:
2408 single_value
= new single_value_struct(*other_value
.single_value
);
2415 case COMPLEMENTED_LIST
:
2416 value_list
.n_values
= other_value
.value_list
.n_values
;
2417 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2418 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2419 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2422 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2424 set_selection(other_value
);
2427 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template()
2431 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(template_sel other_value
)
2432 : Base_Template(other_value
)
2434 check_single_selection(other_value
);
2437 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2439 copy_value(other_value
);
2442 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2444 switch (other_value
.get_selection()) {
2445 case OPTIONAL_PRESENT
:
2446 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2449 set_selection(OMIT_VALUE
);
2452 TTCN_error("Creating a template of type CHARACTER STRING.identification.context-negotiation from an unbound optional field.");
2456 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2459 copy_template(other_value
);
2462 CHARACTER_STRING_identification_context__negotiation_template::~CHARACTER_STRING_identification_context__negotiation_template()
2467 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(template_sel other_value
)
2469 check_single_selection(other_value
);
2471 set_selection(other_value
);
2475 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2478 copy_value(other_value
);
2482 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2485 switch (other_value
.get_selection()) {
2486 case OPTIONAL_PRESENT
:
2487 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2490 set_selection(OMIT_VALUE
);
2493 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.context-negotiation.");
2498 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2500 if (&other_value
!= this) {
2502 copy_template(other_value
);
2507 boolean
CHARACTER_STRING_identification_context__negotiation_template::match(const CHARACTER_STRING_identification_context__negotiation
& other_value
) const
2509 switch (template_selection
) {
2515 case SPECIFIC_VALUE
:
2516 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
2517 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
2518 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
2519 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
2522 case COMPLEMENTED_LIST
:
2523 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2524 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2525 return template_selection
== COMPLEMENTED_LIST
;
2527 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2532 CHARACTER_STRING_identification_context__negotiation
CHARACTER_STRING_identification_context__negotiation_template::valueof() const
2534 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2535 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2536 CHARACTER_STRING_identification_context__negotiation ret_val
;
2537 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
2538 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
2542 void CHARACTER_STRING_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
2544 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2545 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.context-negotiation.");
2547 set_selection(template_type
);
2548 value_list
.n_values
= list_length
;
2549 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[list_length
];
2552 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::list_item(unsigned int list_index
) const
2554 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2555 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.context-negotiation.");
2556 if (list_index
>= value_list
.n_values
)
2557 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.context-negotiation.");
2558 return value_list
.list_value
[list_index
];
2561 INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id()
2564 return single_value
->field_presentation__context__id
;
2567 const INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() const
2569 if (template_selection
!= SPECIFIC_VALUE
)
2570 TTCN_error("Accessing field presentation_context_id of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2571 return single_value
->field_presentation__context__id
;
2574 OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax()
2577 return single_value
->field_transfer__syntax
;
2580 const OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() const
2582 if (template_selection
!= SPECIFIC_VALUE
)
2583 TTCN_error("Accessing field transfer_syntax of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2584 return single_value
->field_transfer__syntax
;
2587 int CHARACTER_STRING_identification_context__negotiation_template::size_of() const
2589 switch (template_selection
)
2591 case SPECIFIC_VALUE
:
2598 if (value_list
.n_values
<1)
2599 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing an empty list.");
2600 int item_size
= value_list
.list_value
[0].size_of();
2601 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2603 if (value_list
.list_value
[i
].size_of()!=item_size
)
2604 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing a value list with different sizes.");
2609 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing omit value.");
2612 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing */? value.");
2613 case COMPLEMENTED_LIST
:
2614 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing complemented list.");
2616 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2621 void CHARACTER_STRING_identification_context__negotiation_template::log() const
2623 switch (template_selection
) {
2624 case SPECIFIC_VALUE
:
2625 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2626 single_value
->field_presentation__context__id
.log();
2627 TTCN_Logger::log_event_str(", transfer_syntax := ");
2628 single_value
->field_transfer__syntax
.log();
2629 TTCN_Logger::log_event_str(" }");
2631 case COMPLEMENTED_LIST
:
2632 TTCN_Logger::log_event_str("complement ");
2635 TTCN_Logger::log_char('(');
2636 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2637 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2638 value_list
.list_value
[list_count
].log();
2640 TTCN_Logger::log_char(')');
2649 void CHARACTER_STRING_identification_context__negotiation_template::log_match(const CHARACTER_STRING_identification_context__negotiation
& match_value
) const
2651 if (template_selection
== SPECIFIC_VALUE
) {
2652 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2653 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
2654 TTCN_Logger::log_event_str(", transfer_syntax := ");
2655 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
2656 TTCN_Logger::log_event_str(" }");
2659 TTCN_Logger::log_event_str(" with ");
2661 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2662 else TTCN_Logger::log_event_str(" unmatched");
2666 void CHARACTER_STRING_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
2668 encode_text_base(text_buf
);
2669 switch (template_selection
) {
2670 case SPECIFIC_VALUE
:
2671 single_value
->field_presentation__context__id
.encode_text(text_buf
);
2672 single_value
->field_transfer__syntax
.encode_text(text_buf
);
2679 case COMPLEMENTED_LIST
:
2680 text_buf
.push_int(value_list
.n_values
);
2681 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2682 value_list
.list_value
[list_count
].encode_text(text_buf
);
2685 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2689 void CHARACTER_STRING_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
2692 decode_text_base(text_buf
);
2693 switch (template_selection
) {
2694 case SPECIFIC_VALUE
:
2695 single_value
= new single_value_struct
;
2696 single_value
->field_presentation__context__id
.decode_text(text_buf
);
2697 single_value
->field_transfer__syntax
.decode_text(text_buf
);
2704 case COMPLEMENTED_LIST
:
2705 value_list
.n_values
= text_buf
.pull_int().get_val();
2706 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2707 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2708 value_list
.list_value
[list_count
].decode_text(text_buf
);
2711 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.context-negotiation.");
2715 boolean
CHARACTER_STRING_identification_context__negotiation_template::is_present() const
2717 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2718 return !match_omit();
2721 boolean
CHARACTER_STRING_identification_context__negotiation_template::match_omit() const
2723 if (is_ifpresent
) return TRUE
;
2724 switch (template_selection
) {
2729 case COMPLEMENTED_LIST
:
2730 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2731 if (value_list
.list_value
[i
].match_omit())
2732 return template_selection
==VALUE_LIST
;
2733 return template_selection
==COMPLEMENTED_LIST
;
2740 #ifndef TITAN_RUNTIME_2
2741 void CHARACTER_STRING_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
) const
2743 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2744 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2746 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2749 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2750 template_selection
==SPECIFIC_VALUE
)) return;
2753 if (!match_omit()) return;
2758 TTCN_error("Restriction `%s' on template of type %s violated.",
2759 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.context-negotiation");
2763 CHARACTER_STRING::CHARACTER_STRING()
2767 CHARACTER_STRING::CHARACTER_STRING(const CHARACTER_STRING_identification
& par_identification
,
2768 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
2769 const OCTETSTRING
& par_string__value
)
2770 : field_identification(par_identification
),
2771 field_data__value__descriptor(par_data__value__descriptor
),
2772 field_string__value(par_string__value
)
2776 boolean
CHARACTER_STRING::operator==(const CHARACTER_STRING
& other_value
) const
2778 return field_identification
==other_value
.field_identification
2779 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
2780 && field_string__value
==other_value
.field_string__value
;
2783 int CHARACTER_STRING::size_of() const
2786 if (field_data__value__descriptor
.ispresent()) ret_val
++;
2790 boolean
CHARACTER_STRING::is_bound() const
2792 if(field_identification
.is_bound()) return TRUE
;
2793 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
2794 if(field_string__value
.is_bound()) return TRUE
;
2798 boolean
CHARACTER_STRING::is_value() const
2800 if(!field_identification
.is_value()) return FALSE
;
2801 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
2802 if(!field_string__value
.is_value()) return FALSE
;
2806 void CHARACTER_STRING::clean_up()
2808 field_identification
.clean_up();
2809 field_data__value__descriptor
.clean_up();
2810 field_string__value
.clean_up();
2813 void CHARACTER_STRING::log() const
2815 TTCN_Logger::log_event_str("{ identification := ");
2816 field_identification
.log();
2817 TTCN_Logger::log_event_str(", data_value_descriptor := ");
2818 field_data__value__descriptor
.log();
2819 TTCN_Logger::log_event_str(", string_value := ");
2820 field_string__value
.log();
2821 TTCN_Logger::log_event_str(" }");
2824 void CHARACTER_STRING::set_param(Module_Param
& param
)
2826 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2827 switch (param
.get_type()) {
2828 case Module_Param::MP_Value_List
:
2829 if (param
.get_size()==0) return;
2830 if (3!=param
.get_size()) {
2831 param
.error("record value of type CHARACTER STRING has 3 fields but list value has %d fields", (int)param
.get_size());
2833 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*param
.get_elem(0));
2834 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*param
.get_elem(1));
2835 if (param
.get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*param
.get_elem(2));
2837 case Module_Param::MP_Assignment_List
: {
2838 Vector
<bool> value_used(param
.get_size());
2839 value_used
.resize(param
.get_size(), false);
2840 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2841 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2842 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
2843 identification().set_param(*curr_param
);
2844 value_used
[val_idx
]=true;
2847 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2848 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2849 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
2850 data__value__descriptor().set_param(*curr_param
);
2851 value_used
[val_idx
]=true;
2854 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2855 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2856 if (!strcmp(curr_param
->get_id()->get_name(), "string_value")) {
2857 string__value().set_param(*curr_param
);
2858 value_used
[val_idx
]=true;
2861 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2862 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2867 param
.type_error("record value", "CHARACTER STRING");
2871 void CHARACTER_STRING_template::set_param(Module_Param
& param
)
2873 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2874 switch (param
.get_type()) {
2875 case Module_Param::MP_Omit
:
2878 case Module_Param::MP_Any
:
2881 case Module_Param::MP_AnyOrNone
:
2882 *this = ANY_OR_OMIT
;
2884 case Module_Param::MP_List_Template
:
2885 case Module_Param::MP_ComplementList_Template
:
2886 set_type(param
.get_type()==Module_Param::MP_List_Template
? VALUE_LIST
: COMPLEMENTED_LIST
, param
.get_size());
2887 for (size_t p_i
=0; p_i
<param
.get_size(); p_i
++) {
2888 list_item(p_i
).set_param(*param
.get_elem(p_i
));
2891 case Module_Param::MP_Value_List
:
2892 if (param
.get_size()==0) break;
2893 if (3!=param
.get_size()) {
2894 param
.error("record template of type CHARACTER STRING has 3 fields but list value has %d fields", (int)param
.get_size());
2896 if (param
.get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*param
.get_elem(0));
2897 if (param
.get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*param
.get_elem(1));
2898 if (param
.get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*param
.get_elem(2));
2900 case Module_Param::MP_Assignment_List
: {
2901 Vector
<bool> value_used(param
.get_size());
2902 value_used
.resize(param
.get_size(), false);
2903 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2904 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2905 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
2906 identification().set_param(*curr_param
);
2907 value_used
[val_idx
]=true;
2910 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2911 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2912 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
2913 data__value__descriptor().set_param(*curr_param
);
2914 value_used
[val_idx
]=true;
2917 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) {
2918 Module_Param
* const curr_param
= param
.get_elem(val_idx
);
2919 if (!strcmp(curr_param
->get_id()->get_name(), "string_value")) {
2920 string__value().set_param(*curr_param
);
2921 value_used
[val_idx
]=true;
2924 for (size_t val_idx
=0; val_idx
<param
.get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2925 param
.get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", param
.get_elem(val_idx
)->get_id()->get_name());
2930 param
.type_error("record template", "CHARACTER STRING");
2932 is_ifpresent
= param
.get_ifpresent();
2935 void CHARACTER_STRING::encode_text(Text_Buf
& text_buf
) const
2937 field_identification
.encode_text(text_buf
);
2938 field_data__value__descriptor
.encode_text(text_buf
);
2939 field_string__value
.encode_text(text_buf
);
2942 void CHARACTER_STRING::decode_text(Text_Buf
& text_buf
)
2944 field_identification
.decode_text(text_buf
);
2945 field_data__value__descriptor
.decode_text(text_buf
);
2946 field_string__value
.decode_text(text_buf
);
2949 void CHARACTER_STRING::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
2952 va_start(pvar
, p_coding
);
2954 case TTCN_EncDec::CT_BER
: {
2955 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
2956 unsigned BER_coding
=va_arg(pvar
, unsigned);
2957 BER_encode_chk_coding(BER_coding
);
2958 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
2959 tlv
->put_in_buffer(p_buf
);
2960 ASN_BER_TLV_t::destruct(tlv
);
2962 case TTCN_EncDec::CT_RAW
: {
2963 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
2964 TTCN_EncDec_ErrorContext::error_internal
2965 ("No RAW descriptor available for type '%s'.", p_td
.name
);
2967 case TTCN_EncDec::CT_TEXT
: {
2968 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
2969 TTCN_EncDec_ErrorContext::error_internal
2970 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
2972 case TTCN_EncDec::CT_XER
: {
2973 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
2974 unsigned XER_coding
=va_arg(pvar
, unsigned);
2975 XER_encode(*p_td
.xer
,p_buf
, XER_coding
, 0, 0);
2978 case TTCN_EncDec::CT_JSON
: {
2979 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
2980 TTCN_EncDec_ErrorContext::error_internal
2981 ("No JSON descriptor available for type '%s'.", p_td
.name
);
2984 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
2989 void CHARACTER_STRING::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
2992 va_start(pvar
, p_coding
);
2994 case TTCN_EncDec::CT_BER
: {
2995 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
2996 unsigned L_form
=va_arg(pvar
, unsigned);
2998 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
2999 BER_decode_TLV(p_td
, tlv
, L_form
);
3000 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3002 case TTCN_EncDec::CT_RAW
: {
3003 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3004 TTCN_EncDec_ErrorContext::error_internal
3005 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3007 case TTCN_EncDec::CT_TEXT
: {
3008 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3009 TTCN_EncDec_ErrorContext::error_internal
3010 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3012 case TTCN_EncDec::CT_XER
: {
3013 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3014 unsigned XER_coding
=va_arg(pvar
, unsigned);
3015 XmlReaderWrap
reader(p_buf
);
3016 int success
= reader
.Read();
3017 for (; success
==1; success
=reader
.Read()) {
3018 int type
= reader
.NodeType();
3019 if (type
==XML_READER_TYPE_ELEMENT
)
3022 XER_decode(*p_td
.xer
, reader
, XER_coding
, 0);
3023 size_t bytes
= reader
.ByteConsumed();
3024 p_buf
.set_pos(bytes
);
3026 case TTCN_EncDec::CT_JSON
: {
3027 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3028 TTCN_EncDec_ErrorContext::error_internal
3029 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3032 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3037 ASN_BER_TLV_t
* CHARACTER_STRING::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
3039 BER_chk_descr(p_td
);
3040 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
3041 TTCN_EncDec_ErrorContext
ec_0("Component '");
3042 TTCN_EncDec_ErrorContext ec_1
;
3043 ec_1
.set_msg("identification': ");
3044 new_tlv
->add_TLV(field_identification
.BER_encode_TLV(CHARACTER_STRING_identification_descr_
, p_coding
));
3045 ec_1
.set_msg("data_value_descriptor': ");
3046 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, p_coding
));
3047 ec_1
.set_msg("string_value': ");
3048 new_tlv
->add_TLV(field_string__value
.BER_encode_TLV(CHARACTER_STRING_string__value_descr_
, p_coding
));
3049 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
3053 boolean
CHARACTER_STRING::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
3055 BER_chk_descr(p_td
);
3056 ASN_BER_TLV_t stripped_tlv
;
3057 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
3058 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING' type: ");
3059 stripped_tlv
.chk_constructed_flag(TRUE
);
3061 ASN_BER_TLV_t tmp_tlv
;
3062 boolean tlv_present
=FALSE
;
3064 TTCN_EncDec_ErrorContext
ec_1("Component '");
3065 TTCN_EncDec_ErrorContext ec_2
;
3066 ec_2
.set_msg("identification': ");
3067 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3068 if(!tlv_present
) return FALSE
;
3069 field_identification
.BER_decode_TLV(CHARACTER_STRING_identification_descr_
, tmp_tlv
, L_form
);
3071 ec_2
.set_msg("data_value_descriptor': ");
3072 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3073 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
3075 field_data__value__descriptor
.BER_decode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, tmp_tlv
, L_form
);
3076 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
3078 ec_2
.set_msg("string_value': ");
3079 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3080 if(!tlv_present
) return FALSE
;
3081 field_string__value
.BER_decode_TLV(CHARACTER_STRING_string__value_descr_
, tmp_tlv
, L_form
);
3084 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
3088 int CHARACTER_STRING::XER_encode(const XERdescriptor_t
& p_td
, TTCN_Buffer
& p_buf
,
3089 unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
3092 TTCN_EncDec_ErrorContext::error
3093 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
3095 int encoded_length
=(int)p_buf
.get_len();
3097 flavor
&= ~XER_RECOF
; // ASN.1 character string doesn't care
3098 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
3100 field_identification
.XER_encode(CHARACTER_STRING_identification_xer_
, p_buf
, flavor
, indent
, 0);
3101 // data-value-descriptor is OPTIONAL and can never be present.
3102 // Its encoding is empty.
3103 field_string__value
.XER_encode(CHARACTER_STRING_data_value_xer_
, p_buf
, flavor
, indent
, 0);
3105 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
3107 return (int)p_buf
.get_len() - encoded_length
;
3110 int CHARACTER_STRING::XER_decode(const XERdescriptor_t
& p_td
,
3111 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
3113 int exer
= is_exer(flavor
);
3114 int success
= reader
.Ok(), depth
= -1, type
;
3115 for (; success
== 1; success
= reader
.Read()) {
3116 type
= reader
.NodeType();
3117 if (XML_READER_TYPE_ELEMENT
== type
) {
3118 verify_name(reader
, p_td
, exer
);
3119 depth
= reader
.Depth();
3124 field_identification
.XER_decode(CHARACTER_STRING_identification_xer_
, reader
, flavor
, 0);
3125 field_data__value__descriptor
.XER_decode(CHARACTER_STRING_data_value_descriptor_xer_
, reader
, flavor
, 0);
3126 if (field_data__value__descriptor
.is_value()) {
3127 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
3128 "data-value-descriptor not allowed for EMBEDDED PDV");
3130 field_string__value
.XER_decode(CHARACTER_STRING_data_value_xer_
, reader
, flavor
, 0);
3131 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
3132 type
= reader
.NodeType();
3133 if (XML_READER_TYPE_END_ELEMENT
== type
) {
3134 verify_end(reader
, p_td
, depth
, exer
);
3144 struct CHARACTER_STRING_template::single_value_struct
{
3145 CHARACTER_STRING_identification_template field_identification
;
3146 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3147 OCTETSTRING_template field_string__value
;
3150 void CHARACTER_STRING_template::clean_up()
3152 switch (template_selection
) {
3153 case SPECIFIC_VALUE
:
3154 delete single_value
;
3157 case COMPLEMENTED_LIST
:
3158 delete [] value_list
.list_value
;
3163 template_selection
= UNINITIALIZED_TEMPLATE
;
3166 void CHARACTER_STRING_template::set_specific()
3168 if (template_selection
!= SPECIFIC_VALUE
) {
3169 template_sel old_selection
= template_selection
;
3171 single_value
= new single_value_struct
;
3172 set_selection(SPECIFIC_VALUE
);
3173 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3174 single_value
->field_identification
= ANY_VALUE
;
3175 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3176 single_value
->field_string__value
= ANY_VALUE
;
3181 void CHARACTER_STRING_template::copy_value(const CHARACTER_STRING
& other_value
)
3183 single_value
= new single_value_struct
;
3184 single_value
->field_identification
= other_value
.identification();
3185 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3186 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3187 single_value
->field_string__value
= other_value
.string__value();
3188 set_selection(SPECIFIC_VALUE
);
3191 void CHARACTER_STRING_template::copy_template(const CHARACTER_STRING_template
& other_value
)
3193 switch (other_value
.template_selection
) {
3194 case SPECIFIC_VALUE
:
3195 single_value
= new single_value_struct(*other_value
.single_value
);
3202 case COMPLEMENTED_LIST
:
3203 value_list
.n_values
= other_value
.value_list
.n_values
;
3204 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3205 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3206 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3209 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.");
3211 set_selection(other_value
);
3214 CHARACTER_STRING_template::CHARACTER_STRING_template()
3218 CHARACTER_STRING_template::CHARACTER_STRING_template(template_sel other_value
)
3219 : Base_Template(other_value
)
3221 check_single_selection(other_value
);
3224 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING
& other_value
)
3226 copy_value(other_value
);
3229 CHARACTER_STRING_template::CHARACTER_STRING_template(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3231 switch (other_value
.get_selection()) {
3232 case OPTIONAL_PRESENT
:
3233 copy_value((const CHARACTER_STRING
&)other_value
);
3236 set_selection(OMIT_VALUE
);
3239 TTCN_error("Creating a template of type CHARACTER STRING from an unbound optional field.");
3243 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING_template
& other_value
)
3246 copy_template(other_value
);
3249 CHARACTER_STRING_template::~CHARACTER_STRING_template()
3254 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(template_sel other_value
)
3256 check_single_selection(other_value
);
3258 set_selection(other_value
);
3262 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING
& other_value
)
3265 copy_value(other_value
);
3269 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3272 switch (other_value
.get_selection()) {
3273 case OPTIONAL_PRESENT
:
3274 copy_value((const CHARACTER_STRING
&)other_value
);
3277 set_selection(OMIT_VALUE
);
3280 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.");
3285 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING_template
& other_value
)
3287 if (&other_value
!= this) {
3289 copy_template(other_value
);
3294 boolean
CHARACTER_STRING_template::match(const CHARACTER_STRING
& other_value
) const
3296 switch (template_selection
) {
3302 case SPECIFIC_VALUE
:
3303 if (!other_value
.identification().is_bound()) return FALSE
;
3304 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3305 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3306 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
;
3307 if (!other_value
.string__value().is_bound()) return FALSE
;
3308 if (!single_value
->field_string__value
.match(other_value
.string__value())) return FALSE
;
3311 case COMPLEMENTED_LIST
:
3312 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3313 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3314 return template_selection
== COMPLEMENTED_LIST
;
3316 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.");
3321 CHARACTER_STRING
CHARACTER_STRING_template::valueof() const
3323 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3324 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.");
3325 CHARACTER_STRING ret_val
;
3326 ret_val
.identification() = single_value
->field_identification
.valueof();
3327 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3328 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3329 ret_val
.string__value() = single_value
->field_string__value
.valueof();
3333 void CHARACTER_STRING_template::set_type(template_sel template_type
, unsigned int list_length
)
3335 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3336 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.");
3338 set_selection(template_type
);
3339 value_list
.n_values
= list_length
;
3340 value_list
.list_value
= new CHARACTER_STRING_template
[list_length
];
3343 CHARACTER_STRING_template
& CHARACTER_STRING_template::list_item(unsigned int list_index
) const
3345 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3346 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.");
3347 if (list_index
>= value_list
.n_values
)
3348 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.");
3349 return value_list
.list_value
[list_index
];
3352 CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification()
3355 return single_value
->field_identification
;
3358 const CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification() const
3360 if (template_selection
!= SPECIFIC_VALUE
)
3361 TTCN_error("Accessing field identification of a non-specific template of type CHARACTER STRING.");
3362 return single_value
->field_identification
;
3365 UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor()
3368 return single_value
->field_data__value__descriptor
;
3371 const UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor() const
3373 if (template_selection
!= SPECIFIC_VALUE
)
3374 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type CHARACTER STRING.");
3375 return single_value
->field_data__value__descriptor
;
3378 OCTETSTRING_template
& CHARACTER_STRING_template::string__value()
3381 return single_value
->field_string__value
;
3384 const OCTETSTRING_template
& CHARACTER_STRING_template::string__value() const
3386 if (template_selection
!= SPECIFIC_VALUE
)
3387 TTCN_error("Accessing field string_value of a non-specific template of type CHARACTER STRING.");
3388 return single_value
->field_string__value
;
3391 int CHARACTER_STRING_template::size_of() const
3393 switch (template_selection
)
3395 case SPECIFIC_VALUE
:
3398 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3403 if (value_list
.n_values
<1)
3404 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING containing an empty list.");
3405 int item_size
= value_list
.list_value
[0].size_of();
3406 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3408 if (value_list
.list_value
[i
].size_of()!=item_size
)
3409 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing a value list with different sizes.");
3414 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing omit value.");
3417 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing */? value.");
3418 case COMPLEMENTED_LIST
:
3419 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing complemented list.");
3421 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.");
3426 void CHARACTER_STRING_template::log() const
3428 switch (template_selection
) {
3429 case SPECIFIC_VALUE
:
3430 TTCN_Logger::log_event_str("{ identification := ");
3431 single_value
->field_identification
.log();
3432 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3433 single_value
->field_data__value__descriptor
.log();
3434 TTCN_Logger::log_event_str(", string_value := ");
3435 single_value
->field_string__value
.log();
3436 TTCN_Logger::log_event_str(" }");
3438 case COMPLEMENTED_LIST
:
3439 TTCN_Logger::log_event_str("complement ");
3442 TTCN_Logger::log_char('(');
3443 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3444 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3445 value_list
.list_value
[list_count
].log();
3447 TTCN_Logger::log_char(')');
3456 void CHARACTER_STRING_template::log_match(const CHARACTER_STRING
& match_value
) const
3458 if (template_selection
== SPECIFIC_VALUE
) {
3459 TTCN_Logger::log_event_str("{ identification := ");
3460 single_value
->field_identification
.log_match(match_value
.identification());
3461 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3462 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3464 single_value
->field_data__value__descriptor
.log();
3465 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3466 else TTCN_Logger::log_event_str(" unmatched");
3468 TTCN_Logger::log_event_str(", string_value := ");
3469 single_value
->field_string__value
.log_match(match_value
.string__value());
3470 TTCN_Logger::log_event_str(" }");
3473 TTCN_Logger::log_event_str(" with ");
3475 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3476 else TTCN_Logger::log_event_str(" unmatched");
3480 void CHARACTER_STRING_template::encode_text(Text_Buf
& text_buf
) const
3482 encode_text_base(text_buf
);
3483 switch (template_selection
) {
3484 case SPECIFIC_VALUE
:
3485 single_value
->field_identification
.encode_text(text_buf
);
3486 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3487 single_value
->field_string__value
.encode_text(text_buf
);
3494 case COMPLEMENTED_LIST
:
3495 text_buf
.push_int(value_list
.n_values
);
3496 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3497 value_list
.list_value
[list_count
].encode_text(text_buf
);
3500 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.");
3504 void CHARACTER_STRING_template::decode_text(Text_Buf
& text_buf
)
3507 decode_text_base(text_buf
);
3508 switch (template_selection
) {
3509 case SPECIFIC_VALUE
:
3510 single_value
= new single_value_struct
;
3511 single_value
->field_identification
.decode_text(text_buf
);
3512 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3513 single_value
->field_string__value
.decode_text(text_buf
);
3520 case COMPLEMENTED_LIST
:
3521 value_list
.n_values
= text_buf
.pull_int().get_val();
3522 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3523 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3524 value_list
.list_value
[list_count
].decode_text(text_buf
);
3527 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.");
3531 boolean
CHARACTER_STRING_template::is_present() const
3533 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3534 return !match_omit();
3537 boolean
CHARACTER_STRING_template::match_omit() const
3539 if (is_ifpresent
) return TRUE
;
3540 switch (template_selection
) {
3545 case COMPLEMENTED_LIST
:
3546 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3547 if (value_list
.list_value
[i
].match_omit())
3548 return template_selection
==VALUE_LIST
;
3549 return template_selection
==COMPLEMENTED_LIST
;
3556 #ifndef TITAN_RUNTIME_2
3557 void CHARACTER_STRING_template::check_restriction(template_res t_res
, const char* t_name
) const
3559 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3560 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3562 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3565 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3566 template_selection
==SPECIFIC_VALUE
)) return;
3569 if (!match_omit()) return;
3574 TTCN_error("Restriction `%s' on template of type %s violated.",
3575 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING");