1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
18 * Szabo, Janos Zoltan – initial implementation
21 ******************************************************************************/
28 #include "Param_Types.hh"
30 #include "ASN_CharacterString.hh"
32 #include "../common/dbgnew.hh"
36 to do when regenerating:
40 add __SUNPRO_CC ifdefs for single_value_struct
44 replace '@CHARACTER STRING' with 'CHARACTER STRING'
46 remove RAW and TEXT enc/dec functions
48 make the type descriptors of embedded types static
52 static const ASN_Tag_t CHARACTER_STRING_identification_tag_
[] = { { ASN_TAG_CONT
, 0u }};
53 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_ber_
= { 1u, CHARACTER_STRING_identification_tag_
};
54 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_descr_
= { "CHARACTER STRING.identification", &CHARACTER_STRING_identification_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
56 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_abstract_tag_
[] = { { ASN_TAG_CONT
, 0u }};
57 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_abstract_tag_
};
58 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
, NULL
, TTCN_Typedescriptor_t::OBJID
};
60 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_transfer_tag_
[] = { { ASN_TAG_CONT
, 1u }};
61 const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_transfer_tag_
};
62 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
, NULL
, TTCN_Typedescriptor_t::OBJID
};
64 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_tag_
[] = { { ASN_TAG_CONT
, 0u }};
65 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_tag_
};
66 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_descr_
= { "CHARACTER STRING.identification.syntaxes", &CHARACTER_STRING_identification_syntaxes_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
68 static const ASN_Tag_t CHARACTER_STRING_identification_syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
69 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntax_ber_
= { 1u, CHARACTER_STRING_identification_syntax_tag_
};
70 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntax_descr_
= { "CHARACTER STRING.identification.syntax", &CHARACTER_STRING_identification_syntax_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
72 static const ASN_Tag_t CHARACTER_STRING_identification_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 2u }};
73 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_presentation__context__id_tag_
};
74 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
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
76 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 0u }};
77 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
};
78 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
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
80 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
81 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
};
82 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
, NULL
, TTCN_Typedescriptor_t::OBJID
};
84 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_tag_
[] = { { ASN_TAG_CONT
, 3u }};
85 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_tag_
};
86 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
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
88 static const ASN_Tag_t CHARACTER_STRING_identification_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 4u }};
89 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_transfer__syntax_tag_
};
90 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
, NULL
, TTCN_Typedescriptor_t::OBJID
};
92 static const ASN_Tag_t CHARACTER_STRING_identification_fixed_tag_
[] = { { ASN_TAG_CONT
, 5u }};
93 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_fixed_ber_
= { 1u, CHARACTER_STRING_identification_fixed_tag_
};
94 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_fixed_descr_
= { "CHARACTER STRING.identification.fixed", &CHARACTER_STRING_identification_fixed_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
96 static const ASN_Tag_t CHARACTER_STRING_string__value_tag_
[] = { { ASN_TAG_CONT
, 2u }};
97 static const ASN_BERdescriptor_t CHARACTER_STRING_string__value_ber_
= { 1u, CHARACTER_STRING_string__value_tag_
};
98 static const TTCN_Typedescriptor_t CHARACTER_STRING_string__value_descr_
= { "CHARACTER STRING.string-value", &CHARACTER_STRING_string__value_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
100 static const ASN_Tag_t CHARACTER_STRING_data__value__descriptor_tag_
[] = { { ASN_TAG_CONT
, 1u }};
101 static const ASN_BERdescriptor_t CHARACTER_STRING_data__value__descriptor_ber_
= { 1u, CHARACTER_STRING_data__value__descriptor_tag_
};
102 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
, NULL
, TTCN_Typedescriptor_t::GRAPHICSTRING
};
104 void CHARACTER_STRING_identification::clean_up()
106 switch (union_selection
) {
108 delete field_syntaxes
;
113 case ALT_presentation__context__id
:
114 delete field_presentation__context__id
;
116 case ALT_context__negotiation
:
117 delete field_context__negotiation
;
119 case ALT_transfer__syntax
:
120 delete field_transfer__syntax
;
128 union_selection
= UNBOUND_VALUE
;
131 void CHARACTER_STRING_identification::copy_value(const CHARACTER_STRING_identification
& other_value
)
133 switch (other_value
.union_selection
) {
135 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes(*other_value
.field_syntaxes
);
138 field_syntax
= new OBJID(*other_value
.field_syntax
);
140 case ALT_presentation__context__id
:
141 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
143 case ALT_context__negotiation
:
144 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation(*other_value
.field_context__negotiation
);
146 case ALT_transfer__syntax
:
147 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
150 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
153 TTCN_error("Assignment of an unbound union value of type CHARACTER STRING.identification.");
155 union_selection
= other_value
.union_selection
;
158 CHARACTER_STRING_identification::CHARACTER_STRING_identification()
160 union_selection
= UNBOUND_VALUE
;
163 CHARACTER_STRING_identification::CHARACTER_STRING_identification(const CHARACTER_STRING_identification
& other_value
)
164 : Base_Type(other_value
)
166 copy_value(other_value
);
169 CHARACTER_STRING_identification::~CHARACTER_STRING_identification()
174 CHARACTER_STRING_identification
& CHARACTER_STRING_identification::operator=(const CHARACTER_STRING_identification
& other_value
)
176 if (this != &other_value
) {
178 copy_value(other_value
);
183 boolean
CHARACTER_STRING_identification::operator==(const CHARACTER_STRING_identification
& other_value
) const
185 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
186 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
187 if (union_selection
!= other_value
.union_selection
) return FALSE
;
188 switch (union_selection
) {
190 return *field_syntaxes
== *other_value
.field_syntaxes
;
192 return *field_syntax
== *other_value
.field_syntax
;
193 case ALT_presentation__context__id
:
194 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
195 case ALT_context__negotiation
:
196 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
197 case ALT_transfer__syntax
:
198 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
200 return *field_fixed
== *other_value
.field_fixed
;
206 CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes()
208 if (union_selection
!= ALT_syntaxes
) {
210 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
211 union_selection
= ALT_syntaxes
;
213 return *field_syntaxes
;
216 const CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes() const
218 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type CHARACTER STRING.identification.");
219 return *field_syntaxes
;
222 OBJID
& CHARACTER_STRING_identification::syntax()
224 if (union_selection
!= ALT_syntax
) {
226 field_syntax
= new OBJID
;
227 union_selection
= ALT_syntax
;
229 return *field_syntax
;
232 const OBJID
& CHARACTER_STRING_identification::syntax() const
234 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type CHARACTER STRING.identification.");
235 return *field_syntax
;
238 INTEGER
& CHARACTER_STRING_identification::presentation__context__id()
240 if (union_selection
!= ALT_presentation__context__id
) {
242 field_presentation__context__id
= new INTEGER
;
243 union_selection
= ALT_presentation__context__id
;
245 return *field_presentation__context__id
;
248 const INTEGER
& CHARACTER_STRING_identification::presentation__context__id() const
250 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.");
251 return *field_presentation__context__id
;
254 CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation()
256 if (union_selection
!= ALT_context__negotiation
) {
258 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
259 union_selection
= ALT_context__negotiation
;
261 return *field_context__negotiation
;
264 const CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation() const
266 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type CHARACTER STRING.identification.");
267 return *field_context__negotiation
;
270 OBJID
& CHARACTER_STRING_identification::transfer__syntax()
272 if (union_selection
!= ALT_transfer__syntax
) {
274 field_transfer__syntax
= new OBJID
;
275 union_selection
= ALT_transfer__syntax
;
277 return *field_transfer__syntax
;
280 const OBJID
& CHARACTER_STRING_identification::transfer__syntax() const
282 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type CHARACTER STRING.identification.");
283 return *field_transfer__syntax
;
286 ASN_NULL
& CHARACTER_STRING_identification::fixed()
288 if (union_selection
!= ALT_fixed
) {
290 field_fixed
= new ASN_NULL
;
291 union_selection
= ALT_fixed
;
296 const ASN_NULL
& CHARACTER_STRING_identification::fixed() const
298 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type CHARACTER STRING.identification.");
302 boolean
CHARACTER_STRING_identification::ischosen(union_selection_type checked_selection
) const
304 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification.");
305 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type CHARACTER STRING.identification.");
306 return union_selection
== checked_selection
;
309 boolean
CHARACTER_STRING_identification::is_bound() const
311 switch (union_selection
) {
313 return field_syntaxes
->is_bound();
315 return field_syntax
->is_bound();
316 case ALT_presentation__context__id
:
317 return field_presentation__context__id
->is_bound();
318 case ALT_context__negotiation
:
319 return field_context__negotiation
->is_bound();
320 case ALT_transfer__syntax
:
321 return field_transfer__syntax
->is_bound();
323 return field_fixed
->is_bound();
329 boolean
CHARACTER_STRING_identification::is_value() const
331 switch (union_selection
) {
333 return field_syntaxes
->is_value();
335 return field_syntax
->is_value();
336 case ALT_presentation__context__id
:
337 return field_presentation__context__id
->is_value();
338 case ALT_context__negotiation
:
339 return field_context__negotiation
->is_value();
340 case ALT_transfer__syntax
:
341 return field_transfer__syntax
->is_value();
343 return field_fixed
->is_value();
349 void CHARACTER_STRING_identification::log() const
351 switch (union_selection
) {
353 TTCN_Logger::log_event_str("{ syntaxes := ");
354 field_syntaxes
->log();
355 TTCN_Logger::log_event_str(" }");
358 TTCN_Logger::log_event_str("{ syntax := ");
360 TTCN_Logger::log_event_str(" }");
362 case ALT_presentation__context__id
:
363 TTCN_Logger::log_event_str("{ presentation_context_id := ");
364 field_presentation__context__id
->log();
365 TTCN_Logger::log_event_str(" }");
367 case ALT_context__negotiation
:
368 TTCN_Logger::log_event_str("{ context_negotiation := ");
369 field_context__negotiation
->log();
370 TTCN_Logger::log_event_str(" }");
372 case ALT_transfer__syntax
:
373 TTCN_Logger::log_event_str("{ transfer_syntax := ");
374 field_transfer__syntax
->log();
375 TTCN_Logger::log_event_str(" }");
378 TTCN_Logger::log_event_str("{ fixed := ");
380 TTCN_Logger::log_event_str(" }");
383 TTCN_Logger::log_event_str("<unbound>");
388 void CHARACTER_STRING_identification::set_param(Module_Param
& param
)
390 param
.basic_check(Module_Param::BC_VALUE
, "union value");
391 Module_Param_Ptr mp
= ¶m
;
392 if (param
.get_type() == Module_Param::MP_Reference
) {
393 mp
= param
.get_referenced_param();
395 if (mp
->get_type()==Module_Param::MP_Value_List
&& mp
->get_size()==0) return;
396 if (mp
->get_type()!=Module_Param::MP_Assignment_List
) {
397 param
.error("union value with field name was expected");
399 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
400 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
401 syntaxes().set_param(*mp_last
);
404 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
405 syntax().set_param(*mp_last
);
408 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
409 presentation__context__id().set_param(*mp_last
);
412 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
413 context__negotiation().set_param(*mp_last
);
416 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
417 transfer__syntax().set_param(*mp_last
);
420 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
421 fixed().set_param(*mp_last
);
424 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
427 Module_Param
* CHARACTER_STRING_identification::get_param(Module_Param_Name
& param_name
) const
430 return new Module_Param_Unbound();
432 Module_Param
* mp_field
= NULL
;
433 switch(get_selection()) {
435 mp_field
= field_syntaxes
->get_param(param_name
);
436 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
439 mp_field
= field_syntax
->get_param(param_name
);
440 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
442 case ALT_presentation__context__id
:
443 mp_field
= field_presentation__context__id
->get_param(param_name
);
444 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
446 case ALT_context__negotiation
:
447 mp_field
= field_context__negotiation
->get_param(param_name
);
448 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
450 case ALT_transfer__syntax
:
451 mp_field
= field_transfer__syntax
->get_param(param_name
);
452 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
455 mp_field
= field_fixed
->get_param(param_name
);
456 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
461 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
462 mp
->add_elem(mp_field
);
466 void CHARACTER_STRING_identification_template::set_param(Module_Param
& param
)
468 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
469 Module_Param_Ptr mp
= ¶m
;
470 if (param
.get_type() == Module_Param::MP_Reference
) {
471 mp
= param
.get_referenced_param();
473 switch (mp
->get_type()) {
474 case Module_Param::MP_Omit
:
477 case Module_Param::MP_Any
:
480 case Module_Param::MP_AnyOrNone
:
483 case Module_Param::MP_List_Template
:
484 case Module_Param::MP_ComplementList_Template
: {
485 CHARACTER_STRING_identification_template temp
;
486 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
487 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
488 for (size_t i
=0; i
<mp
->get_size(); i
++) {
489 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
493 case Module_Param::MP_Value_List
:
494 if (mp
->get_size()==0) break;
495 param
.type_error("union template", "CHARACTER STRING.identification");
497 case Module_Param::MP_Assignment_List
: {
498 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
499 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
500 syntaxes().set_param(*mp_last
);
503 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
504 syntax().set_param(*mp_last
);
507 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
508 presentation__context__id().set_param(*mp_last
);
511 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
512 context__negotiation().set_param(*mp_last
);
515 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
516 transfer__syntax().set_param(*mp_last
);
519 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
520 fixed().set_param(*mp_last
);
523 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
526 param
.type_error("union template", "CHARACTER STRING.identification");
528 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
531 Module_Param
* CHARACTER_STRING_identification_template::get_param(Module_Param_Name
& param_name
) const
533 Module_Param
* mp
= NULL
;
534 switch (template_selection
) {
535 case UNINITIALIZED_TEMPLATE
:
536 mp
= new Module_Param_Unbound();
539 mp
= new Module_Param_Omit();
542 mp
= new Module_Param_Any();
545 mp
= new Module_Param_AnyOrNone();
547 case SPECIFIC_VALUE
: {
548 Module_Param
* mp_field
= NULL
;
549 switch(single_value
.union_selection
) {
550 case CHARACTER_STRING_identification::ALT_syntaxes
:
551 mp_field
= single_value
.field_syntaxes
->get_param(param_name
);
552 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
554 case CHARACTER_STRING_identification::ALT_syntax
:
555 mp_field
= single_value
.field_syntax
->get_param(param_name
);
556 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
558 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
559 mp_field
= single_value
.field_presentation__context__id
->get_param(param_name
);
560 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
562 case CHARACTER_STRING_identification::ALT_context__negotiation
:
563 mp_field
= single_value
.field_context__negotiation
->get_param(param_name
);
564 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
566 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
567 mp_field
= single_value
.field_transfer__syntax
->get_param(param_name
);
568 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
570 case CHARACTER_STRING_identification::ALT_fixed
:
571 mp_field
= single_value
.field_fixed
->get_param(param_name
);
572 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
577 mp
= new Module_Param_Assignment_List();
578 mp
->add_elem(mp_field
);
581 case COMPLEMENTED_LIST
: {
582 if (template_selection
== VALUE_LIST
) {
583 mp
= new Module_Param_List_Template();
586 mp
= new Module_Param_ComplementList_Template();
588 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
589 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
601 void CHARACTER_STRING_identification::encode_text(Text_Buf
& text_buf
) const
603 text_buf
.push_int(union_selection
);
604 switch (union_selection
) {
606 field_syntaxes
->encode_text(text_buf
);
609 field_syntax
->encode_text(text_buf
);
611 case ALT_presentation__context__id
:
612 field_presentation__context__id
->encode_text(text_buf
);
614 case ALT_context__negotiation
:
615 field_context__negotiation
->encode_text(text_buf
);
617 case ALT_transfer__syntax
:
618 field_transfer__syntax
->encode_text(text_buf
);
621 field_fixed
->encode_text(text_buf
);
624 TTCN_error("Text encoder: Encoding an unbound value of union type CHARACTER STRING.identification.");
628 void CHARACTER_STRING_identification::decode_text(Text_Buf
& text_buf
)
630 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
632 syntaxes().decode_text(text_buf
);
635 syntax().decode_text(text_buf
);
637 case ALT_presentation__context__id
:
638 presentation__context__id().decode_text(text_buf
);
640 case ALT_context__negotiation
:
641 context__negotiation().decode_text(text_buf
);
643 case ALT_transfer__syntax
:
644 transfer__syntax().decode_text(text_buf
);
647 fixed().decode_text(text_buf
);
650 TTCN_error("Text decoder: Unrecognized union selector was received for type CHARACTER STRING.identification.");
655 void CHARACTER_STRING_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
656 void CHARACTER_STRING_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
659 ASN_BER_TLV_t
*CHARACTER_STRING_identification::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
662 ASN_BER_TLV_t
*new_tlv
;
663 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
664 TTCN_EncDec_ErrorContext ec_1
;
665 switch (union_selection
) {
667 ec_1
.set_msg("syntaxes': ");
668 new_tlv
= field_syntaxes
->BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, p_coding
);
671 ec_1
.set_msg("syntax': ");
672 new_tlv
= field_syntax
->BER_encode_TLV(CHARACTER_STRING_identification_syntax_descr_
, p_coding
);
674 case ALT_presentation__context__id
:
675 ec_1
.set_msg("presentation_context_id': ");
676 new_tlv
= field_presentation__context__id
->BER_encode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_coding
);
678 case ALT_context__negotiation
:
679 ec_1
.set_msg("context_negotiation': ");
680 new_tlv
= field_context__negotiation
->BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, p_coding
);
682 case ALT_transfer__syntax
:
683 ec_1
.set_msg("transfer_syntax': ");
684 new_tlv
= field_transfer__syntax
->BER_encode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_coding
);
687 ec_1
.set_msg("fixed': ");
688 new_tlv
= field_fixed
->BER_encode_TLV(CHARACTER_STRING_identification_fixed_descr_
, p_coding
);
691 new_tlv
= BER_encode_chk_bound(FALSE
);
694 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
697 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
700 boolean
CHARACTER_STRING_identification::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
703 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
704 union_selection
= ALT_syntaxes
;
705 if (field_syntaxes
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntaxes_descr_
, p_tlv
)) return TRUE
;
706 delete field_syntaxes
;
707 field_syntax
= new OBJID
;
708 union_selection
= ALT_syntax
;
709 if (field_syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntax_descr_
, p_tlv
)) return TRUE
;
711 field_presentation__context__id
= new INTEGER
;
712 union_selection
= ALT_presentation__context__id
;
713 if (field_presentation__context__id
->BER_decode_isMyMsg(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_tlv
)) return TRUE
;
714 delete field_presentation__context__id
;
715 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
716 union_selection
= ALT_context__negotiation
;
717 if (field_context__negotiation
->BER_decode_isMyMsg(CHARACTER_STRING_identification_context__negotiation_descr_
, p_tlv
)) return TRUE
;
718 delete field_context__negotiation
;
719 field_transfer__syntax
= new OBJID
;
720 union_selection
= ALT_transfer__syntax
;
721 if (field_transfer__syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_tlv
)) return TRUE
;
722 delete field_transfer__syntax
;
723 field_fixed
= new ASN_NULL
;
724 union_selection
= ALT_fixed
;
725 if (field_fixed
->BER_decode_isMyMsg(CHARACTER_STRING_identification_fixed_descr_
, p_tlv
)) return TRUE
;
727 union_selection
= UNBOUND_VALUE
;
731 boolean
CHARACTER_STRING_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
733 if (p_td
.ber
->n_tags
== 0) {
734 CHARACTER_STRING_identification tmp_type
;
735 return tmp_type
.BER_decode_set_selection(p_tlv
);
736 } else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
739 boolean
CHARACTER_STRING_identification::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
742 ASN_BER_TLV_t stripped_tlv
;
743 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
744 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification' type: ");
745 ASN_BER_TLV_t tmp_tlv
;
746 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
;
747 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
748 TTCN_EncDec_ErrorContext ec_2
;
749 switch (union_selection
) {
751 ec_2
.set_msg("syntaxes': ");
752 field_syntaxes
->BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, tmp_tlv
, L_form
);
755 ec_2
.set_msg("syntax': ");
756 field_syntax
->BER_decode_TLV(CHARACTER_STRING_identification_syntax_descr_
, tmp_tlv
, L_form
);
758 case ALT_presentation__context__id
:
759 ec_2
.set_msg("presentation_context_id': ");
760 field_presentation__context__id
->BER_decode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, tmp_tlv
, L_form
);
762 case ALT_context__negotiation
:
763 ec_2
.set_msg("context_negotiation': ");
764 field_context__negotiation
->BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, tmp_tlv
, L_form
);
766 case ALT_transfer__syntax
:
767 ec_2
.set_msg("transfer_syntax': ");
768 field_transfer__syntax
->BER_decode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, tmp_tlv
, L_form
);
771 ec_2
.set_msg("fixed': ");
772 field_fixed
->BER_decode_TLV(CHARACTER_STRING_identification_fixed_descr_
, tmp_tlv
, L_form
);
780 // FIXME maybe: XER_encode and decode is virtually identical to EMBEDDED_PDV
782 int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t
& p_td
,
783 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
785 int encoded_length
=(int)p_buf
.get_len();
787 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
790 switch (union_selection
) {
792 field_syntaxes
->XER_encode(EMBEDDED_PDV_identification_sxs_xer_
, p_buf
, flavor
, indent
, 0);
795 field_syntax
->XER_encode(EMBEDDED_PDV_identification_sx_xer_
, p_buf
, flavor
, indent
, 0);
797 case ALT_presentation__context__id
:
798 field_presentation__context__id
->XER_encode(EMBEDDED_PDV_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
800 case ALT_context__negotiation
:
801 field_context__negotiation
->XER_encode(EMBEDDED_PDV_identification_cn_xer_
, p_buf
, flavor
, indent
, 0);
803 case ALT_transfer__syntax
:
804 field_transfer__syntax
->XER_encode(EMBEDDED_PDV_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
807 field_fixed
->XER_encode(EMBEDDED_PDV_identification_fix_xer_
, p_buf
, flavor
, indent
, 0);
810 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
814 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
816 return (int)p_buf
.get_len() - encoded_length
;
819 int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t
& p_td
,
820 XmlReaderWrap
& reader
, unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
822 int exer
= is_exer(flavor
);
823 // we are supposed to be parked on our element
824 for (int success
= 1; success
== 1; success
= reader
.Read()) {
825 int type
= reader
.NodeType();
827 case XML_READER_TYPE_ELEMENT
: {
828 if (verify_name(reader
, p_td
, exer
)) {
830 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
831 type
= reader
.NodeType();
832 if (XML_READER_TYPE_ELEMENT
== type
) break;
833 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
835 const char *name
= (const char*)reader
.Name();
836 // Avoid chained if-else on strcmp. Use the length as a hash
837 // (thankfully, they are all different).
838 size_t namelen
= strlen(name
);
841 syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_
, reader
, flavor
, flavor2
, 0);
845 syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_
, reader
, flavor
, flavor2
, 0);
848 case 23: // presentation-context-id
849 presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_
, reader
, flavor
, flavor2
, 0);
852 case 19: // context-negotiation
853 context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_
, reader
, flavor
, flavor2
, 0);
856 case 15: // transfer-syntax
857 transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_
, reader
, flavor
, flavor2
, 0);
861 fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_
, reader
, flavor
, flavor2
, 0);
868 else { // it belongs to somebody else
872 case XML_READER_TYPE_END_ELEMENT
: {
873 // advance to the next thing and bail
882 void CHARACTER_STRING_identification_template::clean_up()
884 switch (template_selection
) {
886 switch (single_value
.union_selection
) {
887 case CHARACTER_STRING_identification::ALT_syntaxes
:
888 delete single_value
.field_syntaxes
;
890 case CHARACTER_STRING_identification::ALT_syntax
:
891 delete single_value
.field_syntax
;
893 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
894 delete single_value
.field_presentation__context__id
;
896 case CHARACTER_STRING_identification::ALT_context__negotiation
:
897 delete single_value
.field_context__negotiation
;
899 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
900 delete single_value
.field_transfer__syntax
;
902 case CHARACTER_STRING_identification::ALT_fixed
:
903 delete single_value
.field_fixed
;
910 case COMPLEMENTED_LIST
:
911 delete [] value_list
.list_value
;
916 template_selection
= UNINITIALIZED_TEMPLATE
;
919 void CHARACTER_STRING_identification_template::copy_value(const CHARACTER_STRING_identification
& other_value
)
921 single_value
.union_selection
= other_value
.get_selection();
922 switch (single_value
.union_selection
) {
923 case CHARACTER_STRING_identification::ALT_syntaxes
:
924 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(other_value
.syntaxes());
926 case CHARACTER_STRING_identification::ALT_syntax
:
927 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
929 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
930 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
932 case CHARACTER_STRING_identification::ALT_context__negotiation
:
933 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(other_value
.context__negotiation());
935 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
936 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
938 case CHARACTER_STRING_identification::ALT_fixed
:
939 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
942 TTCN_error("Initializing a template with an unbound value of type CHARACTER STRING.identification.");
944 set_selection(SPECIFIC_VALUE
);
947 void CHARACTER_STRING_identification_template::copy_template(const CHARACTER_STRING_identification_template
& other_value
)
949 switch (other_value
.template_selection
) {
951 single_value
.union_selection
= other_value
.single_value
.union_selection
;
952 switch (single_value
.union_selection
) {
953 case CHARACTER_STRING_identification::ALT_syntaxes
:
954 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
956 case CHARACTER_STRING_identification::ALT_syntax
:
957 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
959 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
960 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
962 case CHARACTER_STRING_identification::ALT_context__negotiation
:
963 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
965 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
966 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
968 case CHARACTER_STRING_identification::ALT_fixed
:
969 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
972 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type CHARACTER STRING.identification.");
980 case COMPLEMENTED_LIST
:
981 value_list
.n_values
= other_value
.value_list
.n_values
;
982 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
983 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
984 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
987 TTCN_error("Copying an uninitialized template of union type CHARACTER STRING.identification.");
989 set_selection(other_value
);
992 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template()
996 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(template_sel other_value
)
997 : Base_Template(other_value
)
999 check_single_selection(other_value
);
1002 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification
& other_value
)
1004 copy_value(other_value
);
1007 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
1009 switch (other_value
.get_selection()) {
1010 case OPTIONAL_PRESENT
:
1011 copy_value((const CHARACTER_STRING_identification
&)other_value
);
1014 set_selection(OMIT_VALUE
);
1017 TTCN_error("Creating a template of union type CHARACTER STRING.identification from an unbound optional field.");
1021 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification_template
& other_value
)
1024 copy_template(other_value
);
1027 CHARACTER_STRING_identification_template::~CHARACTER_STRING_identification_template()
1032 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(template_sel other_value
)
1034 check_single_selection(other_value
);
1036 set_selection(other_value
);
1040 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification
& other_value
)
1043 copy_value(other_value
);
1047 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
1050 switch (other_value
.get_selection()) {
1051 case OPTIONAL_PRESENT
:
1052 copy_value((const CHARACTER_STRING_identification
&)other_value
);
1055 set_selection(OMIT_VALUE
);
1058 TTCN_error("Assignment of an unbound optional field to a template of union type CHARACTER STRING.identification.");
1063 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification_template
& other_value
)
1065 if (&other_value
!= this) {
1067 copy_template(other_value
);
1072 boolean
CHARACTER_STRING_identification_template::match(const CHARACTER_STRING_identification
& other_value
,
1073 boolean
/* legacy */) const
1075 switch (template_selection
) {
1081 case SPECIFIC_VALUE
:
1083 CHARACTER_STRING_identification::union_selection_type value_selection
= other_value
.get_selection();
1084 if (value_selection
== CHARACTER_STRING_identification::UNBOUND_VALUE
) return FALSE
;
1085 if (value_selection
!= single_value
.union_selection
) return FALSE
;
1086 switch (value_selection
) {
1087 case CHARACTER_STRING_identification::ALT_syntaxes
:
1088 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
1089 case CHARACTER_STRING_identification::ALT_syntax
:
1090 return single_value
.field_syntax
->match(other_value
.syntax());
1091 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1092 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
1093 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1094 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
1095 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1096 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
1097 case CHARACTER_STRING_identification::ALT_fixed
:
1098 return single_value
.field_fixed
->match(other_value
.fixed());
1100 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type CHARACTER STRING.identification.");
1104 case COMPLEMENTED_LIST
:
1105 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1106 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1107 return template_selection
== COMPLEMENTED_LIST
;
1109 TTCN_error ("Matching an uninitialized template of union type CHARACTER STRING.identification.");
1114 CHARACTER_STRING_identification
CHARACTER_STRING_identification_template::valueof() const
1116 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1117 TTCN_error("Performing valueof or send operation on a non-specific template of union type CHARACTER STRING.identification.");
1118 CHARACTER_STRING_identification ret_val
;
1119 switch (single_value
.union_selection
) {
1120 case CHARACTER_STRING_identification::ALT_syntaxes
:
1121 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
1123 case CHARACTER_STRING_identification::ALT_syntax
:
1124 ret_val
.syntax() = single_value
.field_syntax
->valueof();
1126 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1127 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
1129 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1130 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
1132 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1133 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1135 case CHARACTER_STRING_identification::ALT_fixed
:
1136 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1139 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type CHARACTER STRING.identification.");
1144 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::list_item(unsigned int list_index
) const
1146 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.");
1147 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type CHARACTER STRING.identification.");
1148 return value_list
.list_value
[list_index
];
1150 void CHARACTER_STRING_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1152 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.");
1154 set_selection(template_type
);
1155 value_list
.n_values
= list_length
;
1156 value_list
.list_value
= new CHARACTER_STRING_identification_template
[list_length
];
1159 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes()
1161 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntaxes
) {
1162 template_sel old_selection
= template_selection
;
1164 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(ANY_VALUE
);
1165 else single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1166 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntaxes
;
1167 set_selection(SPECIFIC_VALUE
);
1169 return *single_value
.field_syntaxes
;
1172 const CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes() const
1174 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type CHARACTER STRING.identification.");
1175 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.");
1176 return *single_value
.field_syntaxes
;
1179 OBJID_template
& CHARACTER_STRING_identification_template::syntax()
1181 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntax
) {
1182 template_sel old_selection
= template_selection
;
1184 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1185 else single_value
.field_syntax
= new OBJID_template
;
1186 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntax
;
1187 set_selection(SPECIFIC_VALUE
);
1189 return *single_value
.field_syntax
;
1192 const OBJID_template
& CHARACTER_STRING_identification_template::syntax() const
1194 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type CHARACTER STRING.identification.");
1195 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.");
1196 return *single_value
.field_syntax
;
1199 INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id()
1201 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_presentation__context__id
) {
1202 template_sel old_selection
= template_selection
;
1204 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1205 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1206 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_presentation__context__id
;
1207 set_selection(SPECIFIC_VALUE
);
1209 return *single_value
.field_presentation__context__id
;
1212 const INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id() const
1214 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type CHARACTER STRING.identification.");
1215 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.");
1216 return *single_value
.field_presentation__context__id
;
1219 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation()
1221 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_context__negotiation
) {
1222 template_sel old_selection
= template_selection
;
1224 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(ANY_VALUE
);
1225 else single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1226 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_context__negotiation
;
1227 set_selection(SPECIFIC_VALUE
);
1229 return *single_value
.field_context__negotiation
;
1232 const CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation() const
1234 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type CHARACTER STRING.identification.");
1235 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.");
1236 return *single_value
.field_context__negotiation
;
1239 OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax()
1241 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_transfer__syntax
) {
1242 template_sel old_selection
= template_selection
;
1244 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1245 else single_value
.field_transfer__syntax
= new OBJID_template
;
1246 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_transfer__syntax
;
1247 set_selection(SPECIFIC_VALUE
);
1249 return *single_value
.field_transfer__syntax
;
1252 const OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax() const
1254 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type CHARACTER STRING.identification.");
1255 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.");
1256 return *single_value
.field_transfer__syntax
;
1259 ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed()
1261 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_fixed
) {
1262 template_sel old_selection
= template_selection
;
1264 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1265 else single_value
.field_fixed
= new ASN_NULL_template
;
1266 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_fixed
;
1267 set_selection(SPECIFIC_VALUE
);
1269 return *single_value
.field_fixed
;
1272 const ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed() const
1274 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type CHARACTER STRING.identification.");
1275 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.");
1276 return *single_value
.field_fixed
;
1279 boolean
CHARACTER_STRING_identification_template::ischosen(CHARACTER_STRING_identification::union_selection_type checked_selection
) const
1281 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.");
1282 switch (template_selection
) {
1283 case SPECIFIC_VALUE
:
1284 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.");
1285 return single_value
.union_selection
== checked_selection
;
1288 if (value_list
.n_values
< 1)
1289 TTCN_error("Internal error: Performing ischosen() operation on a template of union type CHARACTER STRING.identification containing an empty list.");
1290 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1291 boolean all_same
= TRUE
;
1292 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1293 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1298 if (all_same
) return ret_val
;
1300 // FIXME really no break?
1304 case COMPLEMENTED_LIST
:
1305 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.");
1307 TTCN_error("Performing ischosen() operation on an uninitialized template of union type CHARACTER STRING.identification");
1312 void CHARACTER_STRING_identification_template::log() const
1314 switch (template_selection
) {
1315 case SPECIFIC_VALUE
:
1316 switch (single_value
.union_selection
) {
1317 case CHARACTER_STRING_identification::ALT_syntaxes
:
1318 TTCN_Logger::log_event_str("{ syntaxes := ");
1319 single_value
.field_syntaxes
->log();
1320 TTCN_Logger::log_event_str(" }");
1322 case CHARACTER_STRING_identification::ALT_syntax
:
1323 TTCN_Logger::log_event_str("{ syntax := ");
1324 single_value
.field_syntax
->log();
1325 TTCN_Logger::log_event_str(" }");
1327 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1328 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1329 single_value
.field_presentation__context__id
->log();
1330 TTCN_Logger::log_event_str(" }");
1332 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1333 TTCN_Logger::log_event_str("{ context_negotiation := ");
1334 single_value
.field_context__negotiation
->log();
1335 TTCN_Logger::log_event_str(" }");
1337 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1338 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1339 single_value
.field_transfer__syntax
->log();
1340 TTCN_Logger::log_event_str(" }");
1342 case CHARACTER_STRING_identification::ALT_fixed
:
1343 TTCN_Logger::log_event_str("{ fixed := ");
1344 single_value
.field_fixed
->log();
1345 TTCN_Logger::log_event_str(" }");
1348 TTCN_Logger::log_event_str("<invalid selector>");
1352 case COMPLEMENTED_LIST
:
1353 TTCN_Logger::log_event_str("complement ");
1356 TTCN_Logger::log_char('(');
1357 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1358 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1359 value_list
.list_value
[list_count
].log();
1361 TTCN_Logger::log_char(')');
1370 void CHARACTER_STRING_identification_template::log_match(const CHARACTER_STRING_identification
& match_value
,
1371 boolean
/* legacy */) const
1373 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1374 if(match(match_value
)){
1375 TTCN_Logger::print_logmatch_buffer();
1376 TTCN_Logger::log_event_str(" matched ");
1380 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1381 switch (single_value
.union_selection
) {
1382 case CHARACTER_STRING_identification::ALT_syntaxes
:
1383 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1384 TTCN_Logger::log_logmatch_info(".syntaxes");
1385 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1387 TTCN_Logger::log_event_str("{ syntaxes := ");
1388 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1389 TTCN_Logger::log_event_str(" }");
1392 case CHARACTER_STRING_identification::ALT_syntax
:
1393 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1394 TTCN_Logger::log_logmatch_info(".syntax");
1395 single_value
.field_syntax
->log_match(match_value
.syntax());
1397 TTCN_Logger::log_event_str("{ syntax := ");
1398 single_value
.field_syntax
->log_match(match_value
.syntax());
1399 TTCN_Logger::log_event_str(" }");
1402 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1403 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1404 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1405 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1407 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1408 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1409 TTCN_Logger::log_event_str(" }");
1412 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1413 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1414 TTCN_Logger::log_logmatch_info(".context_negotiation");
1415 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1417 TTCN_Logger::log_event_str("{ context_negotiation := ");
1418 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1419 TTCN_Logger::log_event_str(" }");
1422 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1423 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1424 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1425 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1427 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1428 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1429 TTCN_Logger::log_event_str(" }");
1432 case CHARACTER_STRING_identification::ALT_fixed
:
1433 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1434 TTCN_Logger::log_logmatch_info(".fixed");
1435 single_value
.field_fixed
->log_match(match_value
.fixed());
1437 TTCN_Logger::log_event_str("{ fixed := ");
1438 single_value
.field_fixed
->log_match(match_value
.fixed());
1439 TTCN_Logger::log_event_str(" }");
1443 TTCN_Logger::print_logmatch_buffer();
1444 TTCN_Logger::log_event_str("<invalid selector>");
1448 TTCN_Logger::print_logmatch_buffer();
1450 TTCN_Logger::log_event_str(" with ");
1452 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1453 else TTCN_Logger::log_event_str(" unmatched");
1457 void CHARACTER_STRING_identification_template::encode_text(Text_Buf
& text_buf
) const
1459 encode_text_base(text_buf
);
1460 switch (template_selection
) {
1461 case SPECIFIC_VALUE
:
1462 text_buf
.push_int(single_value
.union_selection
);
1463 switch (single_value
.union_selection
) {
1464 case CHARACTER_STRING_identification::ALT_syntaxes
:
1465 single_value
.field_syntaxes
->encode_text(text_buf
);
1467 case CHARACTER_STRING_identification::ALT_syntax
:
1468 single_value
.field_syntax
->encode_text(text_buf
);
1470 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1471 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1473 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1474 single_value
.field_context__negotiation
->encode_text(text_buf
);
1476 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1477 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1479 case CHARACTER_STRING_identification::ALT_fixed
:
1480 single_value
.field_fixed
->encode_text(text_buf
);
1483 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type CHARACTER STRING.identification.");
1491 case COMPLEMENTED_LIST
:
1492 text_buf
.push_int(value_list
.n_values
);
1493 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1494 value_list
.list_value
[list_count
].encode_text(text_buf
);
1497 TTCN_error("Text encoder: Encoding an uninitialized template of type CHARACTER STRING.identification.");
1501 void CHARACTER_STRING_identification_template::decode_text(Text_Buf
& text_buf
)
1504 decode_text_base(text_buf
);
1505 switch (template_selection
) {
1506 case SPECIFIC_VALUE
:
1508 single_value
.union_selection
= CHARACTER_STRING_identification::UNBOUND_VALUE
;
1509 CHARACTER_STRING_identification::union_selection_type new_selection
= (CHARACTER_STRING_identification::union_selection_type
)text_buf
.pull_int().get_val();
1510 switch (new_selection
) {
1511 case CHARACTER_STRING_identification::ALT_syntaxes
:
1512 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1513 single_value
.field_syntaxes
->decode_text(text_buf
);
1515 case CHARACTER_STRING_identification::ALT_syntax
:
1516 single_value
.field_syntax
= new OBJID_template
;
1517 single_value
.field_syntax
->decode_text(text_buf
);
1519 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1520 single_value
.field_presentation__context__id
= new INTEGER_template
;
1521 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1523 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1524 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1525 single_value
.field_context__negotiation
->decode_text(text_buf
);
1527 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1528 single_value
.field_transfer__syntax
= new OBJID_template
;
1529 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1531 case CHARACTER_STRING_identification::ALT_fixed
:
1532 single_value
.field_fixed
= new ASN_NULL_template
;
1533 single_value
.field_fixed
->decode_text(text_buf
);
1536 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type CHARACTER STRING.identification.");
1538 single_value
.union_selection
= new_selection
;
1546 case COMPLEMENTED_LIST
:
1547 value_list
.n_values
= text_buf
.pull_int().get_val();
1548 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
1549 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1550 value_list
.list_value
[list_count
].decode_text(text_buf
);
1553 TTCN_error("Text decoder: Unrecognized selector was received in a template of type CHARACTER STRING.identification.");
1557 boolean
CHARACTER_STRING_identification_template::is_present(boolean legacy
/* = FALSE */) const
1559 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1560 return !match_omit(legacy
);
1563 boolean
CHARACTER_STRING_identification_template::match_omit(boolean legacy
/* = FALSE */) const
1565 if (is_ifpresent
) return TRUE
;
1566 switch (template_selection
) {
1571 case COMPLEMENTED_LIST
:
1573 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1574 if (value_list
.list_value
[i
].match_omit())
1575 return template_selection
==VALUE_LIST
;
1576 return template_selection
==COMPLEMENTED_LIST
;
1577 } // else fall through
1584 #ifndef TITAN_RUNTIME_2
1585 void CHARACTER_STRING_identification_template::check_restriction(template_res t_res
, const char* t_name
,
1586 boolean legacy
/* = FALSE */) const
1588 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1589 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1591 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1594 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1595 template_selection
==SPECIFIC_VALUE
)) return;
1598 if (!match_omit(legacy
)) return;
1603 TTCN_error("Restriction `%s' on template of type %s violated.",
1604 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification");
1608 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes()
1612 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes(const OBJID
& par_abstract
,
1613 const OBJID
& par_transfer
)
1614 : field_abstract(par_abstract
),
1615 field_transfer(par_transfer
)
1619 boolean
CHARACTER_STRING_identification_syntaxes::operator==(const CHARACTER_STRING_identification_syntaxes
& other_value
) const
1621 return field_abstract
==other_value
.field_abstract
1622 && field_transfer
==other_value
.field_transfer
;
1625 int CHARACTER_STRING_identification_syntaxes::size_of() const
1631 void CHARACTER_STRING_identification_syntaxes::log() const
1633 TTCN_Logger::log_event_str("{ abstract := ");
1634 field_abstract
.log();
1635 TTCN_Logger::log_event_str(", transfer := ");
1636 field_transfer
.log();
1637 TTCN_Logger::log_event_str(" }");
1640 boolean
CHARACTER_STRING_identification_syntaxes::is_bound() const
1642 if(field_abstract
.is_bound()) return TRUE
;
1643 if(field_transfer
.is_bound()) return TRUE
;
1647 boolean
CHARACTER_STRING_identification_syntaxes::is_value() const
1649 if(!field_abstract
.is_value()) return FALSE
;
1650 if(!field_transfer
.is_value()) return FALSE
;
1654 void CHARACTER_STRING_identification_syntaxes::clean_up()
1656 field_abstract
.clean_up();
1657 field_transfer
.clean_up();
1660 void CHARACTER_STRING_identification_syntaxes::set_param(Module_Param
& param
)
1662 param
.basic_check(Module_Param::BC_VALUE
, "record value");
1663 Module_Param_Ptr mp
= ¶m
;
1664 if (param
.get_type() == Module_Param::MP_Reference
) {
1665 mp
= param
.get_referenced_param();
1667 switch (mp
->get_type()) {
1668 case Module_Param::MP_Value_List
:
1669 if (mp
->get_size()==0) return;
1670 if (2!=mp
->get_size()) {
1671 param
.error("record value of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
1673 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
1674 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
1676 case Module_Param::MP_Assignment_List
: {
1677 Vector
<bool> value_used(mp
->get_size());
1678 value_used
.resize(mp
->get_size(), false);
1679 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1680 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1681 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1682 abstract().set_param(*curr_param
);
1683 value_used
[val_idx
]=true;
1686 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1687 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1688 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1689 transfer().set_param(*curr_param
);
1690 value_used
[val_idx
]=true;
1693 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1694 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
1699 param
.type_error("record value", "CHARACTER STRING.identification.syntaxes");
1703 Module_Param
* CHARACTER_STRING_identification_syntaxes::get_param(Module_Param_Name
& param_name
) const
1706 return new Module_Param_Unbound();
1708 Module_Param
* mp_field_abstract
= field_abstract
.get_param(param_name
);
1709 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
1710 Module_Param
* mp_field_transfer
= field_transfer
.get_param(param_name
);
1711 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
1712 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
1713 mp
->add_elem(mp_field_abstract
);
1714 mp
->add_elem(mp_field_transfer
);
1718 void CHARACTER_STRING_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
1720 field_abstract
.encode_text(text_buf
);
1721 field_transfer
.encode_text(text_buf
);
1724 void CHARACTER_STRING_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
1726 field_abstract
.decode_text(text_buf
);
1727 field_transfer
.decode_text(text_buf
);
1731 void CHARACTER_STRING_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
1732 void CHARACTER_STRING_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
1735 ASN_BER_TLV_t
* CHARACTER_STRING_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
1737 BER_chk_descr(p_td
);
1738 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
1739 TTCN_EncDec_ErrorContext
ec_0("Component '");
1740 TTCN_EncDec_ErrorContext ec_1
;
1741 ec_1
.set_msg("abstract': ");
1742 new_tlv
->add_TLV(field_abstract
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, p_coding
));
1743 ec_1
.set_msg("transfer': ");
1744 new_tlv
->add_TLV(field_transfer
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, p_coding
));
1745 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
1749 boolean
CHARACTER_STRING_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
1751 BER_chk_descr(p_td
);
1752 ASN_BER_TLV_t stripped_tlv
;
1753 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
1754 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.syntaxes' type: ");
1755 stripped_tlv
.chk_constructed_flag(TRUE
);
1757 ASN_BER_TLV_t tmp_tlv
;
1758 boolean tlv_present
=FALSE
;
1760 TTCN_EncDec_ErrorContext
ec_1("Component '");
1761 TTCN_EncDec_ErrorContext ec_2
;
1762 ec_2
.set_msg("abstract': ");
1763 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1764 if(!tlv_present
) return FALSE
;
1765 field_abstract
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, tmp_tlv
, L_form
);
1767 ec_2
.set_msg("transfer': ");
1768 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1769 if(!tlv_present
) return FALSE
;
1770 field_transfer
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, tmp_tlv
, L_form
);
1773 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
1777 int CHARACTER_STRING_identification_syntaxes::XER_encode(const XERdescriptor_t
& p_td
,
1778 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
1780 int encoded_length
=(int)p_buf
.get_len();
1782 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
1784 field_abstract
.XER_encode(CHARACTER_STRING_identification_sxs_abs_xer_
, p_buf
, flavor
, indent
, 0);
1785 field_transfer
.XER_encode(CHARACTER_STRING_identification_sxs_xfr_xer_
, p_buf
, flavor
, indent
, 0);
1787 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
1789 return p_buf
.get_len() - encoded_length
;
1792 int CHARACTER_STRING_identification_syntaxes::XER_decode(
1793 const XERdescriptor_t
& /*p_td*/, XmlReaderWrap
& reader
, unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
1794 { // we stand on <syntaxes>, move ahead first
1795 for (int success
= reader
.Read(); success
== 1; success
= reader
.Read())
1797 int type
= reader
.NodeType();
1798 if (XML_READER_TYPE_ELEMENT
== type
)
1799 // no verify_name for a CHOICE
1802 // FIXME this assumes the right element
1803 field_abstract
.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_
, reader
, flavor
, flavor2
, 0);
1804 field_transfer
.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_
, reader
, flavor
, flavor2
, 0);
1805 for (int success
= 1; success
== 1; success
= reader
.Read())
1807 int type
= reader
.NodeType();
1808 if (XML_READER_TYPE_END_ELEMENT
== type
)
1811 return 0; // TODO maybe return proper value
1815 struct CHARACTER_STRING_identification_syntaxes_template::single_value_struct
{
1816 OBJID_template field_abstract
;
1817 OBJID_template field_transfer
;
1820 void CHARACTER_STRING_identification_syntaxes_template::set_param(Module_Param
& param
)
1822 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
1823 Module_Param_Ptr mp
= ¶m
;
1824 if (param
.get_type() == Module_Param::MP_Reference
) {
1825 mp
= param
.get_referenced_param();
1827 switch (mp
->get_type()) {
1828 case Module_Param::MP_Omit
:
1831 case Module_Param::MP_Any
:
1834 case Module_Param::MP_AnyOrNone
:
1835 *this = ANY_OR_OMIT
;
1837 case Module_Param::MP_List_Template
:
1838 case Module_Param::MP_ComplementList_Template
: {
1839 CHARACTER_STRING_identification_syntaxes_template temp
;
1840 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
1841 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
1842 for (size_t i
=0; i
<mp
->get_size(); i
++) {
1843 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
1847 case Module_Param::MP_Value_List
:
1848 if (mp
->get_size()==0) break;
1849 if (2!=mp
->get_size()) {
1850 param
.error("record template of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
1852 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
1853 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
1855 case Module_Param::MP_Assignment_List
: {
1856 Vector
<bool> value_used(mp
->get_size());
1857 value_used
.resize(mp
->get_size(), false);
1858 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1859 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1860 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1861 abstract().set_param(*curr_param
);
1862 value_used
[val_idx
]=true;
1865 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1866 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1867 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1868 transfer().set_param(*curr_param
);
1869 value_used
[val_idx
]=true;
1872 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1873 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
1878 param
.type_error("record template", "CHARACTER STRING.identification.syntaxes");
1880 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
1883 Module_Param
* CHARACTER_STRING_identification_syntaxes_template::get_param(Module_Param_Name
& param_name
) const
1885 Module_Param
* mp
= NULL
;
1886 switch (template_selection
) {
1887 case UNINITIALIZED_TEMPLATE
:
1888 mp
= new Module_Param_Unbound();
1891 mp
= new Module_Param_Omit();
1894 mp
= new Module_Param_Any();
1897 mp
= new Module_Param_AnyOrNone();
1899 case SPECIFIC_VALUE
: {
1900 Module_Param
* mp_field_abstract
= single_value
->field_abstract
.get_param(param_name
);
1901 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
1902 Module_Param
* mp_field_transfer
= single_value
->field_transfer
.get_param(param_name
);
1903 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
1904 mp
= new Module_Param_Assignment_List();
1905 mp
->add_elem(mp_field_abstract
);
1906 mp
->add_elem(mp_field_transfer
);
1909 case COMPLEMENTED_LIST
: {
1910 if (template_selection
== VALUE_LIST
) {
1911 mp
= new Module_Param_List_Template();
1914 mp
= new Module_Param_ComplementList_Template();
1916 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
1917 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
1924 mp
->set_ifpresent();
1929 void CHARACTER_STRING_identification_syntaxes_template::clean_up()
1931 switch (template_selection
) {
1932 case SPECIFIC_VALUE
:
1933 delete single_value
;
1936 case COMPLEMENTED_LIST
:
1937 delete [] value_list
.list_value
;
1942 template_selection
= UNINITIALIZED_TEMPLATE
;
1945 void CHARACTER_STRING_identification_syntaxes_template::set_specific()
1947 if (template_selection
!= SPECIFIC_VALUE
) {
1948 template_sel old_selection
= template_selection
;
1950 single_value
= new single_value_struct
;
1951 set_selection(SPECIFIC_VALUE
);
1952 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
1953 single_value
->field_abstract
= ANY_VALUE
;
1954 single_value
->field_transfer
= ANY_VALUE
;
1959 void CHARACTER_STRING_identification_syntaxes_template::copy_value(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1961 single_value
= new single_value_struct
;
1962 single_value
->field_abstract
= other_value
.abstract();
1963 single_value
->field_transfer
= other_value
.transfer();
1964 set_selection(SPECIFIC_VALUE
);
1967 void CHARACTER_STRING_identification_syntaxes_template::copy_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
1969 switch (other_value
.template_selection
) {
1970 case SPECIFIC_VALUE
:
1971 single_value
= new single_value_struct(*other_value
.single_value
);
1978 case COMPLEMENTED_LIST
:
1979 value_list
.n_values
= other_value
.value_list
.n_values
;
1980 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
1981 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1982 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1985 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
1987 set_selection(other_value
);
1990 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template()
1994 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(template_sel other_value
)
1995 : Base_Template(other_value
)
1997 check_single_selection(other_value
);
2000 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes
& other_value
)
2002 copy_value(other_value
);
2005 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
2007 switch (other_value
.get_selection()) {
2008 case OPTIONAL_PRESENT
:
2009 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
2012 set_selection(OMIT_VALUE
);
2015 TTCN_error("Creating a template of type CHARACTER STRING.identification.syntaxes from an unbound optional field.");
2019 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
2022 copy_template(other_value
);
2025 CHARACTER_STRING_identification_syntaxes_template::~CHARACTER_STRING_identification_syntaxes_template()
2030 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(template_sel other_value
)
2032 check_single_selection(other_value
);
2034 set_selection(other_value
);
2038 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes
& other_value
)
2041 copy_value(other_value
);
2045 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
2048 switch (other_value
.get_selection()) {
2049 case OPTIONAL_PRESENT
:
2050 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
2053 set_selection(OMIT_VALUE
);
2056 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.syntaxes.");
2061 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
2063 if (&other_value
!= this) {
2065 copy_template(other_value
);
2070 boolean
CHARACTER_STRING_identification_syntaxes_template::match(const CHARACTER_STRING_identification_syntaxes
& other_value
,
2071 boolean
/* legacy */) const
2073 switch (template_selection
) {
2079 case SPECIFIC_VALUE
:
2080 if (!other_value
.abstract().is_bound()) return FALSE
;
2081 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
2082 if (!other_value
.transfer().is_bound()) return FALSE
;
2083 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
2086 case COMPLEMENTED_LIST
:
2087 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2088 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2089 return template_selection
== COMPLEMENTED_LIST
;
2091 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2096 CHARACTER_STRING_identification_syntaxes
CHARACTER_STRING_identification_syntaxes_template::valueof() const
2098 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2099 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2100 CHARACTER_STRING_identification_syntaxes ret_val
;
2101 ret_val
.abstract() = single_value
->field_abstract
.valueof();
2102 ret_val
.transfer() = single_value
->field_transfer
.valueof();
2106 void CHARACTER_STRING_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
2108 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2109 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.syntaxes.");
2111 set_selection(template_type
);
2112 value_list
.n_values
= list_length
;
2113 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[list_length
];
2116 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::list_item(unsigned int list_index
) const
2118 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2119 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.syntaxes.");
2120 if (list_index
>= value_list
.n_values
)
2121 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.syntaxes.");
2122 return value_list
.list_value
[list_index
];
2125 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract()
2128 return single_value
->field_abstract
;
2131 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract() const
2133 if (template_selection
!= SPECIFIC_VALUE
)
2134 TTCN_error("Accessing field abstract of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2135 return single_value
->field_abstract
;
2138 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer()
2141 return single_value
->field_transfer
;
2144 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer() const
2146 if (template_selection
!= SPECIFIC_VALUE
)
2147 TTCN_error("Accessing field transfer of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2148 return single_value
->field_transfer
;
2151 int CHARACTER_STRING_identification_syntaxes_template::size_of() const
2153 switch (template_selection
)
2155 case SPECIFIC_VALUE
:
2162 if (value_list
.n_values
<1)
2163 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing an empty list.");
2164 int item_size
= value_list
.list_value
[0].size_of();
2165 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2167 if (value_list
.list_value
[i
].size_of()!=item_size
)
2168 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing a value list with different sizes.");
2173 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing omit value.");
2176 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing */? value.");
2177 case COMPLEMENTED_LIST
:
2178 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing complemented list.");
2180 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2185 void CHARACTER_STRING_identification_syntaxes_template::log() const
2187 switch (template_selection
) {
2188 case SPECIFIC_VALUE
:
2189 TTCN_Logger::log_event_str("{ abstract := ");
2190 single_value
->field_abstract
.log();
2191 TTCN_Logger::log_event_str(", transfer := ");
2192 single_value
->field_transfer
.log();
2193 TTCN_Logger::log_event_str(" }");
2195 case COMPLEMENTED_LIST
:
2196 TTCN_Logger::log_event_str("complement ");
2199 TTCN_Logger::log_char('(');
2200 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2201 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2202 value_list
.list_value
[list_count
].log();
2204 TTCN_Logger::log_char(')');
2213 void CHARACTER_STRING_identification_syntaxes_template::log_match(const CHARACTER_STRING_identification_syntaxes
& match_value
,
2214 boolean
/* legacy */) const
2216 if (template_selection
== SPECIFIC_VALUE
) {
2217 TTCN_Logger::log_event_str("{ abstract := ");
2218 single_value
->field_abstract
.log_match(match_value
.abstract());
2219 TTCN_Logger::log_event_str(", transfer := ");
2220 single_value
->field_transfer
.log_match(match_value
.transfer());
2221 TTCN_Logger::log_event_str(" }");
2224 TTCN_Logger::log_event_str(" with ");
2226 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2227 else TTCN_Logger::log_event_str(" unmatched");
2231 void CHARACTER_STRING_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2233 encode_text_base(text_buf
);
2234 switch (template_selection
) {
2235 case SPECIFIC_VALUE
:
2236 single_value
->field_abstract
.encode_text(text_buf
);
2237 single_value
->field_transfer
.encode_text(text_buf
);
2244 case COMPLEMENTED_LIST
:
2245 text_buf
.push_int(value_list
.n_values
);
2246 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2247 value_list
.list_value
[list_count
].encode_text(text_buf
);
2250 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2254 void CHARACTER_STRING_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2257 decode_text_base(text_buf
);
2258 switch (template_selection
) {
2259 case SPECIFIC_VALUE
:
2260 single_value
= new single_value_struct
;
2261 single_value
->field_abstract
.decode_text(text_buf
);
2262 single_value
->field_transfer
.decode_text(text_buf
);
2269 case COMPLEMENTED_LIST
:
2270 value_list
.n_values
= text_buf
.pull_int().get_val();
2271 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
2272 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2273 value_list
.list_value
[list_count
].decode_text(text_buf
);
2276 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.syntaxes.");
2280 boolean
CHARACTER_STRING_identification_syntaxes_template::is_present(boolean legacy
/* = FALSE */) const
2282 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2283 return !match_omit(legacy
);
2286 boolean
CHARACTER_STRING_identification_syntaxes_template::match_omit(boolean legacy
/* = FALSE */) const
2288 if (is_ifpresent
) return TRUE
;
2289 switch (template_selection
) {
2294 case COMPLEMENTED_LIST
:
2296 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2297 if (value_list
.list_value
[i
].match_omit())
2298 return template_selection
==VALUE_LIST
;
2299 return template_selection
==COMPLEMENTED_LIST
;
2300 } // else fall through
2307 #ifndef TITAN_RUNTIME_2
2308 void CHARACTER_STRING_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
,
2309 boolean legacy
/* = FALSE */) const
2311 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2312 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2314 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2317 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2318 template_selection
==SPECIFIC_VALUE
)) return;
2321 if (!match_omit(legacy
)) return;
2326 TTCN_error("Restriction `%s' on template of type %s violated.",
2327 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.syntaxes");
2331 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation()
2335 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2336 const OBJID
& par_transfer__syntax
)
2337 : field_presentation__context__id(par_presentation__context__id
),
2338 field_transfer__syntax(par_transfer__syntax
)
2342 boolean
CHARACTER_STRING_identification_context__negotiation::operator==(const CHARACTER_STRING_identification_context__negotiation
& other_value
) const
2344 return field_presentation__context__id
==other_value
.field_presentation__context__id
2345 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2348 int CHARACTER_STRING_identification_context__negotiation::size_of() const
2354 void CHARACTER_STRING_identification_context__negotiation::log() const
2356 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2357 field_presentation__context__id
.log();
2358 TTCN_Logger::log_event_str(", transfer_syntax := ");
2359 field_transfer__syntax
.log();
2360 TTCN_Logger::log_event_str(" }");
2363 boolean
CHARACTER_STRING_identification_context__negotiation::is_bound() const
2365 if(field_presentation__context__id
.is_bound()) return TRUE
;
2366 if(field_transfer__syntax
.is_bound()) return TRUE
;
2370 boolean
CHARACTER_STRING_identification_context__negotiation::is_value() const
2372 if(!field_presentation__context__id
.is_value()) return FALSE
;
2373 if(!field_transfer__syntax
.is_value()) return FALSE
;
2377 void CHARACTER_STRING_identification_context__negotiation::clean_up()
2379 field_presentation__context__id
.clean_up();
2380 field_transfer__syntax
.clean_up();
2383 void CHARACTER_STRING_identification_context__negotiation::set_param(Module_Param
& param
)
2385 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2386 Module_Param_Ptr mp
= ¶m
;
2387 if (param
.get_type() == Module_Param::MP_Reference
) {
2388 mp
= param
.get_referenced_param();
2390 switch (mp
->get_type()) {
2391 case Module_Param::MP_Value_List
:
2392 if (mp
->get_size()==0) return;
2393 if (2!=mp
->get_size()) {
2394 param
.error("record value of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2396 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2397 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2399 case Module_Param::MP_Assignment_List
: {
2400 Vector
<bool> value_used(mp
->get_size());
2401 value_used
.resize(mp
->get_size(), false);
2402 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2403 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2404 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2405 presentation__context__id().set_param(*curr_param
);
2406 value_used
[val_idx
]=true;
2409 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2410 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2411 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2412 transfer__syntax().set_param(*curr_param
);
2413 value_used
[val_idx
]=true;
2416 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2417 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2422 param
.type_error("record value", "CHARACTER STRING.identification.context-negotiation");
2426 Module_Param
* CHARACTER_STRING_identification_context__negotiation::get_param(Module_Param_Name
& param_name
) const
2429 return new Module_Param_Unbound();
2431 Module_Param
* mp_field_presentation_context_id
= field_presentation__context__id
.get_param(param_name
);
2432 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2433 Module_Param
* mp_field_transfer_syntax
= field_transfer__syntax
.get_param(param_name
);
2434 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2435 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2436 mp
->add_elem(mp_field_presentation_context_id
);
2437 mp
->add_elem(mp_field_transfer_syntax
);
2441 void CHARACTER_STRING_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2443 field_presentation__context__id
.encode_text(text_buf
);
2444 field_transfer__syntax
.encode_text(text_buf
);
2447 void CHARACTER_STRING_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2449 field_presentation__context__id
.decode_text(text_buf
);
2450 field_transfer__syntax
.decode_text(text_buf
);
2454 void CHARACTER_STRING_identification_context__negotiation::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
2455 void CHARACTER_STRING_identification_context__negotiation::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
2458 ASN_BER_TLV_t
* CHARACTER_STRING_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
2460 BER_chk_descr(p_td
);
2461 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
2462 TTCN_EncDec_ErrorContext
ec_0("Component '");
2463 TTCN_EncDec_ErrorContext ec_1
;
2464 ec_1
.set_msg("presentation_context_id': ");
2465 new_tlv
->add_TLV(field_presentation__context__id
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, p_coding
));
2466 ec_1
.set_msg("transfer_syntax': ");
2467 new_tlv
->add_TLV(field_transfer__syntax
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, p_coding
));
2468 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
2472 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
)
2474 BER_chk_descr(p_td
);
2475 ASN_BER_TLV_t stripped_tlv
;
2476 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
2477 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.context-negotiation' type: ");
2478 stripped_tlv
.chk_constructed_flag(TRUE
);
2480 ASN_BER_TLV_t tmp_tlv
;
2481 boolean tlv_present
=FALSE
;
2483 TTCN_EncDec_ErrorContext
ec_1("Component '");
2484 TTCN_EncDec_ErrorContext ec_2
;
2485 ec_2
.set_msg("presentation_context_id': ");
2486 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2487 if(!tlv_present
) return FALSE
;
2488 field_presentation__context__id
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, tmp_tlv
, L_form
);
2490 ec_2
.set_msg("transfer_syntax': ");
2491 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2492 if(!tlv_present
) return FALSE
;
2493 field_transfer__syntax
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, tmp_tlv
, L_form
);
2496 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
2500 int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERdescriptor_t
& p_td
,
2501 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
2503 int encoded_length
=(int)p_buf
.get_len();
2505 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
2507 field_presentation__context__id
.XER_encode(CHARACTER_STRING_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
2508 field_transfer__syntax
.XER_encode(CHARACTER_STRING_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
2510 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
2512 return p_buf
.get_len() - encoded_length
;
2515 int CHARACTER_STRING_identification_context__negotiation::XER_decode(
2516 const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
, unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
2518 int exer
= is_exer(flavor
);
2519 int type
= reader
.NodeType(), depth
= -1;
2520 const char* name
= (const char*)reader
.Name();
2521 int success
= reader
.Ok();
2522 if (type
==XML_READER_TYPE_ELEMENT
&& check_name(name
, p_td
, exer
)) {
2523 // we are in the right place
2524 depth
= reader
.Depth();
2525 success
= reader
.Read();
2527 field_presentation__context__id
.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_
, reader
, flavor
, flavor2
, 0);
2528 field_transfer__syntax
.XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_
, reader
, flavor
, flavor2
, 0);
2529 for (; success
== 1; success
= reader
.Read()) {
2530 type
= reader
.NodeType();
2531 if (XML_READER_TYPE_END_ELEMENT
== type
) {
2532 verify_end(reader
, p_td
, depth
, exer
);
2537 return 0; // TODO sensible return value
2540 struct CHARACTER_STRING_identification_context__negotiation_template::single_value_struct
{
2541 INTEGER_template field_presentation__context__id
;
2542 OBJID_template field_transfer__syntax
;
2545 void CHARACTER_STRING_identification_context__negotiation_template::set_param(Module_Param
& param
)
2547 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2548 Module_Param_Ptr mp
= ¶m
;
2549 if (param
.get_type() == Module_Param::MP_Reference
) {
2550 mp
= param
.get_referenced_param();
2552 switch (mp
->get_type()) {
2553 case Module_Param::MP_Omit
:
2556 case Module_Param::MP_Any
:
2559 case Module_Param::MP_AnyOrNone
:
2560 *this = ANY_OR_OMIT
;
2562 case Module_Param::MP_List_Template
:
2563 case Module_Param::MP_ComplementList_Template
: {
2564 CHARACTER_STRING_identification_context__negotiation_template temp
;
2565 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2566 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2567 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2568 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2572 case Module_Param::MP_Value_List
:
2573 if (mp
->get_size()==0) break;
2574 if (2!=mp
->get_size()) {
2575 param
.error("record template of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2577 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2578 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2580 case Module_Param::MP_Assignment_List
: {
2581 Vector
<bool> value_used(mp
->get_size());
2582 value_used
.resize(mp
->get_size(), false);
2583 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2584 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2585 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2586 presentation__context__id().set_param(*curr_param
);
2587 value_used
[val_idx
]=true;
2590 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2591 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2592 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2593 transfer__syntax().set_param(*curr_param
);
2594 value_used
[val_idx
]=true;
2597 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2598 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
2603 param
.type_error("record template", "CHARACTER STRING.identification.context-negotiation");
2605 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2608 Module_Param
* CHARACTER_STRING_identification_context__negotiation_template::get_param(Module_Param_Name
& param_name
) const
2610 Module_Param
* mp
= NULL
;
2611 switch (template_selection
) {
2612 case UNINITIALIZED_TEMPLATE
:
2613 mp
= new Module_Param_Unbound();
2616 mp
= new Module_Param_Omit();
2619 mp
= new Module_Param_Any();
2622 mp
= new Module_Param_AnyOrNone();
2624 case SPECIFIC_VALUE
: {
2625 Module_Param
* mp_field_presentation_context_id
= single_value
->field_presentation__context__id
.get_param(param_name
);
2626 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2627 Module_Param
* mp_field_transfer_syntax
= single_value
->field_transfer__syntax
.get_param(param_name
);
2628 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2629 mp
= new Module_Param_Assignment_List();
2630 mp
->add_elem(mp_field_presentation_context_id
);
2631 mp
->add_elem(mp_field_transfer_syntax
);
2634 case COMPLEMENTED_LIST
: {
2635 if (template_selection
== VALUE_LIST
) {
2636 mp
= new Module_Param_List_Template();
2639 mp
= new Module_Param_ComplementList_Template();
2641 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2642 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2649 mp
->set_ifpresent();
2654 void CHARACTER_STRING_identification_context__negotiation_template::clean_up()
2656 switch (template_selection
) {
2657 case SPECIFIC_VALUE
:
2658 delete single_value
;
2661 case COMPLEMENTED_LIST
:
2662 delete [] value_list
.list_value
;
2667 template_selection
= UNINITIALIZED_TEMPLATE
;
2670 void CHARACTER_STRING_identification_context__negotiation_template::set_specific()
2672 if (template_selection
!= SPECIFIC_VALUE
) {
2673 template_sel old_selection
= template_selection
;
2675 single_value
= new single_value_struct
;
2676 set_selection(SPECIFIC_VALUE
);
2677 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2678 single_value
->field_presentation__context__id
= ANY_VALUE
;
2679 single_value
->field_transfer__syntax
= ANY_VALUE
;
2684 void CHARACTER_STRING_identification_context__negotiation_template::copy_value(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2686 single_value
= new single_value_struct
;
2687 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2688 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2689 set_selection(SPECIFIC_VALUE
);
2692 void CHARACTER_STRING_identification_context__negotiation_template::copy_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2694 switch (other_value
.template_selection
) {
2695 case SPECIFIC_VALUE
:
2696 single_value
= new single_value_struct(*other_value
.single_value
);
2703 case COMPLEMENTED_LIST
:
2704 value_list
.n_values
= other_value
.value_list
.n_values
;
2705 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2706 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2707 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2710 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2712 set_selection(other_value
);
2715 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template()
2719 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(template_sel other_value
)
2720 : Base_Template(other_value
)
2722 check_single_selection(other_value
);
2725 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2727 copy_value(other_value
);
2730 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2732 switch (other_value
.get_selection()) {
2733 case OPTIONAL_PRESENT
:
2734 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2737 set_selection(OMIT_VALUE
);
2740 TTCN_error("Creating a template of type CHARACTER STRING.identification.context-negotiation from an unbound optional field.");
2744 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2747 copy_template(other_value
);
2750 CHARACTER_STRING_identification_context__negotiation_template::~CHARACTER_STRING_identification_context__negotiation_template()
2755 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(template_sel other_value
)
2757 check_single_selection(other_value
);
2759 set_selection(other_value
);
2763 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2766 copy_value(other_value
);
2770 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2773 switch (other_value
.get_selection()) {
2774 case OPTIONAL_PRESENT
:
2775 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2778 set_selection(OMIT_VALUE
);
2781 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.context-negotiation.");
2786 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2788 if (&other_value
!= this) {
2790 copy_template(other_value
);
2795 boolean
CHARACTER_STRING_identification_context__negotiation_template::match(const CHARACTER_STRING_identification_context__negotiation
& other_value
,
2796 boolean
/* legacy */) const
2798 switch (template_selection
) {
2804 case SPECIFIC_VALUE
:
2805 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
2806 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
2807 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
2808 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
2811 case COMPLEMENTED_LIST
:
2812 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2813 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2814 return template_selection
== COMPLEMENTED_LIST
;
2816 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2821 CHARACTER_STRING_identification_context__negotiation
CHARACTER_STRING_identification_context__negotiation_template::valueof() const
2823 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2824 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2825 CHARACTER_STRING_identification_context__negotiation ret_val
;
2826 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
2827 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
2831 void CHARACTER_STRING_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
2833 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2834 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.context-negotiation.");
2836 set_selection(template_type
);
2837 value_list
.n_values
= list_length
;
2838 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[list_length
];
2841 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::list_item(unsigned int list_index
) const
2843 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2844 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.context-negotiation.");
2845 if (list_index
>= value_list
.n_values
)
2846 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.context-negotiation.");
2847 return value_list
.list_value
[list_index
];
2850 INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id()
2853 return single_value
->field_presentation__context__id
;
2856 const INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() const
2858 if (template_selection
!= SPECIFIC_VALUE
)
2859 TTCN_error("Accessing field presentation_context_id of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2860 return single_value
->field_presentation__context__id
;
2863 OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax()
2866 return single_value
->field_transfer__syntax
;
2869 const OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() const
2871 if (template_selection
!= SPECIFIC_VALUE
)
2872 TTCN_error("Accessing field transfer_syntax of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2873 return single_value
->field_transfer__syntax
;
2876 int CHARACTER_STRING_identification_context__negotiation_template::size_of() const
2878 switch (template_selection
)
2880 case SPECIFIC_VALUE
:
2887 if (value_list
.n_values
<1)
2888 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing an empty list.");
2889 int item_size
= value_list
.list_value
[0].size_of();
2890 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2892 if (value_list
.list_value
[i
].size_of()!=item_size
)
2893 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing a value list with different sizes.");
2898 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing omit value.");
2901 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing */? value.");
2902 case COMPLEMENTED_LIST
:
2903 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing complemented list.");
2905 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2910 void CHARACTER_STRING_identification_context__negotiation_template::log() const
2912 switch (template_selection
) {
2913 case SPECIFIC_VALUE
:
2914 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2915 single_value
->field_presentation__context__id
.log();
2916 TTCN_Logger::log_event_str(", transfer_syntax := ");
2917 single_value
->field_transfer__syntax
.log();
2918 TTCN_Logger::log_event_str(" }");
2920 case COMPLEMENTED_LIST
:
2921 TTCN_Logger::log_event_str("complement ");
2924 TTCN_Logger::log_char('(');
2925 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2926 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2927 value_list
.list_value
[list_count
].log();
2929 TTCN_Logger::log_char(')');
2938 void CHARACTER_STRING_identification_context__negotiation_template::log_match(const CHARACTER_STRING_identification_context__negotiation
& match_value
,
2939 boolean
/* legacy */) const
2941 if (template_selection
== SPECIFIC_VALUE
) {
2942 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2943 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
2944 TTCN_Logger::log_event_str(", transfer_syntax := ");
2945 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
2946 TTCN_Logger::log_event_str(" }");
2949 TTCN_Logger::log_event_str(" with ");
2951 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2952 else TTCN_Logger::log_event_str(" unmatched");
2956 void CHARACTER_STRING_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
2958 encode_text_base(text_buf
);
2959 switch (template_selection
) {
2960 case SPECIFIC_VALUE
:
2961 single_value
->field_presentation__context__id
.encode_text(text_buf
);
2962 single_value
->field_transfer__syntax
.encode_text(text_buf
);
2969 case COMPLEMENTED_LIST
:
2970 text_buf
.push_int(value_list
.n_values
);
2971 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2972 value_list
.list_value
[list_count
].encode_text(text_buf
);
2975 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2979 void CHARACTER_STRING_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
2982 decode_text_base(text_buf
);
2983 switch (template_selection
) {
2984 case SPECIFIC_VALUE
:
2985 single_value
= new single_value_struct
;
2986 single_value
->field_presentation__context__id
.decode_text(text_buf
);
2987 single_value
->field_transfer__syntax
.decode_text(text_buf
);
2994 case COMPLEMENTED_LIST
:
2995 value_list
.n_values
= text_buf
.pull_int().get_val();
2996 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2997 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2998 value_list
.list_value
[list_count
].decode_text(text_buf
);
3001 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.context-negotiation.");
3005 boolean
CHARACTER_STRING_identification_context__negotiation_template::is_present(boolean legacy
/* = FALSE */) const
3007 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3008 return !match_omit(legacy
);
3011 boolean
CHARACTER_STRING_identification_context__negotiation_template::match_omit(boolean legacy
/* = FALSE */) const
3013 if (is_ifpresent
) return TRUE
;
3014 switch (template_selection
) {
3019 case COMPLEMENTED_LIST
:
3021 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3022 if (value_list
.list_value
[i
].match_omit())
3023 return template_selection
==VALUE_LIST
;
3024 return template_selection
==COMPLEMENTED_LIST
;
3025 } // else fall through
3032 #ifndef TITAN_RUNTIME_2
3033 void CHARACTER_STRING_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
,
3034 boolean legacy
/* = FALSE */) const
3036 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3037 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3039 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3042 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3043 template_selection
==SPECIFIC_VALUE
)) return;
3046 if (!match_omit(legacy
)) return;
3051 TTCN_error("Restriction `%s' on template of type %s violated.",
3052 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.context-negotiation");
3056 CHARACTER_STRING::CHARACTER_STRING()
3060 CHARACTER_STRING::CHARACTER_STRING(const CHARACTER_STRING_identification
& par_identification
,
3061 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
3062 const OCTETSTRING
& par_string__value
)
3063 : field_identification(par_identification
),
3064 field_data__value__descriptor(par_data__value__descriptor
),
3065 field_string__value(par_string__value
)
3069 boolean
CHARACTER_STRING::operator==(const CHARACTER_STRING
& other_value
) const
3071 return field_identification
==other_value
.field_identification
3072 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
3073 && field_string__value
==other_value
.field_string__value
;
3076 int CHARACTER_STRING::size_of() const
3079 if (field_data__value__descriptor
.ispresent()) ret_val
++;
3083 boolean
CHARACTER_STRING::is_bound() const
3085 if(field_identification
.is_bound()) return TRUE
;
3086 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
3087 if(field_string__value
.is_bound()) return TRUE
;
3091 boolean
CHARACTER_STRING::is_value() const
3093 if(!field_identification
.is_value()) return FALSE
;
3094 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
3095 if(!field_string__value
.is_value()) return FALSE
;
3099 void CHARACTER_STRING::clean_up()
3101 field_identification
.clean_up();
3102 field_data__value__descriptor
.clean_up();
3103 field_string__value
.clean_up();
3106 void CHARACTER_STRING::log() const
3108 TTCN_Logger::log_event_str("{ identification := ");
3109 field_identification
.log();
3110 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3111 field_data__value__descriptor
.log();
3112 TTCN_Logger::log_event_str(", string_value := ");
3113 field_string__value
.log();
3114 TTCN_Logger::log_event_str(" }");
3117 void CHARACTER_STRING::set_param(Module_Param
& param
)
3119 param
.basic_check(Module_Param::BC_VALUE
, "record value");
3120 Module_Param_Ptr mp
= ¶m
;
3121 if (param
.get_type() == Module_Param::MP_Reference
) {
3122 mp
= param
.get_referenced_param();
3124 switch (mp
->get_type()) {
3125 case Module_Param::MP_Value_List
:
3126 if (mp
->get_size()==0) return;
3127 if (3!=mp
->get_size()) {
3128 param
.error("record value of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp
->get_size());
3130 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3131 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3132 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*mp
->get_elem(2));
3134 case Module_Param::MP_Assignment_List
: {
3135 Vector
<bool> value_used(mp
->get_size());
3136 value_used
.resize(mp
->get_size(), false);
3137 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3138 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3139 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3140 identification().set_param(*curr_param
);
3141 value_used
[val_idx
]=true;
3144 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3145 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3146 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3147 data__value__descriptor().set_param(*curr_param
);
3148 value_used
[val_idx
]=true;
3151 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3152 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3153 if (!strcmp(curr_param
->get_id()->get_name(), "string_value")) {
3154 string__value().set_param(*curr_param
);
3155 value_used
[val_idx
]=true;
3158 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3159 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3164 param
.type_error("record value", "CHARACTER STRING");
3168 Module_Param
* CHARACTER_STRING::get_param(Module_Param_Name
& param_name
) const
3171 return new Module_Param_Unbound();
3173 Module_Param
* mp_field_identification
= field_identification
.get_param(param_name
);
3174 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3175 Module_Param
* mp_field_data_value_descriptor
= field_data__value__descriptor
.get_param(param_name
);
3176 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3177 Module_Param
* mp_field_string_value
= field_string__value
.get_param(param_name
);
3178 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("string_value")));
3179 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
3180 mp
->add_elem(mp_field_identification
);
3181 mp
->add_elem(mp_field_data_value_descriptor
);
3182 mp
->add_elem(mp_field_string_value
);
3186 void CHARACTER_STRING::encode_text(Text_Buf
& text_buf
) const
3188 field_identification
.encode_text(text_buf
);
3189 field_data__value__descriptor
.encode_text(text_buf
);
3190 field_string__value
.encode_text(text_buf
);
3193 void CHARACTER_STRING::decode_text(Text_Buf
& text_buf
)
3195 field_identification
.decode_text(text_buf
);
3196 field_data__value__descriptor
.decode_text(text_buf
);
3197 field_string__value
.decode_text(text_buf
);
3200 void CHARACTER_STRING::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
3203 va_start(pvar
, p_coding
);
3205 case TTCN_EncDec::CT_BER
: {
3206 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
3207 unsigned BER_coding
=va_arg(pvar
, unsigned);
3208 BER_encode_chk_coding(BER_coding
);
3209 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
3210 tlv
->put_in_buffer(p_buf
);
3211 ASN_BER_TLV_t::destruct(tlv
);
3213 case TTCN_EncDec::CT_RAW
: {
3214 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
3215 TTCN_EncDec_ErrorContext::error_internal
3216 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3218 case TTCN_EncDec::CT_TEXT
: {
3219 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
3220 TTCN_EncDec_ErrorContext::error_internal
3221 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3223 case TTCN_EncDec::CT_XER
: {
3224 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
3225 unsigned XER_coding
=va_arg(pvar
, unsigned);
3226 XER_encode(*p_td
.xer
,p_buf
, XER_coding
, 0, 0);
3229 case TTCN_EncDec::CT_JSON
: {
3230 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
3231 TTCN_EncDec_ErrorContext::error_internal
3232 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3235 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3240 void CHARACTER_STRING::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3243 va_start(pvar
, p_coding
);
3245 case TTCN_EncDec::CT_BER
: {
3246 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
3247 unsigned L_form
=va_arg(pvar
, unsigned);
3249 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
3250 BER_decode_TLV(p_td
, tlv
, L_form
);
3251 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3253 case TTCN_EncDec::CT_RAW
: {
3254 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3255 TTCN_EncDec_ErrorContext::error_internal
3256 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3258 case TTCN_EncDec::CT_TEXT
: {
3259 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3260 TTCN_EncDec_ErrorContext::error_internal
3261 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3263 case TTCN_EncDec::CT_XER
: {
3264 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3265 unsigned XER_coding
=va_arg(pvar
, unsigned);
3266 XmlReaderWrap
reader(p_buf
);
3267 int success
= reader
.Read();
3268 for (; success
==1; success
=reader
.Read()) {
3269 int type
= reader
.NodeType();
3270 if (type
==XML_READER_TYPE_ELEMENT
)
3273 XER_decode(*p_td
.xer
, reader
, XER_coding
, XER_NONE
, 0);
3274 size_t bytes
= reader
.ByteConsumed();
3275 p_buf
.set_pos(bytes
);
3277 case TTCN_EncDec::CT_JSON
: {
3278 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3279 TTCN_EncDec_ErrorContext::error_internal
3280 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3283 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3288 ASN_BER_TLV_t
* CHARACTER_STRING::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
3290 BER_chk_descr(p_td
);
3291 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
3292 TTCN_EncDec_ErrorContext
ec_0("Component '");
3293 TTCN_EncDec_ErrorContext ec_1
;
3294 ec_1
.set_msg("identification': ");
3295 new_tlv
->add_TLV(field_identification
.BER_encode_TLV(CHARACTER_STRING_identification_descr_
, p_coding
));
3296 ec_1
.set_msg("data_value_descriptor': ");
3297 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, p_coding
));
3298 ec_1
.set_msg("string_value': ");
3299 new_tlv
->add_TLV(field_string__value
.BER_encode_TLV(CHARACTER_STRING_string__value_descr_
, p_coding
));
3300 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
3304 boolean
CHARACTER_STRING::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
3306 BER_chk_descr(p_td
);
3307 ASN_BER_TLV_t stripped_tlv
;
3308 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
3309 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING' type: ");
3310 stripped_tlv
.chk_constructed_flag(TRUE
);
3312 ASN_BER_TLV_t tmp_tlv
;
3313 boolean tlv_present
=FALSE
;
3315 TTCN_EncDec_ErrorContext
ec_1("Component '");
3316 TTCN_EncDec_ErrorContext ec_2
;
3317 ec_2
.set_msg("identification': ");
3318 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3319 if(!tlv_present
) return FALSE
;
3320 field_identification
.BER_decode_TLV(CHARACTER_STRING_identification_descr_
, tmp_tlv
, L_form
);
3322 ec_2
.set_msg("data_value_descriptor': ");
3323 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3324 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
3326 field_data__value__descriptor
.BER_decode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, tmp_tlv
, L_form
);
3327 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
3329 ec_2
.set_msg("string_value': ");
3330 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3331 if(!tlv_present
) return FALSE
;
3332 field_string__value
.BER_decode_TLV(CHARACTER_STRING_string__value_descr_
, tmp_tlv
, L_form
);
3335 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
3339 int CHARACTER_STRING::XER_encode(const XERdescriptor_t
& p_td
, TTCN_Buffer
& p_buf
,
3340 unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
3343 TTCN_EncDec_ErrorContext::error
3344 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
3346 int encoded_length
=(int)p_buf
.get_len();
3348 flavor
&= ~XER_RECOF
; // ASN.1 character string doesn't care
3349 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
3351 field_identification
.XER_encode(CHARACTER_STRING_identification_xer_
, p_buf
, flavor
, indent
, 0);
3352 // data-value-descriptor is OPTIONAL and can never be present.
3353 // Its encoding is empty.
3354 field_string__value
.XER_encode(CHARACTER_STRING_data_value_xer_
, p_buf
, flavor
, indent
, 0);
3356 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
3358 return (int)p_buf
.get_len() - encoded_length
;
3361 int CHARACTER_STRING::XER_decode(const XERdescriptor_t
& p_td
,
3362 XmlReaderWrap
& reader
, unsigned int flavor
, unsigned int flavor2
, embed_values_dec_struct_t
*)
3364 int exer
= is_exer(flavor
);
3365 int success
= reader
.Ok(), depth
= -1, type
;
3366 for (; success
== 1; success
= reader
.Read()) {
3367 type
= reader
.NodeType();
3368 if (XML_READER_TYPE_ELEMENT
== type
) {
3369 verify_name(reader
, p_td
, exer
);
3370 depth
= reader
.Depth();
3375 field_identification
.XER_decode(CHARACTER_STRING_identification_xer_
, reader
, flavor
, flavor2
, 0);
3376 field_data__value__descriptor
.XER_decode(CHARACTER_STRING_data_value_descriptor_xer_
, reader
, flavor
, flavor2
, 0);
3377 if (field_data__value__descriptor
.is_value()) {
3378 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
3379 "data-value-descriptor not allowed for EMBEDDED PDV");
3381 field_string__value
.XER_decode(CHARACTER_STRING_data_value_xer_
, reader
, flavor
, flavor2
, 0);
3382 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
3383 type
= reader
.NodeType();
3384 if (XML_READER_TYPE_END_ELEMENT
== type
) {
3385 verify_end(reader
, p_td
, depth
, exer
);
3395 struct CHARACTER_STRING_template::single_value_struct
{
3396 CHARACTER_STRING_identification_template field_identification
;
3397 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3398 OCTETSTRING_template field_string__value
;
3401 void CHARACTER_STRING_template::set_param(Module_Param
& param
)
3403 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
3404 Module_Param_Ptr mp
= ¶m
;
3405 if (param
.get_type() == Module_Param::MP_Reference
) {
3406 mp
= param
.get_referenced_param();
3408 switch (mp
->get_type()) {
3409 case Module_Param::MP_Omit
:
3412 case Module_Param::MP_Any
:
3415 case Module_Param::MP_AnyOrNone
:
3416 *this = ANY_OR_OMIT
;
3418 case Module_Param::MP_List_Template
:
3419 case Module_Param::MP_ComplementList_Template
: {
3420 CHARACTER_STRING_template temp
;
3421 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
3422 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
3423 for (size_t i
=0; i
<mp
->get_size(); i
++) {
3424 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
3428 case Module_Param::MP_Value_List
:
3429 if (mp
->get_size()==0) break;
3430 if (3!=mp
->get_size()) {
3431 param
.error("record template of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp
->get_size());
3433 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3434 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3435 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*mp
->get_elem(2));
3437 case Module_Param::MP_Assignment_List
: {
3438 Vector
<bool> value_used(mp
->get_size());
3439 value_used
.resize(mp
->get_size(), false);
3440 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3441 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3442 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3443 identification().set_param(*curr_param
);
3444 value_used
[val_idx
]=true;
3447 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3448 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3449 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3450 data__value__descriptor().set_param(*curr_param
);
3451 value_used
[val_idx
]=true;
3454 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3455 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3456 if (!strcmp(curr_param
->get_id()->get_name(), "string_value")) {
3457 string__value().set_param(*curr_param
);
3458 value_used
[val_idx
]=true;
3461 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3462 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3467 param
.type_error("record template", "CHARACTER STRING");
3469 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
3472 Module_Param
* CHARACTER_STRING_template::get_param(Module_Param_Name
& param_name
) const
3474 Module_Param
* mp
= NULL
;
3475 switch (template_selection
) {
3476 case UNINITIALIZED_TEMPLATE
:
3477 mp
= new Module_Param_Unbound();
3480 mp
= new Module_Param_Omit();
3483 mp
= new Module_Param_Any();
3486 mp
= new Module_Param_AnyOrNone();
3488 case SPECIFIC_VALUE
: {
3489 Module_Param
* mp_field_identification
= single_value
->field_identification
.get_param(param_name
);
3490 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3491 Module_Param
* mp_field_data_value_descriptor
= single_value
->field_data__value__descriptor
.get_param(param_name
);
3492 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3493 Module_Param
* mp_field_string_value
= single_value
->field_string__value
.get_param(param_name
);
3494 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("string_value")));
3495 mp
= new Module_Param_Assignment_List();
3496 mp
->add_elem(mp_field_identification
);
3497 mp
->add_elem(mp_field_data_value_descriptor
);
3498 mp
->add_elem(mp_field_string_value
);
3501 case COMPLEMENTED_LIST
: {
3502 if (template_selection
== VALUE_LIST
) {
3503 mp
= new Module_Param_List_Template();
3506 mp
= new Module_Param_ComplementList_Template();
3508 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
3509 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
3516 mp
->set_ifpresent();
3521 void CHARACTER_STRING_template::clean_up()
3523 switch (template_selection
) {
3524 case SPECIFIC_VALUE
:
3525 delete single_value
;
3528 case COMPLEMENTED_LIST
:
3529 delete [] value_list
.list_value
;
3534 template_selection
= UNINITIALIZED_TEMPLATE
;
3537 void CHARACTER_STRING_template::set_specific()
3539 if (template_selection
!= SPECIFIC_VALUE
) {
3540 template_sel old_selection
= template_selection
;
3542 single_value
= new single_value_struct
;
3543 set_selection(SPECIFIC_VALUE
);
3544 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3545 single_value
->field_identification
= ANY_VALUE
;
3546 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3547 single_value
->field_string__value
= ANY_VALUE
;
3552 void CHARACTER_STRING_template::copy_value(const CHARACTER_STRING
& other_value
)
3554 single_value
= new single_value_struct
;
3555 single_value
->field_identification
= other_value
.identification();
3556 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3557 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3558 single_value
->field_string__value
= other_value
.string__value();
3559 set_selection(SPECIFIC_VALUE
);
3562 void CHARACTER_STRING_template::copy_template(const CHARACTER_STRING_template
& other_value
)
3564 switch (other_value
.template_selection
) {
3565 case SPECIFIC_VALUE
:
3566 single_value
= new single_value_struct(*other_value
.single_value
);
3573 case COMPLEMENTED_LIST
:
3574 value_list
.n_values
= other_value
.value_list
.n_values
;
3575 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3576 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3577 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3580 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.");
3582 set_selection(other_value
);
3585 CHARACTER_STRING_template::CHARACTER_STRING_template()
3589 CHARACTER_STRING_template::CHARACTER_STRING_template(template_sel other_value
)
3590 : Base_Template(other_value
)
3592 check_single_selection(other_value
);
3595 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING
& other_value
)
3597 copy_value(other_value
);
3600 CHARACTER_STRING_template::CHARACTER_STRING_template(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3602 switch (other_value
.get_selection()) {
3603 case OPTIONAL_PRESENT
:
3604 copy_value((const CHARACTER_STRING
&)other_value
);
3607 set_selection(OMIT_VALUE
);
3610 TTCN_error("Creating a template of type CHARACTER STRING from an unbound optional field.");
3614 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING_template
& other_value
)
3617 copy_template(other_value
);
3620 CHARACTER_STRING_template::~CHARACTER_STRING_template()
3625 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(template_sel other_value
)
3627 check_single_selection(other_value
);
3629 set_selection(other_value
);
3633 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING
& other_value
)
3636 copy_value(other_value
);
3640 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3643 switch (other_value
.get_selection()) {
3644 case OPTIONAL_PRESENT
:
3645 copy_value((const CHARACTER_STRING
&)other_value
);
3648 set_selection(OMIT_VALUE
);
3651 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.");
3656 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING_template
& other_value
)
3658 if (&other_value
!= this) {
3660 copy_template(other_value
);
3665 boolean
CHARACTER_STRING_template::match(const CHARACTER_STRING
& other_value
,
3666 boolean
/* legacy */) const
3668 switch (template_selection
) {
3674 case SPECIFIC_VALUE
:
3675 if (!other_value
.identification().is_bound()) return FALSE
;
3676 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3677 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3678 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
;
3679 if (!other_value
.string__value().is_bound()) return FALSE
;
3680 if (!single_value
->field_string__value
.match(other_value
.string__value())) return FALSE
;
3683 case COMPLEMENTED_LIST
:
3684 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3685 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3686 return template_selection
== COMPLEMENTED_LIST
;
3688 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.");
3693 CHARACTER_STRING
CHARACTER_STRING_template::valueof() const
3695 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3696 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.");
3697 CHARACTER_STRING ret_val
;
3698 ret_val
.identification() = single_value
->field_identification
.valueof();
3699 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3700 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3701 ret_val
.string__value() = single_value
->field_string__value
.valueof();
3705 void CHARACTER_STRING_template::set_type(template_sel template_type
, unsigned int list_length
)
3707 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3708 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.");
3710 set_selection(template_type
);
3711 value_list
.n_values
= list_length
;
3712 value_list
.list_value
= new CHARACTER_STRING_template
[list_length
];
3715 CHARACTER_STRING_template
& CHARACTER_STRING_template::list_item(unsigned int list_index
) const
3717 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3718 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.");
3719 if (list_index
>= value_list
.n_values
)
3720 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.");
3721 return value_list
.list_value
[list_index
];
3724 CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification()
3727 return single_value
->field_identification
;
3730 const CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification() const
3732 if (template_selection
!= SPECIFIC_VALUE
)
3733 TTCN_error("Accessing field identification of a non-specific template of type CHARACTER STRING.");
3734 return single_value
->field_identification
;
3737 UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor()
3740 return single_value
->field_data__value__descriptor
;
3743 const UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor() const
3745 if (template_selection
!= SPECIFIC_VALUE
)
3746 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type CHARACTER STRING.");
3747 return single_value
->field_data__value__descriptor
;
3750 OCTETSTRING_template
& CHARACTER_STRING_template::string__value()
3753 return single_value
->field_string__value
;
3756 const OCTETSTRING_template
& CHARACTER_STRING_template::string__value() const
3758 if (template_selection
!= SPECIFIC_VALUE
)
3759 TTCN_error("Accessing field string_value of a non-specific template of type CHARACTER STRING.");
3760 return single_value
->field_string__value
;
3763 int CHARACTER_STRING_template::size_of() const
3765 switch (template_selection
)
3767 case SPECIFIC_VALUE
:
3770 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3775 if (value_list
.n_values
<1)
3776 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING containing an empty list.");
3777 int item_size
= value_list
.list_value
[0].size_of();
3778 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3780 if (value_list
.list_value
[i
].size_of()!=item_size
)
3781 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing a value list with different sizes.");
3786 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing omit value.");
3789 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing */? value.");
3790 case COMPLEMENTED_LIST
:
3791 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing complemented list.");
3793 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.");
3798 void CHARACTER_STRING_template::log() const
3800 switch (template_selection
) {
3801 case SPECIFIC_VALUE
:
3802 TTCN_Logger::log_event_str("{ identification := ");
3803 single_value
->field_identification
.log();
3804 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3805 single_value
->field_data__value__descriptor
.log();
3806 TTCN_Logger::log_event_str(", string_value := ");
3807 single_value
->field_string__value
.log();
3808 TTCN_Logger::log_event_str(" }");
3810 case COMPLEMENTED_LIST
:
3811 TTCN_Logger::log_event_str("complement ");
3814 TTCN_Logger::log_char('(');
3815 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3816 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3817 value_list
.list_value
[list_count
].log();
3819 TTCN_Logger::log_char(')');
3828 void CHARACTER_STRING_template::log_match(const CHARACTER_STRING
& match_value
,
3829 boolean
/* legacy */) const
3831 if (template_selection
== SPECIFIC_VALUE
) {
3832 TTCN_Logger::log_event_str("{ identification := ");
3833 single_value
->field_identification
.log_match(match_value
.identification());
3834 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3835 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3837 single_value
->field_data__value__descriptor
.log();
3838 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3839 else TTCN_Logger::log_event_str(" unmatched");
3841 TTCN_Logger::log_event_str(", string_value := ");
3842 single_value
->field_string__value
.log_match(match_value
.string__value());
3843 TTCN_Logger::log_event_str(" }");
3846 TTCN_Logger::log_event_str(" with ");
3848 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3849 else TTCN_Logger::log_event_str(" unmatched");
3853 void CHARACTER_STRING_template::encode_text(Text_Buf
& text_buf
) const
3855 encode_text_base(text_buf
);
3856 switch (template_selection
) {
3857 case SPECIFIC_VALUE
:
3858 single_value
->field_identification
.encode_text(text_buf
);
3859 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3860 single_value
->field_string__value
.encode_text(text_buf
);
3867 case COMPLEMENTED_LIST
:
3868 text_buf
.push_int(value_list
.n_values
);
3869 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3870 value_list
.list_value
[list_count
].encode_text(text_buf
);
3873 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.");
3877 void CHARACTER_STRING_template::decode_text(Text_Buf
& text_buf
)
3880 decode_text_base(text_buf
);
3881 switch (template_selection
) {
3882 case SPECIFIC_VALUE
:
3883 single_value
= new single_value_struct
;
3884 single_value
->field_identification
.decode_text(text_buf
);
3885 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3886 single_value
->field_string__value
.decode_text(text_buf
);
3893 case COMPLEMENTED_LIST
:
3894 value_list
.n_values
= text_buf
.pull_int().get_val();
3895 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3896 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3897 value_list
.list_value
[list_count
].decode_text(text_buf
);
3900 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.");
3904 boolean
CHARACTER_STRING_template::is_present(boolean legacy
/* = FALSE */) const
3906 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3907 return !match_omit(legacy
);
3910 boolean
CHARACTER_STRING_template::match_omit(boolean legacy
/* = FALSE */) const
3912 if (is_ifpresent
) return TRUE
;
3913 switch (template_selection
) {
3918 case COMPLEMENTED_LIST
:
3920 // legacy behavior: 'omit' can appear in the value/complement list
3921 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3922 if (value_list
.list_value
[i
].match_omit())
3923 return template_selection
==VALUE_LIST
;
3924 return template_selection
==COMPLEMENTED_LIST
;
3926 // else fall through
3933 #ifndef TITAN_RUNTIME_2
3934 void CHARACTER_STRING_template::check_restriction(template_res t_res
, const char* t_name
,
3935 boolean legacy
/* = FALSE */) const
3937 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3938 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3940 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3943 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3944 template_selection
==SPECIFIC_VALUE
)) return;
3947 if (!match_omit(legacy
)) return;
3952 TTCN_error("Restriction `%s' on template of type %s violated.",
3953 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING");