Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #include <string.h> | |
9 | ||
10 | #include "Error.hh" | |
11 | #include "Logger.hh" | |
12 | #include "Encdec.hh" | |
13 | #include "BER.hh" | |
14 | #include "Param_Types.hh" | |
15 | ||
16 | #include "ASN_CharacterString.hh" | |
17 | ||
18 | #include "../common/dbgnew.hh" | |
19 | ||
20 | /* | |
21 | ||
22 | to do when regenerating: | |
23 | ||
24 | in .hh file: | |
25 | ||
26 | add __SUNPRO_CC ifdefs for single_value_struct | |
27 | ||
28 | in .cc file: | |
29 | ||
30 | replace '@CHARACTER STRING' with 'CHARACTER STRING' | |
31 | ||
32 | remove RAW and TEXT enc/dec functions | |
33 | ||
34 | make the type descriptors of embedded types static | |
35 | ||
36 | */ | |
37 | ||
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
41 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
45 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
49 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
53 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
57 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
61 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
65 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
69 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
73 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
77 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
81 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
85 | |
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_ }; | |
a38c6d4c | 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 }; |
970ed795 EL |
89 | |
90 | void CHARACTER_STRING_identification::clean_up() | |
91 | { | |
92 | switch (union_selection) { | |
93 | case ALT_syntaxes: | |
94 | delete field_syntaxes; | |
95 | break; | |
96 | case ALT_syntax: | |
97 | delete field_syntax; | |
98 | break; | |
99 | case ALT_presentation__context__id: | |
100 | delete field_presentation__context__id; | |
101 | break; | |
102 | case ALT_context__negotiation: | |
103 | delete field_context__negotiation; | |
104 | break; | |
105 | case ALT_transfer__syntax: | |
106 | delete field_transfer__syntax; | |
107 | break; | |
108 | case ALT_fixed: | |
109 | delete field_fixed; | |
110 | break; | |
111 | default: | |
112 | break; | |
113 | } | |
114 | union_selection = UNBOUND_VALUE; | |
115 | } | |
116 | ||
117 | void CHARACTER_STRING_identification::copy_value(const CHARACTER_STRING_identification& other_value) | |
118 | { | |
119 | switch (other_value.union_selection) { | |
120 | case ALT_syntaxes: | |
121 | field_syntaxes = new CHARACTER_STRING_identification_syntaxes(*other_value.field_syntaxes); | |
122 | break; | |
123 | case ALT_syntax: | |
124 | field_syntax = new OBJID(*other_value.field_syntax); | |
125 | break; | |
126 | case ALT_presentation__context__id: | |
127 | field_presentation__context__id = new INTEGER(*other_value.field_presentation__context__id); | |
128 | break; | |
129 | case ALT_context__negotiation: | |
130 | field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation(*other_value.field_context__negotiation); | |
131 | break; | |
132 | case ALT_transfer__syntax: | |
133 | field_transfer__syntax = new OBJID(*other_value.field_transfer__syntax); | |
134 | break; | |
135 | case ALT_fixed: | |
136 | field_fixed = new ASN_NULL(*other_value.field_fixed); | |
137 | break; | |
138 | default: | |
139 | TTCN_error("Assignment of an unbound union value of type CHARACTER STRING.identification."); | |
140 | } | |
141 | union_selection = other_value.union_selection; | |
142 | } | |
143 | ||
144 | CHARACTER_STRING_identification::CHARACTER_STRING_identification() | |
145 | { | |
146 | union_selection = UNBOUND_VALUE; | |
147 | } | |
148 | ||
149 | CHARACTER_STRING_identification::CHARACTER_STRING_identification(const CHARACTER_STRING_identification& other_value) | |
150 | : Base_Type(other_value) | |
151 | { | |
152 | copy_value(other_value); | |
153 | } | |
154 | ||
155 | CHARACTER_STRING_identification::~CHARACTER_STRING_identification() | |
156 | { | |
157 | clean_up(); | |
158 | } | |
159 | ||
160 | CHARACTER_STRING_identification& CHARACTER_STRING_identification::operator=(const CHARACTER_STRING_identification& other_value) | |
161 | { | |
162 | if (this != &other_value) { | |
163 | clean_up(); | |
164 | copy_value(other_value); | |
165 | } | |
166 | return *this; | |
167 | } | |
168 | ||
169 | boolean CHARACTER_STRING_identification::operator==(const CHARACTER_STRING_identification& other_value) const | |
170 | { | |
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) { | |
175 | case ALT_syntaxes: | |
176 | return *field_syntaxes == *other_value.field_syntaxes; | |
177 | case ALT_syntax: | |
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; | |
185 | case ALT_fixed: | |
186 | return *field_fixed == *other_value.field_fixed; | |
187 | default: | |
188 | return FALSE; | |
189 | } | |
190 | } | |
191 | ||
192 | CHARACTER_STRING_identification_syntaxes& CHARACTER_STRING_identification::syntaxes() | |
193 | { | |
194 | if (union_selection != ALT_syntaxes) { | |
195 | clean_up(); | |
196 | field_syntaxes = new CHARACTER_STRING_identification_syntaxes; | |
197 | union_selection = ALT_syntaxes; | |
198 | } | |
199 | return *field_syntaxes; | |
200 | } | |
201 | ||
202 | const CHARACTER_STRING_identification_syntaxes& CHARACTER_STRING_identification::syntaxes() const | |
203 | { | |
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; | |
206 | } | |
207 | ||
208 | OBJID& CHARACTER_STRING_identification::syntax() | |
209 | { | |
210 | if (union_selection != ALT_syntax) { | |
211 | clean_up(); | |
212 | field_syntax = new OBJID; | |
213 | union_selection = ALT_syntax; | |
214 | } | |
215 | return *field_syntax; | |
216 | } | |
217 | ||
218 | const OBJID& CHARACTER_STRING_identification::syntax() const | |
219 | { | |
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; | |
222 | } | |
223 | ||
224 | INTEGER& CHARACTER_STRING_identification::presentation__context__id() | |
225 | { | |
226 | if (union_selection != ALT_presentation__context__id) { | |
227 | clean_up(); | |
228 | field_presentation__context__id = new INTEGER; | |
229 | union_selection = ALT_presentation__context__id; | |
230 | } | |
231 | return *field_presentation__context__id; | |
232 | } | |
233 | ||
234 | const INTEGER& CHARACTER_STRING_identification::presentation__context__id() const | |
235 | { | |
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; | |
238 | } | |
239 | ||
240 | CHARACTER_STRING_identification_context__negotiation& CHARACTER_STRING_identification::context__negotiation() | |
241 | { | |
242 | if (union_selection != ALT_context__negotiation) { | |
243 | clean_up(); | |
244 | field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation; | |
245 | union_selection = ALT_context__negotiation; | |
246 | } | |
247 | return *field_context__negotiation; | |
248 | } | |
249 | ||
250 | const CHARACTER_STRING_identification_context__negotiation& CHARACTER_STRING_identification::context__negotiation() const | |
251 | { | |
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; | |
254 | } | |
255 | ||
256 | OBJID& CHARACTER_STRING_identification::transfer__syntax() | |
257 | { | |
258 | if (union_selection != ALT_transfer__syntax) { | |
259 | clean_up(); | |
260 | field_transfer__syntax = new OBJID; | |
261 | union_selection = ALT_transfer__syntax; | |
262 | } | |
263 | return *field_transfer__syntax; | |
264 | } | |
265 | ||
266 | const OBJID& CHARACTER_STRING_identification::transfer__syntax() const | |
267 | { | |
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; | |
270 | } | |
271 | ||
272 | ASN_NULL& CHARACTER_STRING_identification::fixed() | |
273 | { | |
274 | if (union_selection != ALT_fixed) { | |
275 | clean_up(); | |
276 | field_fixed = new ASN_NULL; | |
277 | union_selection = ALT_fixed; | |
278 | } | |
279 | return *field_fixed; | |
280 | } | |
281 | ||
282 | const ASN_NULL& CHARACTER_STRING_identification::fixed() const | |
283 | { | |
284 | if (union_selection != ALT_fixed) TTCN_error("Using non-selected field fixed in a value of union type CHARACTER STRING.identification."); | |
285 | return *field_fixed; | |
286 | } | |
287 | ||
288 | boolean CHARACTER_STRING_identification::ischosen(union_selection_type checked_selection) const | |
289 | { | |
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; | |
293 | } | |
294 | ||
295 | boolean CHARACTER_STRING_identification::is_bound() const | |
296 | { | |
297 | switch (union_selection) { | |
298 | case ALT_syntaxes: | |
299 | return field_syntaxes->is_bound(); | |
300 | case ALT_syntax: | |
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(); | |
308 | case ALT_fixed: | |
309 | return field_fixed->is_bound(); | |
310 | default: | |
311 | return FALSE; | |
312 | } | |
313 | } | |
314 | ||
315 | boolean CHARACTER_STRING_identification::is_value() const | |
316 | { | |
317 | switch (union_selection) { | |
318 | case ALT_syntaxes: | |
319 | return field_syntaxes->is_value(); | |
320 | case ALT_syntax: | |
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(); | |
328 | case ALT_fixed: | |
329 | return field_fixed->is_value(); | |
330 | default: | |
331 | return FALSE; | |
332 | } | |
333 | } | |
334 | ||
335 | void CHARACTER_STRING_identification::log() const | |
336 | { | |
337 | switch (union_selection) { | |
338 | case ALT_syntaxes: | |
339 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
340 | field_syntaxes->log(); | |
341 | TTCN_Logger::log_event_str(" }"); | |
342 | break; | |
343 | case ALT_syntax: | |
344 | TTCN_Logger::log_event_str("{ syntax := "); | |
345 | field_syntax->log(); | |
346 | TTCN_Logger::log_event_str(" }"); | |
347 | break; | |
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(" }"); | |
352 | break; | |
353 | case ALT_context__negotiation: | |
354 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
355 | field_context__negotiation->log(); | |
356 | TTCN_Logger::log_event_str(" }"); | |
357 | break; | |
358 | case ALT_transfer__syntax: | |
359 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
360 | field_transfer__syntax->log(); | |
361 | TTCN_Logger::log_event_str(" }"); | |
362 | break; | |
363 | case ALT_fixed: | |
364 | TTCN_Logger::log_event_str("{ fixed := "); | |
365 | field_fixed->log(); | |
366 | TTCN_Logger::log_event_str(" }"); | |
367 | break; | |
368 | default: | |
369 | TTCN_Logger::log_event_str("<unbound>"); | |
370 | break; | |
371 | } | |
372 | } | |
373 | ||
374 | void CHARACTER_STRING_identification::set_param(Module_Param& param) | |
375 | { | |
376 | param.basic_check(Module_Param::BC_VALUE, "union value"); | |
3abe9331 | 377 | Module_Param_Ptr mp = ¶m; |
378 | if (param.get_type() == Module_Param::MP_Reference) { | |
379 | mp = param.get_referenced_param(); | |
380 | } | |
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) { | |
970ed795 EL |
383 | param.error("union value with field name was expected"); |
384 | } | |
3abe9331 | 385 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
386 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
387 | syntaxes().set_param(*mp_last); | |
388 | return; | |
389 | } | |
390 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
391 | syntax().set_param(*mp_last); | |
392 | return; | |
393 | } | |
394 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
395 | presentation__context__id().set_param(*mp_last); | |
396 | return; | |
397 | } | |
398 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
399 | context__negotiation().set_param(*mp_last); | |
400 | return; | |
401 | } | |
402 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
403 | transfer__syntax().set_param(*mp_last); | |
404 | return; | |
405 | } | |
406 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
407 | fixed().set_param(*mp_last); | |
408 | return; | |
409 | } | |
410 | mp_last->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last->get_id()->get_name()); | |
411 | } | |
412 | ||
3abe9331 | 413 | Module_Param* CHARACTER_STRING_identification::get_param(Module_Param_Name& param_name) const |
414 | { | |
415 | if (!is_bound()) { | |
416 | return new Module_Param_Unbound(); | |
417 | } | |
418 | Module_Param* mp_field = NULL; | |
419 | switch(get_selection()) { | |
420 | case ALT_syntaxes: | |
421 | mp_field = field_syntaxes->get_param(param_name); | |
422 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes"))); | |
423 | break; | |
424 | case ALT_syntax: | |
425 | mp_field = field_syntax->get_param(param_name); | |
426 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax"))); | |
427 | break; | |
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"))); | |
431 | break; | |
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"))); | |
435 | break; | |
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"))); | |
439 | break; | |
440 | case ALT_fixed: | |
441 | mp_field = field_fixed->get_param(param_name); | |
442 | mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed"))); | |
443 | break; | |
444 | default: | |
445 | break; | |
446 | } | |
447 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
448 | mp->add_elem(mp_field); | |
449 | return mp; | |
450 | } | |
451 | ||
970ed795 EL |
452 | void CHARACTER_STRING_identification_template::set_param(Module_Param& param) |
453 | { | |
454 | param.basic_check(Module_Param::BC_TEMPLATE, "union template"); | |
3abe9331 | 455 | Module_Param_Ptr mp = ¶m; |
456 | if (param.get_type() == Module_Param::MP_Reference) { | |
457 | mp = param.get_referenced_param(); | |
458 | } | |
459 | switch (mp->get_type()) { | |
970ed795 EL |
460 | case Module_Param::MP_Omit: |
461 | *this = OMIT_VALUE; | |
462 | break; | |
463 | case Module_Param::MP_Any: | |
464 | *this = ANY_VALUE; | |
465 | break; | |
466 | case Module_Param::MP_AnyOrNone: | |
467 | *this = ANY_OR_OMIT; | |
468 | break; | |
469 | case Module_Param::MP_List_Template: | |
3abe9331 | 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)); | |
970ed795 | 476 | } |
3abe9331 | 477 | *this = temp; |
478 | break; } | |
970ed795 | 479 | case Module_Param::MP_Value_List: |
3abe9331 | 480 | if (mp->get_size()==0) break; |
970ed795 EL |
481 | param.type_error("union template", "CHARACTER STRING.identification"); |
482 | break; | |
483 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 484 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
485 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
486 | syntaxes().set_param(*mp_last); | |
487 | break; | |
488 | } | |
489 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
490 | syntax().set_param(*mp_last); | |
491 | break; | |
492 | } | |
493 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
494 | presentation__context__id().set_param(*mp_last); | |
495 | break; | |
496 | } | |
497 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
498 | context__negotiation().set_param(*mp_last); | |
499 | break; | |
500 | } | |
501 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
502 | transfer__syntax().set_param(*mp_last); | |
503 | break; | |
504 | } | |
505 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
506 | fixed().set_param(*mp_last); | |
507 | break; | |
508 | } | |
509 | mp_last->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last->get_id()->get_name()); | |
510 | } break; | |
511 | default: | |
512 | param.type_error("union template", "CHARACTER STRING.identification"); | |
513 | } | |
3abe9331 | 514 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); |
515 | } | |
516 | ||
517 | Module_Param* CHARACTER_STRING_identification_template::get_param(Module_Param_Name& param_name) const | |
518 | { | |
519 | Module_Param* mp = NULL; | |
520 | switch (template_selection) { | |
521 | case UNINITIALIZED_TEMPLATE: | |
522 | mp = new Module_Param_Unbound(); | |
523 | break; | |
524 | case OMIT_VALUE: | |
525 | mp = new Module_Param_Omit(); | |
526 | break; | |
527 | case ANY_VALUE: | |
528 | mp = new Module_Param_Any(); | |
529 | break; | |
530 | case ANY_OR_OMIT: | |
531 | mp = new Module_Param_AnyOrNone(); | |
532 | break; | |
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"))); | |
539 | break; | |
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"))); | |
543 | break; | |
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"))); | |
547 | break; | |
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"))); | |
551 | break; | |
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"))); | |
555 | break; | |
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"))); | |
559 | break; | |
560 | default: | |
561 | break; | |
562 | } | |
563 | mp = new Module_Param_Assignment_List(); | |
564 | mp->add_elem(mp_field); | |
565 | break; } | |
566 | case VALUE_LIST: | |
567 | case COMPLEMENTED_LIST: { | |
568 | if (template_selection == VALUE_LIST) { | |
569 | mp = new Module_Param_List_Template(); | |
570 | } | |
571 | else { | |
572 | mp = new Module_Param_ComplementList_Template(); | |
573 | } | |
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)); | |
576 | } | |
577 | break; } | |
578 | default: | |
579 | break; | |
580 | } | |
581 | if (is_ifpresent) { | |
582 | mp->set_ifpresent(); | |
583 | } | |
584 | return mp; | |
970ed795 EL |
585 | } |
586 | ||
587 | void CHARACTER_STRING_identification::encode_text(Text_Buf& text_buf) const | |
588 | { | |
589 | text_buf.push_int(union_selection); | |
590 | switch (union_selection) { | |
591 | case ALT_syntaxes: | |
592 | field_syntaxes->encode_text(text_buf); | |
593 | break; | |
594 | case ALT_syntax: | |
595 | field_syntax->encode_text(text_buf); | |
596 | break; | |
597 | case ALT_presentation__context__id: | |
598 | field_presentation__context__id->encode_text(text_buf); | |
599 | break; | |
600 | case ALT_context__negotiation: | |
601 | field_context__negotiation->encode_text(text_buf); | |
602 | break; | |
603 | case ALT_transfer__syntax: | |
604 | field_transfer__syntax->encode_text(text_buf); | |
605 | break; | |
606 | case ALT_fixed: | |
607 | field_fixed->encode_text(text_buf); | |
608 | break; | |
609 | default: | |
610 | TTCN_error("Text encoder: Encoding an unbound value of union type CHARACTER STRING.identification."); | |
611 | } | |
612 | } | |
613 | ||
614 | void CHARACTER_STRING_identification::decode_text(Text_Buf& text_buf) | |
615 | { | |
616 | switch ((union_selection_type)text_buf.pull_int().get_val()) { | |
617 | case ALT_syntaxes: | |
618 | syntaxes().decode_text(text_buf); | |
619 | break; | |
620 | case ALT_syntax: | |
621 | syntax().decode_text(text_buf); | |
622 | break; | |
623 | case ALT_presentation__context__id: | |
624 | presentation__context__id().decode_text(text_buf); | |
625 | break; | |
626 | case ALT_context__negotiation: | |
627 | context__negotiation().decode_text(text_buf); | |
628 | break; | |
629 | case ALT_transfer__syntax: | |
630 | transfer__syntax().decode_text(text_buf); | |
631 | break; | |
632 | case ALT_fixed: | |
633 | fixed().decode_text(text_buf); | |
634 | break; | |
635 | default: | |
636 | TTCN_error("Text decoder: Unrecognized union selector was received for type CHARACTER STRING.identification."); | |
637 | } | |
638 | } | |
639 | ||
640 | /* not called | |
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, ...) | |
643 | */ | |
644 | ||
645 | ASN_BER_TLV_t *CHARACTER_STRING_identification::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
646 | { | |
647 | BER_chk_descr(p_td); | |
648 | ASN_BER_TLV_t *new_tlv; | |
649 | TTCN_EncDec_ErrorContext ec_0("Alternative '"); | |
650 | TTCN_EncDec_ErrorContext ec_1; | |
651 | switch (union_selection) { | |
652 | case ALT_syntaxes: | |
653 | ec_1.set_msg("syntaxes': "); | |
654 | new_tlv = field_syntaxes->BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_descr_, p_coding); | |
655 | break; | |
656 | case ALT_syntax: | |
657 | ec_1.set_msg("syntax': "); | |
658 | new_tlv = field_syntax->BER_encode_TLV(CHARACTER_STRING_identification_syntax_descr_, p_coding); | |
659 | break; | |
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); | |
663 | break; | |
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); | |
667 | break; | |
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); | |
671 | break; | |
672 | case ALT_fixed: | |
673 | ec_1.set_msg("fixed': "); | |
674 | new_tlv = field_fixed->BER_encode_TLV(CHARACTER_STRING_identification_fixed_descr_, p_coding); | |
675 | break; | |
676 | case UNBOUND_VALUE: | |
677 | new_tlv = BER_encode_chk_bound(FALSE); | |
678 | break; | |
679 | default: | |
680 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
681 | new_tlv = NULL; | |
682 | } | |
683 | return ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
684 | } | |
685 | ||
686 | boolean CHARACTER_STRING_identification::BER_decode_set_selection(const ASN_BER_TLV_t& p_tlv) | |
687 | { | |
688 | clean_up(); | |
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; | |
696 | delete field_syntax; | |
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; | |
712 | delete field_fixed; | |
713 | union_selection = UNBOUND_VALUE; | |
714 | return FALSE; | |
715 | } | |
716 | ||
717 | boolean CHARACTER_STRING_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv) | |
718 | { | |
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); | |
723 | } | |
724 | ||
725 | boolean CHARACTER_STRING_identification::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
726 | { | |
727 | BER_chk_descr(p_td); | |
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) { | |
736 | case ALT_syntaxes: | |
737 | ec_2.set_msg("syntaxes': "); | |
738 | field_syntaxes->BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_descr_, tmp_tlv, L_form); | |
739 | break; | |
740 | case ALT_syntax: | |
741 | ec_2.set_msg("syntax': "); | |
742 | field_syntax->BER_decode_TLV(CHARACTER_STRING_identification_syntax_descr_, tmp_tlv, L_form); | |
743 | break; | |
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); | |
747 | break; | |
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); | |
751 | break; | |
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); | |
755 | break; | |
756 | case ALT_fixed: | |
757 | ec_2.set_msg("fixed': "); | |
758 | field_fixed->BER_decode_TLV(CHARACTER_STRING_identification_fixed_descr_, tmp_tlv, L_form); | |
759 | break; | |
760 | default: | |
761 | return FALSE; | |
762 | } | |
763 | return TRUE; | |
764 | } | |
765 | ||
766 | // FIXME maybe: XER_encode and decode is virtually identical to EMBEDDED_PDV | |
767 | ||
768 | int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 769 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
770 | { |
771 | int encoded_length=(int)p_buf.get_len(); | |
772 | ||
773 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
774 | ||
775 | flavor &= XER_MASK; | |
776 | switch (union_selection) { | |
777 | case ALT_syntaxes: | |
af710487 | 778 | field_syntaxes->XER_encode(EMBEDDED_PDV_identification_sxs_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
779 | break; |
780 | case ALT_syntax: | |
af710487 | 781 | field_syntax->XER_encode(EMBEDDED_PDV_identification_sx_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
782 | break; |
783 | case ALT_presentation__context__id: | |
af710487 | 784 | field_presentation__context__id->XER_encode(EMBEDDED_PDV_identification_pci_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
785 | break; |
786 | case ALT_context__negotiation: | |
af710487 | 787 | field_context__negotiation->XER_encode(EMBEDDED_PDV_identification_cn_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
788 | break; |
789 | case ALT_transfer__syntax: | |
af710487 | 790 | field_transfer__syntax->XER_encode(EMBEDDED_PDV_identification_ts_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
791 | break; |
792 | case ALT_fixed: | |
af710487 | 793 | field_fixed->XER_encode(EMBEDDED_PDV_identification_fix_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
794 | break; |
795 | default: | |
796 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
797 | break; | |
798 | } | |
799 | ||
800 | end_xml(p_td, p_buf, flavor, --indent, false); | |
801 | ||
802 | return (int)p_buf.get_len() - encoded_length; | |
803 | } | |
804 | ||
805 | int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t& p_td, | |
feade998 | 806 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
807 | { |
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(); | |
812 | switch (type) { | |
813 | case XML_READER_TYPE_ELEMENT: { | |
814 | if (verify_name(reader, p_td, exer)) { | |
815 | // it's us | |
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; | |
820 | } | |
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); | |
825 | switch (namelen) { | |
826 | case 8: // syntaxes | |
feade998 | 827 | syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
828 | break; |
829 | ||
830 | case 6: // syntax | |
feade998 | 831 | syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
832 | break; |
833 | ||
834 | case 23: // presentation-context-id | |
feade998 | 835 | presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
836 | break; |
837 | ||
838 | case 19: // context-negotiation | |
feade998 | 839 | context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
840 | break; |
841 | ||
842 | case 15: // transfer-syntax | |
feade998 | 843 | transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
844 | break; |
845 | ||
846 | case 5: // fixed | |
feade998 | 847 | fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
848 | break; |
849 | ||
850 | default: | |
851 | goto bail; | |
852 | } // switch | |
853 | } | |
854 | else { // it belongs to somebody else | |
855 | goto bail; | |
856 | } | |
857 | break; } | |
858 | case XML_READER_TYPE_END_ELEMENT: { | |
859 | // advance to the next thing and bail | |
860 | reader.Read(); | |
861 | goto bail; } | |
862 | } | |
863 | } | |
864 | bail: | |
865 | return 1; | |
866 | } | |
867 | ||
868 | void CHARACTER_STRING_identification_template::clean_up() | |
869 | { | |
870 | switch (template_selection) { | |
871 | case SPECIFIC_VALUE: | |
872 | switch (single_value.union_selection) { | |
873 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
874 | delete single_value.field_syntaxes; | |
875 | break; | |
876 | case CHARACTER_STRING_identification::ALT_syntax: | |
877 | delete single_value.field_syntax; | |
878 | break; | |
879 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
880 | delete single_value.field_presentation__context__id; | |
881 | break; | |
882 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
883 | delete single_value.field_context__negotiation; | |
884 | break; | |
885 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
886 | delete single_value.field_transfer__syntax; | |
887 | break; | |
888 | case CHARACTER_STRING_identification::ALT_fixed: | |
889 | delete single_value.field_fixed; | |
890 | break; | |
891 | default: | |
892 | break; | |
893 | } | |
894 | break; | |
895 | case VALUE_LIST: | |
896 | case COMPLEMENTED_LIST: | |
897 | delete [] value_list.list_value; | |
898 | break; | |
899 | default: | |
900 | break; | |
901 | } | |
902 | template_selection = UNINITIALIZED_TEMPLATE; | |
903 | } | |
904 | ||
905 | void CHARACTER_STRING_identification_template::copy_value(const CHARACTER_STRING_identification& other_value) | |
906 | { | |
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()); | |
911 | break; | |
912 | case CHARACTER_STRING_identification::ALT_syntax: | |
913 | single_value.field_syntax = new OBJID_template(other_value.syntax()); | |
914 | break; | |
915 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
916 | single_value.field_presentation__context__id = new INTEGER_template(other_value.presentation__context__id()); | |
917 | break; | |
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()); | |
920 | break; | |
921 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
922 | single_value.field_transfer__syntax = new OBJID_template(other_value.transfer__syntax()); | |
923 | break; | |
924 | case CHARACTER_STRING_identification::ALT_fixed: | |
925 | single_value.field_fixed = new ASN_NULL_template(other_value.fixed()); | |
926 | break; | |
927 | default: | |
928 | TTCN_error("Initializing a template with an unbound value of type CHARACTER STRING.identification."); | |
929 | } | |
930 | set_selection(SPECIFIC_VALUE); | |
931 | } | |
932 | ||
933 | void CHARACTER_STRING_identification_template::copy_template(const CHARACTER_STRING_identification_template& other_value) | |
934 | { | |
935 | switch (other_value.template_selection) { | |
936 | case SPECIFIC_VALUE: | |
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); | |
941 | break; | |
942 | case CHARACTER_STRING_identification::ALT_syntax: | |
943 | single_value.field_syntax = new OBJID_template(*other_value.single_value.field_syntax); | |
944 | break; | |
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); | |
947 | break; | |
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); | |
950 | break; | |
951 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
952 | single_value.field_transfer__syntax = new OBJID_template(*other_value.single_value.field_transfer__syntax); | |
953 | break; | |
954 | case CHARACTER_STRING_identification::ALT_fixed: | |
955 | single_value.field_fixed = new ASN_NULL_template(*other_value.single_value.field_fixed); | |
956 | break; | |
957 | default: | |
958 | TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type CHARACTER STRING.identification."); | |
959 | } | |
960 | break; | |
961 | case OMIT_VALUE: | |
962 | case ANY_VALUE: | |
963 | case ANY_OR_OMIT: | |
964 | break; | |
965 | case VALUE_LIST: | |
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]); | |
971 | break; | |
972 | default: | |
973 | TTCN_error("Copying an uninitialized template of union type CHARACTER STRING.identification."); | |
974 | } | |
975 | set_selection(other_value); | |
976 | } | |
977 | ||
978 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template() | |
979 | { | |
980 | } | |
981 | ||
982 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(template_sel other_value) | |
983 | : Base_Template(other_value) | |
984 | { | |
985 | check_single_selection(other_value); | |
986 | } | |
987 | ||
988 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification& other_value) | |
989 | { | |
990 | copy_value(other_value); | |
991 | } | |
992 | ||
993 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const OPTIONAL<CHARACTER_STRING_identification>& other_value) | |
994 | { | |
995 | switch (other_value.get_selection()) { | |
996 | case OPTIONAL_PRESENT: | |
997 | copy_value((const CHARACTER_STRING_identification&)other_value); | |
998 | break; | |
999 | case OPTIONAL_OMIT: | |
1000 | set_selection(OMIT_VALUE); | |
1001 | break; | |
1002 | default: | |
1003 | TTCN_error("Creating a template of union type CHARACTER STRING.identification from an unbound optional field."); | |
1004 | } | |
1005 | } | |
1006 | ||
1007 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification_template& other_value) | |
1008 | : Base_Template() | |
1009 | { | |
1010 | copy_template(other_value); | |
1011 | } | |
1012 | ||
1013 | CHARACTER_STRING_identification_template::~CHARACTER_STRING_identification_template() | |
1014 | { | |
1015 | clean_up(); | |
1016 | } | |
1017 | ||
1018 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(template_sel other_value) | |
1019 | { | |
1020 | check_single_selection(other_value); | |
1021 | clean_up(); | |
1022 | set_selection(other_value); | |
1023 | return *this; | |
1024 | } | |
1025 | ||
1026 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification& other_value) | |
1027 | { | |
1028 | clean_up(); | |
1029 | copy_value(other_value); | |
1030 | return *this; | |
1031 | } | |
1032 | ||
1033 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const OPTIONAL<CHARACTER_STRING_identification>& other_value) | |
1034 | { | |
1035 | clean_up(); | |
1036 | switch (other_value.get_selection()) { | |
1037 | case OPTIONAL_PRESENT: | |
1038 | copy_value((const CHARACTER_STRING_identification&)other_value); | |
1039 | break; | |
1040 | case OPTIONAL_OMIT: | |
1041 | set_selection(OMIT_VALUE); | |
1042 | break; | |
1043 | default: | |
1044 | TTCN_error("Assignment of an unbound optional field to a template of union type CHARACTER STRING.identification."); | |
1045 | } | |
1046 | return *this; | |
1047 | } | |
1048 | ||
1049 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification_template& other_value) | |
1050 | { | |
1051 | if (&other_value != this) { | |
1052 | clean_up(); | |
1053 | copy_template(other_value); | |
1054 | } | |
1055 | return *this; | |
1056 | } | |
1057 | ||
3abe9331 | 1058 | boolean CHARACTER_STRING_identification_template::match(const CHARACTER_STRING_identification& other_value, |
1059 | boolean /* legacy */) const | |
970ed795 EL |
1060 | { |
1061 | switch (template_selection) { | |
1062 | case ANY_VALUE: | |
1063 | case ANY_OR_OMIT: | |
1064 | return TRUE; | |
1065 | case OMIT_VALUE: | |
1066 | return FALSE; | |
1067 | case SPECIFIC_VALUE: | |
1068 | { | |
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()); | |
1085 | default: | |
1086 | TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type CHARACTER STRING.identification."); | |
1087 | } | |
1088 | } | |
1089 | case VALUE_LIST: | |
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; | |
1094 | default: | |
1095 | TTCN_error ("Matching an uninitialized template of union type CHARACTER STRING.identification."); | |
1096 | } | |
1097 | return FALSE; | |
1098 | } | |
1099 | ||
1100 | CHARACTER_STRING_identification CHARACTER_STRING_identification_template::valueof() const | |
1101 | { | |
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(); | |
1108 | break; | |
1109 | case CHARACTER_STRING_identification::ALT_syntax: | |
1110 | ret_val.syntax() = single_value.field_syntax->valueof(); | |
1111 | break; | |
1112 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1113 | ret_val.presentation__context__id() = single_value.field_presentation__context__id->valueof(); | |
1114 | break; | |
1115 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1116 | ret_val.context__negotiation() = single_value.field_context__negotiation->valueof(); | |
1117 | break; | |
1118 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1119 | ret_val.transfer__syntax() = single_value.field_transfer__syntax->valueof(); | |
1120 | break; | |
1121 | case CHARACTER_STRING_identification::ALT_fixed: | |
1122 | ret_val.fixed() = single_value.field_fixed->valueof(); | |
1123 | break; | |
1124 | default: | |
1125 | TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type CHARACTER STRING.identification."); | |
1126 | } | |
1127 | return ret_val; | |
1128 | } | |
1129 | ||
1130 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::list_item(unsigned int list_index) const | |
1131 | { | |
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]; | |
1135 | } | |
1136 | void CHARACTER_STRING_identification_template::set_type(template_sel template_type, unsigned int list_length) | |
1137 | { | |
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."); | |
1139 | clean_up(); | |
1140 | set_selection(template_type); | |
1141 | value_list.n_values = list_length; | |
1142 | value_list.list_value = new CHARACTER_STRING_identification_template[list_length]; | |
1143 | } | |
1144 | ||
1145 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_template::syntaxes() | |
1146 | { | |
1147 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_syntaxes) { | |
1148 | template_sel old_selection = template_selection; | |
1149 | clean_up(); | |
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); | |
1154 | } | |
1155 | return *single_value.field_syntaxes; | |
1156 | } | |
1157 | ||
1158 | const CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_template::syntaxes() const | |
1159 | { | |
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; | |
1163 | } | |
1164 | ||
1165 | OBJID_template& CHARACTER_STRING_identification_template::syntax() | |
1166 | { | |
1167 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_syntax) { | |
1168 | template_sel old_selection = template_selection; | |
1169 | clean_up(); | |
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); | |
1174 | } | |
1175 | return *single_value.field_syntax; | |
1176 | } | |
1177 | ||
1178 | const OBJID_template& CHARACTER_STRING_identification_template::syntax() const | |
1179 | { | |
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; | |
1183 | } | |
1184 | ||
1185 | INTEGER_template& CHARACTER_STRING_identification_template::presentation__context__id() | |
1186 | { | |
1187 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_presentation__context__id) { | |
1188 | template_sel old_selection = template_selection; | |
1189 | clean_up(); | |
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); | |
1194 | } | |
1195 | return *single_value.field_presentation__context__id; | |
1196 | } | |
1197 | ||
1198 | const INTEGER_template& CHARACTER_STRING_identification_template::presentation__context__id() const | |
1199 | { | |
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; | |
1203 | } | |
1204 | ||
1205 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_template::context__negotiation() | |
1206 | { | |
1207 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_context__negotiation) { | |
1208 | template_sel old_selection = template_selection; | |
1209 | clean_up(); | |
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); | |
1214 | } | |
1215 | return *single_value.field_context__negotiation; | |
1216 | } | |
1217 | ||
1218 | const CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_template::context__negotiation() const | |
1219 | { | |
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; | |
1223 | } | |
1224 | ||
1225 | OBJID_template& CHARACTER_STRING_identification_template::transfer__syntax() | |
1226 | { | |
1227 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_transfer__syntax) { | |
1228 | template_sel old_selection = template_selection; | |
1229 | clean_up(); | |
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); | |
1234 | } | |
1235 | return *single_value.field_transfer__syntax; | |
1236 | } | |
1237 | ||
1238 | const OBJID_template& CHARACTER_STRING_identification_template::transfer__syntax() const | |
1239 | { | |
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; | |
1243 | } | |
1244 | ||
1245 | ASN_NULL_template& CHARACTER_STRING_identification_template::fixed() | |
1246 | { | |
1247 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_fixed) { | |
1248 | template_sel old_selection = template_selection; | |
1249 | clean_up(); | |
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); | |
1254 | } | |
1255 | return *single_value.field_fixed; | |
1256 | } | |
1257 | ||
1258 | const ASN_NULL_template& CHARACTER_STRING_identification_template::fixed() const | |
1259 | { | |
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; | |
1263 | } | |
1264 | ||
1265 | boolean CHARACTER_STRING_identification_template::ischosen(CHARACTER_STRING_identification::union_selection_type checked_selection) const | |
1266 | { | |
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; | |
1272 | case VALUE_LIST: | |
1273 | { | |
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) { | |
1280 | all_same = FALSE; | |
1281 | break; | |
1282 | } | |
1283 | } | |
1284 | if (all_same) return ret_val; | |
1285 | } | |
1286 | // FIXME really no break? | |
1287 | case ANY_VALUE: | |
1288 | case ANY_OR_OMIT: | |
1289 | case OMIT_VALUE: | |
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."); | |
1292 | default: | |
1293 | TTCN_error("Performing ischosen() operation on an uninitialized template of union type CHARACTER STRING.identification"); | |
1294 | } | |
1295 | return FALSE; | |
1296 | } | |
1297 | ||
1298 | void CHARACTER_STRING_identification_template::log() const | |
1299 | { | |
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(" }"); | |
1307 | break; | |
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(" }"); | |
1312 | break; | |
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(" }"); | |
1317 | break; | |
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(" }"); | |
1322 | break; | |
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(" }"); | |
1327 | break; | |
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(" }"); | |
1332 | break; | |
1333 | default: | |
1334 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1335 | break; | |
1336 | } | |
1337 | break; | |
1338 | case COMPLEMENTED_LIST: | |
1339 | TTCN_Logger::log_event_str("complement "); | |
1340 | // no break | |
1341 | case VALUE_LIST: | |
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(); | |
1346 | } | |
1347 | TTCN_Logger::log_char(')'); | |
1348 | break; | |
1349 | default: | |
1350 | log_generic(); | |
1351 | break; | |
1352 | } | |
1353 | log_ifpresent(); | |
1354 | } | |
1355 | ||
3abe9331 | 1356 | void CHARACTER_STRING_identification_template::log_match(const CHARACTER_STRING_identification& match_value, |
1357 | boolean /* legacy */) const | |
970ed795 EL |
1358 | { |
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 "); | |
1363 | } | |
1364 | return; | |
1365 | } | |
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()); | |
1372 | }else{ | |
1373 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
1374 | single_value.field_syntaxes->log_match(match_value.syntaxes()); | |
1375 | TTCN_Logger::log_event_str(" }"); | |
1376 | } | |
1377 | break; | |
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()); | |
1382 | }else{ | |
1383 | TTCN_Logger::log_event_str("{ syntax := "); | |
1384 | single_value.field_syntax->log_match(match_value.syntax()); | |
1385 | TTCN_Logger::log_event_str(" }"); | |
1386 | } | |
1387 | break; | |
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()); | |
1392 | }else{ | |
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(" }"); | |
1396 | } | |
1397 | break; | |
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()); | |
1402 | }else{ | |
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(" }"); | |
1406 | } | |
1407 | break; | |
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()); | |
1412 | }else{ | |
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(" }"); | |
1416 | } | |
1417 | break; | |
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()); | |
1422 | }else{ | |
1423 | TTCN_Logger::log_event_str("{ fixed := "); | |
1424 | single_value.field_fixed->log_match(match_value.fixed()); | |
1425 | TTCN_Logger::log_event_str(" }"); | |
1426 | } | |
1427 | break; | |
1428 | default: | |
1429 | TTCN_Logger::print_logmatch_buffer(); | |
1430 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1431 | break; | |
1432 | } | |
1433 | } else { | |
1434 | TTCN_Logger::print_logmatch_buffer(); | |
1435 | match_value.log(); | |
1436 | TTCN_Logger::log_event_str(" with "); | |
1437 | log(); | |
1438 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
1439 | else TTCN_Logger::log_event_str(" unmatched"); | |
1440 | } | |
1441 | } | |
1442 | ||
1443 | void CHARACTER_STRING_identification_template::encode_text(Text_Buf& text_buf) const | |
1444 | { | |
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); | |
1452 | break; | |
1453 | case CHARACTER_STRING_identification::ALT_syntax: | |
1454 | single_value.field_syntax->encode_text(text_buf); | |
1455 | break; | |
1456 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1457 | single_value.field_presentation__context__id->encode_text(text_buf); | |
1458 | break; | |
1459 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1460 | single_value.field_context__negotiation->encode_text(text_buf); | |
1461 | break; | |
1462 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1463 | single_value.field_transfer__syntax->encode_text(text_buf); | |
1464 | break; | |
1465 | case CHARACTER_STRING_identification::ALT_fixed: | |
1466 | single_value.field_fixed->encode_text(text_buf); | |
1467 | break; | |
1468 | default: | |
1469 | TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type CHARACTER STRING.identification."); | |
1470 | } | |
1471 | break; | |
1472 | case OMIT_VALUE: | |
1473 | case ANY_VALUE: | |
1474 | case ANY_OR_OMIT: | |
1475 | break; | |
1476 | case VALUE_LIST: | |
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); | |
1481 | break; | |
1482 | default: | |
1483 | TTCN_error("Text encoder: Encoding an uninitialized template of type CHARACTER STRING.identification."); | |
1484 | } | |
1485 | } | |
1486 | ||
1487 | void CHARACTER_STRING_identification_template::decode_text(Text_Buf& text_buf) | |
1488 | { | |
1489 | clean_up(); | |
1490 | decode_text_base(text_buf); | |
1491 | switch (template_selection) { | |
1492 | case SPECIFIC_VALUE: | |
1493 | { | |
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); | |
1500 | break; | |
1501 | case CHARACTER_STRING_identification::ALT_syntax: | |
1502 | single_value.field_syntax = new OBJID_template; | |
1503 | single_value.field_syntax->decode_text(text_buf); | |
1504 | break; | |
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); | |
1508 | break; | |
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); | |
1512 | break; | |
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); | |
1516 | break; | |
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); | |
1520 | break; | |
1521 | default: | |
1522 | TTCN_error("Text decoder: Unrecognized union selector was received for a template of type CHARACTER STRING.identification."); | |
1523 | } | |
1524 | single_value.union_selection = new_selection; | |
1525 | } | |
1526 | break; | |
1527 | case OMIT_VALUE: | |
1528 | case ANY_VALUE: | |
1529 | case ANY_OR_OMIT: | |
1530 | break; | |
1531 | case VALUE_LIST: | |
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); | |
1537 | break; | |
1538 | default: | |
1539 | TTCN_error("Text decoder: Unrecognized selector was received in a template of type CHARACTER STRING.identification."); | |
1540 | } | |
1541 | } | |
1542 | ||
3abe9331 | 1543 | boolean CHARACTER_STRING_identification_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
1544 | { |
1545 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 1546 | return !match_omit(legacy); |
970ed795 EL |
1547 | } |
1548 | ||
3abe9331 | 1549 | boolean CHARACTER_STRING_identification_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
1550 | { |
1551 | if (is_ifpresent) return TRUE; | |
1552 | switch (template_selection) { | |
1553 | case OMIT_VALUE: | |
1554 | case ANY_OR_OMIT: | |
1555 | return TRUE; | |
1556 | case VALUE_LIST: | |
1557 | case COMPLEMENTED_LIST: | |
3abe9331 | 1558 | if (legacy) { |
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 | |
970ed795 EL |
1564 | default: |
1565 | return FALSE; | |
1566 | } | |
1567 | return FALSE; | |
1568 | } | |
1569 | ||
1570 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 1571 | void CHARACTER_STRING_identification_template::check_restriction(template_res t_res, const char* t_name, |
1572 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
1573 | { |
1574 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
1575 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
1576 | case TR_VALUE: | |
1577 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
1578 | break; | |
1579 | case TR_OMIT: | |
1580 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
1581 | template_selection==SPECIFIC_VALUE)) return; | |
1582 | break; | |
1583 | case TR_PRESENT: | |
3abe9331 | 1584 | if (!match_omit(legacy)) return; |
970ed795 EL |
1585 | break; |
1586 | default: | |
1587 | return; | |
1588 | } | |
1589 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
1590 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING.identification"); | |
1591 | } | |
1592 | #endif | |
1593 | ||
1594 | CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes() | |
1595 | { | |
1596 | } | |
1597 | ||
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) | |
1602 | { | |
1603 | } | |
1604 | ||
1605 | boolean CHARACTER_STRING_identification_syntaxes::operator==(const CHARACTER_STRING_identification_syntaxes& other_value) const | |
1606 | { | |
1607 | return field_abstract==other_value.field_abstract | |
1608 | && field_transfer==other_value.field_transfer; | |
1609 | } | |
1610 | ||
1611 | int CHARACTER_STRING_identification_syntaxes::size_of() const | |
1612 | { | |
1613 | int ret_val = 2; | |
1614 | return ret_val; | |
1615 | } | |
1616 | ||
1617 | void CHARACTER_STRING_identification_syntaxes::log() const | |
1618 | { | |
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(" }"); | |
1624 | } | |
1625 | ||
1626 | boolean CHARACTER_STRING_identification_syntaxes::is_bound() const | |
1627 | { | |
1628 | if(field_abstract.is_bound()) return TRUE; | |
1629 | if(field_transfer.is_bound()) return TRUE; | |
1630 | return FALSE; | |
1631 | } | |
1632 | ||
1633 | boolean CHARACTER_STRING_identification_syntaxes::is_value() const | |
1634 | { | |
1635 | if(!field_abstract.is_value()) return FALSE; | |
1636 | if(!field_transfer.is_value()) return FALSE; | |
1637 | return TRUE; | |
1638 | } | |
1639 | ||
1640 | void CHARACTER_STRING_identification_syntaxes::clean_up() | |
1641 | { | |
1642 | field_abstract.clean_up(); | |
1643 | field_transfer.clean_up(); | |
1644 | } | |
1645 | ||
1646 | void CHARACTER_STRING_identification_syntaxes::set_param(Module_Param& param) | |
1647 | { | |
1648 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 1649 | Module_Param_Ptr mp = ¶m; |
1650 | if (param.get_type() == Module_Param::MP_Reference) { | |
1651 | mp = param.get_referenced_param(); | |
1652 | } | |
1653 | switch (mp->get_type()) { | |
970ed795 | 1654 | case Module_Param::MP_Value_List: |
3abe9331 | 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()); | |
970ed795 | 1658 | } |
3abe9331 | 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)); | |
970ed795 EL |
1661 | break; |
1662 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 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); | |
970ed795 EL |
1667 | if (!strcmp(curr_param->get_id()->get_name(), "abstract")) { |
1668 | abstract().set_param(*curr_param); | |
1669 | value_used[val_idx]=true; | |
1670 | } | |
1671 | } | |
3abe9331 | 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); | |
970ed795 EL |
1674 | if (!strcmp(curr_param->get_id()->get_name(), "transfer")) { |
1675 | transfer().set_param(*curr_param); | |
1676 | value_used[val_idx]=true; | |
1677 | } | |
1678 | } | |
3abe9331 | 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()); | |
970ed795 EL |
1681 | break; |
1682 | } | |
1683 | } break; | |
1684 | default: | |
1685 | param.type_error("record value", "CHARACTER STRING.identification.syntaxes"); | |
1686 | } | |
1687 | } | |
1688 | ||
3abe9331 | 1689 | Module_Param* CHARACTER_STRING_identification_syntaxes::get_param(Module_Param_Name& param_name) const |
970ed795 | 1690 | { |
3abe9331 | 1691 | if (!is_bound()) { |
1692 | return new Module_Param_Unbound(); | |
970ed795 | 1693 | } |
3abe9331 | 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); | |
1701 | return mp; | |
970ed795 EL |
1702 | } |
1703 | ||
1704 | void CHARACTER_STRING_identification_syntaxes::encode_text(Text_Buf& text_buf) const | |
1705 | { | |
1706 | field_abstract.encode_text(text_buf); | |
1707 | field_transfer.encode_text(text_buf); | |
1708 | } | |
1709 | ||
1710 | void CHARACTER_STRING_identification_syntaxes::decode_text(Text_Buf& text_buf) | |
1711 | { | |
1712 | field_abstract.decode_text(text_buf); | |
1713 | field_transfer.decode_text(text_buf); | |
1714 | } | |
1715 | ||
1716 | /* not called | |
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, ...) | |
1719 | */ | |
1720 | ||
1721 | ASN_BER_TLV_t* CHARACTER_STRING_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
1722 | { | |
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); | |
1732 | return new_tlv; | |
1733 | } | |
1734 | ||
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) | |
1736 | { | |
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); | |
1742 | size_t V_pos=0; | |
1743 | ASN_BER_TLV_t tmp_tlv; | |
1744 | boolean tlv_present=FALSE; | |
1745 | { | |
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); | |
1752 | tlv_present=FALSE; | |
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); | |
1757 | tlv_present=FALSE; | |
1758 | } | |
1759 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
1760 | return TRUE; | |
1761 | } | |
1762 | ||
1763 | int CHARACTER_STRING_identification_syntaxes::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 1764 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
1765 | { |
1766 | int encoded_length=(int)p_buf.get_len(); | |
1767 | ||
1768 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
1769 | ||
af710487 | 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); | |
970ed795 EL |
1772 | |
1773 | end_xml(p_td, p_buf, flavor, --indent, false); | |
1774 | ||
1775 | return p_buf.get_len() - encoded_length; | |
1776 | } | |
1777 | ||
1778 | int CHARACTER_STRING_identification_syntaxes::XER_decode( | |
feade998 | 1779 | const XERdescriptor_t& /*p_td*/, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
1780 | { // we stand on <syntaxes>, move ahead first |
1781 | for (int success = reader.Read(); success == 1; success = reader.Read()) | |
1782 | { | |
1783 | int type = reader.NodeType(); | |
1784 | if (XML_READER_TYPE_ELEMENT == type) | |
1785 | // no verify_name for a CHOICE | |
1786 | break; | |
1787 | } | |
1788 | // FIXME this assumes the right element | |
feade998 | 1789 | field_abstract.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_, reader, flavor, flavor2, 0); |
1790 | field_transfer.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
1791 | for (int success = 1; success == 1; success = reader.Read()) |
1792 | { | |
1793 | int type = reader.NodeType(); | |
1794 | if (XML_READER_TYPE_END_ELEMENT == type) | |
1795 | break; | |
1796 | } | |
1797 | return 0; // TODO maybe return proper value | |
1798 | } | |
1799 | ||
1800 | ||
1801 | struct CHARACTER_STRING_identification_syntaxes_template::single_value_struct { | |
1802 | OBJID_template field_abstract; | |
1803 | OBJID_template field_transfer; | |
1804 | }; | |
1805 | ||
3abe9331 | 1806 | void CHARACTER_STRING_identification_syntaxes_template::set_param(Module_Param& param) |
1807 | { | |
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(); | |
1812 | } | |
1813 | switch (mp->get_type()) { | |
1814 | case Module_Param::MP_Omit: | |
1815 | *this = OMIT_VALUE; | |
1816 | break; | |
1817 | case Module_Param::MP_Any: | |
1818 | *this = ANY_VALUE; | |
1819 | break; | |
1820 | case Module_Param::MP_AnyOrNone: | |
1821 | *this = ANY_OR_OMIT; | |
1822 | break; | |
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)); | |
1830 | } | |
1831 | *this = temp; | |
1832 | break; } | |
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()); | |
1837 | } | |
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)); | |
1840 | break; | |
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; | |
1849 | } | |
1850 | } | |
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; | |
1856 | } | |
1857 | } | |
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()); | |
1860 | break; | |
1861 | } | |
1862 | } break; | |
1863 | default: | |
1864 | param.type_error("record template", "CHARACTER STRING.identification.syntaxes"); | |
1865 | } | |
1866 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
1867 | } | |
1868 | ||
1869 | Module_Param* CHARACTER_STRING_identification_syntaxes_template::get_param(Module_Param_Name& param_name) const | |
1870 | { | |
1871 | Module_Param* mp = NULL; | |
1872 | switch (template_selection) { | |
1873 | case UNINITIALIZED_TEMPLATE: | |
1874 | mp = new Module_Param_Unbound(); | |
1875 | break; | |
1876 | case OMIT_VALUE: | |
1877 | mp = new Module_Param_Omit(); | |
1878 | break; | |
1879 | case ANY_VALUE: | |
1880 | mp = new Module_Param_Any(); | |
1881 | break; | |
1882 | case ANY_OR_OMIT: | |
1883 | mp = new Module_Param_AnyOrNone(); | |
1884 | break; | |
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); | |
1893 | break; } | |
1894 | case VALUE_LIST: | |
1895 | case COMPLEMENTED_LIST: { | |
1896 | if (template_selection == VALUE_LIST) { | |
1897 | mp = new Module_Param_List_Template(); | |
1898 | } | |
1899 | else { | |
1900 | mp = new Module_Param_ComplementList_Template(); | |
1901 | } | |
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)); | |
1904 | } | |
1905 | break; } | |
1906 | default: | |
1907 | break; | |
1908 | } | |
1909 | if (is_ifpresent) { | |
1910 | mp->set_ifpresent(); | |
1911 | } | |
1912 | return mp; | |
1913 | } | |
1914 | ||
970ed795 EL |
1915 | void CHARACTER_STRING_identification_syntaxes_template::clean_up() |
1916 | { | |
1917 | switch (template_selection) { | |
1918 | case SPECIFIC_VALUE: | |
1919 | delete single_value; | |
1920 | break; | |
1921 | case VALUE_LIST: | |
1922 | case COMPLEMENTED_LIST: | |
1923 | delete [] value_list.list_value; | |
1924 | break; | |
1925 | default: | |
1926 | break; | |
1927 | } | |
1928 | template_selection = UNINITIALIZED_TEMPLATE; | |
1929 | } | |
1930 | ||
1931 | void CHARACTER_STRING_identification_syntaxes_template::set_specific() | |
1932 | { | |
1933 | if (template_selection != SPECIFIC_VALUE) { | |
1934 | template_sel old_selection = template_selection; | |
1935 | clean_up(); | |
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; | |
1941 | } | |
1942 | } | |
1943 | } | |
1944 | ||
1945 | void CHARACTER_STRING_identification_syntaxes_template::copy_value(const CHARACTER_STRING_identification_syntaxes& other_value) | |
1946 | { | |
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); | |
1951 | } | |
1952 | ||
1953 | void CHARACTER_STRING_identification_syntaxes_template::copy_template(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
1954 | { | |
1955 | switch (other_value.template_selection) { | |
1956 | case SPECIFIC_VALUE: | |
1957 | single_value = new single_value_struct(*other_value.single_value); | |
1958 | break; | |
1959 | case OMIT_VALUE: | |
1960 | case ANY_VALUE: | |
1961 | case ANY_OR_OMIT: | |
1962 | break; | |
1963 | case VALUE_LIST: | |
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]); | |
1969 | break; | |
1970 | default: | |
1971 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
1972 | } | |
1973 | set_selection(other_value); | |
1974 | } | |
1975 | ||
1976 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template() | |
1977 | { | |
1978 | } | |
1979 | ||
1980 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(template_sel other_value) | |
1981 | : Base_Template(other_value) | |
1982 | { | |
1983 | check_single_selection(other_value); | |
1984 | } | |
1985 | ||
1986 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes& other_value) | |
1987 | { | |
1988 | copy_value(other_value); | |
1989 | } | |
1990 | ||
1991 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const OPTIONAL<CHARACTER_STRING_identification_syntaxes>& other_value) | |
1992 | { | |
1993 | switch (other_value.get_selection()) { | |
1994 | case OPTIONAL_PRESENT: | |
1995 | copy_value((const CHARACTER_STRING_identification_syntaxes&)other_value); | |
1996 | break; | |
1997 | case OPTIONAL_OMIT: | |
1998 | set_selection(OMIT_VALUE); | |
1999 | break; | |
2000 | default: | |
2001 | TTCN_error("Creating a template of type CHARACTER STRING.identification.syntaxes from an unbound optional field."); | |
2002 | } | |
2003 | } | |
2004 | ||
2005 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
2006 | : Base_Template() | |
2007 | { | |
2008 | copy_template(other_value); | |
2009 | } | |
2010 | ||
2011 | CHARACTER_STRING_identification_syntaxes_template::~CHARACTER_STRING_identification_syntaxes_template() | |
2012 | { | |
2013 | clean_up(); | |
2014 | } | |
2015 | ||
2016 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(template_sel other_value) | |
2017 | { | |
2018 | check_single_selection(other_value); | |
2019 | clean_up(); | |
2020 | set_selection(other_value); | |
2021 | return *this; | |
2022 | } | |
2023 | ||
2024 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes& other_value) | |
2025 | { | |
2026 | clean_up(); | |
2027 | copy_value(other_value); | |
2028 | return *this; | |
2029 | } | |
2030 | ||
2031 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const OPTIONAL<CHARACTER_STRING_identification_syntaxes>& other_value) | |
2032 | { | |
2033 | clean_up(); | |
2034 | switch (other_value.get_selection()) { | |
2035 | case OPTIONAL_PRESENT: | |
2036 | copy_value((const CHARACTER_STRING_identification_syntaxes&)other_value); | |
2037 | break; | |
2038 | case OPTIONAL_OMIT: | |
2039 | set_selection(OMIT_VALUE); | |
2040 | break; | |
2041 | default: | |
2042 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.syntaxes."); | |
2043 | } | |
2044 | return *this; | |
2045 | } | |
2046 | ||
2047 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
2048 | { | |
2049 | if (&other_value != this) { | |
2050 | clean_up(); | |
2051 | copy_template(other_value); | |
2052 | } | |
2053 | return *this; | |
2054 | } | |
2055 | ||
3abe9331 | 2056 | boolean CHARACTER_STRING_identification_syntaxes_template::match(const CHARACTER_STRING_identification_syntaxes& other_value, |
2057 | boolean /* legacy */) const | |
970ed795 EL |
2058 | { |
2059 | switch (template_selection) { | |
2060 | case ANY_VALUE: | |
2061 | case ANY_OR_OMIT: | |
2062 | return TRUE; | |
2063 | case OMIT_VALUE: | |
2064 | return FALSE; | |
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; | |
2070 | return TRUE; | |
2071 | case VALUE_LIST: | |
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; | |
2076 | default: | |
2077 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2078 | } | |
2079 | return FALSE; | |
2080 | } | |
2081 | ||
2082 | CHARACTER_STRING_identification_syntaxes CHARACTER_STRING_identification_syntaxes_template::valueof() const | |
2083 | { | |
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(); | |
2089 | return ret_val; | |
2090 | } | |
2091 | ||
2092 | void CHARACTER_STRING_identification_syntaxes_template::set_type(template_sel template_type, unsigned int list_length) | |
2093 | { | |
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."); | |
2096 | clean_up(); | |
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]; | |
2100 | } | |
2101 | ||
2102 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::list_item(unsigned int list_index) const | |
2103 | { | |
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]; | |
2109 | } | |
2110 | ||
2111 | OBJID_template& CHARACTER_STRING_identification_syntaxes_template::abstract() | |
2112 | { | |
2113 | set_specific(); | |
2114 | return single_value->field_abstract; | |
2115 | } | |
2116 | ||
2117 | const OBJID_template& CHARACTER_STRING_identification_syntaxes_template::abstract() const | |
2118 | { | |
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; | |
2122 | } | |
2123 | ||
2124 | OBJID_template& CHARACTER_STRING_identification_syntaxes_template::transfer() | |
2125 | { | |
2126 | set_specific(); | |
2127 | return single_value->field_transfer; | |
2128 | } | |
2129 | ||
2130 | const OBJID_template& CHARACTER_STRING_identification_syntaxes_template::transfer() const | |
2131 | { | |
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; | |
2135 | } | |
2136 | ||
2137 | int CHARACTER_STRING_identification_syntaxes_template::size_of() const | |
2138 | { | |
2139 | switch (template_selection) | |
2140 | { | |
2141 | case SPECIFIC_VALUE: | |
2142 | { | |
2143 | int ret_val = 2; | |
2144 | return ret_val; | |
2145 | } | |
2146 | case VALUE_LIST: | |
2147 | { | |
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++) | |
2152 | { | |
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."); | |
2155 | } | |
2156 | return item_size; | |
2157 | } | |
2158 | case OMIT_VALUE: | |
2159 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing omit value."); | |
2160 | case ANY_VALUE: | |
2161 | case ANY_OR_OMIT: | |
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."); | |
2165 | default: | |
2166 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2167 | } | |
2168 | return 0; | |
2169 | } | |
2170 | ||
2171 | void CHARACTER_STRING_identification_syntaxes_template::log() const | |
2172 | { | |
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(" }"); | |
2180 | break; | |
2181 | case COMPLEMENTED_LIST: | |
2182 | TTCN_Logger::log_event_str("complement "); | |
2183 | // no break | |
2184 | case VALUE_LIST: | |
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(); | |
2189 | } | |
2190 | TTCN_Logger::log_char(')'); | |
2191 | break; | |
2192 | default: | |
2193 | log_generic(); | |
2194 | break; | |
2195 | } | |
2196 | log_ifpresent(); | |
2197 | } | |
2198 | ||
3abe9331 | 2199 | void CHARACTER_STRING_identification_syntaxes_template::log_match(const CHARACTER_STRING_identification_syntaxes& match_value, |
2200 | boolean /* legacy */) const | |
970ed795 EL |
2201 | { |
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(" }"); | |
2208 | } else { | |
2209 | match_value.log(); | |
2210 | TTCN_Logger::log_event_str(" with "); | |
2211 | log(); | |
2212 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2213 | else TTCN_Logger::log_event_str(" unmatched"); | |
2214 | } | |
2215 | } | |
2216 | ||
2217 | void CHARACTER_STRING_identification_syntaxes_template::encode_text(Text_Buf& text_buf) const | |
2218 | { | |
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); | |
2224 | break; | |
2225 | case OMIT_VALUE: | |
2226 | case ANY_VALUE: | |
2227 | case ANY_OR_OMIT: | |
2228 | break; | |
2229 | case VALUE_LIST: | |
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); | |
2234 | break; | |
2235 | default: | |
2236 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2237 | } | |
2238 | } | |
2239 | ||
2240 | void CHARACTER_STRING_identification_syntaxes_template::decode_text(Text_Buf& text_buf) | |
2241 | { | |
2242 | clean_up(); | |
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); | |
2249 | break; | |
2250 | case OMIT_VALUE: | |
2251 | case ANY_VALUE: | |
2252 | case ANY_OR_OMIT: | |
2253 | break; | |
2254 | case VALUE_LIST: | |
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); | |
2260 | break; | |
2261 | default: | |
2262 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.syntaxes."); | |
2263 | } | |
2264 | } | |
2265 | ||
3abe9331 | 2266 | boolean CHARACTER_STRING_identification_syntaxes_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
2267 | { |
2268 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 2269 | return !match_omit(legacy); |
970ed795 EL |
2270 | } |
2271 | ||
3abe9331 | 2272 | boolean CHARACTER_STRING_identification_syntaxes_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
2273 | { |
2274 | if (is_ifpresent) return TRUE; | |
2275 | switch (template_selection) { | |
2276 | case OMIT_VALUE: | |
2277 | case ANY_OR_OMIT: | |
2278 | return TRUE; | |
2279 | case VALUE_LIST: | |
2280 | case COMPLEMENTED_LIST: | |
3abe9331 | 2281 | if (legacy) { |
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 | |
970ed795 EL |
2287 | default: |
2288 | return FALSE; | |
2289 | } | |
2290 | return FALSE; | |
2291 | } | |
2292 | ||
2293 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 2294 | void CHARACTER_STRING_identification_syntaxes_template::check_restriction(template_res t_res, const char* t_name, |
2295 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
2296 | { |
2297 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
2298 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
2299 | case TR_VALUE: | |
2300 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
2301 | break; | |
2302 | case TR_OMIT: | |
2303 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
2304 | template_selection==SPECIFIC_VALUE)) return; | |
2305 | break; | |
2306 | case TR_PRESENT: | |
3abe9331 | 2307 | if (!match_omit(legacy)) return; |
970ed795 EL |
2308 | break; |
2309 | default: | |
2310 | return; | |
2311 | } | |
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"); | |
2314 | } | |
2315 | #endif | |
2316 | ||
2317 | CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation() | |
2318 | { | |
2319 | } | |
2320 | ||
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) | |
2325 | { | |
2326 | } | |
2327 | ||
2328 | boolean CHARACTER_STRING_identification_context__negotiation::operator==(const CHARACTER_STRING_identification_context__negotiation& other_value) const | |
2329 | { | |
2330 | return field_presentation__context__id==other_value.field_presentation__context__id | |
2331 | && field_transfer__syntax==other_value.field_transfer__syntax; | |
2332 | } | |
2333 | ||
2334 | int CHARACTER_STRING_identification_context__negotiation::size_of() const | |
2335 | { | |
2336 | int ret_val = 2; | |
2337 | return ret_val; | |
2338 | } | |
2339 | ||
2340 | void CHARACTER_STRING_identification_context__negotiation::log() const | |
2341 | { | |
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(" }"); | |
2347 | } | |
2348 | ||
2349 | boolean CHARACTER_STRING_identification_context__negotiation::is_bound() const | |
2350 | { | |
2351 | if(field_presentation__context__id.is_bound()) return TRUE; | |
2352 | if(field_transfer__syntax.is_bound()) return TRUE; | |
2353 | return FALSE; | |
2354 | } | |
2355 | ||
2356 | boolean CHARACTER_STRING_identification_context__negotiation::is_value() const | |
2357 | { | |
2358 | if(!field_presentation__context__id.is_value()) return FALSE; | |
2359 | if(!field_transfer__syntax.is_value()) return FALSE; | |
2360 | return TRUE; | |
2361 | } | |
2362 | ||
2363 | void CHARACTER_STRING_identification_context__negotiation::clean_up() | |
2364 | { | |
2365 | field_presentation__context__id.clean_up(); | |
2366 | field_transfer__syntax.clean_up(); | |
2367 | } | |
2368 | ||
2369 | void CHARACTER_STRING_identification_context__negotiation::set_param(Module_Param& param) | |
2370 | { | |
2371 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 2372 | Module_Param_Ptr mp = ¶m; |
2373 | if (param.get_type() == Module_Param::MP_Reference) { | |
2374 | mp = param.get_referenced_param(); | |
2375 | } | |
2376 | switch (mp->get_type()) { | |
970ed795 | 2377 | case Module_Param::MP_Value_List: |
3abe9331 | 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()); | |
970ed795 | 2381 | } |
3abe9331 | 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)); | |
970ed795 EL |
2384 | break; |
2385 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 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); | |
970ed795 EL |
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; | |
2393 | } | |
2394 | } | |
3abe9331 | 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); | |
970ed795 EL |
2397 | if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) { |
2398 | transfer__syntax().set_param(*curr_param); | |
2399 | value_used[val_idx]=true; | |
2400 | } | |
2401 | } | |
3abe9331 | 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()); | |
970ed795 EL |
2404 | break; |
2405 | } | |
2406 | } break; | |
2407 | default: | |
2408 | param.type_error("record value", "CHARACTER STRING.identification.context-negotiation"); | |
2409 | } | |
2410 | } | |
2411 | ||
3abe9331 | 2412 | Module_Param* CHARACTER_STRING_identification_context__negotiation::get_param(Module_Param_Name& param_name) const |
970ed795 | 2413 | { |
3abe9331 | 2414 | if (!is_bound()) { |
2415 | return new Module_Param_Unbound(); | |
970ed795 | 2416 | } |
3abe9331 | 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); | |
2424 | return mp; | |
970ed795 EL |
2425 | } |
2426 | ||
2427 | void CHARACTER_STRING_identification_context__negotiation::encode_text(Text_Buf& text_buf) const | |
2428 | { | |
2429 | field_presentation__context__id.encode_text(text_buf); | |
2430 | field_transfer__syntax.encode_text(text_buf); | |
2431 | } | |
2432 | ||
2433 | void CHARACTER_STRING_identification_context__negotiation::decode_text(Text_Buf& text_buf) | |
2434 | { | |
2435 | field_presentation__context__id.decode_text(text_buf); | |
2436 | field_transfer__syntax.decode_text(text_buf); | |
2437 | } | |
2438 | ||
2439 | /* not called | |
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, ...) | |
2442 | */ | |
2443 | ||
2444 | ASN_BER_TLV_t* CHARACTER_STRING_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
2445 | { | |
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); | |
2455 | return new_tlv; | |
2456 | } | |
2457 | ||
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) | |
2459 | { | |
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); | |
2465 | size_t V_pos=0; | |
2466 | ASN_BER_TLV_t tmp_tlv; | |
2467 | boolean tlv_present=FALSE; | |
2468 | { | |
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); | |
2475 | tlv_present=FALSE; | |
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); | |
2480 | tlv_present=FALSE; | |
2481 | } | |
2482 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
2483 | return TRUE; | |
2484 | } | |
2485 | ||
2486 | int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 2487 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
2488 | { |
2489 | int encoded_length=(int)p_buf.get_len(); | |
2490 | ||
2491 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
2492 | ||
af710487 | 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); | |
970ed795 EL |
2495 | |
2496 | end_xml(p_td, p_buf, flavor, --indent, false); | |
2497 | ||
2498 | return p_buf.get_len() - encoded_length; | |
2499 | } | |
2500 | ||
2501 | int CHARACTER_STRING_identification_context__negotiation::XER_decode( | |
feade998 | 2502 | const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
2503 | { |
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(); | |
2512 | } | |
feade998 | 2513 | field_presentation__context__id.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_, reader, flavor, flavor2, 0); |
2514 | field_transfer__syntax .XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
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); | |
2519 | reader.Read(); | |
2520 | break; | |
2521 | } | |
2522 | } | |
2523 | return 0; // TODO sensible return value | |
2524 | } | |
2525 | ||
2526 | struct CHARACTER_STRING_identification_context__negotiation_template::single_value_struct { | |
2527 | INTEGER_template field_presentation__context__id; | |
2528 | OBJID_template field_transfer__syntax; | |
2529 | }; | |
2530 | ||
3abe9331 | 2531 | void CHARACTER_STRING_identification_context__negotiation_template::set_param(Module_Param& param) |
2532 | { | |
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(); | |
2537 | } | |
2538 | switch (mp->get_type()) { | |
2539 | case Module_Param::MP_Omit: | |
2540 | *this = OMIT_VALUE; | |
2541 | break; | |
2542 | case Module_Param::MP_Any: | |
2543 | *this = ANY_VALUE; | |
2544 | break; | |
2545 | case Module_Param::MP_AnyOrNone: | |
2546 | *this = ANY_OR_OMIT; | |
2547 | break; | |
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)); | |
2555 | } | |
2556 | *this = temp; | |
2557 | break; } | |
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()); | |
2562 | } | |
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)); | |
2565 | break; | |
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; | |
2574 | } | |
2575 | } | |
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; | |
2581 | } | |
2582 | } | |
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()); | |
2585 | break; | |
2586 | } | |
2587 | } break; | |
2588 | default: | |
2589 | param.type_error("record template", "CHARACTER STRING.identification.context-negotiation"); | |
2590 | } | |
2591 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
2592 | } | |
2593 | ||
2594 | Module_Param* CHARACTER_STRING_identification_context__negotiation_template::get_param(Module_Param_Name& param_name) const | |
2595 | { | |
2596 | Module_Param* mp = NULL; | |
2597 | switch (template_selection) { | |
2598 | case UNINITIALIZED_TEMPLATE: | |
2599 | mp = new Module_Param_Unbound(); | |
2600 | break; | |
2601 | case OMIT_VALUE: | |
2602 | mp = new Module_Param_Omit(); | |
2603 | break; | |
2604 | case ANY_VALUE: | |
2605 | mp = new Module_Param_Any(); | |
2606 | break; | |
2607 | case ANY_OR_OMIT: | |
2608 | mp = new Module_Param_AnyOrNone(); | |
2609 | break; | |
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); | |
2618 | break; } | |
2619 | case VALUE_LIST: | |
2620 | case COMPLEMENTED_LIST: { | |
2621 | if (template_selection == VALUE_LIST) { | |
2622 | mp = new Module_Param_List_Template(); | |
2623 | } | |
2624 | else { | |
2625 | mp = new Module_Param_ComplementList_Template(); | |
2626 | } | |
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)); | |
2629 | } | |
2630 | break; } | |
2631 | default: | |
2632 | break; | |
2633 | } | |
2634 | if (is_ifpresent) { | |
2635 | mp->set_ifpresent(); | |
2636 | } | |
2637 | return mp; | |
2638 | } | |
2639 | ||
970ed795 EL |
2640 | void CHARACTER_STRING_identification_context__negotiation_template::clean_up() |
2641 | { | |
2642 | switch (template_selection) { | |
2643 | case SPECIFIC_VALUE: | |
2644 | delete single_value; | |
2645 | break; | |
2646 | case VALUE_LIST: | |
2647 | case COMPLEMENTED_LIST: | |
2648 | delete [] value_list.list_value; | |
2649 | break; | |
2650 | default: | |
2651 | break; | |
2652 | } | |
2653 | template_selection = UNINITIALIZED_TEMPLATE; | |
2654 | } | |
2655 | ||
2656 | void CHARACTER_STRING_identification_context__negotiation_template::set_specific() | |
2657 | { | |
2658 | if (template_selection != SPECIFIC_VALUE) { | |
2659 | template_sel old_selection = template_selection; | |
2660 | clean_up(); | |
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; | |
2666 | } | |
2667 | } | |
2668 | } | |
2669 | ||
2670 | void CHARACTER_STRING_identification_context__negotiation_template::copy_value(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2671 | { | |
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); | |
2676 | } | |
2677 | ||
2678 | void CHARACTER_STRING_identification_context__negotiation_template::copy_template(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2679 | { | |
2680 | switch (other_value.template_selection) { | |
2681 | case SPECIFIC_VALUE: | |
2682 | single_value = new single_value_struct(*other_value.single_value); | |
2683 | break; | |
2684 | case OMIT_VALUE: | |
2685 | case ANY_VALUE: | |
2686 | case ANY_OR_OMIT: | |
2687 | break; | |
2688 | case VALUE_LIST: | |
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]); | |
2694 | break; | |
2695 | default: | |
2696 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2697 | } | |
2698 | set_selection(other_value); | |
2699 | } | |
2700 | ||
2701 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template() | |
2702 | { | |
2703 | } | |
2704 | ||
2705 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(template_sel other_value) | |
2706 | : Base_Template(other_value) | |
2707 | { | |
2708 | check_single_selection(other_value); | |
2709 | } | |
2710 | ||
2711 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2712 | { | |
2713 | copy_value(other_value); | |
2714 | } | |
2715 | ||
2716 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const OPTIONAL<CHARACTER_STRING_identification_context__negotiation>& other_value) | |
2717 | { | |
2718 | switch (other_value.get_selection()) { | |
2719 | case OPTIONAL_PRESENT: | |
2720 | copy_value((const CHARACTER_STRING_identification_context__negotiation&)other_value); | |
2721 | break; | |
2722 | case OPTIONAL_OMIT: | |
2723 | set_selection(OMIT_VALUE); | |
2724 | break; | |
2725 | default: | |
2726 | TTCN_error("Creating a template of type CHARACTER STRING.identification.context-negotiation from an unbound optional field."); | |
2727 | } | |
2728 | } | |
2729 | ||
2730 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2731 | : Base_Template() | |
2732 | { | |
2733 | copy_template(other_value); | |
2734 | } | |
2735 | ||
2736 | CHARACTER_STRING_identification_context__negotiation_template::~CHARACTER_STRING_identification_context__negotiation_template() | |
2737 | { | |
2738 | clean_up(); | |
2739 | } | |
2740 | ||
2741 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(template_sel other_value) | |
2742 | { | |
2743 | check_single_selection(other_value); | |
2744 | clean_up(); | |
2745 | set_selection(other_value); | |
2746 | return *this; | |
2747 | } | |
2748 | ||
2749 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2750 | { | |
2751 | clean_up(); | |
2752 | copy_value(other_value); | |
2753 | return *this; | |
2754 | } | |
2755 | ||
2756 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const OPTIONAL<CHARACTER_STRING_identification_context__negotiation>& other_value) | |
2757 | { | |
2758 | clean_up(); | |
2759 | switch (other_value.get_selection()) { | |
2760 | case OPTIONAL_PRESENT: | |
2761 | copy_value((const CHARACTER_STRING_identification_context__negotiation&)other_value); | |
2762 | break; | |
2763 | case OPTIONAL_OMIT: | |
2764 | set_selection(OMIT_VALUE); | |
2765 | break; | |
2766 | default: | |
2767 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.context-negotiation."); | |
2768 | } | |
2769 | return *this; | |
2770 | } | |
2771 | ||
2772 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2773 | { | |
2774 | if (&other_value != this) { | |
2775 | clean_up(); | |
2776 | copy_template(other_value); | |
2777 | } | |
2778 | return *this; | |
2779 | } | |
2780 | ||
3abe9331 | 2781 | boolean CHARACTER_STRING_identification_context__negotiation_template::match(const CHARACTER_STRING_identification_context__negotiation& other_value, |
2782 | boolean /* legacy */) const | |
970ed795 EL |
2783 | { |
2784 | switch (template_selection) { | |
2785 | case ANY_VALUE: | |
2786 | case ANY_OR_OMIT: | |
2787 | return TRUE; | |
2788 | case OMIT_VALUE: | |
2789 | return FALSE; | |
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; | |
2795 | return TRUE; | |
2796 | case VALUE_LIST: | |
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; | |
2801 | default: | |
2802 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2803 | } | |
2804 | return FALSE; | |
2805 | } | |
2806 | ||
2807 | CHARACTER_STRING_identification_context__negotiation CHARACTER_STRING_identification_context__negotiation_template::valueof() const | |
2808 | { | |
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(); | |
2814 | return ret_val; | |
2815 | } | |
2816 | ||
2817 | void CHARACTER_STRING_identification_context__negotiation_template::set_type(template_sel template_type, unsigned int list_length) | |
2818 | { | |
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."); | |
2821 | clean_up(); | |
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]; | |
2825 | } | |
2826 | ||
2827 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::list_item(unsigned int list_index) const | |
2828 | { | |
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]; | |
2834 | } | |
2835 | ||
2836 | INTEGER_template& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() | |
2837 | { | |
2838 | set_specific(); | |
2839 | return single_value->field_presentation__context__id; | |
2840 | } | |
2841 | ||
2842 | const INTEGER_template& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() const | |
2843 | { | |
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; | |
2847 | } | |
2848 | ||
2849 | OBJID_template& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() | |
2850 | { | |
2851 | set_specific(); | |
2852 | return single_value->field_transfer__syntax; | |
2853 | } | |
2854 | ||
2855 | const OBJID_template& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() const | |
2856 | { | |
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; | |
2860 | } | |
2861 | ||
2862 | int CHARACTER_STRING_identification_context__negotiation_template::size_of() const | |
2863 | { | |
2864 | switch (template_selection) | |
2865 | { | |
2866 | case SPECIFIC_VALUE: | |
2867 | { | |
2868 | int ret_val = 2; | |
2869 | return ret_val; | |
2870 | } | |
2871 | case VALUE_LIST: | |
2872 | { | |
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++) | |
2877 | { | |
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."); | |
2880 | } | |
2881 | return item_size; | |
2882 | } | |
2883 | case OMIT_VALUE: | |
2884 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing omit value."); | |
2885 | case ANY_VALUE: | |
2886 | case ANY_OR_OMIT: | |
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."); | |
2890 | default: | |
2891 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2892 | } | |
2893 | return 0; | |
2894 | } | |
2895 | ||
2896 | void CHARACTER_STRING_identification_context__negotiation_template::log() const | |
2897 | { | |
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(" }"); | |
2905 | break; | |
2906 | case COMPLEMENTED_LIST: | |
2907 | TTCN_Logger::log_event_str("complement "); | |
2908 | // no break | |
2909 | case VALUE_LIST: | |
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(); | |
2914 | } | |
2915 | TTCN_Logger::log_char(')'); | |
2916 | break; | |
2917 | default: | |
2918 | log_generic(); | |
2919 | break; | |
2920 | } | |
2921 | log_ifpresent(); | |
2922 | } | |
2923 | ||
3abe9331 | 2924 | void CHARACTER_STRING_identification_context__negotiation_template::log_match(const CHARACTER_STRING_identification_context__negotiation& match_value, |
2925 | boolean /* legacy */) const | |
970ed795 EL |
2926 | { |
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(" }"); | |
2933 | } else { | |
2934 | match_value.log(); | |
2935 | TTCN_Logger::log_event_str(" with "); | |
2936 | log(); | |
2937 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2938 | else TTCN_Logger::log_event_str(" unmatched"); | |
2939 | } | |
2940 | } | |
2941 | ||
2942 | void CHARACTER_STRING_identification_context__negotiation_template::encode_text(Text_Buf& text_buf) const | |
2943 | { | |
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); | |
2949 | break; | |
2950 | case OMIT_VALUE: | |
2951 | case ANY_VALUE: | |
2952 | case ANY_OR_OMIT: | |
2953 | break; | |
2954 | case VALUE_LIST: | |
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); | |
2959 | break; | |
2960 | default: | |
2961 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2962 | } | |
2963 | } | |
2964 | ||
2965 | void CHARACTER_STRING_identification_context__negotiation_template::decode_text(Text_Buf& text_buf) | |
2966 | { | |
2967 | clean_up(); | |
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); | |
2974 | break; | |
2975 | case OMIT_VALUE: | |
2976 | case ANY_VALUE: | |
2977 | case ANY_OR_OMIT: | |
2978 | break; | |
2979 | case VALUE_LIST: | |
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); | |
2985 | break; | |
2986 | default: | |
2987 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.context-negotiation."); | |
2988 | } | |
2989 | } | |
2990 | ||
3abe9331 | 2991 | boolean CHARACTER_STRING_identification_context__negotiation_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
2992 | { |
2993 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 2994 | return !match_omit(legacy); |
970ed795 EL |
2995 | } |
2996 | ||
3abe9331 | 2997 | boolean CHARACTER_STRING_identification_context__negotiation_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
2998 | { |
2999 | if (is_ifpresent) return TRUE; | |
3000 | switch (template_selection) { | |
3001 | case OMIT_VALUE: | |
3002 | case ANY_OR_OMIT: | |
3003 | return TRUE; | |
3004 | case VALUE_LIST: | |
3005 | case COMPLEMENTED_LIST: | |
3abe9331 | 3006 | if (legacy) { |
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 | |
970ed795 EL |
3012 | default: |
3013 | return FALSE; | |
3014 | } | |
3015 | return FALSE; | |
3016 | } | |
3017 | ||
3018 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3019 | void CHARACTER_STRING_identification_context__negotiation_template::check_restriction(template_res t_res, const char* t_name, |
3020 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3021 | { |
3022 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3023 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3024 | case TR_VALUE: | |
3025 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3026 | break; | |
3027 | case TR_OMIT: | |
3028 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3029 | template_selection==SPECIFIC_VALUE)) return; | |
3030 | break; | |
3031 | case TR_PRESENT: | |
3abe9331 | 3032 | if (!match_omit(legacy)) return; |
970ed795 EL |
3033 | break; |
3034 | default: | |
3035 | return; | |
3036 | } | |
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"); | |
3039 | } | |
3040 | #endif | |
3041 | ||
3042 | CHARACTER_STRING::CHARACTER_STRING() | |
3043 | { | |
3044 | } | |
3045 | ||
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) | |
3052 | { | |
3053 | } | |
3054 | ||
3055 | boolean CHARACTER_STRING::operator==(const CHARACTER_STRING& other_value) const | |
3056 | { | |
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; | |
3060 | } | |
3061 | ||
3062 | int CHARACTER_STRING::size_of() const | |
3063 | { | |
3064 | int ret_val = 2; | |
3065 | if (field_data__value__descriptor.ispresent()) ret_val++; | |
3066 | return ret_val; | |
3067 | } | |
3068 | ||
3069 | boolean CHARACTER_STRING::is_bound() const | |
3070 | { | |
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; | |
3074 | return FALSE; | |
3075 | } | |
3076 | ||
3077 | boolean CHARACTER_STRING::is_value() const | |
3078 | { | |
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; | |
3082 | return TRUE; | |
3083 | } | |
3084 | ||
3085 | void CHARACTER_STRING::clean_up() | |
3086 | { | |
3087 | field_identification.clean_up(); | |
3088 | field_data__value__descriptor.clean_up(); | |
3089 | field_string__value.clean_up(); | |
3090 | } | |
3091 | ||
3092 | void CHARACTER_STRING::log() const | |
3093 | { | |
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(" }"); | |
3101 | } | |
3102 | ||
3103 | void CHARACTER_STRING::set_param(Module_Param& param) | |
3104 | { | |
3105 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 3106 | Module_Param_Ptr mp = ¶m; |
3107 | if (param.get_type() == Module_Param::MP_Reference) { | |
3108 | mp = param.get_referenced_param(); | |
3109 | } | |
3110 | switch (mp->get_type()) { | |
970ed795 | 3111 | case Module_Param::MP_Value_List: |
3abe9331 | 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()); | |
970ed795 | 3115 | } |
3abe9331 | 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)); | |
970ed795 EL |
3119 | break; |
3120 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 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); | |
970ed795 EL |
3125 | if (!strcmp(curr_param->get_id()->get_name(), "identification")) { |
3126 | identification().set_param(*curr_param); | |
3127 | value_used[val_idx]=true; | |
3128 | } | |
3129 | } | |
3abe9331 | 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); | |
970ed795 EL |
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; | |
3135 | } | |
3136 | } | |
3abe9331 | 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); | |
970ed795 EL |
3139 | if (!strcmp(curr_param->get_id()->get_name(), "string_value")) { |
3140 | string__value().set_param(*curr_param); | |
3141 | value_used[val_idx]=true; | |
3142 | } | |
3143 | } | |
3abe9331 | 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()); | |
970ed795 EL |
3146 | break; |
3147 | } | |
3148 | } break; | |
3149 | default: | |
3150 | param.type_error("record value", "CHARACTER STRING"); | |
3151 | } | |
3152 | } | |
3153 | ||
3abe9331 | 3154 | Module_Param* CHARACTER_STRING::get_param(Module_Param_Name& param_name) const |
970ed795 | 3155 | { |
3abe9331 | 3156 | if (!is_bound()) { |
3157 | return new Module_Param_Unbound(); | |
970ed795 | 3158 | } |
3abe9331 | 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); | |
3169 | return mp; | |
970ed795 EL |
3170 | } |
3171 | ||
3172 | void CHARACTER_STRING::encode_text(Text_Buf& text_buf) const | |
3173 | { | |
3174 | field_identification.encode_text(text_buf); | |
3175 | field_data__value__descriptor.encode_text(text_buf); | |
3176 | field_string__value.encode_text(text_buf); | |
3177 | } | |
3178 | ||
3179 | void CHARACTER_STRING::decode_text(Text_Buf& text_buf) | |
3180 | { | |
3181 | field_identification.decode_text(text_buf); | |
3182 | field_data__value__descriptor.decode_text(text_buf); | |
3183 | field_string__value.decode_text(text_buf); | |
3184 | } | |
3185 | ||
3186 | void CHARACTER_STRING::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
3187 | { | |
3188 | va_list pvar; | |
3189 | va_start(pvar, p_coding); | |
3190 | switch(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); | |
3198 | break;} | |
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); | |
3203 | break;} | |
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); | |
3208 | break;} | |
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); | |
af710487 | 3212 | XER_encode(*p_td.xer,p_buf, XER_coding, 0, 0); |
970ed795 EL |
3213 | p_buf.put_c('\n'); |
3214 | break;} | |
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); | |
3219 | break;} | |
3220 | default: | |
3221 | TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name); | |
3222 | } | |
3223 | va_end(pvar); | |
3224 | } | |
3225 | ||
3226 | void CHARACTER_STRING::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
3227 | { | |
3228 | va_list pvar; | |
3229 | va_start(pvar, p_coding); | |
3230 | switch(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); | |
3234 | ASN_BER_TLV_t tlv; | |
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()); | |
3238 | break;} | |
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); | |
3243 | break;} | |
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); | |
3248 | break;} | |
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) | |
3257 | break; | |
3258 | } | |
feade998 | 3259 | XER_decode(*p_td.xer, reader, XER_coding, XER_NONE, 0); |
970ed795 EL |
3260 | size_t bytes = reader.ByteConsumed(); |
3261 | p_buf.set_pos(bytes); | |
3262 | break;} | |
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); | |
3267 | break;} | |
3268 | default: | |
3269 | TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name); | |
3270 | } | |
3271 | va_end(pvar); | |
3272 | } | |
3273 | ||
3274 | ASN_BER_TLV_t* CHARACTER_STRING::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
3275 | { | |
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); | |
3287 | return new_tlv; | |
3288 | } | |
3289 | ||
3290 | boolean CHARACTER_STRING::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
3291 | { | |
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); | |
3297 | size_t V_pos=0; | |
3298 | ASN_BER_TLV_t tmp_tlv; | |
3299 | boolean tlv_present=FALSE; | |
3300 | { | |
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); | |
3307 | tlv_present=FALSE; | |
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; | |
3311 | else { | |
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; | |
3314 | } | |
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); | |
3319 | tlv_present=FALSE; | |
3320 | } | |
3321 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
3322 | return TRUE; | |
3323 | } | |
3324 | ||
af710487 | 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 | |
970ed795 EL |
3327 | { |
3328 | if(!is_bound()) { | |
3329 | TTCN_EncDec_ErrorContext::error | |
3330 | (TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); | |
3331 | } | |
3332 | int encoded_length=(int)p_buf.get_len(); | |
3333 | ||
3334 | flavor &= ~XER_RECOF; // ASN.1 character string doesn't care | |
3335 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
3336 | ||
af710487 | 3337 | field_identification.XER_encode(CHARACTER_STRING_identification_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
3338 | // data-value-descriptor is OPTIONAL and can never be present. |
3339 | // Its encoding is empty. | |
af710487 | 3340 | field_string__value .XER_encode(CHARACTER_STRING_data_value_xer_ , p_buf, flavor, indent, 0); |
970ed795 EL |
3341 | |
3342 | end_xml(p_td, p_buf, flavor, --indent, false); | |
3343 | ||
3344 | return (int)p_buf.get_len() - encoded_length; | |
3345 | } | |
3346 | ||
3347 | int CHARACTER_STRING::XER_decode(const XERdescriptor_t& p_td, | |
feade998 | 3348 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
3349 | { |
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(); | |
3357 | reader.Read(); | |
3358 | break; | |
3359 | } | |
3360 | } | |
feade998 | 3361 | field_identification .XER_decode(CHARACTER_STRING_identification_xer_ , reader, flavor, flavor2, 0); |
3362 | field_data__value__descriptor.XER_decode(CHARACTER_STRING_data_value_descriptor_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
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"); | |
3366 | } | |
feade998 | 3367 | field_string__value .XER_decode(CHARACTER_STRING_data_value_xer_ , reader, flavor, flavor2, 0); |
970ed795 EL |
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); | |
3372 | reader.Read(); | |
3373 | break; | |
3374 | } | |
3375 | } | |
3376 | return 1; | |
3377 | ||
3378 | } | |
3379 | ||
3380 | ||
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; | |
3385 | }; | |
3386 | ||
3abe9331 | 3387 | void CHARACTER_STRING_template::set_param(Module_Param& param) |
3388 | { | |
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(); | |
3393 | } | |
3394 | switch (mp->get_type()) { | |
3395 | case Module_Param::MP_Omit: | |
3396 | *this = OMIT_VALUE; | |
3397 | break; | |
3398 | case Module_Param::MP_Any: | |
3399 | *this = ANY_VALUE; | |
3400 | break; | |
3401 | case Module_Param::MP_AnyOrNone: | |
3402 | *this = ANY_OR_OMIT; | |
3403 | break; | |
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)); | |
3411 | } | |
3412 | *this = temp; | |
3413 | break; } | |
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()); | |
3418 | } | |
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)); | |
3422 | break; | |
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; | |
3431 | } | |
3432 | } | |
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; | |
3438 | } | |
3439 | } | |
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; | |
3445 | } | |
3446 | } | |
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()); | |
3449 | break; | |
3450 | } | |
3451 | } break; | |
3452 | default: | |
3453 | param.type_error("record template", "CHARACTER STRING"); | |
3454 | } | |
3455 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
3456 | } | |
3457 | ||
3458 | Module_Param* CHARACTER_STRING_template::get_param(Module_Param_Name& param_name) const | |
3459 | { | |
3460 | Module_Param* mp = NULL; | |
3461 | switch (template_selection) { | |
3462 | case UNINITIALIZED_TEMPLATE: | |
3463 | mp = new Module_Param_Unbound(); | |
3464 | break; | |
3465 | case OMIT_VALUE: | |
3466 | mp = new Module_Param_Omit(); | |
3467 | break; | |
3468 | case ANY_VALUE: | |
3469 | mp = new Module_Param_Any(); | |
3470 | break; | |
3471 | case ANY_OR_OMIT: | |
3472 | mp = new Module_Param_AnyOrNone(); | |
3473 | break; | |
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); | |
3485 | break; } | |
3486 | case VALUE_LIST: | |
3487 | case COMPLEMENTED_LIST: { | |
3488 | if (template_selection == VALUE_LIST) { | |
3489 | mp = new Module_Param_List_Template(); | |
3490 | } | |
3491 | else { | |
3492 | mp = new Module_Param_ComplementList_Template(); | |
3493 | } | |
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)); | |
3496 | } | |
3497 | break; } | |
3498 | default: | |
3499 | break; | |
3500 | } | |
3501 | if (is_ifpresent) { | |
3502 | mp->set_ifpresent(); | |
3503 | } | |
3504 | return mp; | |
3505 | } | |
3506 | ||
970ed795 EL |
3507 | void CHARACTER_STRING_template::clean_up() |
3508 | { | |
3509 | switch (template_selection) { | |
3510 | case SPECIFIC_VALUE: | |
3511 | delete single_value; | |
3512 | break; | |
3513 | case VALUE_LIST: | |
3514 | case COMPLEMENTED_LIST: | |
3515 | delete [] value_list.list_value; | |
3516 | break; | |
3517 | default: | |
3518 | break; | |
3519 | } | |
3520 | template_selection = UNINITIALIZED_TEMPLATE; | |
3521 | } | |
3522 | ||
3523 | void CHARACTER_STRING_template::set_specific() | |
3524 | { | |
3525 | if (template_selection != SPECIFIC_VALUE) { | |
3526 | template_sel old_selection = template_selection; | |
3527 | clean_up(); | |
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; | |
3534 | } | |
3535 | } | |
3536 | } | |
3537 | ||
3538 | void CHARACTER_STRING_template::copy_value(const CHARACTER_STRING& other_value) | |
3539 | { | |
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); | |
3546 | } | |
3547 | ||
3548 | void CHARACTER_STRING_template::copy_template(const CHARACTER_STRING_template& other_value) | |
3549 | { | |
3550 | switch (other_value.template_selection) { | |
3551 | case SPECIFIC_VALUE: | |
3552 | single_value = new single_value_struct(*other_value.single_value); | |
3553 | break; | |
3554 | case OMIT_VALUE: | |
3555 | case ANY_VALUE: | |
3556 | case ANY_OR_OMIT: | |
3557 | break; | |
3558 | case VALUE_LIST: | |
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]); | |
3564 | break; | |
3565 | default: | |
3566 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING."); | |
3567 | } | |
3568 | set_selection(other_value); | |
3569 | } | |
3570 | ||
3571 | CHARACTER_STRING_template::CHARACTER_STRING_template() | |
3572 | { | |
3573 | } | |
3574 | ||
3575 | CHARACTER_STRING_template::CHARACTER_STRING_template(template_sel other_value) | |
3576 | : Base_Template(other_value) | |
3577 | { | |
3578 | check_single_selection(other_value); | |
3579 | } | |
3580 | ||
3581 | CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING& other_value) | |
3582 | { | |
3583 | copy_value(other_value); | |
3584 | } | |
3585 | ||
3586 | CHARACTER_STRING_template::CHARACTER_STRING_template(const OPTIONAL<CHARACTER_STRING>& other_value) | |
3587 | { | |
3588 | switch (other_value.get_selection()) { | |
3589 | case OPTIONAL_PRESENT: | |
3590 | copy_value((const CHARACTER_STRING&)other_value); | |
3591 | break; | |
3592 | case OPTIONAL_OMIT: | |
3593 | set_selection(OMIT_VALUE); | |
3594 | break; | |
3595 | default: | |
3596 | TTCN_error("Creating a template of type CHARACTER STRING from an unbound optional field."); | |
3597 | } | |
3598 | } | |
3599 | ||
3600 | CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING_template& other_value) | |
3601 | : Base_Template() | |
3602 | { | |
3603 | copy_template(other_value); | |
3604 | } | |
3605 | ||
3606 | CHARACTER_STRING_template::~CHARACTER_STRING_template() | |
3607 | { | |
3608 | clean_up(); | |
3609 | } | |
3610 | ||
3611 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(template_sel other_value) | |
3612 | { | |
3613 | check_single_selection(other_value); | |
3614 | clean_up(); | |
3615 | set_selection(other_value); | |
3616 | return *this; | |
3617 | } | |
3618 | ||
3619 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const CHARACTER_STRING& other_value) | |
3620 | { | |
3621 | clean_up(); | |
3622 | copy_value(other_value); | |
3623 | return *this; | |
3624 | } | |
3625 | ||
3626 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const OPTIONAL<CHARACTER_STRING>& other_value) | |
3627 | { | |
3628 | clean_up(); | |
3629 | switch (other_value.get_selection()) { | |
3630 | case OPTIONAL_PRESENT: | |
3631 | copy_value((const CHARACTER_STRING&)other_value); | |
3632 | break; | |
3633 | case OPTIONAL_OMIT: | |
3634 | set_selection(OMIT_VALUE); | |
3635 | break; | |
3636 | default: | |
3637 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING."); | |
3638 | } | |
3639 | return *this; | |
3640 | } | |
3641 | ||
3642 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const CHARACTER_STRING_template& other_value) | |
3643 | { | |
3644 | if (&other_value != this) { | |
3645 | clean_up(); | |
3646 | copy_template(other_value); | |
3647 | } | |
3648 | return *this; | |
3649 | } | |
3650 | ||
3abe9331 | 3651 | boolean CHARACTER_STRING_template::match(const CHARACTER_STRING& other_value, |
3652 | boolean /* legacy */) const | |
970ed795 EL |
3653 | { |
3654 | switch (template_selection) { | |
3655 | case ANY_VALUE: | |
3656 | case ANY_OR_OMIT: | |
3657 | return TRUE; | |
3658 | case OMIT_VALUE: | |
3659 | return FALSE; | |
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; | |
3667 | return TRUE; | |
3668 | case VALUE_LIST: | |
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; | |
3673 | default: | |
3674 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING."); | |
3675 | } | |
3676 | return FALSE; | |
3677 | } | |
3678 | ||
3679 | CHARACTER_STRING CHARACTER_STRING_template::valueof() const | |
3680 | { | |
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(); | |
3688 | return ret_val; | |
3689 | } | |
3690 | ||
3691 | void CHARACTER_STRING_template::set_type(template_sel template_type, unsigned int list_length) | |
3692 | { | |
3693 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
3694 | TTCN_error("Setting an invalid list for a template of type CHARACTER STRING."); | |
3695 | clean_up(); | |
3696 | set_selection(template_type); | |
3697 | value_list.n_values = list_length; | |
3698 | value_list.list_value = new CHARACTER_STRING_template[list_length]; | |
3699 | } | |
3700 | ||
3701 | CHARACTER_STRING_template& CHARACTER_STRING_template::list_item(unsigned int list_index) const | |
3702 | { | |
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]; | |
3708 | } | |
3709 | ||
3710 | CHARACTER_STRING_identification_template& CHARACTER_STRING_template::identification() | |
3711 | { | |
3712 | set_specific(); | |
3713 | return single_value->field_identification; | |
3714 | } | |
3715 | ||
3716 | const CHARACTER_STRING_identification_template& CHARACTER_STRING_template::identification() const | |
3717 | { | |
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; | |
3721 | } | |
3722 | ||
3723 | UNIVERSAL_CHARSTRING_template& CHARACTER_STRING_template::data__value__descriptor() | |
3724 | { | |
3725 | set_specific(); | |
3726 | return single_value->field_data__value__descriptor; | |
3727 | } | |
3728 | ||
3729 | const UNIVERSAL_CHARSTRING_template& CHARACTER_STRING_template::data__value__descriptor() const | |
3730 | { | |
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; | |
3734 | } | |
3735 | ||
3736 | OCTETSTRING_template& CHARACTER_STRING_template::string__value() | |
3737 | { | |
3738 | set_specific(); | |
3739 | return single_value->field_string__value; | |
3740 | } | |
3741 | ||
3742 | const OCTETSTRING_template& CHARACTER_STRING_template::string__value() const | |
3743 | { | |
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; | |
3747 | } | |
3748 | ||
3749 | int CHARACTER_STRING_template::size_of() const | |
3750 | { | |
3751 | switch (template_selection) | |
3752 | { | |
3753 | case SPECIFIC_VALUE: | |
3754 | { | |
3755 | int ret_val = 2; | |
3756 | if (single_value->field_data__value__descriptor.is_present()) ret_val++; | |
3757 | return ret_val; | |
3758 | } | |
3759 | case VALUE_LIST: | |
3760 | { | |
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++) | |
3765 | { | |
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."); | |
3768 | } | |
3769 | return item_size; | |
3770 | } | |
3771 | case OMIT_VALUE: | |
3772 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing omit value."); | |
3773 | case ANY_VALUE: | |
3774 | case ANY_OR_OMIT: | |
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."); | |
3778 | default: | |
3779 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING."); | |
3780 | } | |
3781 | return 0; | |
3782 | } | |
3783 | ||
3784 | void CHARACTER_STRING_template::log() const | |
3785 | { | |
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(" }"); | |
3795 | break; | |
3796 | case COMPLEMENTED_LIST: | |
3797 | TTCN_Logger::log_event_str("complement "); | |
3798 | // no break | |
3799 | case VALUE_LIST: | |
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(); | |
3804 | } | |
3805 | TTCN_Logger::log_char(')'); | |
3806 | break; | |
3807 | default: | |
3808 | log_generic(); | |
3809 | break; | |
3810 | } | |
3811 | log_ifpresent(); | |
3812 | } | |
3813 | ||
3abe9331 | 3814 | void CHARACTER_STRING_template::log_match(const CHARACTER_STRING& match_value, |
3815 | boolean /* legacy */) const | |
970ed795 EL |
3816 | { |
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()); | |
3822 | else { | |
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"); | |
3826 | } | |
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(" }"); | |
3830 | } else { | |
3831 | match_value.log(); | |
3832 | TTCN_Logger::log_event_str(" with "); | |
3833 | log(); | |
3834 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
3835 | else TTCN_Logger::log_event_str(" unmatched"); | |
3836 | } | |
3837 | } | |
3838 | ||
3839 | void CHARACTER_STRING_template::encode_text(Text_Buf& text_buf) const | |
3840 | { | |
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); | |
3847 | break; | |
3848 | case OMIT_VALUE: | |
3849 | case ANY_VALUE: | |
3850 | case ANY_OR_OMIT: | |
3851 | break; | |
3852 | case VALUE_LIST: | |
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); | |
3857 | break; | |
3858 | default: | |
3859 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING."); | |
3860 | } | |
3861 | } | |
3862 | ||
3863 | void CHARACTER_STRING_template::decode_text(Text_Buf& text_buf) | |
3864 | { | |
3865 | clean_up(); | |
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); | |
3873 | break; | |
3874 | case OMIT_VALUE: | |
3875 | case ANY_VALUE: | |
3876 | case ANY_OR_OMIT: | |
3877 | break; | |
3878 | case VALUE_LIST: | |
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); | |
3884 | break; | |
3885 | default: | |
3886 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING."); | |
3887 | } | |
3888 | } | |
3889 | ||
3abe9331 | 3890 | boolean CHARACTER_STRING_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
3891 | { |
3892 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 3893 | return !match_omit(legacy); |
970ed795 EL |
3894 | } |
3895 | ||
3abe9331 | 3896 | boolean CHARACTER_STRING_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
3897 | { |
3898 | if (is_ifpresent) return TRUE; | |
3899 | switch (template_selection) { | |
3900 | case OMIT_VALUE: | |
3901 | case ANY_OR_OMIT: | |
3902 | return TRUE; | |
3903 | case VALUE_LIST: | |
3904 | case COMPLEMENTED_LIST: | |
3abe9331 | 3905 | if (legacy) { |
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; | |
3911 | } | |
3912 | // else fall through | |
970ed795 EL |
3913 | default: |
3914 | return FALSE; | |
3915 | } | |
3916 | return FALSE; | |
3917 | } | |
3918 | ||
3919 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3920 | void CHARACTER_STRING_template::check_restriction(template_res t_res, const char* t_name, |
3921 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3922 | { |
3923 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3924 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3925 | case TR_VALUE: | |
3926 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3927 | break; | |
3928 | case TR_OMIT: | |
3929 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3930 | template_selection==SPECIFIC_VALUE)) return; | |
3931 | break; | |
3932 | case TR_PRESENT: | |
3abe9331 | 3933 | if (!match_omit(legacy)) return; |
970ed795 EL |
3934 | break; |
3935 | default: | |
3936 | return; | |
3937 | } | |
3938 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
3939 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING"); | |
3940 | } | |
3941 | #endif |