1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
14 #include "Param_Types.hh"
16 #include "ASN_CharacterString.hh"
18 #include "../common/dbgnew.hh"
22 to do when regenerating:
26 add __SUNPRO_CC ifdefs for single_value_struct
30 replace '@CHARACTER STRING' with 'CHARACTER STRING'
32 remove RAW and TEXT enc/dec functions
34 make the type descriptors of embedded types static
38 static const ASN_Tag_t CHARACTER_STRING_identification_tag_
[] = { { ASN_TAG_CONT
, 0u }};
39 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_ber_
= { 1u, CHARACTER_STRING_identification_tag_
};
40 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_descr_
= { "CHARACTER STRING.identification", &CHARACTER_STRING_identification_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
42 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_abstract_tag_
[] = { { ASN_TAG_CONT
, 0u }};
43 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_abstract_tag_
};
44 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_descr_
= { "CHARACTER STRING.identification.syntaxes.abstract", &CHARACTER_STRING_identification_syntaxes_abstract_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
46 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_transfer_tag_
[] = { { ASN_TAG_CONT
, 1u }};
47 const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_transfer_tag_
};
48 const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_descr_
= { "CHARACTER STRING.identification.syntaxes.transfer", &CHARACTER_STRING_identification_syntaxes_transfer_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
50 static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_tag_
[] = { { ASN_TAG_CONT
, 0u }};
51 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_ber_
= { 1u, CHARACTER_STRING_identification_syntaxes_tag_
};
52 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_descr_
= { "CHARACTER STRING.identification.syntaxes", &CHARACTER_STRING_identification_syntaxes_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
54 static const ASN_Tag_t CHARACTER_STRING_identification_syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
55 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntax_ber_
= { 1u, CHARACTER_STRING_identification_syntax_tag_
};
56 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntax_descr_
= { "CHARACTER STRING.identification.syntax", &CHARACTER_STRING_identification_syntax_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
58 static const ASN_Tag_t CHARACTER_STRING_identification_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 2u }};
59 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_presentation__context__id_tag_
};
60 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_presentation__context__id_descr_
= { "CHARACTER STRING.identification.presentation-context-id", &CHARACTER_STRING_identification_presentation__context__id_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
62 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
[] = { { ASN_TAG_CONT
, 0u }};
63 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_
};
64 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
= { "CHARACTER STRING.identification.context-negotiation.presentation-context-id", &CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
66 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 1u }};
67 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_
};
68 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
= { "CHARACTER STRING.identification.context-negotiation.transfer-syntax", &CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
70 static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_tag_
[] = { { ASN_TAG_CONT
, 3u }};
71 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_ber_
= { 1u, CHARACTER_STRING_identification_context__negotiation_tag_
};
72 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_descr_
= { "CHARACTER STRING.identification.context-negotiation", &CHARACTER_STRING_identification_context__negotiation_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
74 static const ASN_Tag_t CHARACTER_STRING_identification_transfer__syntax_tag_
[] = { { ASN_TAG_CONT
, 4u }};
75 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_transfer__syntax_ber_
= { 1u, CHARACTER_STRING_identification_transfer__syntax_tag_
};
76 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_transfer__syntax_descr_
= { "CHARACTER STRING.identification.transfer-syntax", &CHARACTER_STRING_identification_transfer__syntax_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::OBJID
};
78 static const ASN_Tag_t CHARACTER_STRING_identification_fixed_tag_
[] = { { ASN_TAG_CONT
, 5u }};
79 static const ASN_BERdescriptor_t CHARACTER_STRING_identification_fixed_ber_
= { 1u, CHARACTER_STRING_identification_fixed_tag_
};
80 static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_fixed_descr_
= { "CHARACTER STRING.identification.fixed", &CHARACTER_STRING_identification_fixed_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
82 static const ASN_Tag_t CHARACTER_STRING_string__value_tag_
[] = { { ASN_TAG_CONT
, 2u }};
83 static const ASN_BERdescriptor_t CHARACTER_STRING_string__value_ber_
= { 1u, CHARACTER_STRING_string__value_tag_
};
84 static const TTCN_Typedescriptor_t CHARACTER_STRING_string__value_descr_
= { "CHARACTER STRING.string-value", &CHARACTER_STRING_string__value_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::DONTCARE
};
86 static const ASN_Tag_t CHARACTER_STRING_data__value__descriptor_tag_
[] = { { ASN_TAG_CONT
, 1u }};
87 static const ASN_BERdescriptor_t CHARACTER_STRING_data__value__descriptor_ber_
= { 1u, CHARACTER_STRING_data__value__descriptor_tag_
};
88 static const TTCN_Typedescriptor_t CHARACTER_STRING_data__value__descriptor_descr_
= { "CHARACTER STRING.data-value-descriptor", &CHARACTER_STRING_data__value__descriptor_ber_
, NULL
, NULL
, NULL
, NULL
, NULL
, TTCN_Typedescriptor_t::GRAPHICSTRING
};
90 void CHARACTER_STRING_identification::clean_up()
92 switch (union_selection
) {
94 delete field_syntaxes
;
99 case ALT_presentation__context__id
:
100 delete field_presentation__context__id
;
102 case ALT_context__negotiation
:
103 delete field_context__negotiation
;
105 case ALT_transfer__syntax
:
106 delete field_transfer__syntax
;
114 union_selection
= UNBOUND_VALUE
;
117 void CHARACTER_STRING_identification::copy_value(const CHARACTER_STRING_identification
& other_value
)
119 switch (other_value
.union_selection
) {
121 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes(*other_value
.field_syntaxes
);
124 field_syntax
= new OBJID(*other_value
.field_syntax
);
126 case ALT_presentation__context__id
:
127 field_presentation__context__id
= new INTEGER(*other_value
.field_presentation__context__id
);
129 case ALT_context__negotiation
:
130 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation(*other_value
.field_context__negotiation
);
132 case ALT_transfer__syntax
:
133 field_transfer__syntax
= new OBJID(*other_value
.field_transfer__syntax
);
136 field_fixed
= new ASN_NULL(*other_value
.field_fixed
);
139 TTCN_error("Assignment of an unbound union value of type CHARACTER STRING.identification.");
141 union_selection
= other_value
.union_selection
;
144 CHARACTER_STRING_identification::CHARACTER_STRING_identification()
146 union_selection
= UNBOUND_VALUE
;
149 CHARACTER_STRING_identification::CHARACTER_STRING_identification(const CHARACTER_STRING_identification
& other_value
)
150 : Base_Type(other_value
)
152 copy_value(other_value
);
155 CHARACTER_STRING_identification::~CHARACTER_STRING_identification()
160 CHARACTER_STRING_identification
& CHARACTER_STRING_identification::operator=(const CHARACTER_STRING_identification
& other_value
)
162 if (this != &other_value
) {
164 copy_value(other_value
);
169 boolean
CHARACTER_STRING_identification::operator==(const CHARACTER_STRING_identification
& other_value
) const
171 if (union_selection
== UNBOUND_VALUE
) TTCN_error("The left operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
172 if (other_value
.union_selection
== UNBOUND_VALUE
) TTCN_error("The right operand of comparison is an unbound value of union type CHARACTER STRING.identification.");
173 if (union_selection
!= other_value
.union_selection
) return FALSE
;
174 switch (union_selection
) {
176 return *field_syntaxes
== *other_value
.field_syntaxes
;
178 return *field_syntax
== *other_value
.field_syntax
;
179 case ALT_presentation__context__id
:
180 return *field_presentation__context__id
== *other_value
.field_presentation__context__id
;
181 case ALT_context__negotiation
:
182 return *field_context__negotiation
== *other_value
.field_context__negotiation
;
183 case ALT_transfer__syntax
:
184 return *field_transfer__syntax
== *other_value
.field_transfer__syntax
;
186 return *field_fixed
== *other_value
.field_fixed
;
192 CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes()
194 if (union_selection
!= ALT_syntaxes
) {
196 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
197 union_selection
= ALT_syntaxes
;
199 return *field_syntaxes
;
202 const CHARACTER_STRING_identification_syntaxes
& CHARACTER_STRING_identification::syntaxes() const
204 if (union_selection
!= ALT_syntaxes
) TTCN_error("Using non-selected field syntaxes in a value of union type CHARACTER STRING.identification.");
205 return *field_syntaxes
;
208 OBJID
& CHARACTER_STRING_identification::syntax()
210 if (union_selection
!= ALT_syntax
) {
212 field_syntax
= new OBJID
;
213 union_selection
= ALT_syntax
;
215 return *field_syntax
;
218 const OBJID
& CHARACTER_STRING_identification::syntax() const
220 if (union_selection
!= ALT_syntax
) TTCN_error("Using non-selected field syntax in a value of union type CHARACTER STRING.identification.");
221 return *field_syntax
;
224 INTEGER
& CHARACTER_STRING_identification::presentation__context__id()
226 if (union_selection
!= ALT_presentation__context__id
) {
228 field_presentation__context__id
= new INTEGER
;
229 union_selection
= ALT_presentation__context__id
;
231 return *field_presentation__context__id
;
234 const INTEGER
& CHARACTER_STRING_identification::presentation__context__id() const
236 if (union_selection
!= ALT_presentation__context__id
) TTCN_error("Using non-selected field presentation_context_id in a value of union type CHARACTER STRING.identification.");
237 return *field_presentation__context__id
;
240 CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation()
242 if (union_selection
!= ALT_context__negotiation
) {
244 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
245 union_selection
= ALT_context__negotiation
;
247 return *field_context__negotiation
;
250 const CHARACTER_STRING_identification_context__negotiation
& CHARACTER_STRING_identification::context__negotiation() const
252 if (union_selection
!= ALT_context__negotiation
) TTCN_error("Using non-selected field context_negotiation in a value of union type CHARACTER STRING.identification.");
253 return *field_context__negotiation
;
256 OBJID
& CHARACTER_STRING_identification::transfer__syntax()
258 if (union_selection
!= ALT_transfer__syntax
) {
260 field_transfer__syntax
= new OBJID
;
261 union_selection
= ALT_transfer__syntax
;
263 return *field_transfer__syntax
;
266 const OBJID
& CHARACTER_STRING_identification::transfer__syntax() const
268 if (union_selection
!= ALT_transfer__syntax
) TTCN_error("Using non-selected field transfer_syntax in a value of union type CHARACTER STRING.identification.");
269 return *field_transfer__syntax
;
272 ASN_NULL
& CHARACTER_STRING_identification::fixed()
274 if (union_selection
!= ALT_fixed
) {
276 field_fixed
= new ASN_NULL
;
277 union_selection
= ALT_fixed
;
282 const ASN_NULL
& CHARACTER_STRING_identification::fixed() const
284 if (union_selection
!= ALT_fixed
) TTCN_error("Using non-selected field fixed in a value of union type CHARACTER STRING.identification.");
288 boolean
CHARACTER_STRING_identification::ischosen(union_selection_type checked_selection
) const
290 if (checked_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification.");
291 if (union_selection
== UNBOUND_VALUE
) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type CHARACTER STRING.identification.");
292 return union_selection
== checked_selection
;
295 boolean
CHARACTER_STRING_identification::is_bound() const
297 switch (union_selection
) {
299 return field_syntaxes
->is_bound();
301 return field_syntax
->is_bound();
302 case ALT_presentation__context__id
:
303 return field_presentation__context__id
->is_bound();
304 case ALT_context__negotiation
:
305 return field_context__negotiation
->is_bound();
306 case ALT_transfer__syntax
:
307 return field_transfer__syntax
->is_bound();
309 return field_fixed
->is_bound();
315 boolean
CHARACTER_STRING_identification::is_value() const
317 switch (union_selection
) {
319 return field_syntaxes
->is_value();
321 return field_syntax
->is_value();
322 case ALT_presentation__context__id
:
323 return field_presentation__context__id
->is_value();
324 case ALT_context__negotiation
:
325 return field_context__negotiation
->is_value();
326 case ALT_transfer__syntax
:
327 return field_transfer__syntax
->is_value();
329 return field_fixed
->is_value();
335 void CHARACTER_STRING_identification::log() const
337 switch (union_selection
) {
339 TTCN_Logger::log_event_str("{ syntaxes := ");
340 field_syntaxes
->log();
341 TTCN_Logger::log_event_str(" }");
344 TTCN_Logger::log_event_str("{ syntax := ");
346 TTCN_Logger::log_event_str(" }");
348 case ALT_presentation__context__id
:
349 TTCN_Logger::log_event_str("{ presentation_context_id := ");
350 field_presentation__context__id
->log();
351 TTCN_Logger::log_event_str(" }");
353 case ALT_context__negotiation
:
354 TTCN_Logger::log_event_str("{ context_negotiation := ");
355 field_context__negotiation
->log();
356 TTCN_Logger::log_event_str(" }");
358 case ALT_transfer__syntax
:
359 TTCN_Logger::log_event_str("{ transfer_syntax := ");
360 field_transfer__syntax
->log();
361 TTCN_Logger::log_event_str(" }");
364 TTCN_Logger::log_event_str("{ fixed := ");
366 TTCN_Logger::log_event_str(" }");
369 TTCN_Logger::log_event_str("<unbound>");
374 void CHARACTER_STRING_identification::set_param(Module_Param
& param
)
376 param
.basic_check(Module_Param::BC_VALUE
, "union value");
377 Module_Param_Ptr mp
= ¶m
;
378 if (param
.get_type() == Module_Param::MP_Reference
) {
379 mp
= param
.get_referenced_param();
381 if (mp
->get_type()==Module_Param::MP_Value_List
&& mp
->get_size()==0) return;
382 if (mp
->get_type()!=Module_Param::MP_Assignment_List
) {
383 param
.error("union value with field name was expected");
385 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
386 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
387 syntaxes().set_param(*mp_last
);
390 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
391 syntax().set_param(*mp_last
);
394 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
395 presentation__context__id().set_param(*mp_last
);
398 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
399 context__negotiation().set_param(*mp_last
);
402 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
403 transfer__syntax().set_param(*mp_last
);
406 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
407 fixed().set_param(*mp_last
);
410 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
413 Module_Param
* CHARACTER_STRING_identification::get_param(Module_Param_Name
& param_name
) const
416 return new Module_Param_Unbound();
418 Module_Param
* mp_field
= NULL
;
419 switch(get_selection()) {
421 mp_field
= field_syntaxes
->get_param(param_name
);
422 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
425 mp_field
= field_syntax
->get_param(param_name
);
426 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
428 case ALT_presentation__context__id
:
429 mp_field
= field_presentation__context__id
->get_param(param_name
);
430 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
432 case ALT_context__negotiation
:
433 mp_field
= field_context__negotiation
->get_param(param_name
);
434 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
436 case ALT_transfer__syntax
:
437 mp_field
= field_transfer__syntax
->get_param(param_name
);
438 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
441 mp_field
= field_fixed
->get_param(param_name
);
442 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
447 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
448 mp
->add_elem(mp_field
);
452 void CHARACTER_STRING_identification_template::set_param(Module_Param
& param
)
454 param
.basic_check(Module_Param::BC_TEMPLATE
, "union template");
455 Module_Param_Ptr mp
= ¶m
;
456 if (param
.get_type() == Module_Param::MP_Reference
) {
457 mp
= param
.get_referenced_param();
459 switch (mp
->get_type()) {
460 case Module_Param::MP_Omit
:
463 case Module_Param::MP_Any
:
466 case Module_Param::MP_AnyOrNone
:
469 case Module_Param::MP_List_Template
:
470 case Module_Param::MP_ComplementList_Template
: {
471 CHARACTER_STRING_identification_template temp
;
472 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
473 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
474 for (size_t i
=0; i
<mp
->get_size(); i
++) {
475 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
479 case Module_Param::MP_Value_List
:
480 if (mp
->get_size()==0) break;
481 param
.type_error("union template", "CHARACTER STRING.identification");
483 case Module_Param::MP_Assignment_List
: {
484 Module_Param
* mp_last
= mp
->get_elem(mp
->get_size()-1);
485 if (!strcmp(mp_last
->get_id()->get_name(), "syntaxes")) {
486 syntaxes().set_param(*mp_last
);
489 if (!strcmp(mp_last
->get_id()->get_name(), "syntax")) {
490 syntax().set_param(*mp_last
);
493 if (!strcmp(mp_last
->get_id()->get_name(), "presentation_context_id")) {
494 presentation__context__id().set_param(*mp_last
);
497 if (!strcmp(mp_last
->get_id()->get_name(), "context_negotiation")) {
498 context__negotiation().set_param(*mp_last
);
501 if (!strcmp(mp_last
->get_id()->get_name(), "transfer_syntax")) {
502 transfer__syntax().set_param(*mp_last
);
505 if (!strcmp(mp_last
->get_id()->get_name(), "fixed")) {
506 fixed().set_param(*mp_last
);
509 mp_last
->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last
->get_id()->get_name());
512 param
.type_error("union template", "CHARACTER STRING.identification");
514 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
517 Module_Param
* CHARACTER_STRING_identification_template::get_param(Module_Param_Name
& param_name
) const
519 Module_Param
* mp
= NULL
;
520 switch (template_selection
) {
521 case UNINITIALIZED_TEMPLATE
:
522 mp
= new Module_Param_Unbound();
525 mp
= new Module_Param_Omit();
528 mp
= new Module_Param_Any();
531 mp
= new Module_Param_AnyOrNone();
533 case SPECIFIC_VALUE
: {
534 Module_Param
* mp_field
= NULL
;
535 switch(single_value
.union_selection
) {
536 case CHARACTER_STRING_identification::ALT_syntaxes
:
537 mp_field
= single_value
.field_syntaxes
->get_param(param_name
);
538 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
540 case CHARACTER_STRING_identification::ALT_syntax
:
541 mp_field
= single_value
.field_syntax
->get_param(param_name
);
542 mp_field
->set_id(new Module_Param_FieldName(mcopystr("syntax")));
544 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
545 mp_field
= single_value
.field_presentation__context__id
->get_param(param_name
);
546 mp_field
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
548 case CHARACTER_STRING_identification::ALT_context__negotiation
:
549 mp_field
= single_value
.field_context__negotiation
->get_param(param_name
);
550 mp_field
->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
552 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
553 mp_field
= single_value
.field_transfer__syntax
->get_param(param_name
);
554 mp_field
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
556 case CHARACTER_STRING_identification::ALT_fixed
:
557 mp_field
= single_value
.field_fixed
->get_param(param_name
);
558 mp_field
->set_id(new Module_Param_FieldName(mcopystr("fixed")));
563 mp
= new Module_Param_Assignment_List();
564 mp
->add_elem(mp_field
);
567 case COMPLEMENTED_LIST
: {
568 if (template_selection
== VALUE_LIST
) {
569 mp
= new Module_Param_List_Template();
572 mp
= new Module_Param_ComplementList_Template();
574 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
575 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
587 void CHARACTER_STRING_identification::encode_text(Text_Buf
& text_buf
) const
589 text_buf
.push_int(union_selection
);
590 switch (union_selection
) {
592 field_syntaxes
->encode_text(text_buf
);
595 field_syntax
->encode_text(text_buf
);
597 case ALT_presentation__context__id
:
598 field_presentation__context__id
->encode_text(text_buf
);
600 case ALT_context__negotiation
:
601 field_context__negotiation
->encode_text(text_buf
);
603 case ALT_transfer__syntax
:
604 field_transfer__syntax
->encode_text(text_buf
);
607 field_fixed
->encode_text(text_buf
);
610 TTCN_error("Text encoder: Encoding an unbound value of union type CHARACTER STRING.identification.");
614 void CHARACTER_STRING_identification::decode_text(Text_Buf
& text_buf
)
616 switch ((union_selection_type
)text_buf
.pull_int().get_val()) {
618 syntaxes().decode_text(text_buf
);
621 syntax().decode_text(text_buf
);
623 case ALT_presentation__context__id
:
624 presentation__context__id().decode_text(text_buf
);
626 case ALT_context__negotiation
:
627 context__negotiation().decode_text(text_buf
);
629 case ALT_transfer__syntax
:
630 transfer__syntax().decode_text(text_buf
);
633 fixed().decode_text(text_buf
);
636 TTCN_error("Text decoder: Unrecognized union selector was received for type CHARACTER STRING.identification.");
641 void CHARACTER_STRING_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
642 void CHARACTER_STRING_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
645 ASN_BER_TLV_t
*CHARACTER_STRING_identification::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
648 ASN_BER_TLV_t
*new_tlv
;
649 TTCN_EncDec_ErrorContext
ec_0("Alternative '");
650 TTCN_EncDec_ErrorContext ec_1
;
651 switch (union_selection
) {
653 ec_1
.set_msg("syntaxes': ");
654 new_tlv
= field_syntaxes
->BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, p_coding
);
657 ec_1
.set_msg("syntax': ");
658 new_tlv
= field_syntax
->BER_encode_TLV(CHARACTER_STRING_identification_syntax_descr_
, p_coding
);
660 case ALT_presentation__context__id
:
661 ec_1
.set_msg("presentation_context_id': ");
662 new_tlv
= field_presentation__context__id
->BER_encode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_coding
);
664 case ALT_context__negotiation
:
665 ec_1
.set_msg("context_negotiation': ");
666 new_tlv
= field_context__negotiation
->BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, p_coding
);
668 case ALT_transfer__syntax
:
669 ec_1
.set_msg("transfer_syntax': ");
670 new_tlv
= field_transfer__syntax
->BER_encode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_coding
);
673 ec_1
.set_msg("fixed': ");
674 new_tlv
= field_fixed
->BER_encode_TLV(CHARACTER_STRING_identification_fixed_descr_
, p_coding
);
677 new_tlv
= BER_encode_chk_bound(FALSE
);
680 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
683 return ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
686 boolean
CHARACTER_STRING_identification::BER_decode_set_selection(const ASN_BER_TLV_t
& p_tlv
)
689 field_syntaxes
= new CHARACTER_STRING_identification_syntaxes
;
690 union_selection
= ALT_syntaxes
;
691 if (field_syntaxes
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntaxes_descr_
, p_tlv
)) return TRUE
;
692 delete field_syntaxes
;
693 field_syntax
= new OBJID
;
694 union_selection
= ALT_syntax
;
695 if (field_syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntax_descr_
, p_tlv
)) return TRUE
;
697 field_presentation__context__id
= new INTEGER
;
698 union_selection
= ALT_presentation__context__id
;
699 if (field_presentation__context__id
->BER_decode_isMyMsg(CHARACTER_STRING_identification_presentation__context__id_descr_
, p_tlv
)) return TRUE
;
700 delete field_presentation__context__id
;
701 field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation
;
702 union_selection
= ALT_context__negotiation
;
703 if (field_context__negotiation
->BER_decode_isMyMsg(CHARACTER_STRING_identification_context__negotiation_descr_
, p_tlv
)) return TRUE
;
704 delete field_context__negotiation
;
705 field_transfer__syntax
= new OBJID
;
706 union_selection
= ALT_transfer__syntax
;
707 if (field_transfer__syntax
->BER_decode_isMyMsg(CHARACTER_STRING_identification_transfer__syntax_descr_
, p_tlv
)) return TRUE
;
708 delete field_transfer__syntax
;
709 field_fixed
= new ASN_NULL
;
710 union_selection
= ALT_fixed
;
711 if (field_fixed
->BER_decode_isMyMsg(CHARACTER_STRING_identification_fixed_descr_
, p_tlv
)) return TRUE
;
713 union_selection
= UNBOUND_VALUE
;
717 boolean
CHARACTER_STRING_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
)
719 if (p_td
.ber
->n_tags
== 0) {
720 CHARACTER_STRING_identification tmp_type
;
721 return tmp_type
.BER_decode_set_selection(p_tlv
);
722 } else return Base_Type::BER_decode_isMyMsg(p_td
, p_tlv
);
725 boolean
CHARACTER_STRING_identification::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
728 ASN_BER_TLV_t stripped_tlv
;
729 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
730 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification' type: ");
731 ASN_BER_TLV_t tmp_tlv
;
732 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
;
733 TTCN_EncDec_ErrorContext
ec_1("Alternative '");
734 TTCN_EncDec_ErrorContext ec_2
;
735 switch (union_selection
) {
737 ec_2
.set_msg("syntaxes': ");
738 field_syntaxes
->BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_descr_
, tmp_tlv
, L_form
);
741 ec_2
.set_msg("syntax': ");
742 field_syntax
->BER_decode_TLV(CHARACTER_STRING_identification_syntax_descr_
, tmp_tlv
, L_form
);
744 case ALT_presentation__context__id
:
745 ec_2
.set_msg("presentation_context_id': ");
746 field_presentation__context__id
->BER_decode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_
, tmp_tlv
, L_form
);
748 case ALT_context__negotiation
:
749 ec_2
.set_msg("context_negotiation': ");
750 field_context__negotiation
->BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_
, tmp_tlv
, L_form
);
752 case ALT_transfer__syntax
:
753 ec_2
.set_msg("transfer_syntax': ");
754 field_transfer__syntax
->BER_decode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_
, tmp_tlv
, L_form
);
757 ec_2
.set_msg("fixed': ");
758 field_fixed
->BER_decode_TLV(CHARACTER_STRING_identification_fixed_descr_
, tmp_tlv
, L_form
);
766 // FIXME maybe: XER_encode and decode is virtually identical to EMBEDDED_PDV
768 int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t
& p_td
,
769 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
771 int encoded_length
=(int)p_buf
.get_len();
773 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
776 switch (union_selection
) {
778 field_syntaxes
->XER_encode(EMBEDDED_PDV_identification_sxs_xer_
, p_buf
, flavor
, indent
, 0);
781 field_syntax
->XER_encode(EMBEDDED_PDV_identification_sx_xer_
, p_buf
, flavor
, indent
, 0);
783 case ALT_presentation__context__id
:
784 field_presentation__context__id
->XER_encode(EMBEDDED_PDV_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
786 case ALT_context__negotiation
:
787 field_context__negotiation
->XER_encode(EMBEDDED_PDV_identification_cn_xer_
, p_buf
, flavor
, indent
, 0);
789 case ALT_transfer__syntax
:
790 field_transfer__syntax
->XER_encode(EMBEDDED_PDV_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
793 field_fixed
->XER_encode(EMBEDDED_PDV_identification_fix_xer_
, p_buf
, flavor
, indent
, 0);
796 TTCN_EncDec_ErrorContext::error_internal("Unknown selection.");
800 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
802 return (int)p_buf
.get_len() - encoded_length
;
805 int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t
& p_td
,
806 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
808 int exer
= is_exer(flavor
);
809 // we are supposed to be parked on our element
810 for (int success
= 1; success
== 1; success
= reader
.Read()) {
811 int type
= reader
.NodeType();
813 case XML_READER_TYPE_ELEMENT
: {
814 if (verify_name(reader
, p_td
, exer
)) {
816 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
817 type
= reader
.NodeType();
818 if (XML_READER_TYPE_ELEMENT
== type
) break;
819 else if (XML_READER_TYPE_END_ELEMENT
== type
) goto bail
;
821 const char *name
= (const char*)reader
.Name();
822 // Avoid chained if-else on strcmp. Use the length as a hash
823 // (thankfully, they are all different).
824 size_t namelen
= strlen(name
);
827 syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_
, reader
, flavor
, 0);
831 syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_
, reader
, flavor
, 0);
834 case 23: // presentation-context-id
835 presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_
, reader
, flavor
, 0);
838 case 19: // context-negotiation
839 context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_
, reader
, flavor
, 0);
842 case 15: // transfer-syntax
843 transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_
, reader
, flavor
, 0);
847 fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_
, reader
, flavor
, 0);
854 else { // it belongs to somebody else
858 case XML_READER_TYPE_END_ELEMENT
: {
859 // advance to the next thing and bail
868 void CHARACTER_STRING_identification_template::clean_up()
870 switch (template_selection
) {
872 switch (single_value
.union_selection
) {
873 case CHARACTER_STRING_identification::ALT_syntaxes
:
874 delete single_value
.field_syntaxes
;
876 case CHARACTER_STRING_identification::ALT_syntax
:
877 delete single_value
.field_syntax
;
879 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
880 delete single_value
.field_presentation__context__id
;
882 case CHARACTER_STRING_identification::ALT_context__negotiation
:
883 delete single_value
.field_context__negotiation
;
885 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
886 delete single_value
.field_transfer__syntax
;
888 case CHARACTER_STRING_identification::ALT_fixed
:
889 delete single_value
.field_fixed
;
896 case COMPLEMENTED_LIST
:
897 delete [] value_list
.list_value
;
902 template_selection
= UNINITIALIZED_TEMPLATE
;
905 void CHARACTER_STRING_identification_template::copy_value(const CHARACTER_STRING_identification
& other_value
)
907 single_value
.union_selection
= other_value
.get_selection();
908 switch (single_value
.union_selection
) {
909 case CHARACTER_STRING_identification::ALT_syntaxes
:
910 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(other_value
.syntaxes());
912 case CHARACTER_STRING_identification::ALT_syntax
:
913 single_value
.field_syntax
= new OBJID_template(other_value
.syntax());
915 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
916 single_value
.field_presentation__context__id
= new INTEGER_template(other_value
.presentation__context__id());
918 case CHARACTER_STRING_identification::ALT_context__negotiation
:
919 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(other_value
.context__negotiation());
921 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
922 single_value
.field_transfer__syntax
= new OBJID_template(other_value
.transfer__syntax());
924 case CHARACTER_STRING_identification::ALT_fixed
:
925 single_value
.field_fixed
= new ASN_NULL_template(other_value
.fixed());
928 TTCN_error("Initializing a template with an unbound value of type CHARACTER STRING.identification.");
930 set_selection(SPECIFIC_VALUE
);
933 void CHARACTER_STRING_identification_template::copy_template(const CHARACTER_STRING_identification_template
& other_value
)
935 switch (other_value
.template_selection
) {
937 single_value
.union_selection
= other_value
.single_value
.union_selection
;
938 switch (single_value
.union_selection
) {
939 case CHARACTER_STRING_identification::ALT_syntaxes
:
940 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(*other_value
.single_value
.field_syntaxes
);
942 case CHARACTER_STRING_identification::ALT_syntax
:
943 single_value
.field_syntax
= new OBJID_template(*other_value
.single_value
.field_syntax
);
945 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
946 single_value
.field_presentation__context__id
= new INTEGER_template(*other_value
.single_value
.field_presentation__context__id
);
948 case CHARACTER_STRING_identification::ALT_context__negotiation
:
949 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(*other_value
.single_value
.field_context__negotiation
);
951 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
952 single_value
.field_transfer__syntax
= new OBJID_template(*other_value
.single_value
.field_transfer__syntax
);
954 case CHARACTER_STRING_identification::ALT_fixed
:
955 single_value
.field_fixed
= new ASN_NULL_template(*other_value
.single_value
.field_fixed
);
958 TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type CHARACTER STRING.identification.");
966 case COMPLEMENTED_LIST
:
967 value_list
.n_values
= other_value
.value_list
.n_values
;
968 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
969 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
970 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
973 TTCN_error("Copying an uninitialized template of union type CHARACTER STRING.identification.");
975 set_selection(other_value
);
978 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template()
982 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(template_sel other_value
)
983 : Base_Template(other_value
)
985 check_single_selection(other_value
);
988 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification
& other_value
)
990 copy_value(other_value
);
993 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
995 switch (other_value
.get_selection()) {
996 case OPTIONAL_PRESENT
:
997 copy_value((const CHARACTER_STRING_identification
&)other_value
);
1000 set_selection(OMIT_VALUE
);
1003 TTCN_error("Creating a template of union type CHARACTER STRING.identification from an unbound optional field.");
1007 CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification_template
& other_value
)
1010 copy_template(other_value
);
1013 CHARACTER_STRING_identification_template::~CHARACTER_STRING_identification_template()
1018 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(template_sel other_value
)
1020 check_single_selection(other_value
);
1022 set_selection(other_value
);
1026 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification
& other_value
)
1029 copy_value(other_value
);
1033 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification
>& other_value
)
1036 switch (other_value
.get_selection()) {
1037 case OPTIONAL_PRESENT
:
1038 copy_value((const CHARACTER_STRING_identification
&)other_value
);
1041 set_selection(OMIT_VALUE
);
1044 TTCN_error("Assignment of an unbound optional field to a template of union type CHARACTER STRING.identification.");
1049 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification_template
& other_value
)
1051 if (&other_value
!= this) {
1053 copy_template(other_value
);
1058 boolean
CHARACTER_STRING_identification_template::match(const CHARACTER_STRING_identification
& other_value
,
1059 boolean
/* legacy */) const
1061 switch (template_selection
) {
1067 case SPECIFIC_VALUE
:
1069 CHARACTER_STRING_identification::union_selection_type value_selection
= other_value
.get_selection();
1070 if (value_selection
== CHARACTER_STRING_identification::UNBOUND_VALUE
) return FALSE
;
1071 if (value_selection
!= single_value
.union_selection
) return FALSE
;
1072 switch (value_selection
) {
1073 case CHARACTER_STRING_identification::ALT_syntaxes
:
1074 return single_value
.field_syntaxes
->match(other_value
.syntaxes());
1075 case CHARACTER_STRING_identification::ALT_syntax
:
1076 return single_value
.field_syntax
->match(other_value
.syntax());
1077 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1078 return single_value
.field_presentation__context__id
->match(other_value
.presentation__context__id());
1079 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1080 return single_value
.field_context__negotiation
->match(other_value
.context__negotiation());
1081 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1082 return single_value
.field_transfer__syntax
->match(other_value
.transfer__syntax());
1083 case CHARACTER_STRING_identification::ALT_fixed
:
1084 return single_value
.field_fixed
->match(other_value
.fixed());
1086 TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type CHARACTER STRING.identification.");
1090 case COMPLEMENTED_LIST
:
1091 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1092 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
1093 return template_selection
== COMPLEMENTED_LIST
;
1095 TTCN_error ("Matching an uninitialized template of union type CHARACTER STRING.identification.");
1100 CHARACTER_STRING_identification
CHARACTER_STRING_identification_template::valueof() const
1102 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
1103 TTCN_error("Performing valueof or send operation on a non-specific template of union type CHARACTER STRING.identification.");
1104 CHARACTER_STRING_identification ret_val
;
1105 switch (single_value
.union_selection
) {
1106 case CHARACTER_STRING_identification::ALT_syntaxes
:
1107 ret_val
.syntaxes() = single_value
.field_syntaxes
->valueof();
1109 case CHARACTER_STRING_identification::ALT_syntax
:
1110 ret_val
.syntax() = single_value
.field_syntax
->valueof();
1112 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1113 ret_val
.presentation__context__id() = single_value
.field_presentation__context__id
->valueof();
1115 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1116 ret_val
.context__negotiation() = single_value
.field_context__negotiation
->valueof();
1118 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1119 ret_val
.transfer__syntax() = single_value
.field_transfer__syntax
->valueof();
1121 case CHARACTER_STRING_identification::ALT_fixed
:
1122 ret_val
.fixed() = single_value
.field_fixed
->valueof();
1125 TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type CHARACTER STRING.identification.");
1130 CHARACTER_STRING_identification_template
& CHARACTER_STRING_identification_template::list_item(unsigned int list_index
) const
1132 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.");
1133 if (list_index
>= value_list
.n_values
) TTCN_error("Internal error: Index overflow in a value list template of union type CHARACTER STRING.identification.");
1134 return value_list
.list_value
[list_index
];
1136 void CHARACTER_STRING_identification_template::set_type(template_sel template_type
, unsigned int list_length
)
1138 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.");
1140 set_selection(template_type
);
1141 value_list
.n_values
= list_length
;
1142 value_list
.list_value
= new CHARACTER_STRING_identification_template
[list_length
];
1145 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes()
1147 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntaxes
) {
1148 template_sel old_selection
= template_selection
;
1150 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template(ANY_VALUE
);
1151 else single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1152 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntaxes
;
1153 set_selection(SPECIFIC_VALUE
);
1155 return *single_value
.field_syntaxes
;
1158 const CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_template::syntaxes() const
1160 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntaxes in a non-specific template of union type CHARACTER STRING.identification.");
1161 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.");
1162 return *single_value
.field_syntaxes
;
1165 OBJID_template
& CHARACTER_STRING_identification_template::syntax()
1167 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_syntax
) {
1168 template_sel old_selection
= template_selection
;
1170 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_syntax
= new OBJID_template(ANY_VALUE
);
1171 else single_value
.field_syntax
= new OBJID_template
;
1172 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_syntax
;
1173 set_selection(SPECIFIC_VALUE
);
1175 return *single_value
.field_syntax
;
1178 const OBJID_template
& CHARACTER_STRING_identification_template::syntax() const
1180 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field syntax in a non-specific template of union type CHARACTER STRING.identification.");
1181 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.");
1182 return *single_value
.field_syntax
;
1185 INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id()
1187 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_presentation__context__id
) {
1188 template_sel old_selection
= template_selection
;
1190 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_presentation__context__id
= new INTEGER_template(ANY_VALUE
);
1191 else single_value
.field_presentation__context__id
= new INTEGER_template
;
1192 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_presentation__context__id
;
1193 set_selection(SPECIFIC_VALUE
);
1195 return *single_value
.field_presentation__context__id
;
1198 const INTEGER_template
& CHARACTER_STRING_identification_template::presentation__context__id() const
1200 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type CHARACTER STRING.identification.");
1201 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.");
1202 return *single_value
.field_presentation__context__id
;
1205 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation()
1207 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_context__negotiation
) {
1208 template_sel old_selection
= template_selection
;
1210 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template(ANY_VALUE
);
1211 else single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1212 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_context__negotiation
;
1213 set_selection(SPECIFIC_VALUE
);
1215 return *single_value
.field_context__negotiation
;
1218 const CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_template::context__negotiation() const
1220 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field context_negotiation in a non-specific template of union type CHARACTER STRING.identification.");
1221 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.");
1222 return *single_value
.field_context__negotiation
;
1225 OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax()
1227 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_transfer__syntax
) {
1228 template_sel old_selection
= template_selection
;
1230 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_transfer__syntax
= new OBJID_template(ANY_VALUE
);
1231 else single_value
.field_transfer__syntax
= new OBJID_template
;
1232 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_transfer__syntax
;
1233 set_selection(SPECIFIC_VALUE
);
1235 return *single_value
.field_transfer__syntax
;
1238 const OBJID_template
& CHARACTER_STRING_identification_template::transfer__syntax() const
1240 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type CHARACTER STRING.identification.");
1241 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.");
1242 return *single_value
.field_transfer__syntax
;
1245 ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed()
1247 if (template_selection
!= SPECIFIC_VALUE
|| single_value
.union_selection
!= CHARACTER_STRING_identification::ALT_fixed
) {
1248 template_sel old_selection
= template_selection
;
1250 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) single_value
.field_fixed
= new ASN_NULL_template(ANY_VALUE
);
1251 else single_value
.field_fixed
= new ASN_NULL_template
;
1252 single_value
.union_selection
= CHARACTER_STRING_identification::ALT_fixed
;
1253 set_selection(SPECIFIC_VALUE
);
1255 return *single_value
.field_fixed
;
1258 const ASN_NULL_template
& CHARACTER_STRING_identification_template::fixed() const
1260 if (template_selection
!= SPECIFIC_VALUE
) TTCN_error("Accessing field fixed in a non-specific template of union type CHARACTER STRING.identification.");
1261 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.");
1262 return *single_value
.field_fixed
;
1265 boolean
CHARACTER_STRING_identification_template::ischosen(CHARACTER_STRING_identification::union_selection_type checked_selection
) const
1267 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.");
1268 switch (template_selection
) {
1269 case SPECIFIC_VALUE
:
1270 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.");
1271 return single_value
.union_selection
== checked_selection
;
1274 if (value_list
.n_values
< 1)
1275 TTCN_error("Internal error: Performing ischosen() operation on a template of union type CHARACTER STRING.identification containing an empty list.");
1276 boolean ret_val
= value_list
.list_value
[0].ischosen(checked_selection
);
1277 boolean all_same
= TRUE
;
1278 for (unsigned int list_count
= 1; list_count
< value_list
.n_values
; list_count
++) {
1279 if (value_list
.list_value
[list_count
].ischosen(checked_selection
) != ret_val
) {
1284 if (all_same
) return ret_val
;
1286 // FIXME really no break?
1290 case COMPLEMENTED_LIST
:
1291 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.");
1293 TTCN_error("Performing ischosen() operation on an uninitialized template of union type CHARACTER STRING.identification");
1298 void CHARACTER_STRING_identification_template::log() const
1300 switch (template_selection
) {
1301 case SPECIFIC_VALUE
:
1302 switch (single_value
.union_selection
) {
1303 case CHARACTER_STRING_identification::ALT_syntaxes
:
1304 TTCN_Logger::log_event_str("{ syntaxes := ");
1305 single_value
.field_syntaxes
->log();
1306 TTCN_Logger::log_event_str(" }");
1308 case CHARACTER_STRING_identification::ALT_syntax
:
1309 TTCN_Logger::log_event_str("{ syntax := ");
1310 single_value
.field_syntax
->log();
1311 TTCN_Logger::log_event_str(" }");
1313 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1314 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1315 single_value
.field_presentation__context__id
->log();
1316 TTCN_Logger::log_event_str(" }");
1318 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1319 TTCN_Logger::log_event_str("{ context_negotiation := ");
1320 single_value
.field_context__negotiation
->log();
1321 TTCN_Logger::log_event_str(" }");
1323 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1324 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1325 single_value
.field_transfer__syntax
->log();
1326 TTCN_Logger::log_event_str(" }");
1328 case CHARACTER_STRING_identification::ALT_fixed
:
1329 TTCN_Logger::log_event_str("{ fixed := ");
1330 single_value
.field_fixed
->log();
1331 TTCN_Logger::log_event_str(" }");
1334 TTCN_Logger::log_event_str("<invalid selector>");
1338 case COMPLEMENTED_LIST
:
1339 TTCN_Logger::log_event_str("complement ");
1342 TTCN_Logger::log_char('(');
1343 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
1344 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
1345 value_list
.list_value
[list_count
].log();
1347 TTCN_Logger::log_char(')');
1356 void CHARACTER_STRING_identification_template::log_match(const CHARACTER_STRING_identification
& match_value
,
1357 boolean
/* legacy */) const
1359 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1360 if(match(match_value
)){
1361 TTCN_Logger::print_logmatch_buffer();
1362 TTCN_Logger::log_event_str(" matched ");
1366 if (template_selection
== SPECIFIC_VALUE
&& single_value
.union_selection
== match_value
.get_selection()) {
1367 switch (single_value
.union_selection
) {
1368 case CHARACTER_STRING_identification::ALT_syntaxes
:
1369 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1370 TTCN_Logger::log_logmatch_info(".syntaxes");
1371 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1373 TTCN_Logger::log_event_str("{ syntaxes := ");
1374 single_value
.field_syntaxes
->log_match(match_value
.syntaxes());
1375 TTCN_Logger::log_event_str(" }");
1378 case CHARACTER_STRING_identification::ALT_syntax
:
1379 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1380 TTCN_Logger::log_logmatch_info(".syntax");
1381 single_value
.field_syntax
->log_match(match_value
.syntax());
1383 TTCN_Logger::log_event_str("{ syntax := ");
1384 single_value
.field_syntax
->log_match(match_value
.syntax());
1385 TTCN_Logger::log_event_str(" }");
1388 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1389 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1390 TTCN_Logger::log_logmatch_info(".presentation_context_id");
1391 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1393 TTCN_Logger::log_event_str("{ presentation_context_id := ");
1394 single_value
.field_presentation__context__id
->log_match(match_value
.presentation__context__id());
1395 TTCN_Logger::log_event_str(" }");
1398 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1399 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1400 TTCN_Logger::log_logmatch_info(".context_negotiation");
1401 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1403 TTCN_Logger::log_event_str("{ context_negotiation := ");
1404 single_value
.field_context__negotiation
->log_match(match_value
.context__negotiation());
1405 TTCN_Logger::log_event_str(" }");
1408 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1409 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1410 TTCN_Logger::log_logmatch_info(".transfer_syntax");
1411 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1413 TTCN_Logger::log_event_str("{ transfer_syntax := ");
1414 single_value
.field_transfer__syntax
->log_match(match_value
.transfer__syntax());
1415 TTCN_Logger::log_event_str(" }");
1418 case CHARACTER_STRING_identification::ALT_fixed
:
1419 if(TTCN_Logger::VERBOSITY_COMPACT
== TTCN_Logger::get_matching_verbosity()){
1420 TTCN_Logger::log_logmatch_info(".fixed");
1421 single_value
.field_fixed
->log_match(match_value
.fixed());
1423 TTCN_Logger::log_event_str("{ fixed := ");
1424 single_value
.field_fixed
->log_match(match_value
.fixed());
1425 TTCN_Logger::log_event_str(" }");
1429 TTCN_Logger::print_logmatch_buffer();
1430 TTCN_Logger::log_event_str("<invalid selector>");
1434 TTCN_Logger::print_logmatch_buffer();
1436 TTCN_Logger::log_event_str(" with ");
1438 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
1439 else TTCN_Logger::log_event_str(" unmatched");
1443 void CHARACTER_STRING_identification_template::encode_text(Text_Buf
& text_buf
) const
1445 encode_text_base(text_buf
);
1446 switch (template_selection
) {
1447 case SPECIFIC_VALUE
:
1448 text_buf
.push_int(single_value
.union_selection
);
1449 switch (single_value
.union_selection
) {
1450 case CHARACTER_STRING_identification::ALT_syntaxes
:
1451 single_value
.field_syntaxes
->encode_text(text_buf
);
1453 case CHARACTER_STRING_identification::ALT_syntax
:
1454 single_value
.field_syntax
->encode_text(text_buf
);
1456 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1457 single_value
.field_presentation__context__id
->encode_text(text_buf
);
1459 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1460 single_value
.field_context__negotiation
->encode_text(text_buf
);
1462 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1463 single_value
.field_transfer__syntax
->encode_text(text_buf
);
1465 case CHARACTER_STRING_identification::ALT_fixed
:
1466 single_value
.field_fixed
->encode_text(text_buf
);
1469 TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type CHARACTER STRING.identification.");
1477 case COMPLEMENTED_LIST
:
1478 text_buf
.push_int(value_list
.n_values
);
1479 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1480 value_list
.list_value
[list_count
].encode_text(text_buf
);
1483 TTCN_error("Text encoder: Encoding an uninitialized template of type CHARACTER STRING.identification.");
1487 void CHARACTER_STRING_identification_template::decode_text(Text_Buf
& text_buf
)
1490 decode_text_base(text_buf
);
1491 switch (template_selection
) {
1492 case SPECIFIC_VALUE
:
1494 single_value
.union_selection
= CHARACTER_STRING_identification::UNBOUND_VALUE
;
1495 CHARACTER_STRING_identification::union_selection_type new_selection
= (CHARACTER_STRING_identification::union_selection_type
)text_buf
.pull_int().get_val();
1496 switch (new_selection
) {
1497 case CHARACTER_STRING_identification::ALT_syntaxes
:
1498 single_value
.field_syntaxes
= new CHARACTER_STRING_identification_syntaxes_template
;
1499 single_value
.field_syntaxes
->decode_text(text_buf
);
1501 case CHARACTER_STRING_identification::ALT_syntax
:
1502 single_value
.field_syntax
= new OBJID_template
;
1503 single_value
.field_syntax
->decode_text(text_buf
);
1505 case CHARACTER_STRING_identification::ALT_presentation__context__id
:
1506 single_value
.field_presentation__context__id
= new INTEGER_template
;
1507 single_value
.field_presentation__context__id
->decode_text(text_buf
);
1509 case CHARACTER_STRING_identification::ALT_context__negotiation
:
1510 single_value
.field_context__negotiation
= new CHARACTER_STRING_identification_context__negotiation_template
;
1511 single_value
.field_context__negotiation
->decode_text(text_buf
);
1513 case CHARACTER_STRING_identification::ALT_transfer__syntax
:
1514 single_value
.field_transfer__syntax
= new OBJID_template
;
1515 single_value
.field_transfer__syntax
->decode_text(text_buf
);
1517 case CHARACTER_STRING_identification::ALT_fixed
:
1518 single_value
.field_fixed
= new ASN_NULL_template
;
1519 single_value
.field_fixed
->decode_text(text_buf
);
1522 TTCN_error("Text decoder: Unrecognized union selector was received for a template of type CHARACTER STRING.identification.");
1524 single_value
.union_selection
= new_selection
;
1532 case COMPLEMENTED_LIST
:
1533 value_list
.n_values
= text_buf
.pull_int().get_val();
1534 value_list
.list_value
= new CHARACTER_STRING_identification_template
[value_list
.n_values
];
1535 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1536 value_list
.list_value
[list_count
].decode_text(text_buf
);
1539 TTCN_error("Text decoder: Unrecognized selector was received in a template of type CHARACTER STRING.identification.");
1543 boolean
CHARACTER_STRING_identification_template::is_present(boolean legacy
/* = FALSE */) const
1545 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
1546 return !match_omit(legacy
);
1549 boolean
CHARACTER_STRING_identification_template::match_omit(boolean legacy
/* = FALSE */) const
1551 if (is_ifpresent
) return TRUE
;
1552 switch (template_selection
) {
1557 case COMPLEMENTED_LIST
:
1559 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
1560 if (value_list
.list_value
[i
].match_omit())
1561 return template_selection
==VALUE_LIST
;
1562 return template_selection
==COMPLEMENTED_LIST
;
1563 } // else fall through
1570 #ifndef TITAN_RUNTIME_2
1571 void CHARACTER_STRING_identification_template::check_restriction(template_res t_res
, const char* t_name
,
1572 boolean legacy
/* = FALSE */) const
1574 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
1575 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
1577 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
1580 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
1581 template_selection
==SPECIFIC_VALUE
)) return;
1584 if (!match_omit(legacy
)) return;
1589 TTCN_error("Restriction `%s' on template of type %s violated.",
1590 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification");
1594 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes()
1598 CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes(const OBJID
& par_abstract
,
1599 const OBJID
& par_transfer
)
1600 : field_abstract(par_abstract
),
1601 field_transfer(par_transfer
)
1605 boolean
CHARACTER_STRING_identification_syntaxes::operator==(const CHARACTER_STRING_identification_syntaxes
& other_value
) const
1607 return field_abstract
==other_value
.field_abstract
1608 && field_transfer
==other_value
.field_transfer
;
1611 int CHARACTER_STRING_identification_syntaxes::size_of() const
1617 void CHARACTER_STRING_identification_syntaxes::log() const
1619 TTCN_Logger::log_event_str("{ abstract := ");
1620 field_abstract
.log();
1621 TTCN_Logger::log_event_str(", transfer := ");
1622 field_transfer
.log();
1623 TTCN_Logger::log_event_str(" }");
1626 boolean
CHARACTER_STRING_identification_syntaxes::is_bound() const
1628 if(field_abstract
.is_bound()) return TRUE
;
1629 if(field_transfer
.is_bound()) return TRUE
;
1633 boolean
CHARACTER_STRING_identification_syntaxes::is_value() const
1635 if(!field_abstract
.is_value()) return FALSE
;
1636 if(!field_transfer
.is_value()) return FALSE
;
1640 void CHARACTER_STRING_identification_syntaxes::clean_up()
1642 field_abstract
.clean_up();
1643 field_transfer
.clean_up();
1646 void CHARACTER_STRING_identification_syntaxes::set_param(Module_Param
& param
)
1648 param
.basic_check(Module_Param::BC_VALUE
, "record value");
1649 Module_Param_Ptr mp
= ¶m
;
1650 if (param
.get_type() == Module_Param::MP_Reference
) {
1651 mp
= param
.get_referenced_param();
1653 switch (mp
->get_type()) {
1654 case Module_Param::MP_Value_List
:
1655 if (mp
->get_size()==0) return;
1656 if (2!=mp
->get_size()) {
1657 param
.error("record value of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
1659 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
1660 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
1662 case Module_Param::MP_Assignment_List
: {
1663 Vector
<bool> value_used(mp
->get_size());
1664 value_used
.resize(mp
->get_size(), false);
1665 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1666 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1667 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1668 abstract().set_param(*curr_param
);
1669 value_used
[val_idx
]=true;
1672 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1673 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1674 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1675 transfer().set_param(*curr_param
);
1676 value_used
[val_idx
]=true;
1679 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1680 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());
1685 param
.type_error("record value", "CHARACTER STRING.identification.syntaxes");
1689 Module_Param
* CHARACTER_STRING_identification_syntaxes::get_param(Module_Param_Name
& param_name
) const
1692 return new Module_Param_Unbound();
1694 Module_Param
* mp_field_abstract
= field_abstract
.get_param(param_name
);
1695 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
1696 Module_Param
* mp_field_transfer
= field_transfer
.get_param(param_name
);
1697 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
1698 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
1699 mp
->add_elem(mp_field_abstract
);
1700 mp
->add_elem(mp_field_transfer
);
1704 void CHARACTER_STRING_identification_syntaxes::encode_text(Text_Buf
& text_buf
) const
1706 field_abstract
.encode_text(text_buf
);
1707 field_transfer
.encode_text(text_buf
);
1710 void CHARACTER_STRING_identification_syntaxes::decode_text(Text_Buf
& text_buf
)
1712 field_abstract
.decode_text(text_buf
);
1713 field_transfer
.decode_text(text_buf
);
1717 void CHARACTER_STRING_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
1718 void CHARACTER_STRING_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
1721 ASN_BER_TLV_t
* CHARACTER_STRING_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
1723 BER_chk_descr(p_td
);
1724 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
1725 TTCN_EncDec_ErrorContext
ec_0("Component '");
1726 TTCN_EncDec_ErrorContext ec_1
;
1727 ec_1
.set_msg("abstract': ");
1728 new_tlv
->add_TLV(field_abstract
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, p_coding
));
1729 ec_1
.set_msg("transfer': ");
1730 new_tlv
->add_TLV(field_transfer
.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, p_coding
));
1731 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
1735 boolean
CHARACTER_STRING_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
1737 BER_chk_descr(p_td
);
1738 ASN_BER_TLV_t stripped_tlv
;
1739 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
1740 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.syntaxes' type: ");
1741 stripped_tlv
.chk_constructed_flag(TRUE
);
1743 ASN_BER_TLV_t tmp_tlv
;
1744 boolean tlv_present
=FALSE
;
1746 TTCN_EncDec_ErrorContext
ec_1("Component '");
1747 TTCN_EncDec_ErrorContext ec_2
;
1748 ec_2
.set_msg("abstract': ");
1749 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1750 if(!tlv_present
) return FALSE
;
1751 field_abstract
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_
, tmp_tlv
, L_form
);
1753 ec_2
.set_msg("transfer': ");
1754 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
1755 if(!tlv_present
) return FALSE
;
1756 field_transfer
.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_
, tmp_tlv
, L_form
);
1759 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
1763 int CHARACTER_STRING_identification_syntaxes::XER_encode(const XERdescriptor_t
& p_td
,
1764 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
1766 int encoded_length
=(int)p_buf
.get_len();
1768 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
1770 field_abstract
.XER_encode(CHARACTER_STRING_identification_sxs_abs_xer_
, p_buf
, flavor
, indent
, 0);
1771 field_transfer
.XER_encode(CHARACTER_STRING_identification_sxs_xfr_xer_
, p_buf
, flavor
, indent
, 0);
1773 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
1775 return p_buf
.get_len() - encoded_length
;
1778 int CHARACTER_STRING_identification_syntaxes::XER_decode(
1779 const XERdescriptor_t
& /*p_td*/, XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
1780 { // we stand on <syntaxes>, move ahead first
1781 for (int success
= reader
.Read(); success
== 1; success
= reader
.Read())
1783 int type
= reader
.NodeType();
1784 if (XML_READER_TYPE_ELEMENT
== type
)
1785 // no verify_name for a CHOICE
1788 // FIXME this assumes the right element
1789 field_abstract
.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_
, reader
, flavor
, 0);
1790 field_transfer
.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_
, reader
, flavor
, 0);
1791 for (int success
= 1; success
== 1; success
= reader
.Read())
1793 int type
= reader
.NodeType();
1794 if (XML_READER_TYPE_END_ELEMENT
== type
)
1797 return 0; // TODO maybe return proper value
1801 struct CHARACTER_STRING_identification_syntaxes_template::single_value_struct
{
1802 OBJID_template field_abstract
;
1803 OBJID_template field_transfer
;
1806 void CHARACTER_STRING_identification_syntaxes_template::set_param(Module_Param
& param
)
1808 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
1809 Module_Param_Ptr mp
= ¶m
;
1810 if (param
.get_type() == Module_Param::MP_Reference
) {
1811 mp
= param
.get_referenced_param();
1813 switch (mp
->get_type()) {
1814 case Module_Param::MP_Omit
:
1817 case Module_Param::MP_Any
:
1820 case Module_Param::MP_AnyOrNone
:
1821 *this = ANY_OR_OMIT
;
1823 case Module_Param::MP_List_Template
:
1824 case Module_Param::MP_ComplementList_Template
: {
1825 CHARACTER_STRING_identification_syntaxes_template temp
;
1826 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
1827 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
1828 for (size_t i
=0; i
<mp
->get_size(); i
++) {
1829 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
1833 case Module_Param::MP_Value_List
:
1834 if (mp
->get_size()==0) break;
1835 if (2!=mp
->get_size()) {
1836 param
.error("record template of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp
->get_size());
1838 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) abstract().set_param(*mp
->get_elem(0));
1839 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer().set_param(*mp
->get_elem(1));
1841 case Module_Param::MP_Assignment_List
: {
1842 Vector
<bool> value_used(mp
->get_size());
1843 value_used
.resize(mp
->get_size(), false);
1844 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1845 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1846 if (!strcmp(curr_param
->get_id()->get_name(), "abstract")) {
1847 abstract().set_param(*curr_param
);
1848 value_used
[val_idx
]=true;
1851 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
1852 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
1853 if (!strcmp(curr_param
->get_id()->get_name(), "transfer")) {
1854 transfer().set_param(*curr_param
);
1855 value_used
[val_idx
]=true;
1858 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
1859 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());
1864 param
.type_error("record template", "CHARACTER STRING.identification.syntaxes");
1866 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
1869 Module_Param
* CHARACTER_STRING_identification_syntaxes_template::get_param(Module_Param_Name
& param_name
) const
1871 Module_Param
* mp
= NULL
;
1872 switch (template_selection
) {
1873 case UNINITIALIZED_TEMPLATE
:
1874 mp
= new Module_Param_Unbound();
1877 mp
= new Module_Param_Omit();
1880 mp
= new Module_Param_Any();
1883 mp
= new Module_Param_AnyOrNone();
1885 case SPECIFIC_VALUE
: {
1886 Module_Param
* mp_field_abstract
= single_value
->field_abstract
.get_param(param_name
);
1887 mp_field_abstract
->set_id(new Module_Param_FieldName(mcopystr("abstract")));
1888 Module_Param
* mp_field_transfer
= single_value
->field_transfer
.get_param(param_name
);
1889 mp_field_transfer
->set_id(new Module_Param_FieldName(mcopystr("transfer")));
1890 mp
= new Module_Param_Assignment_List();
1891 mp
->add_elem(mp_field_abstract
);
1892 mp
->add_elem(mp_field_transfer
);
1895 case COMPLEMENTED_LIST
: {
1896 if (template_selection
== VALUE_LIST
) {
1897 mp
= new Module_Param_List_Template();
1900 mp
= new Module_Param_ComplementList_Template();
1902 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
1903 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
1910 mp
->set_ifpresent();
1915 void CHARACTER_STRING_identification_syntaxes_template::clean_up()
1917 switch (template_selection
) {
1918 case SPECIFIC_VALUE
:
1919 delete single_value
;
1922 case COMPLEMENTED_LIST
:
1923 delete [] value_list
.list_value
;
1928 template_selection
= UNINITIALIZED_TEMPLATE
;
1931 void CHARACTER_STRING_identification_syntaxes_template::set_specific()
1933 if (template_selection
!= SPECIFIC_VALUE
) {
1934 template_sel old_selection
= template_selection
;
1936 single_value
= new single_value_struct
;
1937 set_selection(SPECIFIC_VALUE
);
1938 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
1939 single_value
->field_abstract
= ANY_VALUE
;
1940 single_value
->field_transfer
= ANY_VALUE
;
1945 void CHARACTER_STRING_identification_syntaxes_template::copy_value(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1947 single_value
= new single_value_struct
;
1948 single_value
->field_abstract
= other_value
.abstract();
1949 single_value
->field_transfer
= other_value
.transfer();
1950 set_selection(SPECIFIC_VALUE
);
1953 void CHARACTER_STRING_identification_syntaxes_template::copy_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
1955 switch (other_value
.template_selection
) {
1956 case SPECIFIC_VALUE
:
1957 single_value
= new single_value_struct(*other_value
.single_value
);
1964 case COMPLEMENTED_LIST
:
1965 value_list
.n_values
= other_value
.value_list
.n_values
;
1966 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
1967 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
1968 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
1971 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
1973 set_selection(other_value
);
1976 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template()
1980 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(template_sel other_value
)
1981 : Base_Template(other_value
)
1983 check_single_selection(other_value
);
1986 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes
& other_value
)
1988 copy_value(other_value
);
1991 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
1993 switch (other_value
.get_selection()) {
1994 case OPTIONAL_PRESENT
:
1995 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
1998 set_selection(OMIT_VALUE
);
2001 TTCN_error("Creating a template of type CHARACTER STRING.identification.syntaxes from an unbound optional field.");
2005 CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
2008 copy_template(other_value
);
2011 CHARACTER_STRING_identification_syntaxes_template::~CHARACTER_STRING_identification_syntaxes_template()
2016 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(template_sel other_value
)
2018 check_single_selection(other_value
);
2020 set_selection(other_value
);
2024 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes
& other_value
)
2027 copy_value(other_value
);
2031 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_syntaxes
>& other_value
)
2034 switch (other_value
.get_selection()) {
2035 case OPTIONAL_PRESENT
:
2036 copy_value((const CHARACTER_STRING_identification_syntaxes
&)other_value
);
2039 set_selection(OMIT_VALUE
);
2042 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.syntaxes.");
2047 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes_template
& other_value
)
2049 if (&other_value
!= this) {
2051 copy_template(other_value
);
2056 boolean
CHARACTER_STRING_identification_syntaxes_template::match(const CHARACTER_STRING_identification_syntaxes
& other_value
,
2057 boolean
/* legacy */) const
2059 switch (template_selection
) {
2065 case SPECIFIC_VALUE
:
2066 if (!other_value
.abstract().is_bound()) return FALSE
;
2067 if (!single_value
->field_abstract
.match(other_value
.abstract())) return FALSE
;
2068 if (!other_value
.transfer().is_bound()) return FALSE
;
2069 if (!single_value
->field_transfer
.match(other_value
.transfer())) return FALSE
;
2072 case COMPLEMENTED_LIST
:
2073 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2074 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2075 return template_selection
== COMPLEMENTED_LIST
;
2077 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2082 CHARACTER_STRING_identification_syntaxes
CHARACTER_STRING_identification_syntaxes_template::valueof() const
2084 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2085 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2086 CHARACTER_STRING_identification_syntaxes ret_val
;
2087 ret_val
.abstract() = single_value
->field_abstract
.valueof();
2088 ret_val
.transfer() = single_value
->field_transfer
.valueof();
2092 void CHARACTER_STRING_identification_syntaxes_template::set_type(template_sel template_type
, unsigned int list_length
)
2094 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2095 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.syntaxes.");
2097 set_selection(template_type
);
2098 value_list
.n_values
= list_length
;
2099 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[list_length
];
2102 CHARACTER_STRING_identification_syntaxes_template
& CHARACTER_STRING_identification_syntaxes_template::list_item(unsigned int list_index
) const
2104 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2105 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.syntaxes.");
2106 if (list_index
>= value_list
.n_values
)
2107 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.syntaxes.");
2108 return value_list
.list_value
[list_index
];
2111 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract()
2114 return single_value
->field_abstract
;
2117 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::abstract() const
2119 if (template_selection
!= SPECIFIC_VALUE
)
2120 TTCN_error("Accessing field abstract of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2121 return single_value
->field_abstract
;
2124 OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer()
2127 return single_value
->field_transfer
;
2130 const OBJID_template
& CHARACTER_STRING_identification_syntaxes_template::transfer() const
2132 if (template_selection
!= SPECIFIC_VALUE
)
2133 TTCN_error("Accessing field transfer of a non-specific template of type CHARACTER STRING.identification.syntaxes.");
2134 return single_value
->field_transfer
;
2137 int CHARACTER_STRING_identification_syntaxes_template::size_of() const
2139 switch (template_selection
)
2141 case SPECIFIC_VALUE
:
2148 if (value_list
.n_values
<1)
2149 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing an empty list.");
2150 int item_size
= value_list
.list_value
[0].size_of();
2151 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2153 if (value_list
.list_value
[i
].size_of()!=item_size
)
2154 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing a value list with different sizes.");
2159 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing omit value.");
2162 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing */? value.");
2163 case COMPLEMENTED_LIST
:
2164 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing complemented list.");
2166 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2171 void CHARACTER_STRING_identification_syntaxes_template::log() const
2173 switch (template_selection
) {
2174 case SPECIFIC_VALUE
:
2175 TTCN_Logger::log_event_str("{ abstract := ");
2176 single_value
->field_abstract
.log();
2177 TTCN_Logger::log_event_str(", transfer := ");
2178 single_value
->field_transfer
.log();
2179 TTCN_Logger::log_event_str(" }");
2181 case COMPLEMENTED_LIST
:
2182 TTCN_Logger::log_event_str("complement ");
2185 TTCN_Logger::log_char('(');
2186 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2187 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2188 value_list
.list_value
[list_count
].log();
2190 TTCN_Logger::log_char(')');
2199 void CHARACTER_STRING_identification_syntaxes_template::log_match(const CHARACTER_STRING_identification_syntaxes
& match_value
,
2200 boolean
/* legacy */) const
2202 if (template_selection
== SPECIFIC_VALUE
) {
2203 TTCN_Logger::log_event_str("{ abstract := ");
2204 single_value
->field_abstract
.log_match(match_value
.abstract());
2205 TTCN_Logger::log_event_str(", transfer := ");
2206 single_value
->field_transfer
.log_match(match_value
.transfer());
2207 TTCN_Logger::log_event_str(" }");
2210 TTCN_Logger::log_event_str(" with ");
2212 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2213 else TTCN_Logger::log_event_str(" unmatched");
2217 void CHARACTER_STRING_identification_syntaxes_template::encode_text(Text_Buf
& text_buf
) const
2219 encode_text_base(text_buf
);
2220 switch (template_selection
) {
2221 case SPECIFIC_VALUE
:
2222 single_value
->field_abstract
.encode_text(text_buf
);
2223 single_value
->field_transfer
.encode_text(text_buf
);
2230 case COMPLEMENTED_LIST
:
2231 text_buf
.push_int(value_list
.n_values
);
2232 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2233 value_list
.list_value
[list_count
].encode_text(text_buf
);
2236 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes.");
2240 void CHARACTER_STRING_identification_syntaxes_template::decode_text(Text_Buf
& text_buf
)
2243 decode_text_base(text_buf
);
2244 switch (template_selection
) {
2245 case SPECIFIC_VALUE
:
2246 single_value
= new single_value_struct
;
2247 single_value
->field_abstract
.decode_text(text_buf
);
2248 single_value
->field_transfer
.decode_text(text_buf
);
2255 case COMPLEMENTED_LIST
:
2256 value_list
.n_values
= text_buf
.pull_int().get_val();
2257 value_list
.list_value
= new CHARACTER_STRING_identification_syntaxes_template
[value_list
.n_values
];
2258 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2259 value_list
.list_value
[list_count
].decode_text(text_buf
);
2262 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.syntaxes.");
2266 boolean
CHARACTER_STRING_identification_syntaxes_template::is_present(boolean legacy
/* = FALSE */) const
2268 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2269 return !match_omit(legacy
);
2272 boolean
CHARACTER_STRING_identification_syntaxes_template::match_omit(boolean legacy
/* = FALSE */) const
2274 if (is_ifpresent
) return TRUE
;
2275 switch (template_selection
) {
2280 case COMPLEMENTED_LIST
:
2282 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
2283 if (value_list
.list_value
[i
].match_omit())
2284 return template_selection
==VALUE_LIST
;
2285 return template_selection
==COMPLEMENTED_LIST
;
2286 } // else fall through
2293 #ifndef TITAN_RUNTIME_2
2294 void CHARACTER_STRING_identification_syntaxes_template::check_restriction(template_res t_res
, const char* t_name
,
2295 boolean legacy
/* = FALSE */) const
2297 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
2298 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
2300 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
2303 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
2304 template_selection
==SPECIFIC_VALUE
)) return;
2307 if (!match_omit(legacy
)) return;
2312 TTCN_error("Restriction `%s' on template of type %s violated.",
2313 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.syntaxes");
2317 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation()
2321 CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation(const INTEGER
& par_presentation__context__id
,
2322 const OBJID
& par_transfer__syntax
)
2323 : field_presentation__context__id(par_presentation__context__id
),
2324 field_transfer__syntax(par_transfer__syntax
)
2328 boolean
CHARACTER_STRING_identification_context__negotiation::operator==(const CHARACTER_STRING_identification_context__negotiation
& other_value
) const
2330 return field_presentation__context__id
==other_value
.field_presentation__context__id
2331 && field_transfer__syntax
==other_value
.field_transfer__syntax
;
2334 int CHARACTER_STRING_identification_context__negotiation::size_of() const
2340 void CHARACTER_STRING_identification_context__negotiation::log() const
2342 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2343 field_presentation__context__id
.log();
2344 TTCN_Logger::log_event_str(", transfer_syntax := ");
2345 field_transfer__syntax
.log();
2346 TTCN_Logger::log_event_str(" }");
2349 boolean
CHARACTER_STRING_identification_context__negotiation::is_bound() const
2351 if(field_presentation__context__id
.is_bound()) return TRUE
;
2352 if(field_transfer__syntax
.is_bound()) return TRUE
;
2356 boolean
CHARACTER_STRING_identification_context__negotiation::is_value() const
2358 if(!field_presentation__context__id
.is_value()) return FALSE
;
2359 if(!field_transfer__syntax
.is_value()) return FALSE
;
2363 void CHARACTER_STRING_identification_context__negotiation::clean_up()
2365 field_presentation__context__id
.clean_up();
2366 field_transfer__syntax
.clean_up();
2369 void CHARACTER_STRING_identification_context__negotiation::set_param(Module_Param
& param
)
2371 param
.basic_check(Module_Param::BC_VALUE
, "record value");
2372 Module_Param_Ptr mp
= ¶m
;
2373 if (param
.get_type() == Module_Param::MP_Reference
) {
2374 mp
= param
.get_referenced_param();
2376 switch (mp
->get_type()) {
2377 case Module_Param::MP_Value_List
:
2378 if (mp
->get_size()==0) return;
2379 if (2!=mp
->get_size()) {
2380 param
.error("record value of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2382 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2383 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2385 case Module_Param::MP_Assignment_List
: {
2386 Vector
<bool> value_used(mp
->get_size());
2387 value_used
.resize(mp
->get_size(), false);
2388 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2389 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2390 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2391 presentation__context__id().set_param(*curr_param
);
2392 value_used
[val_idx
]=true;
2395 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2396 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2397 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2398 transfer__syntax().set_param(*curr_param
);
2399 value_used
[val_idx
]=true;
2402 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2403 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());
2408 param
.type_error("record value", "CHARACTER STRING.identification.context-negotiation");
2412 Module_Param
* CHARACTER_STRING_identification_context__negotiation::get_param(Module_Param_Name
& param_name
) const
2415 return new Module_Param_Unbound();
2417 Module_Param
* mp_field_presentation_context_id
= field_presentation__context__id
.get_param(param_name
);
2418 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2419 Module_Param
* mp_field_transfer_syntax
= field_transfer__syntax
.get_param(param_name
);
2420 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2421 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
2422 mp
->add_elem(mp_field_presentation_context_id
);
2423 mp
->add_elem(mp_field_transfer_syntax
);
2427 void CHARACTER_STRING_identification_context__negotiation::encode_text(Text_Buf
& text_buf
) const
2429 field_presentation__context__id
.encode_text(text_buf
);
2430 field_transfer__syntax
.encode_text(text_buf
);
2433 void CHARACTER_STRING_identification_context__negotiation::decode_text(Text_Buf
& text_buf
)
2435 field_presentation__context__id
.decode_text(text_buf
);
2436 field_transfer__syntax
.decode_text(text_buf
);
2440 void CHARACTER_STRING_identification_context__negotiation::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
2441 void CHARACTER_STRING_identification_context__negotiation::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
2444 ASN_BER_TLV_t
* CHARACTER_STRING_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
2446 BER_chk_descr(p_td
);
2447 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
2448 TTCN_EncDec_ErrorContext
ec_0("Component '");
2449 TTCN_EncDec_ErrorContext ec_1
;
2450 ec_1
.set_msg("presentation_context_id': ");
2451 new_tlv
->add_TLV(field_presentation__context__id
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, p_coding
));
2452 ec_1
.set_msg("transfer_syntax': ");
2453 new_tlv
->add_TLV(field_transfer__syntax
.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, p_coding
));
2454 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
2458 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
)
2460 BER_chk_descr(p_td
);
2461 ASN_BER_TLV_t stripped_tlv
;
2462 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
2463 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING.identification.context-negotiation' type: ");
2464 stripped_tlv
.chk_constructed_flag(TRUE
);
2466 ASN_BER_TLV_t tmp_tlv
;
2467 boolean tlv_present
=FALSE
;
2469 TTCN_EncDec_ErrorContext
ec_1("Component '");
2470 TTCN_EncDec_ErrorContext ec_2
;
2471 ec_2
.set_msg("presentation_context_id': ");
2472 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2473 if(!tlv_present
) return FALSE
;
2474 field_presentation__context__id
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_
, tmp_tlv
, L_form
);
2476 ec_2
.set_msg("transfer_syntax': ");
2477 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
2478 if(!tlv_present
) return FALSE
;
2479 field_transfer__syntax
.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_
, tmp_tlv
, L_form
);
2482 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
2486 int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERdescriptor_t
& p_td
,
2487 TTCN_Buffer
& p_buf
, unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
2489 int encoded_length
=(int)p_buf
.get_len();
2491 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
2493 field_presentation__context__id
.XER_encode(CHARACTER_STRING_identification_pci_xer_
, p_buf
, flavor
, indent
, 0);
2494 field_transfer__syntax
.XER_encode(CHARACTER_STRING_identification_ts_xer_
, p_buf
, flavor
, indent
, 0);
2496 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
2498 return p_buf
.get_len() - encoded_length
;
2501 int CHARACTER_STRING_identification_context__negotiation::XER_decode(
2502 const XERdescriptor_t
& p_td
, XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
2504 int exer
= is_exer(flavor
);
2505 int type
= reader
.NodeType(), depth
= -1;
2506 const char* name
= (const char*)reader
.Name();
2507 int success
= reader
.Ok();
2508 if (type
==XML_READER_TYPE_ELEMENT
&& check_name(name
, p_td
, exer
)) {
2509 // we are in the right place
2510 depth
= reader
.Depth();
2511 success
= reader
.Read();
2513 field_presentation__context__id
.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_
, reader
, flavor
, 0);
2514 field_transfer__syntax
.XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_
, reader
, flavor
, 0);
2515 for (; success
== 1; success
= reader
.Read()) {
2516 type
= reader
.NodeType();
2517 if (XML_READER_TYPE_END_ELEMENT
== type
) {
2518 verify_end(reader
, p_td
, depth
, exer
);
2523 return 0; // TODO sensible return value
2526 struct CHARACTER_STRING_identification_context__negotiation_template::single_value_struct
{
2527 INTEGER_template field_presentation__context__id
;
2528 OBJID_template field_transfer__syntax
;
2531 void CHARACTER_STRING_identification_context__negotiation_template::set_param(Module_Param
& param
)
2533 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
2534 Module_Param_Ptr mp
= ¶m
;
2535 if (param
.get_type() == Module_Param::MP_Reference
) {
2536 mp
= param
.get_referenced_param();
2538 switch (mp
->get_type()) {
2539 case Module_Param::MP_Omit
:
2542 case Module_Param::MP_Any
:
2545 case Module_Param::MP_AnyOrNone
:
2546 *this = ANY_OR_OMIT
;
2548 case Module_Param::MP_List_Template
:
2549 case Module_Param::MP_ComplementList_Template
: {
2550 CHARACTER_STRING_identification_context__negotiation_template temp
;
2551 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
2552 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
2553 for (size_t i
=0; i
<mp
->get_size(); i
++) {
2554 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
2558 case Module_Param::MP_Value_List
:
2559 if (mp
->get_size()==0) break;
2560 if (2!=mp
->get_size()) {
2561 param
.error("record template of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp
->get_size());
2563 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) presentation__context__id().set_param(*mp
->get_elem(0));
2564 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) transfer__syntax().set_param(*mp
->get_elem(1));
2566 case Module_Param::MP_Assignment_List
: {
2567 Vector
<bool> value_used(mp
->get_size());
2568 value_used
.resize(mp
->get_size(), false);
2569 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2570 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2571 if (!strcmp(curr_param
->get_id()->get_name(), "presentation_context_id")) {
2572 presentation__context__id().set_param(*curr_param
);
2573 value_used
[val_idx
]=true;
2576 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
2577 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
2578 if (!strcmp(curr_param
->get_id()->get_name(), "transfer_syntax")) {
2579 transfer__syntax().set_param(*curr_param
);
2580 value_used
[val_idx
]=true;
2583 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
2584 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());
2589 param
.type_error("record template", "CHARACTER STRING.identification.context-negotiation");
2591 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
2594 Module_Param
* CHARACTER_STRING_identification_context__negotiation_template::get_param(Module_Param_Name
& param_name
) const
2596 Module_Param
* mp
= NULL
;
2597 switch (template_selection
) {
2598 case UNINITIALIZED_TEMPLATE
:
2599 mp
= new Module_Param_Unbound();
2602 mp
= new Module_Param_Omit();
2605 mp
= new Module_Param_Any();
2608 mp
= new Module_Param_AnyOrNone();
2610 case SPECIFIC_VALUE
: {
2611 Module_Param
* mp_field_presentation_context_id
= single_value
->field_presentation__context__id
.get_param(param_name
);
2612 mp_field_presentation_context_id
->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
2613 Module_Param
* mp_field_transfer_syntax
= single_value
->field_transfer__syntax
.get_param(param_name
);
2614 mp_field_transfer_syntax
->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
2615 mp
= new Module_Param_Assignment_List();
2616 mp
->add_elem(mp_field_presentation_context_id
);
2617 mp
->add_elem(mp_field_transfer_syntax
);
2620 case COMPLEMENTED_LIST
: {
2621 if (template_selection
== VALUE_LIST
) {
2622 mp
= new Module_Param_List_Template();
2625 mp
= new Module_Param_ComplementList_Template();
2627 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
2628 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
2635 mp
->set_ifpresent();
2640 void CHARACTER_STRING_identification_context__negotiation_template::clean_up()
2642 switch (template_selection
) {
2643 case SPECIFIC_VALUE
:
2644 delete single_value
;
2647 case COMPLEMENTED_LIST
:
2648 delete [] value_list
.list_value
;
2653 template_selection
= UNINITIALIZED_TEMPLATE
;
2656 void CHARACTER_STRING_identification_context__negotiation_template::set_specific()
2658 if (template_selection
!= SPECIFIC_VALUE
) {
2659 template_sel old_selection
= template_selection
;
2661 single_value
= new single_value_struct
;
2662 set_selection(SPECIFIC_VALUE
);
2663 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
2664 single_value
->field_presentation__context__id
= ANY_VALUE
;
2665 single_value
->field_transfer__syntax
= ANY_VALUE
;
2670 void CHARACTER_STRING_identification_context__negotiation_template::copy_value(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2672 single_value
= new single_value_struct
;
2673 single_value
->field_presentation__context__id
= other_value
.presentation__context__id();
2674 single_value
->field_transfer__syntax
= other_value
.transfer__syntax();
2675 set_selection(SPECIFIC_VALUE
);
2678 void CHARACTER_STRING_identification_context__negotiation_template::copy_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2680 switch (other_value
.template_selection
) {
2681 case SPECIFIC_VALUE
:
2682 single_value
= new single_value_struct(*other_value
.single_value
);
2689 case COMPLEMENTED_LIST
:
2690 value_list
.n_values
= other_value
.value_list
.n_values
;
2691 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2692 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2693 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
2696 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2698 set_selection(other_value
);
2701 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template()
2705 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(template_sel other_value
)
2706 : Base_Template(other_value
)
2708 check_single_selection(other_value
);
2711 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2713 copy_value(other_value
);
2716 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2718 switch (other_value
.get_selection()) {
2719 case OPTIONAL_PRESENT
:
2720 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2723 set_selection(OMIT_VALUE
);
2726 TTCN_error("Creating a template of type CHARACTER STRING.identification.context-negotiation from an unbound optional field.");
2730 CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2733 copy_template(other_value
);
2736 CHARACTER_STRING_identification_context__negotiation_template::~CHARACTER_STRING_identification_context__negotiation_template()
2741 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(template_sel other_value
)
2743 check_single_selection(other_value
);
2745 set_selection(other_value
);
2749 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation
& other_value
)
2752 copy_value(other_value
);
2756 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const OPTIONAL
<CHARACTER_STRING_identification_context__negotiation
>& other_value
)
2759 switch (other_value
.get_selection()) {
2760 case OPTIONAL_PRESENT
:
2761 copy_value((const CHARACTER_STRING_identification_context__negotiation
&)other_value
);
2764 set_selection(OMIT_VALUE
);
2767 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.context-negotiation.");
2772 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation_template
& other_value
)
2774 if (&other_value
!= this) {
2776 copy_template(other_value
);
2781 boolean
CHARACTER_STRING_identification_context__negotiation_template::match(const CHARACTER_STRING_identification_context__negotiation
& other_value
,
2782 boolean
/* legacy */) const
2784 switch (template_selection
) {
2790 case SPECIFIC_VALUE
:
2791 if (!other_value
.presentation__context__id().is_bound()) return FALSE
;
2792 if (!single_value
->field_presentation__context__id
.match(other_value
.presentation__context__id())) return FALSE
;
2793 if (!other_value
.transfer__syntax().is_bound()) return FALSE
;
2794 if (!single_value
->field_transfer__syntax
.match(other_value
.transfer__syntax())) return FALSE
;
2797 case COMPLEMENTED_LIST
:
2798 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2799 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
2800 return template_selection
== COMPLEMENTED_LIST
;
2802 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2807 CHARACTER_STRING_identification_context__negotiation
CHARACTER_STRING_identification_context__negotiation_template::valueof() const
2809 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
2810 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2811 CHARACTER_STRING_identification_context__negotiation ret_val
;
2812 ret_val
.presentation__context__id() = single_value
->field_presentation__context__id
.valueof();
2813 ret_val
.transfer__syntax() = single_value
->field_transfer__syntax
.valueof();
2817 void CHARACTER_STRING_identification_context__negotiation_template::set_type(template_sel template_type
, unsigned int list_length
)
2819 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
2820 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.context-negotiation.");
2822 set_selection(template_type
);
2823 value_list
.n_values
= list_length
;
2824 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[list_length
];
2827 CHARACTER_STRING_identification_context__negotiation_template
& CHARACTER_STRING_identification_context__negotiation_template::list_item(unsigned int list_index
) const
2829 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
2830 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.context-negotiation.");
2831 if (list_index
>= value_list
.n_values
)
2832 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.context-negotiation.");
2833 return value_list
.list_value
[list_index
];
2836 INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id()
2839 return single_value
->field_presentation__context__id
;
2842 const INTEGER_template
& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() const
2844 if (template_selection
!= SPECIFIC_VALUE
)
2845 TTCN_error("Accessing field presentation_context_id of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2846 return single_value
->field_presentation__context__id
;
2849 OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax()
2852 return single_value
->field_transfer__syntax
;
2855 const OBJID_template
& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() const
2857 if (template_selection
!= SPECIFIC_VALUE
)
2858 TTCN_error("Accessing field transfer_syntax of a non-specific template of type CHARACTER STRING.identification.context-negotiation.");
2859 return single_value
->field_transfer__syntax
;
2862 int CHARACTER_STRING_identification_context__negotiation_template::size_of() const
2864 switch (template_selection
)
2866 case SPECIFIC_VALUE
:
2873 if (value_list
.n_values
<1)
2874 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing an empty list.");
2875 int item_size
= value_list
.list_value
[0].size_of();
2876 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
2878 if (value_list
.list_value
[i
].size_of()!=item_size
)
2879 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing a value list with different sizes.");
2884 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing omit value.");
2887 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing */? value.");
2888 case COMPLEMENTED_LIST
:
2889 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing complemented list.");
2891 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2896 void CHARACTER_STRING_identification_context__negotiation_template::log() const
2898 switch (template_selection
) {
2899 case SPECIFIC_VALUE
:
2900 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2901 single_value
->field_presentation__context__id
.log();
2902 TTCN_Logger::log_event_str(", transfer_syntax := ");
2903 single_value
->field_transfer__syntax
.log();
2904 TTCN_Logger::log_event_str(" }");
2906 case COMPLEMENTED_LIST
:
2907 TTCN_Logger::log_event_str("complement ");
2910 TTCN_Logger::log_char('(');
2911 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
2912 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
2913 value_list
.list_value
[list_count
].log();
2915 TTCN_Logger::log_char(')');
2924 void CHARACTER_STRING_identification_context__negotiation_template::log_match(const CHARACTER_STRING_identification_context__negotiation
& match_value
,
2925 boolean
/* legacy */) const
2927 if (template_selection
== SPECIFIC_VALUE
) {
2928 TTCN_Logger::log_event_str("{ presentation_context_id := ");
2929 single_value
->field_presentation__context__id
.log_match(match_value
.presentation__context__id());
2930 TTCN_Logger::log_event_str(", transfer_syntax := ");
2931 single_value
->field_transfer__syntax
.log_match(match_value
.transfer__syntax());
2932 TTCN_Logger::log_event_str(" }");
2935 TTCN_Logger::log_event_str(" with ");
2937 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
2938 else TTCN_Logger::log_event_str(" unmatched");
2942 void CHARACTER_STRING_identification_context__negotiation_template::encode_text(Text_Buf
& text_buf
) const
2944 encode_text_base(text_buf
);
2945 switch (template_selection
) {
2946 case SPECIFIC_VALUE
:
2947 single_value
->field_presentation__context__id
.encode_text(text_buf
);
2948 single_value
->field_transfer__syntax
.encode_text(text_buf
);
2955 case COMPLEMENTED_LIST
:
2956 text_buf
.push_int(value_list
.n_values
);
2957 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2958 value_list
.list_value
[list_count
].encode_text(text_buf
);
2961 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation.");
2965 void CHARACTER_STRING_identification_context__negotiation_template::decode_text(Text_Buf
& text_buf
)
2968 decode_text_base(text_buf
);
2969 switch (template_selection
) {
2970 case SPECIFIC_VALUE
:
2971 single_value
= new single_value_struct
;
2972 single_value
->field_presentation__context__id
.decode_text(text_buf
);
2973 single_value
->field_transfer__syntax
.decode_text(text_buf
);
2980 case COMPLEMENTED_LIST
:
2981 value_list
.n_values
= text_buf
.pull_int().get_val();
2982 value_list
.list_value
= new CHARACTER_STRING_identification_context__negotiation_template
[value_list
.n_values
];
2983 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
2984 value_list
.list_value
[list_count
].decode_text(text_buf
);
2987 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.context-negotiation.");
2991 boolean
CHARACTER_STRING_identification_context__negotiation_template::is_present(boolean legacy
/* = FALSE */) const
2993 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
2994 return !match_omit(legacy
);
2997 boolean
CHARACTER_STRING_identification_context__negotiation_template::match_omit(boolean legacy
/* = FALSE */) const
2999 if (is_ifpresent
) return TRUE
;
3000 switch (template_selection
) {
3005 case COMPLEMENTED_LIST
:
3007 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3008 if (value_list
.list_value
[i
].match_omit())
3009 return template_selection
==VALUE_LIST
;
3010 return template_selection
==COMPLEMENTED_LIST
;
3011 } // else fall through
3018 #ifndef TITAN_RUNTIME_2
3019 void CHARACTER_STRING_identification_context__negotiation_template::check_restriction(template_res t_res
, const char* t_name
,
3020 boolean legacy
/* = FALSE */) const
3022 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3023 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3025 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3028 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3029 template_selection
==SPECIFIC_VALUE
)) return;
3032 if (!match_omit(legacy
)) return;
3037 TTCN_error("Restriction `%s' on template of type %s violated.",
3038 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING.identification.context-negotiation");
3042 CHARACTER_STRING::CHARACTER_STRING()
3046 CHARACTER_STRING::CHARACTER_STRING(const CHARACTER_STRING_identification
& par_identification
,
3047 const OPTIONAL
<UNIVERSAL_CHARSTRING
>& par_data__value__descriptor
,
3048 const OCTETSTRING
& par_string__value
)
3049 : field_identification(par_identification
),
3050 field_data__value__descriptor(par_data__value__descriptor
),
3051 field_string__value(par_string__value
)
3055 boolean
CHARACTER_STRING::operator==(const CHARACTER_STRING
& other_value
) const
3057 return field_identification
==other_value
.field_identification
3058 && field_data__value__descriptor
==other_value
.field_data__value__descriptor
3059 && field_string__value
==other_value
.field_string__value
;
3062 int CHARACTER_STRING::size_of() const
3065 if (field_data__value__descriptor
.ispresent()) ret_val
++;
3069 boolean
CHARACTER_STRING::is_bound() const
3071 if(field_identification
.is_bound()) return TRUE
;
3072 if(OPTIONAL_OMIT
== field_data__value__descriptor
.get_selection() || field_data__value__descriptor
.is_bound()) return TRUE
;
3073 if(field_string__value
.is_bound()) return TRUE
;
3077 boolean
CHARACTER_STRING::is_value() const
3079 if(!field_identification
.is_value()) return FALSE
;
3080 if(OPTIONAL_OMIT
!= field_data__value__descriptor
.get_selection() && !field_data__value__descriptor
.is_value()) return FALSE
;
3081 if(!field_string__value
.is_value()) return FALSE
;
3085 void CHARACTER_STRING::clean_up()
3087 field_identification
.clean_up();
3088 field_data__value__descriptor
.clean_up();
3089 field_string__value
.clean_up();
3092 void CHARACTER_STRING::log() const
3094 TTCN_Logger::log_event_str("{ identification := ");
3095 field_identification
.log();
3096 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3097 field_data__value__descriptor
.log();
3098 TTCN_Logger::log_event_str(", string_value := ");
3099 field_string__value
.log();
3100 TTCN_Logger::log_event_str(" }");
3103 void CHARACTER_STRING::set_param(Module_Param
& param
)
3105 param
.basic_check(Module_Param::BC_VALUE
, "record value");
3106 Module_Param_Ptr mp
= ¶m
;
3107 if (param
.get_type() == Module_Param::MP_Reference
) {
3108 mp
= param
.get_referenced_param();
3110 switch (mp
->get_type()) {
3111 case Module_Param::MP_Value_List
:
3112 if (mp
->get_size()==0) return;
3113 if (3!=mp
->get_size()) {
3114 param
.error("record value of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp
->get_size());
3116 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3117 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3118 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*mp
->get_elem(2));
3120 case Module_Param::MP_Assignment_List
: {
3121 Vector
<bool> value_used(mp
->get_size());
3122 value_used
.resize(mp
->get_size(), false);
3123 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3124 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3125 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3126 identification().set_param(*curr_param
);
3127 value_used
[val_idx
]=true;
3130 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3131 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3132 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3133 data__value__descriptor().set_param(*curr_param
);
3134 value_used
[val_idx
]=true;
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(), "string_value")) {
3140 string__value().set_param(*curr_param
);
3141 value_used
[val_idx
]=true;
3144 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3145 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3150 param
.type_error("record value", "CHARACTER STRING");
3154 Module_Param
* CHARACTER_STRING::get_param(Module_Param_Name
& param_name
) const
3157 return new Module_Param_Unbound();
3159 Module_Param
* mp_field_identification
= field_identification
.get_param(param_name
);
3160 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3161 Module_Param
* mp_field_data_value_descriptor
= field_data__value__descriptor
.get_param(param_name
);
3162 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3163 Module_Param
* mp_field_string_value
= field_string__value
.get_param(param_name
);
3164 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("string_value")));
3165 Module_Param_Assignment_List
* mp
= new Module_Param_Assignment_List();
3166 mp
->add_elem(mp_field_identification
);
3167 mp
->add_elem(mp_field_data_value_descriptor
);
3168 mp
->add_elem(mp_field_string_value
);
3172 void CHARACTER_STRING::encode_text(Text_Buf
& text_buf
) const
3174 field_identification
.encode_text(text_buf
);
3175 field_data__value__descriptor
.encode_text(text_buf
);
3176 field_string__value
.encode_text(text_buf
);
3179 void CHARACTER_STRING::decode_text(Text_Buf
& text_buf
)
3181 field_identification
.decode_text(text_buf
);
3182 field_data__value__descriptor
.decode_text(text_buf
);
3183 field_string__value
.decode_text(text_buf
);
3186 void CHARACTER_STRING::encode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...) const
3189 va_start(pvar
, p_coding
);
3191 case TTCN_EncDec::CT_BER
: {
3192 TTCN_EncDec_ErrorContext
ec("While BER-encoding type '%s': ", p_td
.name
);
3193 unsigned BER_coding
=va_arg(pvar
, unsigned);
3194 BER_encode_chk_coding(BER_coding
);
3195 ASN_BER_TLV_t
*tlv
=BER_encode_TLV(p_td
, BER_coding
);
3196 tlv
->put_in_buffer(p_buf
);
3197 ASN_BER_TLV_t::destruct(tlv
);
3199 case TTCN_EncDec::CT_RAW
: {
3200 TTCN_EncDec_ErrorContext
ec("While RAW-encoding type '%s': ", p_td
.name
);
3201 TTCN_EncDec_ErrorContext::error_internal
3202 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3204 case TTCN_EncDec::CT_TEXT
: {
3205 TTCN_EncDec_ErrorContext
ec("While TEXT-encoding type '%s': ", p_td
.name
);
3206 TTCN_EncDec_ErrorContext::error_internal
3207 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3209 case TTCN_EncDec::CT_XER
: {
3210 TTCN_EncDec_ErrorContext
ec("While XER-encoding type '%s': ", p_td
.name
);
3211 unsigned XER_coding
=va_arg(pvar
, unsigned);
3212 XER_encode(*p_td
.xer
,p_buf
, XER_coding
, 0, 0);
3215 case TTCN_EncDec::CT_JSON
: {
3216 TTCN_EncDec_ErrorContext
ec("While JSON-encoding type '%s': ", p_td
.name
);
3217 TTCN_EncDec_ErrorContext::error_internal
3218 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3221 TTCN_error("Unknown coding method requested to encode type '%s'", p_td
.name
);
3226 void CHARACTER_STRING::decode(const TTCN_Typedescriptor_t
& p_td
, TTCN_Buffer
& p_buf
, TTCN_EncDec::coding_t p_coding
, ...)
3229 va_start(pvar
, p_coding
);
3231 case TTCN_EncDec::CT_BER
: {
3232 TTCN_EncDec_ErrorContext
ec("While BER-decoding type '%s': ", p_td
.name
);
3233 unsigned L_form
=va_arg(pvar
, unsigned);
3235 BER_decode_str2TLV(p_buf
, tlv
, L_form
);
3236 BER_decode_TLV(p_td
, tlv
, L_form
);
3237 if(tlv
.isComplete
) p_buf
.increase_pos(tlv
.get_len());
3239 case TTCN_EncDec::CT_RAW
: {
3240 TTCN_EncDec_ErrorContext
ec("While RAW-decoding type '%s': ", p_td
.name
);
3241 TTCN_EncDec_ErrorContext::error_internal
3242 ("No RAW descriptor available for type '%s'.", p_td
.name
);
3244 case TTCN_EncDec::CT_TEXT
: {
3245 TTCN_EncDec_ErrorContext
ec("While TEXT-decoding type '%s': ", p_td
.name
);
3246 TTCN_EncDec_ErrorContext::error_internal
3247 ("No TEXT descriptor available for type '%s'.", p_td
.name
);
3249 case TTCN_EncDec::CT_XER
: {
3250 TTCN_EncDec_ErrorContext
ec("While XER-decoding type '%s': ", p_td
.name
);
3251 unsigned XER_coding
=va_arg(pvar
, unsigned);
3252 XmlReaderWrap
reader(p_buf
);
3253 int success
= reader
.Read();
3254 for (; success
==1; success
=reader
.Read()) {
3255 int type
= reader
.NodeType();
3256 if (type
==XML_READER_TYPE_ELEMENT
)
3259 XER_decode(*p_td
.xer
, reader
, XER_coding
, 0);
3260 size_t bytes
= reader
.ByteConsumed();
3261 p_buf
.set_pos(bytes
);
3263 case TTCN_EncDec::CT_JSON
: {
3264 TTCN_EncDec_ErrorContext
ec("While JSON-decoding type '%s': ", p_td
.name
);
3265 TTCN_EncDec_ErrorContext::error_internal
3266 ("No JSON descriptor available for type '%s'.", p_td
.name
);
3269 TTCN_error("Unknown coding method requested to decode type '%s'", p_td
.name
);
3274 ASN_BER_TLV_t
* CHARACTER_STRING::BER_encode_TLV(const TTCN_Typedescriptor_t
& p_td
, unsigned p_coding
) const
3276 BER_chk_descr(p_td
);
3277 ASN_BER_TLV_t
*new_tlv
=ASN_BER_TLV_t::construct(NULL
);
3278 TTCN_EncDec_ErrorContext
ec_0("Component '");
3279 TTCN_EncDec_ErrorContext ec_1
;
3280 ec_1
.set_msg("identification': ");
3281 new_tlv
->add_TLV(field_identification
.BER_encode_TLV(CHARACTER_STRING_identification_descr_
, p_coding
));
3282 ec_1
.set_msg("data_value_descriptor': ");
3283 new_tlv
->add_TLV(field_data__value__descriptor
.BER_encode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, p_coding
));
3284 ec_1
.set_msg("string_value': ");
3285 new_tlv
->add_TLV(field_string__value
.BER_encode_TLV(CHARACTER_STRING_string__value_descr_
, p_coding
));
3286 new_tlv
=ASN_BER_V2TLV(new_tlv
, p_td
, p_coding
);
3290 boolean
CHARACTER_STRING::BER_decode_TLV(const TTCN_Typedescriptor_t
& p_td
, const ASN_BER_TLV_t
& p_tlv
, unsigned L_form
)
3292 BER_chk_descr(p_td
);
3293 ASN_BER_TLV_t stripped_tlv
;
3294 BER_decode_strip_tags(*p_td
.ber
, p_tlv
, L_form
, stripped_tlv
);
3295 TTCN_EncDec_ErrorContext
ec_0("While decoding 'CHARACTER STRING' type: ");
3296 stripped_tlv
.chk_constructed_flag(TRUE
);
3298 ASN_BER_TLV_t tmp_tlv
;
3299 boolean tlv_present
=FALSE
;
3301 TTCN_EncDec_ErrorContext
ec_1("Component '");
3302 TTCN_EncDec_ErrorContext ec_2
;
3303 ec_2
.set_msg("identification': ");
3304 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3305 if(!tlv_present
) return FALSE
;
3306 field_identification
.BER_decode_TLV(CHARACTER_STRING_identification_descr_
, tmp_tlv
, L_form
);
3308 ec_2
.set_msg("data_value_descriptor': ");
3309 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3310 if(!tlv_present
) field_data__value__descriptor
=OMIT_VALUE
;
3312 field_data__value__descriptor
.BER_decode_TLV(CHARACTER_STRING_data__value__descriptor_descr_
, tmp_tlv
, L_form
);
3313 if(field_data__value__descriptor
.ispresent()) tlv_present
=FALSE
;
3315 ec_2
.set_msg("string_value': ");
3316 if(!tlv_present
) tlv_present
=BER_decode_constdTLV_next(stripped_tlv
, V_pos
, L_form
, tmp_tlv
);
3317 if(!tlv_present
) return FALSE
;
3318 field_string__value
.BER_decode_TLV(CHARACTER_STRING_string__value_descr_
, tmp_tlv
, L_form
);
3321 BER_decode_constdTLV_end(stripped_tlv
, V_pos
, L_form
, tmp_tlv
, tlv_present
);
3325 int CHARACTER_STRING::XER_encode(const XERdescriptor_t
& p_td
, TTCN_Buffer
& p_buf
,
3326 unsigned int flavor
, int indent
, embed_values_enc_struct_t
*) const
3329 TTCN_EncDec_ErrorContext::error
3330 (TTCN_EncDec::ET_UNBOUND
, "Encoding an unbound value.");
3332 int encoded_length
=(int)p_buf
.get_len();
3334 flavor
&= ~XER_RECOF
; // ASN.1 character string doesn't care
3335 begin_xml(p_td
, p_buf
, flavor
, indent
++, false);
3337 field_identification
.XER_encode(CHARACTER_STRING_identification_xer_
, p_buf
, flavor
, indent
, 0);
3338 // data-value-descriptor is OPTIONAL and can never be present.
3339 // Its encoding is empty.
3340 field_string__value
.XER_encode(CHARACTER_STRING_data_value_xer_
, p_buf
, flavor
, indent
, 0);
3342 end_xml(p_td
, p_buf
, flavor
, --indent
, false);
3344 return (int)p_buf
.get_len() - encoded_length
;
3347 int CHARACTER_STRING::XER_decode(const XERdescriptor_t
& p_td
,
3348 XmlReaderWrap
& reader
, unsigned int flavor
, embed_values_dec_struct_t
*)
3350 int exer
= is_exer(flavor
);
3351 int success
= reader
.Ok(), depth
= -1, type
;
3352 for (; success
== 1; success
= reader
.Read()) {
3353 type
= reader
.NodeType();
3354 if (XML_READER_TYPE_ELEMENT
== type
) {
3355 verify_name(reader
, p_td
, exer
);
3356 depth
= reader
.Depth();
3361 field_identification
.XER_decode(CHARACTER_STRING_identification_xer_
, reader
, flavor
, 0);
3362 field_data__value__descriptor
.XER_decode(CHARACTER_STRING_data_value_descriptor_xer_
, reader
, flavor
, 0);
3363 if (field_data__value__descriptor
.is_value()) {
3364 TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG
,
3365 "data-value-descriptor not allowed for EMBEDDED PDV");
3367 field_string__value
.XER_decode(CHARACTER_STRING_data_value_xer_
, reader
, flavor
, 0);
3368 for (success
= reader
.Read(); success
== 1; success
= reader
.Read()) {
3369 type
= reader
.NodeType();
3370 if (XML_READER_TYPE_END_ELEMENT
== type
) {
3371 verify_end(reader
, p_td
, depth
, exer
);
3381 struct CHARACTER_STRING_template::single_value_struct
{
3382 CHARACTER_STRING_identification_template field_identification
;
3383 UNIVERSAL_CHARSTRING_template field_data__value__descriptor
;
3384 OCTETSTRING_template field_string__value
;
3387 void CHARACTER_STRING_template::set_param(Module_Param
& param
)
3389 param
.basic_check(Module_Param::BC_TEMPLATE
, "record template");
3390 Module_Param_Ptr mp
= ¶m
;
3391 if (param
.get_type() == Module_Param::MP_Reference
) {
3392 mp
= param
.get_referenced_param();
3394 switch (mp
->get_type()) {
3395 case Module_Param::MP_Omit
:
3398 case Module_Param::MP_Any
:
3401 case Module_Param::MP_AnyOrNone
:
3402 *this = ANY_OR_OMIT
;
3404 case Module_Param::MP_List_Template
:
3405 case Module_Param::MP_ComplementList_Template
: {
3406 CHARACTER_STRING_template temp
;
3407 temp
.set_type(mp
->get_type() == Module_Param::MP_List_Template
?
3408 VALUE_LIST
: COMPLEMENTED_LIST
, mp
->get_size());
3409 for (size_t i
=0; i
<mp
->get_size(); i
++) {
3410 temp
.list_item(i
).set_param(*mp
->get_elem(i
));
3414 case Module_Param::MP_Value_List
:
3415 if (mp
->get_size()==0) break;
3416 if (3!=mp
->get_size()) {
3417 param
.error("record template of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp
->get_size());
3419 if (mp
->get_elem(0)->get_type()!=Module_Param::MP_NotUsed
) identification().set_param(*mp
->get_elem(0));
3420 if (mp
->get_elem(1)->get_type()!=Module_Param::MP_NotUsed
) data__value__descriptor().set_param(*mp
->get_elem(1));
3421 if (mp
->get_elem(2)->get_type()!=Module_Param::MP_NotUsed
) string__value().set_param(*mp
->get_elem(2));
3423 case Module_Param::MP_Assignment_List
: {
3424 Vector
<bool> value_used(mp
->get_size());
3425 value_used
.resize(mp
->get_size(), false);
3426 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3427 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3428 if (!strcmp(curr_param
->get_id()->get_name(), "identification")) {
3429 identification().set_param(*curr_param
);
3430 value_used
[val_idx
]=true;
3433 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) {
3434 Module_Param
* const curr_param
= mp
->get_elem(val_idx
);
3435 if (!strcmp(curr_param
->get_id()->get_name(), "data_value_descriptor")) {
3436 data__value__descriptor().set_param(*curr_param
);
3437 value_used
[val_idx
]=true;
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(), "string_value")) {
3443 string__value().set_param(*curr_param
);
3444 value_used
[val_idx
]=true;
3447 for (size_t val_idx
=0; val_idx
<mp
->get_size(); val_idx
++) if (!value_used
[val_idx
]) {
3448 mp
->get_elem(val_idx
)->error("Non existent field name in type CHARACTER STRING: %s", mp
->get_elem(val_idx
)->get_id()->get_name());
3453 param
.type_error("record template", "CHARACTER STRING");
3455 is_ifpresent
= param
.get_ifpresent() || mp
->get_ifpresent();
3458 Module_Param
* CHARACTER_STRING_template::get_param(Module_Param_Name
& param_name
) const
3460 Module_Param
* mp
= NULL
;
3461 switch (template_selection
) {
3462 case UNINITIALIZED_TEMPLATE
:
3463 mp
= new Module_Param_Unbound();
3466 mp
= new Module_Param_Omit();
3469 mp
= new Module_Param_Any();
3472 mp
= new Module_Param_AnyOrNone();
3474 case SPECIFIC_VALUE
: {
3475 Module_Param
* mp_field_identification
= single_value
->field_identification
.get_param(param_name
);
3476 mp_field_identification
->set_id(new Module_Param_FieldName(mcopystr("identification")));
3477 Module_Param
* mp_field_data_value_descriptor
= single_value
->field_data__value__descriptor
.get_param(param_name
);
3478 mp_field_data_value_descriptor
->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
3479 Module_Param
* mp_field_string_value
= single_value
->field_string__value
.get_param(param_name
);
3480 mp_field_string_value
->set_id(new Module_Param_FieldName(mcopystr("string_value")));
3481 mp
= new Module_Param_Assignment_List();
3482 mp
->add_elem(mp_field_identification
);
3483 mp
->add_elem(mp_field_data_value_descriptor
);
3484 mp
->add_elem(mp_field_string_value
);
3487 case COMPLEMENTED_LIST
: {
3488 if (template_selection
== VALUE_LIST
) {
3489 mp
= new Module_Param_List_Template();
3492 mp
= new Module_Param_ComplementList_Template();
3494 for (size_t i
= 0; i
< value_list
.n_values
; ++i
) {
3495 mp
->add_elem(value_list
.list_value
[i
].get_param(param_name
));
3502 mp
->set_ifpresent();
3507 void CHARACTER_STRING_template::clean_up()
3509 switch (template_selection
) {
3510 case SPECIFIC_VALUE
:
3511 delete single_value
;
3514 case COMPLEMENTED_LIST
:
3515 delete [] value_list
.list_value
;
3520 template_selection
= UNINITIALIZED_TEMPLATE
;
3523 void CHARACTER_STRING_template::set_specific()
3525 if (template_selection
!= SPECIFIC_VALUE
) {
3526 template_sel old_selection
= template_selection
;
3528 single_value
= new single_value_struct
;
3529 set_selection(SPECIFIC_VALUE
);
3530 if (old_selection
== ANY_VALUE
|| old_selection
== ANY_OR_OMIT
) {
3531 single_value
->field_identification
= ANY_VALUE
;
3532 single_value
->field_data__value__descriptor
= ANY_OR_OMIT
;
3533 single_value
->field_string__value
= ANY_VALUE
;
3538 void CHARACTER_STRING_template::copy_value(const CHARACTER_STRING
& other_value
)
3540 single_value
= new single_value_struct
;
3541 single_value
->field_identification
= other_value
.identification();
3542 if (other_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
= (const UNIVERSAL_CHARSTRING
&)(other_value
.data__value__descriptor());
3543 else single_value
->field_data__value__descriptor
= OMIT_VALUE
;
3544 single_value
->field_string__value
= other_value
.string__value();
3545 set_selection(SPECIFIC_VALUE
);
3548 void CHARACTER_STRING_template::copy_template(const CHARACTER_STRING_template
& other_value
)
3550 switch (other_value
.template_selection
) {
3551 case SPECIFIC_VALUE
:
3552 single_value
= new single_value_struct(*other_value
.single_value
);
3559 case COMPLEMENTED_LIST
:
3560 value_list
.n_values
= other_value
.value_list
.n_values
;
3561 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3562 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3563 value_list
.list_value
[list_count
].copy_template(other_value
.value_list
.list_value
[list_count
]);
3566 TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.");
3568 set_selection(other_value
);
3571 CHARACTER_STRING_template::CHARACTER_STRING_template()
3575 CHARACTER_STRING_template::CHARACTER_STRING_template(template_sel other_value
)
3576 : Base_Template(other_value
)
3578 check_single_selection(other_value
);
3581 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING
& other_value
)
3583 copy_value(other_value
);
3586 CHARACTER_STRING_template::CHARACTER_STRING_template(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3588 switch (other_value
.get_selection()) {
3589 case OPTIONAL_PRESENT
:
3590 copy_value((const CHARACTER_STRING
&)other_value
);
3593 set_selection(OMIT_VALUE
);
3596 TTCN_error("Creating a template of type CHARACTER STRING from an unbound optional field.");
3600 CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING_template
& other_value
)
3603 copy_template(other_value
);
3606 CHARACTER_STRING_template::~CHARACTER_STRING_template()
3611 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(template_sel other_value
)
3613 check_single_selection(other_value
);
3615 set_selection(other_value
);
3619 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING
& other_value
)
3622 copy_value(other_value
);
3626 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const OPTIONAL
<CHARACTER_STRING
>& other_value
)
3629 switch (other_value
.get_selection()) {
3630 case OPTIONAL_PRESENT
:
3631 copy_value((const CHARACTER_STRING
&)other_value
);
3634 set_selection(OMIT_VALUE
);
3637 TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.");
3642 CHARACTER_STRING_template
& CHARACTER_STRING_template::operator=(const CHARACTER_STRING_template
& other_value
)
3644 if (&other_value
!= this) {
3646 copy_template(other_value
);
3651 boolean
CHARACTER_STRING_template::match(const CHARACTER_STRING
& other_value
,
3652 boolean
/* legacy */) const
3654 switch (template_selection
) {
3660 case SPECIFIC_VALUE
:
3661 if (!other_value
.identification().is_bound()) return FALSE
;
3662 if (!single_value
->field_identification
.match(other_value
.identification())) return FALSE
;
3663 if (!other_value
.data__value__descriptor().is_bound()) return FALSE
;
3664 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
;
3665 if (!other_value
.string__value().is_bound()) return FALSE
;
3666 if (!single_value
->field_string__value
.match(other_value
.string__value())) return FALSE
;
3669 case COMPLEMENTED_LIST
:
3670 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3671 if (value_list
.list_value
[list_count
].match(other_value
)) return template_selection
== VALUE_LIST
;
3672 return template_selection
== COMPLEMENTED_LIST
;
3674 TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.");
3679 CHARACTER_STRING
CHARACTER_STRING_template::valueof() const
3681 if (template_selection
!= SPECIFIC_VALUE
|| is_ifpresent
)
3682 TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.");
3683 CHARACTER_STRING ret_val
;
3684 ret_val
.identification() = single_value
->field_identification
.valueof();
3685 if (single_value
->field_data__value__descriptor
.is_omit()) ret_val
.data__value__descriptor() = OMIT_VALUE
;
3686 else ret_val
.data__value__descriptor() = single_value
->field_data__value__descriptor
.valueof();
3687 ret_val
.string__value() = single_value
->field_string__value
.valueof();
3691 void CHARACTER_STRING_template::set_type(template_sel template_type
, unsigned int list_length
)
3693 if (template_type
!= VALUE_LIST
&& template_type
!= COMPLEMENTED_LIST
)
3694 TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.");
3696 set_selection(template_type
);
3697 value_list
.n_values
= list_length
;
3698 value_list
.list_value
= new CHARACTER_STRING_template
[list_length
];
3701 CHARACTER_STRING_template
& CHARACTER_STRING_template::list_item(unsigned int list_index
) const
3703 if (template_selection
!= VALUE_LIST
&& template_selection
!= COMPLEMENTED_LIST
)
3704 TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.");
3705 if (list_index
>= value_list
.n_values
)
3706 TTCN_error("Index overflow in a value list template of type CHARACTER STRING.");
3707 return value_list
.list_value
[list_index
];
3710 CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification()
3713 return single_value
->field_identification
;
3716 const CHARACTER_STRING_identification_template
& CHARACTER_STRING_template::identification() const
3718 if (template_selection
!= SPECIFIC_VALUE
)
3719 TTCN_error("Accessing field identification of a non-specific template of type CHARACTER STRING.");
3720 return single_value
->field_identification
;
3723 UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor()
3726 return single_value
->field_data__value__descriptor
;
3729 const UNIVERSAL_CHARSTRING_template
& CHARACTER_STRING_template::data__value__descriptor() const
3731 if (template_selection
!= SPECIFIC_VALUE
)
3732 TTCN_error("Accessing field data_value_descriptor of a non-specific template of type CHARACTER STRING.");
3733 return single_value
->field_data__value__descriptor
;
3736 OCTETSTRING_template
& CHARACTER_STRING_template::string__value()
3739 return single_value
->field_string__value
;
3742 const OCTETSTRING_template
& CHARACTER_STRING_template::string__value() const
3744 if (template_selection
!= SPECIFIC_VALUE
)
3745 TTCN_error("Accessing field string_value of a non-specific template of type CHARACTER STRING.");
3746 return single_value
->field_string__value
;
3749 int CHARACTER_STRING_template::size_of() const
3751 switch (template_selection
)
3753 case SPECIFIC_VALUE
:
3756 if (single_value
->field_data__value__descriptor
.is_present()) ret_val
++;
3761 if (value_list
.n_values
<1)
3762 TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING containing an empty list.");
3763 int item_size
= value_list
.list_value
[0].size_of();
3764 for (unsigned int i
= 1; i
< value_list
.n_values
; i
++)
3766 if (value_list
.list_value
[i
].size_of()!=item_size
)
3767 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing a value list with different sizes.");
3772 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing omit value.");
3775 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing */? value.");
3776 case COMPLEMENTED_LIST
:
3777 TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing complemented list.");
3779 TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.");
3784 void CHARACTER_STRING_template::log() const
3786 switch (template_selection
) {
3787 case SPECIFIC_VALUE
:
3788 TTCN_Logger::log_event_str("{ identification := ");
3789 single_value
->field_identification
.log();
3790 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3791 single_value
->field_data__value__descriptor
.log();
3792 TTCN_Logger::log_event_str(", string_value := ");
3793 single_value
->field_string__value
.log();
3794 TTCN_Logger::log_event_str(" }");
3796 case COMPLEMENTED_LIST
:
3797 TTCN_Logger::log_event_str("complement ");
3800 TTCN_Logger::log_char('(');
3801 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++) {
3802 if (list_count
> 0) TTCN_Logger::log_event_str(", ");
3803 value_list
.list_value
[list_count
].log();
3805 TTCN_Logger::log_char(')');
3814 void CHARACTER_STRING_template::log_match(const CHARACTER_STRING
& match_value
,
3815 boolean
/* legacy */) const
3817 if (template_selection
== SPECIFIC_VALUE
) {
3818 TTCN_Logger::log_event_str("{ identification := ");
3819 single_value
->field_identification
.log_match(match_value
.identification());
3820 TTCN_Logger::log_event_str(", data_value_descriptor := ");
3821 if (match_value
.data__value__descriptor().ispresent()) single_value
->field_data__value__descriptor
.log_match(match_value
.data__value__descriptor());
3823 single_value
->field_data__value__descriptor
.log();
3824 if (single_value
->field_data__value__descriptor
.match_omit()) TTCN_Logger::log_event_str(" matched");
3825 else TTCN_Logger::log_event_str(" unmatched");
3827 TTCN_Logger::log_event_str(", string_value := ");
3828 single_value
->field_string__value
.log_match(match_value
.string__value());
3829 TTCN_Logger::log_event_str(" }");
3832 TTCN_Logger::log_event_str(" with ");
3834 if (match(match_value
)) TTCN_Logger::log_event_str(" matched");
3835 else TTCN_Logger::log_event_str(" unmatched");
3839 void CHARACTER_STRING_template::encode_text(Text_Buf
& text_buf
) const
3841 encode_text_base(text_buf
);
3842 switch (template_selection
) {
3843 case SPECIFIC_VALUE
:
3844 single_value
->field_identification
.encode_text(text_buf
);
3845 single_value
->field_data__value__descriptor
.encode_text(text_buf
);
3846 single_value
->field_string__value
.encode_text(text_buf
);
3853 case COMPLEMENTED_LIST
:
3854 text_buf
.push_int(value_list
.n_values
);
3855 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3856 value_list
.list_value
[list_count
].encode_text(text_buf
);
3859 TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.");
3863 void CHARACTER_STRING_template::decode_text(Text_Buf
& text_buf
)
3866 decode_text_base(text_buf
);
3867 switch (template_selection
) {
3868 case SPECIFIC_VALUE
:
3869 single_value
= new single_value_struct
;
3870 single_value
->field_identification
.decode_text(text_buf
);
3871 single_value
->field_data__value__descriptor
.decode_text(text_buf
);
3872 single_value
->field_string__value
.decode_text(text_buf
);
3879 case COMPLEMENTED_LIST
:
3880 value_list
.n_values
= text_buf
.pull_int().get_val();
3881 value_list
.list_value
= new CHARACTER_STRING_template
[value_list
.n_values
];
3882 for (unsigned int list_count
= 0; list_count
< value_list
.n_values
; list_count
++)
3883 value_list
.list_value
[list_count
].decode_text(text_buf
);
3886 TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.");
3890 boolean
CHARACTER_STRING_template::is_present(boolean legacy
/* = FALSE */) const
3892 if (template_selection
==UNINITIALIZED_TEMPLATE
) return FALSE
;
3893 return !match_omit(legacy
);
3896 boolean
CHARACTER_STRING_template::match_omit(boolean legacy
/* = FALSE */) const
3898 if (is_ifpresent
) return TRUE
;
3899 switch (template_selection
) {
3904 case COMPLEMENTED_LIST
:
3906 // legacy behavior: 'omit' can appear in the value/complement list
3907 for (unsigned int i
=0; i
<value_list
.n_values
; i
++)
3908 if (value_list
.list_value
[i
].match_omit())
3909 return template_selection
==VALUE_LIST
;
3910 return template_selection
==COMPLEMENTED_LIST
;
3912 // else fall through
3919 #ifndef TITAN_RUNTIME_2
3920 void CHARACTER_STRING_template::check_restriction(template_res t_res
, const char* t_name
,
3921 boolean legacy
/* = FALSE */) const
3923 if (template_selection
==UNINITIALIZED_TEMPLATE
) return;
3924 switch ((t_name
&&(t_res
==TR_VALUE
))?TR_OMIT
:t_res
) {
3926 if (!is_ifpresent
&& template_selection
==SPECIFIC_VALUE
) return;
3929 if (!is_ifpresent
&& (template_selection
==OMIT_VALUE
||
3930 template_selection
==SPECIFIC_VALUE
)) return;
3933 if (!match_omit(legacy
)) return;
3938 TTCN_error("Restriction `%s' on template of type %s violated.",
3939 get_res_name(t_res
), t_name
? t_name
: "CHARACTER STRING");