Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Baranyi, Botond | |
11 | * Beres, Szabolcs | |
12 | * Delic, Adam | |
13 | * Forstner, Matyas | |
14 | * Kovacs, Ferenc | |
15 | * Raduly, Csaba | |
16 | * Szabados, Kristof | |
17 | * Szabo, Bence Janos | |
18 | * Szabo, Janos Zoltan – initial implementation | |
19 | * Szalai, Gabor | |
20 | * | |
21 | ******************************************************************************/ | |
970ed795 EL |
22 | #include <string.h> |
23 | ||
24 | #include "Error.hh" | |
25 | #include "Logger.hh" | |
26 | #include "Encdec.hh" | |
27 | #include "BER.hh" | |
28 | #include "Param_Types.hh" | |
29 | ||
30 | #include "ASN_CharacterString.hh" | |
31 | ||
32 | #include "../common/dbgnew.hh" | |
33 | ||
34 | /* | |
35 | ||
36 | to do when regenerating: | |
37 | ||
38 | in .hh file: | |
39 | ||
40 | add __SUNPRO_CC ifdefs for single_value_struct | |
41 | ||
42 | in .cc file: | |
43 | ||
44 | replace '@CHARACTER STRING' with 'CHARACTER STRING' | |
45 | ||
46 | remove RAW and TEXT enc/dec functions | |
47 | ||
48 | make the type descriptors of embedded types static | |
49 | ||
50 | */ | |
51 | ||
52 | static const ASN_Tag_t CHARACTER_STRING_identification_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
53 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_ber_ = { 1u, CHARACTER_STRING_identification_tag_ }; | |
a38c6d4c | 54 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_descr_ = { "CHARACTER STRING.identification", &CHARACTER_STRING_identification_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
55 | |
56 | static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_abstract_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
57 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_ber_ = { 1u, CHARACTER_STRING_identification_syntaxes_abstract_tag_ }; | |
a38c6d4c | 58 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_abstract_descr_ = { "CHARACTER STRING.identification.syntaxes.abstract", &CHARACTER_STRING_identification_syntaxes_abstract_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
59 | |
60 | static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_transfer_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
61 | const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_ber_ = { 1u, CHARACTER_STRING_identification_syntaxes_transfer_tag_ }; | |
a38c6d4c | 62 | const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_transfer_descr_ = { "CHARACTER STRING.identification.syntaxes.transfer", &CHARACTER_STRING_identification_syntaxes_transfer_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
63 | |
64 | static const ASN_Tag_t CHARACTER_STRING_identification_syntaxes_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
65 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntaxes_ber_ = { 1u, CHARACTER_STRING_identification_syntaxes_tag_ }; | |
a38c6d4c | 66 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntaxes_descr_ = { "CHARACTER STRING.identification.syntaxes", &CHARACTER_STRING_identification_syntaxes_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
67 | |
68 | static const ASN_Tag_t CHARACTER_STRING_identification_syntax_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
69 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_syntax_ber_ = { 1u, CHARACTER_STRING_identification_syntax_tag_ }; | |
a38c6d4c | 70 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_syntax_descr_ = { "CHARACTER STRING.identification.syntax", &CHARACTER_STRING_identification_syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
71 | |
72 | static const ASN_Tag_t CHARACTER_STRING_identification_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 2u }}; | |
73 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_presentation__context__id_ber_ = { 1u, CHARACTER_STRING_identification_presentation__context__id_tag_ }; | |
a38c6d4c | 74 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_presentation__context__id_descr_ = { "CHARACTER STRING.identification.presentation-context-id", &CHARACTER_STRING_identification_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
75 | |
76 | static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_[] = { { ASN_TAG_CONT, 0u }}; | |
77 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_ = { 1u, CHARACTER_STRING_identification_context__negotiation_presentation__context__id_tag_ }; | |
a38c6d4c | 78 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_ = { "CHARACTER STRING.identification.context-negotiation.presentation-context-id", &CHARACTER_STRING_identification_context__negotiation_presentation__context__id_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
79 | |
80 | static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
81 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_ = { 1u, CHARACTER_STRING_identification_context__negotiation_transfer__syntax_tag_ }; | |
a38c6d4c | 82 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_ = { "CHARACTER STRING.identification.context-negotiation.transfer-syntax", &CHARACTER_STRING_identification_context__negotiation_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
83 | |
84 | static const ASN_Tag_t CHARACTER_STRING_identification_context__negotiation_tag_[] = { { ASN_TAG_CONT, 3u }}; | |
85 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_context__negotiation_ber_ = { 1u, CHARACTER_STRING_identification_context__negotiation_tag_ }; | |
a38c6d4c | 86 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_context__negotiation_descr_ = { "CHARACTER STRING.identification.context-negotiation", &CHARACTER_STRING_identification_context__negotiation_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
87 | |
88 | static const ASN_Tag_t CHARACTER_STRING_identification_transfer__syntax_tag_[] = { { ASN_TAG_CONT, 4u }}; | |
89 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_transfer__syntax_ber_ = { 1u, CHARACTER_STRING_identification_transfer__syntax_tag_ }; | |
a38c6d4c | 90 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_transfer__syntax_descr_ = { "CHARACTER STRING.identification.transfer-syntax", &CHARACTER_STRING_identification_transfer__syntax_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::OBJID }; |
970ed795 EL |
91 | |
92 | static const ASN_Tag_t CHARACTER_STRING_identification_fixed_tag_[] = { { ASN_TAG_CONT, 5u }}; | |
93 | static const ASN_BERdescriptor_t CHARACTER_STRING_identification_fixed_ber_ = { 1u, CHARACTER_STRING_identification_fixed_tag_ }; | |
a38c6d4c | 94 | static const TTCN_Typedescriptor_t CHARACTER_STRING_identification_fixed_descr_ = { "CHARACTER STRING.identification.fixed", &CHARACTER_STRING_identification_fixed_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
95 | |
96 | static const ASN_Tag_t CHARACTER_STRING_string__value_tag_[] = { { ASN_TAG_CONT, 2u }}; | |
97 | static const ASN_BERdescriptor_t CHARACTER_STRING_string__value_ber_ = { 1u, CHARACTER_STRING_string__value_tag_ }; | |
a38c6d4c | 98 | static const TTCN_Typedescriptor_t CHARACTER_STRING_string__value_descr_ = { "CHARACTER STRING.string-value", &CHARACTER_STRING_string__value_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
970ed795 EL |
99 | |
100 | static const ASN_Tag_t CHARACTER_STRING_data__value__descriptor_tag_[] = { { ASN_TAG_CONT, 1u }}; | |
101 | static const ASN_BERdescriptor_t CHARACTER_STRING_data__value__descriptor_ber_ = { 1u, CHARACTER_STRING_data__value__descriptor_tag_ }; | |
a38c6d4c | 102 | static const TTCN_Typedescriptor_t CHARACTER_STRING_data__value__descriptor_descr_ = { "CHARACTER STRING.data-value-descriptor", &CHARACTER_STRING_data__value__descriptor_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::GRAPHICSTRING }; |
970ed795 EL |
103 | |
104 | void CHARACTER_STRING_identification::clean_up() | |
105 | { | |
106 | switch (union_selection) { | |
107 | case ALT_syntaxes: | |
108 | delete field_syntaxes; | |
109 | break; | |
110 | case ALT_syntax: | |
111 | delete field_syntax; | |
112 | break; | |
113 | case ALT_presentation__context__id: | |
114 | delete field_presentation__context__id; | |
115 | break; | |
116 | case ALT_context__negotiation: | |
117 | delete field_context__negotiation; | |
118 | break; | |
119 | case ALT_transfer__syntax: | |
120 | delete field_transfer__syntax; | |
121 | break; | |
122 | case ALT_fixed: | |
123 | delete field_fixed; | |
124 | break; | |
125 | default: | |
126 | break; | |
127 | } | |
128 | union_selection = UNBOUND_VALUE; | |
129 | } | |
130 | ||
131 | void CHARACTER_STRING_identification::copy_value(const CHARACTER_STRING_identification& other_value) | |
132 | { | |
133 | switch (other_value.union_selection) { | |
134 | case ALT_syntaxes: | |
135 | field_syntaxes = new CHARACTER_STRING_identification_syntaxes(*other_value.field_syntaxes); | |
136 | break; | |
137 | case ALT_syntax: | |
138 | field_syntax = new OBJID(*other_value.field_syntax); | |
139 | break; | |
140 | case ALT_presentation__context__id: | |
141 | field_presentation__context__id = new INTEGER(*other_value.field_presentation__context__id); | |
142 | break; | |
143 | case ALT_context__negotiation: | |
144 | field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation(*other_value.field_context__negotiation); | |
145 | break; | |
146 | case ALT_transfer__syntax: | |
147 | field_transfer__syntax = new OBJID(*other_value.field_transfer__syntax); | |
148 | break; | |
149 | case ALT_fixed: | |
150 | field_fixed = new ASN_NULL(*other_value.field_fixed); | |
151 | break; | |
152 | default: | |
153 | TTCN_error("Assignment of an unbound union value of type CHARACTER STRING.identification."); | |
154 | } | |
155 | union_selection = other_value.union_selection; | |
156 | } | |
157 | ||
158 | CHARACTER_STRING_identification::CHARACTER_STRING_identification() | |
159 | { | |
160 | union_selection = UNBOUND_VALUE; | |
161 | } | |
162 | ||
163 | CHARACTER_STRING_identification::CHARACTER_STRING_identification(const CHARACTER_STRING_identification& other_value) | |
164 | : Base_Type(other_value) | |
165 | { | |
166 | copy_value(other_value); | |
167 | } | |
168 | ||
169 | CHARACTER_STRING_identification::~CHARACTER_STRING_identification() | |
170 | { | |
171 | clean_up(); | |
172 | } | |
173 | ||
174 | CHARACTER_STRING_identification& CHARACTER_STRING_identification::operator=(const CHARACTER_STRING_identification& other_value) | |
175 | { | |
176 | if (this != &other_value) { | |
177 | clean_up(); | |
178 | copy_value(other_value); | |
179 | } | |
180 | return *this; | |
181 | } | |
182 | ||
183 | boolean CHARACTER_STRING_identification::operator==(const CHARACTER_STRING_identification& other_value) const | |
184 | { | |
185 | if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type CHARACTER STRING.identification."); | |
186 | if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type CHARACTER STRING.identification."); | |
187 | if (union_selection != other_value.union_selection) return FALSE; | |
188 | switch (union_selection) { | |
189 | case ALT_syntaxes: | |
190 | return *field_syntaxes == *other_value.field_syntaxes; | |
191 | case ALT_syntax: | |
192 | return *field_syntax == *other_value.field_syntax; | |
193 | case ALT_presentation__context__id: | |
194 | return *field_presentation__context__id == *other_value.field_presentation__context__id; | |
195 | case ALT_context__negotiation: | |
196 | return *field_context__negotiation == *other_value.field_context__negotiation; | |
197 | case ALT_transfer__syntax: | |
198 | return *field_transfer__syntax == *other_value.field_transfer__syntax; | |
199 | case ALT_fixed: | |
200 | return *field_fixed == *other_value.field_fixed; | |
201 | default: | |
202 | return FALSE; | |
203 | } | |
204 | } | |
205 | ||
206 | CHARACTER_STRING_identification_syntaxes& CHARACTER_STRING_identification::syntaxes() | |
207 | { | |
208 | if (union_selection != ALT_syntaxes) { | |
209 | clean_up(); | |
210 | field_syntaxes = new CHARACTER_STRING_identification_syntaxes; | |
211 | union_selection = ALT_syntaxes; | |
212 | } | |
213 | return *field_syntaxes; | |
214 | } | |
215 | ||
216 | const CHARACTER_STRING_identification_syntaxes& CHARACTER_STRING_identification::syntaxes() const | |
217 | { | |
218 | if (union_selection != ALT_syntaxes) TTCN_error("Using non-selected field syntaxes in a value of union type CHARACTER STRING.identification."); | |
219 | return *field_syntaxes; | |
220 | } | |
221 | ||
222 | OBJID& CHARACTER_STRING_identification::syntax() | |
223 | { | |
224 | if (union_selection != ALT_syntax) { | |
225 | clean_up(); | |
226 | field_syntax = new OBJID; | |
227 | union_selection = ALT_syntax; | |
228 | } | |
229 | return *field_syntax; | |
230 | } | |
231 | ||
232 | const OBJID& CHARACTER_STRING_identification::syntax() const | |
233 | { | |
234 | if (union_selection != ALT_syntax) TTCN_error("Using non-selected field syntax in a value of union type CHARACTER STRING.identification."); | |
235 | return *field_syntax; | |
236 | } | |
237 | ||
238 | INTEGER& CHARACTER_STRING_identification::presentation__context__id() | |
239 | { | |
240 | if (union_selection != ALT_presentation__context__id) { | |
241 | clean_up(); | |
242 | field_presentation__context__id = new INTEGER; | |
243 | union_selection = ALT_presentation__context__id; | |
244 | } | |
245 | return *field_presentation__context__id; | |
246 | } | |
247 | ||
248 | const INTEGER& CHARACTER_STRING_identification::presentation__context__id() const | |
249 | { | |
250 | if (union_selection != ALT_presentation__context__id) TTCN_error("Using non-selected field presentation_context_id in a value of union type CHARACTER STRING.identification."); | |
251 | return *field_presentation__context__id; | |
252 | } | |
253 | ||
254 | CHARACTER_STRING_identification_context__negotiation& CHARACTER_STRING_identification::context__negotiation() | |
255 | { | |
256 | if (union_selection != ALT_context__negotiation) { | |
257 | clean_up(); | |
258 | field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation; | |
259 | union_selection = ALT_context__negotiation; | |
260 | } | |
261 | return *field_context__negotiation; | |
262 | } | |
263 | ||
264 | const CHARACTER_STRING_identification_context__negotiation& CHARACTER_STRING_identification::context__negotiation() const | |
265 | { | |
266 | if (union_selection != ALT_context__negotiation) TTCN_error("Using non-selected field context_negotiation in a value of union type CHARACTER STRING.identification."); | |
267 | return *field_context__negotiation; | |
268 | } | |
269 | ||
270 | OBJID& CHARACTER_STRING_identification::transfer__syntax() | |
271 | { | |
272 | if (union_selection != ALT_transfer__syntax) { | |
273 | clean_up(); | |
274 | field_transfer__syntax = new OBJID; | |
275 | union_selection = ALT_transfer__syntax; | |
276 | } | |
277 | return *field_transfer__syntax; | |
278 | } | |
279 | ||
280 | const OBJID& CHARACTER_STRING_identification::transfer__syntax() const | |
281 | { | |
282 | if (union_selection != ALT_transfer__syntax) TTCN_error("Using non-selected field transfer_syntax in a value of union type CHARACTER STRING.identification."); | |
283 | return *field_transfer__syntax; | |
284 | } | |
285 | ||
286 | ASN_NULL& CHARACTER_STRING_identification::fixed() | |
287 | { | |
288 | if (union_selection != ALT_fixed) { | |
289 | clean_up(); | |
290 | field_fixed = new ASN_NULL; | |
291 | union_selection = ALT_fixed; | |
292 | } | |
293 | return *field_fixed; | |
294 | } | |
295 | ||
296 | const ASN_NULL& CHARACTER_STRING_identification::fixed() const | |
297 | { | |
298 | if (union_selection != ALT_fixed) TTCN_error("Using non-selected field fixed in a value of union type CHARACTER STRING.identification."); | |
299 | return *field_fixed; | |
300 | } | |
301 | ||
302 | boolean CHARACTER_STRING_identification::ischosen(union_selection_type checked_selection) const | |
303 | { | |
304 | if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification."); | |
305 | if (union_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an unbound value of union type CHARACTER STRING.identification."); | |
306 | return union_selection == checked_selection; | |
307 | } | |
308 | ||
309 | boolean CHARACTER_STRING_identification::is_bound() const | |
310 | { | |
311 | switch (union_selection) { | |
312 | case ALT_syntaxes: | |
313 | return field_syntaxes->is_bound(); | |
314 | case ALT_syntax: | |
315 | return field_syntax->is_bound(); | |
316 | case ALT_presentation__context__id: | |
317 | return field_presentation__context__id->is_bound(); | |
318 | case ALT_context__negotiation: | |
319 | return field_context__negotiation->is_bound(); | |
320 | case ALT_transfer__syntax: | |
321 | return field_transfer__syntax->is_bound(); | |
322 | case ALT_fixed: | |
323 | return field_fixed->is_bound(); | |
324 | default: | |
325 | return FALSE; | |
326 | } | |
327 | } | |
328 | ||
329 | boolean CHARACTER_STRING_identification::is_value() const | |
330 | { | |
331 | switch (union_selection) { | |
332 | case ALT_syntaxes: | |
333 | return field_syntaxes->is_value(); | |
334 | case ALT_syntax: | |
335 | return field_syntax->is_value(); | |
336 | case ALT_presentation__context__id: | |
337 | return field_presentation__context__id->is_value(); | |
338 | case ALT_context__negotiation: | |
339 | return field_context__negotiation->is_value(); | |
340 | case ALT_transfer__syntax: | |
341 | return field_transfer__syntax->is_value(); | |
342 | case ALT_fixed: | |
343 | return field_fixed->is_value(); | |
344 | default: | |
345 | return FALSE; | |
346 | } | |
347 | } | |
348 | ||
349 | void CHARACTER_STRING_identification::log() const | |
350 | { | |
351 | switch (union_selection) { | |
352 | case ALT_syntaxes: | |
353 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
354 | field_syntaxes->log(); | |
355 | TTCN_Logger::log_event_str(" }"); | |
356 | break; | |
357 | case ALT_syntax: | |
358 | TTCN_Logger::log_event_str("{ syntax := "); | |
359 | field_syntax->log(); | |
360 | TTCN_Logger::log_event_str(" }"); | |
361 | break; | |
362 | case ALT_presentation__context__id: | |
363 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
364 | field_presentation__context__id->log(); | |
365 | TTCN_Logger::log_event_str(" }"); | |
366 | break; | |
367 | case ALT_context__negotiation: | |
368 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
369 | field_context__negotiation->log(); | |
370 | TTCN_Logger::log_event_str(" }"); | |
371 | break; | |
372 | case ALT_transfer__syntax: | |
373 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
374 | field_transfer__syntax->log(); | |
375 | TTCN_Logger::log_event_str(" }"); | |
376 | break; | |
377 | case ALT_fixed: | |
378 | TTCN_Logger::log_event_str("{ fixed := "); | |
379 | field_fixed->log(); | |
380 | TTCN_Logger::log_event_str(" }"); | |
381 | break; | |
382 | default: | |
383 | TTCN_Logger::log_event_str("<unbound>"); | |
384 | break; | |
385 | } | |
386 | } | |
387 | ||
388 | void CHARACTER_STRING_identification::set_param(Module_Param& param) | |
389 | { | |
390 | param.basic_check(Module_Param::BC_VALUE, "union value"); | |
3abe9331 | 391 | Module_Param_Ptr mp = ¶m; |
392 | if (param.get_type() == Module_Param::MP_Reference) { | |
393 | mp = param.get_referenced_param(); | |
394 | } | |
395 | if (mp->get_type()==Module_Param::MP_Value_List && mp->get_size()==0) return; | |
396 | if (mp->get_type()!=Module_Param::MP_Assignment_List) { | |
970ed795 EL |
397 | param.error("union value with field name was expected"); |
398 | } | |
3abe9331 | 399 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
400 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
401 | syntaxes().set_param(*mp_last); | |
402 | return; | |
403 | } | |
404 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
405 | syntax().set_param(*mp_last); | |
406 | return; | |
407 | } | |
408 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
409 | presentation__context__id().set_param(*mp_last); | |
410 | return; | |
411 | } | |
412 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
413 | context__negotiation().set_param(*mp_last); | |
414 | return; | |
415 | } | |
416 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
417 | transfer__syntax().set_param(*mp_last); | |
418 | return; | |
419 | } | |
420 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
421 | fixed().set_param(*mp_last); | |
422 | return; | |
423 | } | |
424 | mp_last->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last->get_id()->get_name()); | |
425 | } | |
426 | ||
3abe9331 | 427 | Module_Param* CHARACTER_STRING_identification::get_param(Module_Param_Name& param_name) const |
428 | { | |
429 | if (!is_bound()) { | |
430 | return new Module_Param_Unbound(); | |
431 | } | |
432 | Module_Param* mp_field = NULL; | |
433 | switch(get_selection()) { | |
434 | case ALT_syntaxes: | |
435 | mp_field = field_syntaxes->get_param(param_name); | |
436 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes"))); | |
437 | break; | |
438 | case ALT_syntax: | |
439 | mp_field = field_syntax->get_param(param_name); | |
440 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax"))); | |
441 | break; | |
442 | case ALT_presentation__context__id: | |
443 | mp_field = field_presentation__context__id->get_param(param_name); | |
444 | mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
445 | break; | |
446 | case ALT_context__negotiation: | |
447 | mp_field = field_context__negotiation->get_param(param_name); | |
448 | mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation"))); | |
449 | break; | |
450 | case ALT_transfer__syntax: | |
451 | mp_field = field_transfer__syntax->get_param(param_name); | |
452 | mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
453 | break; | |
454 | case ALT_fixed: | |
455 | mp_field = field_fixed->get_param(param_name); | |
456 | mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed"))); | |
457 | break; | |
458 | default: | |
459 | break; | |
460 | } | |
461 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
462 | mp->add_elem(mp_field); | |
463 | return mp; | |
464 | } | |
465 | ||
970ed795 EL |
466 | void CHARACTER_STRING_identification_template::set_param(Module_Param& param) |
467 | { | |
468 | param.basic_check(Module_Param::BC_TEMPLATE, "union template"); | |
3abe9331 | 469 | Module_Param_Ptr mp = ¶m; |
470 | if (param.get_type() == Module_Param::MP_Reference) { | |
471 | mp = param.get_referenced_param(); | |
472 | } | |
473 | switch (mp->get_type()) { | |
970ed795 EL |
474 | case Module_Param::MP_Omit: |
475 | *this = OMIT_VALUE; | |
476 | break; | |
477 | case Module_Param::MP_Any: | |
478 | *this = ANY_VALUE; | |
479 | break; | |
480 | case Module_Param::MP_AnyOrNone: | |
481 | *this = ANY_OR_OMIT; | |
482 | break; | |
483 | case Module_Param::MP_List_Template: | |
3abe9331 | 484 | case Module_Param::MP_ComplementList_Template: { |
485 | CHARACTER_STRING_identification_template temp; | |
486 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
487 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
488 | for (size_t i=0; i<mp->get_size(); i++) { | |
489 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
970ed795 | 490 | } |
3abe9331 | 491 | *this = temp; |
492 | break; } | |
970ed795 | 493 | case Module_Param::MP_Value_List: |
3abe9331 | 494 | if (mp->get_size()==0) break; |
970ed795 EL |
495 | param.type_error("union template", "CHARACTER STRING.identification"); |
496 | break; | |
497 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 498 | Module_Param* mp_last = mp->get_elem(mp->get_size()-1); |
970ed795 EL |
499 | if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) { |
500 | syntaxes().set_param(*mp_last); | |
501 | break; | |
502 | } | |
503 | if (!strcmp(mp_last->get_id()->get_name(), "syntax")) { | |
504 | syntax().set_param(*mp_last); | |
505 | break; | |
506 | } | |
507 | if (!strcmp(mp_last->get_id()->get_name(), "presentation_context_id")) { | |
508 | presentation__context__id().set_param(*mp_last); | |
509 | break; | |
510 | } | |
511 | if (!strcmp(mp_last->get_id()->get_name(), "context_negotiation")) { | |
512 | context__negotiation().set_param(*mp_last); | |
513 | break; | |
514 | } | |
515 | if (!strcmp(mp_last->get_id()->get_name(), "transfer_syntax")) { | |
516 | transfer__syntax().set_param(*mp_last); | |
517 | break; | |
518 | } | |
519 | if (!strcmp(mp_last->get_id()->get_name(), "fixed")) { | |
520 | fixed().set_param(*mp_last); | |
521 | break; | |
522 | } | |
523 | mp_last->error("Field %s does not exist in type CHARACTER STRING.identification.", mp_last->get_id()->get_name()); | |
524 | } break; | |
525 | default: | |
526 | param.type_error("union template", "CHARACTER STRING.identification"); | |
527 | } | |
3abe9331 | 528 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); |
529 | } | |
530 | ||
531 | Module_Param* CHARACTER_STRING_identification_template::get_param(Module_Param_Name& param_name) const | |
532 | { | |
533 | Module_Param* mp = NULL; | |
534 | switch (template_selection) { | |
535 | case UNINITIALIZED_TEMPLATE: | |
536 | mp = new Module_Param_Unbound(); | |
537 | break; | |
538 | case OMIT_VALUE: | |
539 | mp = new Module_Param_Omit(); | |
540 | break; | |
541 | case ANY_VALUE: | |
542 | mp = new Module_Param_Any(); | |
543 | break; | |
544 | case ANY_OR_OMIT: | |
545 | mp = new Module_Param_AnyOrNone(); | |
546 | break; | |
547 | case SPECIFIC_VALUE: { | |
548 | Module_Param* mp_field = NULL; | |
549 | switch(single_value.union_selection) { | |
550 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
551 | mp_field = single_value.field_syntaxes->get_param(param_name); | |
552 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes"))); | |
553 | break; | |
554 | case CHARACTER_STRING_identification::ALT_syntax: | |
555 | mp_field = single_value.field_syntax->get_param(param_name); | |
556 | mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax"))); | |
557 | break; | |
558 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
559 | mp_field = single_value.field_presentation__context__id->get_param(param_name); | |
560 | mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
561 | break; | |
562 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
563 | mp_field = single_value.field_context__negotiation->get_param(param_name); | |
564 | mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation"))); | |
565 | break; | |
566 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
567 | mp_field = single_value.field_transfer__syntax->get_param(param_name); | |
568 | mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
569 | break; | |
570 | case CHARACTER_STRING_identification::ALT_fixed: | |
571 | mp_field = single_value.field_fixed->get_param(param_name); | |
572 | mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed"))); | |
573 | break; | |
574 | default: | |
575 | break; | |
576 | } | |
577 | mp = new Module_Param_Assignment_List(); | |
578 | mp->add_elem(mp_field); | |
579 | break; } | |
580 | case VALUE_LIST: | |
581 | case COMPLEMENTED_LIST: { | |
582 | if (template_selection == VALUE_LIST) { | |
583 | mp = new Module_Param_List_Template(); | |
584 | } | |
585 | else { | |
586 | mp = new Module_Param_ComplementList_Template(); | |
587 | } | |
588 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
589 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
590 | } | |
591 | break; } | |
592 | default: | |
593 | break; | |
594 | } | |
595 | if (is_ifpresent) { | |
596 | mp->set_ifpresent(); | |
597 | } | |
598 | return mp; | |
970ed795 EL |
599 | } |
600 | ||
601 | void CHARACTER_STRING_identification::encode_text(Text_Buf& text_buf) const | |
602 | { | |
603 | text_buf.push_int(union_selection); | |
604 | switch (union_selection) { | |
605 | case ALT_syntaxes: | |
606 | field_syntaxes->encode_text(text_buf); | |
607 | break; | |
608 | case ALT_syntax: | |
609 | field_syntax->encode_text(text_buf); | |
610 | break; | |
611 | case ALT_presentation__context__id: | |
612 | field_presentation__context__id->encode_text(text_buf); | |
613 | break; | |
614 | case ALT_context__negotiation: | |
615 | field_context__negotiation->encode_text(text_buf); | |
616 | break; | |
617 | case ALT_transfer__syntax: | |
618 | field_transfer__syntax->encode_text(text_buf); | |
619 | break; | |
620 | case ALT_fixed: | |
621 | field_fixed->encode_text(text_buf); | |
622 | break; | |
623 | default: | |
624 | TTCN_error("Text encoder: Encoding an unbound value of union type CHARACTER STRING.identification."); | |
625 | } | |
626 | } | |
627 | ||
628 | void CHARACTER_STRING_identification::decode_text(Text_Buf& text_buf) | |
629 | { | |
630 | switch ((union_selection_type)text_buf.pull_int().get_val()) { | |
631 | case ALT_syntaxes: | |
632 | syntaxes().decode_text(text_buf); | |
633 | break; | |
634 | case ALT_syntax: | |
635 | syntax().decode_text(text_buf); | |
636 | break; | |
637 | case ALT_presentation__context__id: | |
638 | presentation__context__id().decode_text(text_buf); | |
639 | break; | |
640 | case ALT_context__negotiation: | |
641 | context__negotiation().decode_text(text_buf); | |
642 | break; | |
643 | case ALT_transfer__syntax: | |
644 | transfer__syntax().decode_text(text_buf); | |
645 | break; | |
646 | case ALT_fixed: | |
647 | fixed().decode_text(text_buf); | |
648 | break; | |
649 | default: | |
650 | TTCN_error("Text decoder: Unrecognized union selector was received for type CHARACTER STRING.identification."); | |
651 | } | |
652 | } | |
653 | ||
654 | /* not called | |
655 | void CHARACTER_STRING_identification::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
656 | void CHARACTER_STRING_identification::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
657 | */ | |
658 | ||
659 | ASN_BER_TLV_t *CHARACTER_STRING_identification::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
660 | { | |
661 | BER_chk_descr(p_td); | |
662 | ASN_BER_TLV_t *new_tlv; | |
663 | TTCN_EncDec_ErrorContext ec_0("Alternative '"); | |
664 | TTCN_EncDec_ErrorContext ec_1; | |
665 | switch (union_selection) { | |
666 | case ALT_syntaxes: | |
667 | ec_1.set_msg("syntaxes': "); | |
668 | new_tlv = field_syntaxes->BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_descr_, p_coding); | |
669 | break; | |
670 | case ALT_syntax: | |
671 | ec_1.set_msg("syntax': "); | |
672 | new_tlv = field_syntax->BER_encode_TLV(CHARACTER_STRING_identification_syntax_descr_, p_coding); | |
673 | break; | |
674 | case ALT_presentation__context__id: | |
675 | ec_1.set_msg("presentation_context_id': "); | |
676 | new_tlv = field_presentation__context__id->BER_encode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_, p_coding); | |
677 | break; | |
678 | case ALT_context__negotiation: | |
679 | ec_1.set_msg("context_negotiation': "); | |
680 | new_tlv = field_context__negotiation->BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_, p_coding); | |
681 | break; | |
682 | case ALT_transfer__syntax: | |
683 | ec_1.set_msg("transfer_syntax': "); | |
684 | new_tlv = field_transfer__syntax->BER_encode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_, p_coding); | |
685 | break; | |
686 | case ALT_fixed: | |
687 | ec_1.set_msg("fixed': "); | |
688 | new_tlv = field_fixed->BER_encode_TLV(CHARACTER_STRING_identification_fixed_descr_, p_coding); | |
689 | break; | |
690 | case UNBOUND_VALUE: | |
691 | new_tlv = BER_encode_chk_bound(FALSE); | |
692 | break; | |
693 | default: | |
694 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
695 | new_tlv = NULL; | |
696 | } | |
697 | return ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
698 | } | |
699 | ||
700 | boolean CHARACTER_STRING_identification::BER_decode_set_selection(const ASN_BER_TLV_t& p_tlv) | |
701 | { | |
702 | clean_up(); | |
703 | field_syntaxes = new CHARACTER_STRING_identification_syntaxes; | |
704 | union_selection = ALT_syntaxes; | |
705 | if (field_syntaxes->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntaxes_descr_, p_tlv)) return TRUE; | |
706 | delete field_syntaxes; | |
707 | field_syntax = new OBJID; | |
708 | union_selection = ALT_syntax; | |
709 | if (field_syntax->BER_decode_isMyMsg(CHARACTER_STRING_identification_syntax_descr_, p_tlv)) return TRUE; | |
710 | delete field_syntax; | |
711 | field_presentation__context__id = new INTEGER; | |
712 | union_selection = ALT_presentation__context__id; | |
713 | if (field_presentation__context__id->BER_decode_isMyMsg(CHARACTER_STRING_identification_presentation__context__id_descr_, p_tlv)) return TRUE; | |
714 | delete field_presentation__context__id; | |
715 | field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation; | |
716 | union_selection = ALT_context__negotiation; | |
717 | if (field_context__negotiation->BER_decode_isMyMsg(CHARACTER_STRING_identification_context__negotiation_descr_, p_tlv)) return TRUE; | |
718 | delete field_context__negotiation; | |
719 | field_transfer__syntax = new OBJID; | |
720 | union_selection = ALT_transfer__syntax; | |
721 | if (field_transfer__syntax->BER_decode_isMyMsg(CHARACTER_STRING_identification_transfer__syntax_descr_, p_tlv)) return TRUE; | |
722 | delete field_transfer__syntax; | |
723 | field_fixed = new ASN_NULL; | |
724 | union_selection = ALT_fixed; | |
725 | if (field_fixed->BER_decode_isMyMsg(CHARACTER_STRING_identification_fixed_descr_, p_tlv)) return TRUE; | |
726 | delete field_fixed; | |
727 | union_selection = UNBOUND_VALUE; | |
728 | return FALSE; | |
729 | } | |
730 | ||
731 | boolean CHARACTER_STRING_identification::BER_decode_isMyMsg(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv) | |
732 | { | |
733 | if (p_td.ber->n_tags == 0) { | |
734 | CHARACTER_STRING_identification tmp_type; | |
735 | return tmp_type.BER_decode_set_selection(p_tlv); | |
736 | } else return Base_Type::BER_decode_isMyMsg(p_td, p_tlv); | |
737 | } | |
738 | ||
739 | boolean CHARACTER_STRING_identification::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
740 | { | |
741 | BER_chk_descr(p_td); | |
742 | ASN_BER_TLV_t stripped_tlv; | |
743 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
744 | TTCN_EncDec_ErrorContext ec_0("While decoding 'CHARACTER STRING.identification' type: "); | |
745 | ASN_BER_TLV_t tmp_tlv; | |
746 | if (!BER_decode_TLV_CHOICE(*p_td.ber, stripped_tlv, L_form, tmp_tlv) || !BER_decode_CHOICE_selection(BER_decode_set_selection(tmp_tlv), tmp_tlv)) return FALSE; | |
747 | TTCN_EncDec_ErrorContext ec_1("Alternative '"); | |
748 | TTCN_EncDec_ErrorContext ec_2; | |
749 | switch (union_selection) { | |
750 | case ALT_syntaxes: | |
751 | ec_2.set_msg("syntaxes': "); | |
752 | field_syntaxes->BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_descr_, tmp_tlv, L_form); | |
753 | break; | |
754 | case ALT_syntax: | |
755 | ec_2.set_msg("syntax': "); | |
756 | field_syntax->BER_decode_TLV(CHARACTER_STRING_identification_syntax_descr_, tmp_tlv, L_form); | |
757 | break; | |
758 | case ALT_presentation__context__id: | |
759 | ec_2.set_msg("presentation_context_id': "); | |
760 | field_presentation__context__id->BER_decode_TLV(CHARACTER_STRING_identification_presentation__context__id_descr_, tmp_tlv, L_form); | |
761 | break; | |
762 | case ALT_context__negotiation: | |
763 | ec_2.set_msg("context_negotiation': "); | |
764 | field_context__negotiation->BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_descr_, tmp_tlv, L_form); | |
765 | break; | |
766 | case ALT_transfer__syntax: | |
767 | ec_2.set_msg("transfer_syntax': "); | |
768 | field_transfer__syntax->BER_decode_TLV(CHARACTER_STRING_identification_transfer__syntax_descr_, tmp_tlv, L_form); | |
769 | break; | |
770 | case ALT_fixed: | |
771 | ec_2.set_msg("fixed': "); | |
772 | field_fixed->BER_decode_TLV(CHARACTER_STRING_identification_fixed_descr_, tmp_tlv, L_form); | |
773 | break; | |
774 | default: | |
775 | return FALSE; | |
776 | } | |
777 | return TRUE; | |
778 | } | |
779 | ||
780 | // FIXME maybe: XER_encode and decode is virtually identical to EMBEDDED_PDV | |
781 | ||
782 | int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 783 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
784 | { |
785 | int encoded_length=(int)p_buf.get_len(); | |
786 | ||
787 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
788 | ||
789 | flavor &= XER_MASK; | |
790 | switch (union_selection) { | |
791 | case ALT_syntaxes: | |
af710487 | 792 | field_syntaxes->XER_encode(EMBEDDED_PDV_identification_sxs_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
793 | break; |
794 | case ALT_syntax: | |
af710487 | 795 | field_syntax->XER_encode(EMBEDDED_PDV_identification_sx_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
796 | break; |
797 | case ALT_presentation__context__id: | |
af710487 | 798 | field_presentation__context__id->XER_encode(EMBEDDED_PDV_identification_pci_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
799 | break; |
800 | case ALT_context__negotiation: | |
af710487 | 801 | field_context__negotiation->XER_encode(EMBEDDED_PDV_identification_cn_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
802 | break; |
803 | case ALT_transfer__syntax: | |
af710487 | 804 | field_transfer__syntax->XER_encode(EMBEDDED_PDV_identification_ts_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
805 | break; |
806 | case ALT_fixed: | |
af710487 | 807 | field_fixed->XER_encode(EMBEDDED_PDV_identification_fix_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
808 | break; |
809 | default: | |
810 | TTCN_EncDec_ErrorContext::error_internal("Unknown selection."); | |
811 | break; | |
812 | } | |
813 | ||
814 | end_xml(p_td, p_buf, flavor, --indent, false); | |
815 | ||
816 | return (int)p_buf.get_len() - encoded_length; | |
817 | } | |
818 | ||
819 | int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t& p_td, | |
feade998 | 820 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
821 | { |
822 | int exer = is_exer(flavor); | |
823 | // we are supposed to be parked on our element | |
824 | for (int success = 1; success == 1; success = reader.Read()) { | |
825 | int type = reader.NodeType(); | |
826 | switch (type) { | |
827 | case XML_READER_TYPE_ELEMENT: { | |
828 | if (verify_name(reader, p_td, exer)) { | |
829 | // it's us | |
830 | for (success = reader.Read(); success == 1; success = reader.Read()) { | |
831 | type = reader.NodeType(); | |
832 | if (XML_READER_TYPE_ELEMENT == type) break; | |
833 | else if (XML_READER_TYPE_END_ELEMENT == type) goto bail; | |
834 | } | |
835 | const char *name = (const char*)reader.Name(); | |
836 | // Avoid chained if-else on strcmp. Use the length as a hash | |
837 | // (thankfully, they are all different). | |
838 | size_t namelen = strlen(name); | |
839 | switch (namelen) { | |
840 | case 8: // syntaxes | |
feade998 | 841 | syntaxes().XER_decode(EMBEDDED_PDV_identification_sxs_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
842 | break; |
843 | ||
844 | case 6: // syntax | |
feade998 | 845 | syntax().XER_decode(EMBEDDED_PDV_identification_sx_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
846 | break; |
847 | ||
848 | case 23: // presentation-context-id | |
feade998 | 849 | presentation__context__id().XER_decode(EMBEDDED_PDV_identification_pci_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
850 | break; |
851 | ||
852 | case 19: // context-negotiation | |
feade998 | 853 | context__negotiation().XER_decode(EMBEDDED_PDV_identification_cn_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
854 | break; |
855 | ||
856 | case 15: // transfer-syntax | |
feade998 | 857 | transfer__syntax().XER_decode(EMBEDDED_PDV_identification_ts_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
858 | break; |
859 | ||
860 | case 5: // fixed | |
feade998 | 861 | fixed().XER_decode(EMBEDDED_PDV_identification_fix_xer_, reader, flavor, flavor2, 0); |
970ed795 EL |
862 | break; |
863 | ||
864 | default: | |
865 | goto bail; | |
866 | } // switch | |
867 | } | |
868 | else { // it belongs to somebody else | |
869 | goto bail; | |
870 | } | |
871 | break; } | |
872 | case XML_READER_TYPE_END_ELEMENT: { | |
873 | // advance to the next thing and bail | |
874 | reader.Read(); | |
875 | goto bail; } | |
876 | } | |
877 | } | |
878 | bail: | |
879 | return 1; | |
880 | } | |
881 | ||
882 | void CHARACTER_STRING_identification_template::clean_up() | |
883 | { | |
884 | switch (template_selection) { | |
885 | case SPECIFIC_VALUE: | |
886 | switch (single_value.union_selection) { | |
887 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
888 | delete single_value.field_syntaxes; | |
889 | break; | |
890 | case CHARACTER_STRING_identification::ALT_syntax: | |
891 | delete single_value.field_syntax; | |
892 | break; | |
893 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
894 | delete single_value.field_presentation__context__id; | |
895 | break; | |
896 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
897 | delete single_value.field_context__negotiation; | |
898 | break; | |
899 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
900 | delete single_value.field_transfer__syntax; | |
901 | break; | |
902 | case CHARACTER_STRING_identification::ALT_fixed: | |
903 | delete single_value.field_fixed; | |
904 | break; | |
905 | default: | |
906 | break; | |
907 | } | |
908 | break; | |
909 | case VALUE_LIST: | |
910 | case COMPLEMENTED_LIST: | |
911 | delete [] value_list.list_value; | |
912 | break; | |
913 | default: | |
914 | break; | |
915 | } | |
916 | template_selection = UNINITIALIZED_TEMPLATE; | |
917 | } | |
918 | ||
919 | void CHARACTER_STRING_identification_template::copy_value(const CHARACTER_STRING_identification& other_value) | |
920 | { | |
921 | single_value.union_selection = other_value.get_selection(); | |
922 | switch (single_value.union_selection) { | |
923 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
924 | single_value.field_syntaxes = new CHARACTER_STRING_identification_syntaxes_template(other_value.syntaxes()); | |
925 | break; | |
926 | case CHARACTER_STRING_identification::ALT_syntax: | |
927 | single_value.field_syntax = new OBJID_template(other_value.syntax()); | |
928 | break; | |
929 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
930 | single_value.field_presentation__context__id = new INTEGER_template(other_value.presentation__context__id()); | |
931 | break; | |
932 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
933 | single_value.field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation_template(other_value.context__negotiation()); | |
934 | break; | |
935 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
936 | single_value.field_transfer__syntax = new OBJID_template(other_value.transfer__syntax()); | |
937 | break; | |
938 | case CHARACTER_STRING_identification::ALT_fixed: | |
939 | single_value.field_fixed = new ASN_NULL_template(other_value.fixed()); | |
940 | break; | |
941 | default: | |
942 | TTCN_error("Initializing a template with an unbound value of type CHARACTER STRING.identification."); | |
943 | } | |
944 | set_selection(SPECIFIC_VALUE); | |
945 | } | |
946 | ||
947 | void CHARACTER_STRING_identification_template::copy_template(const CHARACTER_STRING_identification_template& other_value) | |
948 | { | |
949 | switch (other_value.template_selection) { | |
950 | case SPECIFIC_VALUE: | |
951 | single_value.union_selection = other_value.single_value.union_selection; | |
952 | switch (single_value.union_selection) { | |
953 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
954 | single_value.field_syntaxes = new CHARACTER_STRING_identification_syntaxes_template(*other_value.single_value.field_syntaxes); | |
955 | break; | |
956 | case CHARACTER_STRING_identification::ALT_syntax: | |
957 | single_value.field_syntax = new OBJID_template(*other_value.single_value.field_syntax); | |
958 | break; | |
959 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
960 | single_value.field_presentation__context__id = new INTEGER_template(*other_value.single_value.field_presentation__context__id); | |
961 | break; | |
962 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
963 | single_value.field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation_template(*other_value.single_value.field_context__negotiation); | |
964 | break; | |
965 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
966 | single_value.field_transfer__syntax = new OBJID_template(*other_value.single_value.field_transfer__syntax); | |
967 | break; | |
968 | case CHARACTER_STRING_identification::ALT_fixed: | |
969 | single_value.field_fixed = new ASN_NULL_template(*other_value.single_value.field_fixed); | |
970 | break; | |
971 | default: | |
972 | TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type CHARACTER STRING.identification."); | |
973 | } | |
974 | break; | |
975 | case OMIT_VALUE: | |
976 | case ANY_VALUE: | |
977 | case ANY_OR_OMIT: | |
978 | break; | |
979 | case VALUE_LIST: | |
980 | case COMPLEMENTED_LIST: | |
981 | value_list.n_values = other_value.value_list.n_values; | |
982 | value_list.list_value = new CHARACTER_STRING_identification_template[value_list.n_values]; | |
983 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
984 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
985 | break; | |
986 | default: | |
987 | TTCN_error("Copying an uninitialized template of union type CHARACTER STRING.identification."); | |
988 | } | |
989 | set_selection(other_value); | |
990 | } | |
991 | ||
992 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template() | |
993 | { | |
994 | } | |
995 | ||
996 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(template_sel other_value) | |
997 | : Base_Template(other_value) | |
998 | { | |
999 | check_single_selection(other_value); | |
1000 | } | |
1001 | ||
1002 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification& other_value) | |
1003 | { | |
1004 | copy_value(other_value); | |
1005 | } | |
1006 | ||
1007 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const OPTIONAL<CHARACTER_STRING_identification>& other_value) | |
1008 | { | |
1009 | switch (other_value.get_selection()) { | |
1010 | case OPTIONAL_PRESENT: | |
1011 | copy_value((const CHARACTER_STRING_identification&)other_value); | |
1012 | break; | |
1013 | case OPTIONAL_OMIT: | |
1014 | set_selection(OMIT_VALUE); | |
1015 | break; | |
1016 | default: | |
1017 | TTCN_error("Creating a template of union type CHARACTER STRING.identification from an unbound optional field."); | |
1018 | } | |
1019 | } | |
1020 | ||
1021 | CHARACTER_STRING_identification_template::CHARACTER_STRING_identification_template(const CHARACTER_STRING_identification_template& other_value) | |
1022 | : Base_Template() | |
1023 | { | |
1024 | copy_template(other_value); | |
1025 | } | |
1026 | ||
1027 | CHARACTER_STRING_identification_template::~CHARACTER_STRING_identification_template() | |
1028 | { | |
1029 | clean_up(); | |
1030 | } | |
1031 | ||
1032 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(template_sel other_value) | |
1033 | { | |
1034 | check_single_selection(other_value); | |
1035 | clean_up(); | |
1036 | set_selection(other_value); | |
1037 | return *this; | |
1038 | } | |
1039 | ||
1040 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification& other_value) | |
1041 | { | |
1042 | clean_up(); | |
1043 | copy_value(other_value); | |
1044 | return *this; | |
1045 | } | |
1046 | ||
1047 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const OPTIONAL<CHARACTER_STRING_identification>& other_value) | |
1048 | { | |
1049 | clean_up(); | |
1050 | switch (other_value.get_selection()) { | |
1051 | case OPTIONAL_PRESENT: | |
1052 | copy_value((const CHARACTER_STRING_identification&)other_value); | |
1053 | break; | |
1054 | case OPTIONAL_OMIT: | |
1055 | set_selection(OMIT_VALUE); | |
1056 | break; | |
1057 | default: | |
1058 | TTCN_error("Assignment of an unbound optional field to a template of union type CHARACTER STRING.identification."); | |
1059 | } | |
1060 | return *this; | |
1061 | } | |
1062 | ||
1063 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::operator=(const CHARACTER_STRING_identification_template& other_value) | |
1064 | { | |
1065 | if (&other_value != this) { | |
1066 | clean_up(); | |
1067 | copy_template(other_value); | |
1068 | } | |
1069 | return *this; | |
1070 | } | |
1071 | ||
3abe9331 | 1072 | boolean CHARACTER_STRING_identification_template::match(const CHARACTER_STRING_identification& other_value, |
1073 | boolean /* legacy */) const | |
970ed795 EL |
1074 | { |
1075 | switch (template_selection) { | |
1076 | case ANY_VALUE: | |
1077 | case ANY_OR_OMIT: | |
1078 | return TRUE; | |
1079 | case OMIT_VALUE: | |
1080 | return FALSE; | |
1081 | case SPECIFIC_VALUE: | |
1082 | { | |
1083 | CHARACTER_STRING_identification::union_selection_type value_selection = other_value.get_selection(); | |
1084 | if (value_selection == CHARACTER_STRING_identification::UNBOUND_VALUE) return FALSE; | |
1085 | if (value_selection != single_value.union_selection) return FALSE; | |
1086 | switch (value_selection) { | |
1087 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1088 | return single_value.field_syntaxes->match(other_value.syntaxes()); | |
1089 | case CHARACTER_STRING_identification::ALT_syntax: | |
1090 | return single_value.field_syntax->match(other_value.syntax()); | |
1091 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1092 | return single_value.field_presentation__context__id->match(other_value.presentation__context__id()); | |
1093 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1094 | return single_value.field_context__negotiation->match(other_value.context__negotiation()); | |
1095 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1096 | return single_value.field_transfer__syntax->match(other_value.transfer__syntax()); | |
1097 | case CHARACTER_STRING_identification::ALT_fixed: | |
1098 | return single_value.field_fixed->match(other_value.fixed()); | |
1099 | default: | |
1100 | TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type CHARACTER STRING.identification."); | |
1101 | } | |
1102 | } | |
1103 | case VALUE_LIST: | |
1104 | case COMPLEMENTED_LIST: | |
1105 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1106 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
1107 | return template_selection == COMPLEMENTED_LIST; | |
1108 | default: | |
1109 | TTCN_error ("Matching an uninitialized template of union type CHARACTER STRING.identification."); | |
1110 | } | |
1111 | return FALSE; | |
1112 | } | |
1113 | ||
1114 | CHARACTER_STRING_identification CHARACTER_STRING_identification_template::valueof() const | |
1115 | { | |
1116 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
1117 | TTCN_error("Performing valueof or send operation on a non-specific template of union type CHARACTER STRING.identification."); | |
1118 | CHARACTER_STRING_identification ret_val; | |
1119 | switch (single_value.union_selection) { | |
1120 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1121 | ret_val.syntaxes() = single_value.field_syntaxes->valueof(); | |
1122 | break; | |
1123 | case CHARACTER_STRING_identification::ALT_syntax: | |
1124 | ret_val.syntax() = single_value.field_syntax->valueof(); | |
1125 | break; | |
1126 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1127 | ret_val.presentation__context__id() = single_value.field_presentation__context__id->valueof(); | |
1128 | break; | |
1129 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1130 | ret_val.context__negotiation() = single_value.field_context__negotiation->valueof(); | |
1131 | break; | |
1132 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1133 | ret_val.transfer__syntax() = single_value.field_transfer__syntax->valueof(); | |
1134 | break; | |
1135 | case CHARACTER_STRING_identification::ALT_fixed: | |
1136 | ret_val.fixed() = single_value.field_fixed->valueof(); | |
1137 | break; | |
1138 | default: | |
1139 | TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type CHARACTER STRING.identification."); | |
1140 | } | |
1141 | return ret_val; | |
1142 | } | |
1143 | ||
1144 | CHARACTER_STRING_identification_template& CHARACTER_STRING_identification_template::list_item(unsigned int list_index) const | |
1145 | { | |
1146 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type CHARACTER STRING.identification."); | |
1147 | if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type CHARACTER STRING.identification."); | |
1148 | return value_list.list_value[list_index]; | |
1149 | } | |
1150 | void CHARACTER_STRING_identification_template::set_type(template_sel template_type, unsigned int list_length) | |
1151 | { | |
1152 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type CHARACTER STRING.identification."); | |
1153 | clean_up(); | |
1154 | set_selection(template_type); | |
1155 | value_list.n_values = list_length; | |
1156 | value_list.list_value = new CHARACTER_STRING_identification_template[list_length]; | |
1157 | } | |
1158 | ||
1159 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_template::syntaxes() | |
1160 | { | |
1161 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_syntaxes) { | |
1162 | template_sel old_selection = template_selection; | |
1163 | clean_up(); | |
1164 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntaxes = new CHARACTER_STRING_identification_syntaxes_template(ANY_VALUE); | |
1165 | else single_value.field_syntaxes = new CHARACTER_STRING_identification_syntaxes_template; | |
1166 | single_value.union_selection = CHARACTER_STRING_identification::ALT_syntaxes; | |
1167 | set_selection(SPECIFIC_VALUE); | |
1168 | } | |
1169 | return *single_value.field_syntaxes; | |
1170 | } | |
1171 | ||
1172 | const CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_template::syntaxes() const | |
1173 | { | |
1174 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntaxes in a non-specific template of union type CHARACTER STRING.identification."); | |
1175 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_syntaxes) TTCN_error("Accessing non-selected field syntaxes in a template of union type CHARACTER STRING.identification."); | |
1176 | return *single_value.field_syntaxes; | |
1177 | } | |
1178 | ||
1179 | OBJID_template& CHARACTER_STRING_identification_template::syntax() | |
1180 | { | |
1181 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_syntax) { | |
1182 | template_sel old_selection = template_selection; | |
1183 | clean_up(); | |
1184 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_syntax = new OBJID_template(ANY_VALUE); | |
1185 | else single_value.field_syntax = new OBJID_template; | |
1186 | single_value.union_selection = CHARACTER_STRING_identification::ALT_syntax; | |
1187 | set_selection(SPECIFIC_VALUE); | |
1188 | } | |
1189 | return *single_value.field_syntax; | |
1190 | } | |
1191 | ||
1192 | const OBJID_template& CHARACTER_STRING_identification_template::syntax() const | |
1193 | { | |
1194 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field syntax in a non-specific template of union type CHARACTER STRING.identification."); | |
1195 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_syntax) TTCN_error("Accessing non-selected field syntax in a template of union type CHARACTER STRING.identification."); | |
1196 | return *single_value.field_syntax; | |
1197 | } | |
1198 | ||
1199 | INTEGER_template& CHARACTER_STRING_identification_template::presentation__context__id() | |
1200 | { | |
1201 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_presentation__context__id) { | |
1202 | template_sel old_selection = template_selection; | |
1203 | clean_up(); | |
1204 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_presentation__context__id = new INTEGER_template(ANY_VALUE); | |
1205 | else single_value.field_presentation__context__id = new INTEGER_template; | |
1206 | single_value.union_selection = CHARACTER_STRING_identification::ALT_presentation__context__id; | |
1207 | set_selection(SPECIFIC_VALUE); | |
1208 | } | |
1209 | return *single_value.field_presentation__context__id; | |
1210 | } | |
1211 | ||
1212 | const INTEGER_template& CHARACTER_STRING_identification_template::presentation__context__id() const | |
1213 | { | |
1214 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field presentation_context_id in a non-specific template of union type CHARACTER STRING.identification."); | |
1215 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_presentation__context__id) TTCN_error("Accessing non-selected field presentation_context_id in a template of union type CHARACTER STRING.identification."); | |
1216 | return *single_value.field_presentation__context__id; | |
1217 | } | |
1218 | ||
1219 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_template::context__negotiation() | |
1220 | { | |
1221 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_context__negotiation) { | |
1222 | template_sel old_selection = template_selection; | |
1223 | clean_up(); | |
1224 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation_template(ANY_VALUE); | |
1225 | else single_value.field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation_template; | |
1226 | single_value.union_selection = CHARACTER_STRING_identification::ALT_context__negotiation; | |
1227 | set_selection(SPECIFIC_VALUE); | |
1228 | } | |
1229 | return *single_value.field_context__negotiation; | |
1230 | } | |
1231 | ||
1232 | const CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_template::context__negotiation() const | |
1233 | { | |
1234 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field context_negotiation in a non-specific template of union type CHARACTER STRING.identification."); | |
1235 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_context__negotiation) TTCN_error("Accessing non-selected field context_negotiation in a template of union type CHARACTER STRING.identification."); | |
1236 | return *single_value.field_context__negotiation; | |
1237 | } | |
1238 | ||
1239 | OBJID_template& CHARACTER_STRING_identification_template::transfer__syntax() | |
1240 | { | |
1241 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_transfer__syntax) { | |
1242 | template_sel old_selection = template_selection; | |
1243 | clean_up(); | |
1244 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_transfer__syntax = new OBJID_template(ANY_VALUE); | |
1245 | else single_value.field_transfer__syntax = new OBJID_template; | |
1246 | single_value.union_selection = CHARACTER_STRING_identification::ALT_transfer__syntax; | |
1247 | set_selection(SPECIFIC_VALUE); | |
1248 | } | |
1249 | return *single_value.field_transfer__syntax; | |
1250 | } | |
1251 | ||
1252 | const OBJID_template& CHARACTER_STRING_identification_template::transfer__syntax() const | |
1253 | { | |
1254 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field transfer_syntax in a non-specific template of union type CHARACTER STRING.identification."); | |
1255 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_transfer__syntax) TTCN_error("Accessing non-selected field transfer_syntax in a template of union type CHARACTER STRING.identification."); | |
1256 | return *single_value.field_transfer__syntax; | |
1257 | } | |
1258 | ||
1259 | ASN_NULL_template& CHARACTER_STRING_identification_template::fixed() | |
1260 | { | |
1261 | if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CHARACTER_STRING_identification::ALT_fixed) { | |
1262 | template_sel old_selection = template_selection; | |
1263 | clean_up(); | |
1264 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_fixed = new ASN_NULL_template(ANY_VALUE); | |
1265 | else single_value.field_fixed = new ASN_NULL_template; | |
1266 | single_value.union_selection = CHARACTER_STRING_identification::ALT_fixed; | |
1267 | set_selection(SPECIFIC_VALUE); | |
1268 | } | |
1269 | return *single_value.field_fixed; | |
1270 | } | |
1271 | ||
1272 | const ASN_NULL_template& CHARACTER_STRING_identification_template::fixed() const | |
1273 | { | |
1274 | if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field fixed in a non-specific template of union type CHARACTER STRING.identification."); | |
1275 | if (single_value.union_selection != CHARACTER_STRING_identification::ALT_fixed) TTCN_error("Accessing non-selected field fixed in a template of union type CHARACTER STRING.identification."); | |
1276 | return *single_value.field_fixed; | |
1277 | } | |
1278 | ||
1279 | boolean CHARACTER_STRING_identification_template::ischosen(CHARACTER_STRING_identification::union_selection_type checked_selection) const | |
1280 | { | |
1281 | if (checked_selection == CHARACTER_STRING_identification::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type CHARACTER STRING.identification."); | |
1282 | switch (template_selection) { | |
1283 | case SPECIFIC_VALUE: | |
1284 | if (single_value.union_selection == CHARACTER_STRING_identification::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type CHARACTER STRING.identification."); | |
1285 | return single_value.union_selection == checked_selection; | |
1286 | case VALUE_LIST: | |
1287 | { | |
1288 | if (value_list.n_values < 1) | |
1289 | TTCN_error("Internal error: Performing ischosen() operation on a template of union type CHARACTER STRING.identification containing an empty list."); | |
1290 | boolean ret_val = value_list.list_value[0].ischosen(checked_selection); | |
1291 | boolean all_same = TRUE; | |
1292 | for (unsigned int list_count = 1; list_count < value_list.n_values; list_count++) { | |
1293 | if (value_list.list_value[list_count].ischosen(checked_selection) != ret_val) { | |
1294 | all_same = FALSE; | |
1295 | break; | |
1296 | } | |
1297 | } | |
1298 | if (all_same) return ret_val; | |
1299 | } | |
1300 | // FIXME really no break? | |
1301 | case ANY_VALUE: | |
1302 | case ANY_OR_OMIT: | |
1303 | case OMIT_VALUE: | |
1304 | case COMPLEMENTED_LIST: | |
1305 | TTCN_error("Performing ischosen() operation on a template of union type CHARACTER STRING.identification, which does not determine unambiguously the chosen field of the matching values."); | |
1306 | default: | |
1307 | TTCN_error("Performing ischosen() operation on an uninitialized template of union type CHARACTER STRING.identification"); | |
1308 | } | |
1309 | return FALSE; | |
1310 | } | |
1311 | ||
1312 | void CHARACTER_STRING_identification_template::log() const | |
1313 | { | |
1314 | switch (template_selection) { | |
1315 | case SPECIFIC_VALUE: | |
1316 | switch (single_value.union_selection) { | |
1317 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1318 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
1319 | single_value.field_syntaxes->log(); | |
1320 | TTCN_Logger::log_event_str(" }"); | |
1321 | break; | |
1322 | case CHARACTER_STRING_identification::ALT_syntax: | |
1323 | TTCN_Logger::log_event_str("{ syntax := "); | |
1324 | single_value.field_syntax->log(); | |
1325 | TTCN_Logger::log_event_str(" }"); | |
1326 | break; | |
1327 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1328 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
1329 | single_value.field_presentation__context__id->log(); | |
1330 | TTCN_Logger::log_event_str(" }"); | |
1331 | break; | |
1332 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1333 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
1334 | single_value.field_context__negotiation->log(); | |
1335 | TTCN_Logger::log_event_str(" }"); | |
1336 | break; | |
1337 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1338 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
1339 | single_value.field_transfer__syntax->log(); | |
1340 | TTCN_Logger::log_event_str(" }"); | |
1341 | break; | |
1342 | case CHARACTER_STRING_identification::ALT_fixed: | |
1343 | TTCN_Logger::log_event_str("{ fixed := "); | |
1344 | single_value.field_fixed->log(); | |
1345 | TTCN_Logger::log_event_str(" }"); | |
1346 | break; | |
1347 | default: | |
1348 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1349 | break; | |
1350 | } | |
1351 | break; | |
1352 | case COMPLEMENTED_LIST: | |
1353 | TTCN_Logger::log_event_str("complement "); | |
1354 | // no break | |
1355 | case VALUE_LIST: | |
1356 | TTCN_Logger::log_char('('); | |
1357 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
1358 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
1359 | value_list.list_value[list_count].log(); | |
1360 | } | |
1361 | TTCN_Logger::log_char(')'); | |
1362 | break; | |
1363 | default: | |
1364 | log_generic(); | |
1365 | break; | |
1366 | } | |
1367 | log_ifpresent(); | |
1368 | } | |
1369 | ||
3abe9331 | 1370 | void CHARACTER_STRING_identification_template::log_match(const CHARACTER_STRING_identification& match_value, |
1371 | boolean /* legacy */) const | |
970ed795 EL |
1372 | { |
1373 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1374 | if(match(match_value)){ | |
1375 | TTCN_Logger::print_logmatch_buffer(); | |
1376 | TTCN_Logger::log_event_str(" matched "); | |
1377 | } | |
1378 | return; | |
1379 | } | |
1380 | if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) { | |
1381 | switch (single_value.union_selection) { | |
1382 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1383 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1384 | TTCN_Logger::log_logmatch_info(".syntaxes"); | |
1385 | single_value.field_syntaxes->log_match(match_value.syntaxes()); | |
1386 | }else{ | |
1387 | TTCN_Logger::log_event_str("{ syntaxes := "); | |
1388 | single_value.field_syntaxes->log_match(match_value.syntaxes()); | |
1389 | TTCN_Logger::log_event_str(" }"); | |
1390 | } | |
1391 | break; | |
1392 | case CHARACTER_STRING_identification::ALT_syntax: | |
1393 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1394 | TTCN_Logger::log_logmatch_info(".syntax"); | |
1395 | single_value.field_syntax->log_match(match_value.syntax()); | |
1396 | }else{ | |
1397 | TTCN_Logger::log_event_str("{ syntax := "); | |
1398 | single_value.field_syntax->log_match(match_value.syntax()); | |
1399 | TTCN_Logger::log_event_str(" }"); | |
1400 | } | |
1401 | break; | |
1402 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1403 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1404 | TTCN_Logger::log_logmatch_info(".presentation_context_id"); | |
1405 | single_value.field_presentation__context__id->log_match(match_value.presentation__context__id()); | |
1406 | }else{ | |
1407 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
1408 | single_value.field_presentation__context__id->log_match(match_value.presentation__context__id()); | |
1409 | TTCN_Logger::log_event_str(" }"); | |
1410 | } | |
1411 | break; | |
1412 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1413 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1414 | TTCN_Logger::log_logmatch_info(".context_negotiation"); | |
1415 | single_value.field_context__negotiation->log_match(match_value.context__negotiation()); | |
1416 | }else{ | |
1417 | TTCN_Logger::log_event_str("{ context_negotiation := "); | |
1418 | single_value.field_context__negotiation->log_match(match_value.context__negotiation()); | |
1419 | TTCN_Logger::log_event_str(" }"); | |
1420 | } | |
1421 | break; | |
1422 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1423 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1424 | TTCN_Logger::log_logmatch_info(".transfer_syntax"); | |
1425 | single_value.field_transfer__syntax->log_match(match_value.transfer__syntax()); | |
1426 | }else{ | |
1427 | TTCN_Logger::log_event_str("{ transfer_syntax := "); | |
1428 | single_value.field_transfer__syntax->log_match(match_value.transfer__syntax()); | |
1429 | TTCN_Logger::log_event_str(" }"); | |
1430 | } | |
1431 | break; | |
1432 | case CHARACTER_STRING_identification::ALT_fixed: | |
1433 | if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ | |
1434 | TTCN_Logger::log_logmatch_info(".fixed"); | |
1435 | single_value.field_fixed->log_match(match_value.fixed()); | |
1436 | }else{ | |
1437 | TTCN_Logger::log_event_str("{ fixed := "); | |
1438 | single_value.field_fixed->log_match(match_value.fixed()); | |
1439 | TTCN_Logger::log_event_str(" }"); | |
1440 | } | |
1441 | break; | |
1442 | default: | |
1443 | TTCN_Logger::print_logmatch_buffer(); | |
1444 | TTCN_Logger::log_event_str("<invalid selector>"); | |
1445 | break; | |
1446 | } | |
1447 | } else { | |
1448 | TTCN_Logger::print_logmatch_buffer(); | |
1449 | match_value.log(); | |
1450 | TTCN_Logger::log_event_str(" with "); | |
1451 | log(); | |
1452 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
1453 | else TTCN_Logger::log_event_str(" unmatched"); | |
1454 | } | |
1455 | } | |
1456 | ||
1457 | void CHARACTER_STRING_identification_template::encode_text(Text_Buf& text_buf) const | |
1458 | { | |
1459 | encode_text_base(text_buf); | |
1460 | switch (template_selection) { | |
1461 | case SPECIFIC_VALUE: | |
1462 | text_buf.push_int(single_value.union_selection); | |
1463 | switch (single_value.union_selection) { | |
1464 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1465 | single_value.field_syntaxes->encode_text(text_buf); | |
1466 | break; | |
1467 | case CHARACTER_STRING_identification::ALT_syntax: | |
1468 | single_value.field_syntax->encode_text(text_buf); | |
1469 | break; | |
1470 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1471 | single_value.field_presentation__context__id->encode_text(text_buf); | |
1472 | break; | |
1473 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1474 | single_value.field_context__negotiation->encode_text(text_buf); | |
1475 | break; | |
1476 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1477 | single_value.field_transfer__syntax->encode_text(text_buf); | |
1478 | break; | |
1479 | case CHARACTER_STRING_identification::ALT_fixed: | |
1480 | single_value.field_fixed->encode_text(text_buf); | |
1481 | break; | |
1482 | default: | |
1483 | TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type CHARACTER STRING.identification."); | |
1484 | } | |
1485 | break; | |
1486 | case OMIT_VALUE: | |
1487 | case ANY_VALUE: | |
1488 | case ANY_OR_OMIT: | |
1489 | break; | |
1490 | case VALUE_LIST: | |
1491 | case COMPLEMENTED_LIST: | |
1492 | text_buf.push_int(value_list.n_values); | |
1493 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1494 | value_list.list_value[list_count].encode_text(text_buf); | |
1495 | break; | |
1496 | default: | |
1497 | TTCN_error("Text encoder: Encoding an uninitialized template of type CHARACTER STRING.identification."); | |
1498 | } | |
1499 | } | |
1500 | ||
1501 | void CHARACTER_STRING_identification_template::decode_text(Text_Buf& text_buf) | |
1502 | { | |
1503 | clean_up(); | |
1504 | decode_text_base(text_buf); | |
1505 | switch (template_selection) { | |
1506 | case SPECIFIC_VALUE: | |
1507 | { | |
1508 | single_value.union_selection = CHARACTER_STRING_identification::UNBOUND_VALUE; | |
1509 | CHARACTER_STRING_identification::union_selection_type new_selection = (CHARACTER_STRING_identification::union_selection_type)text_buf.pull_int().get_val(); | |
1510 | switch (new_selection) { | |
1511 | case CHARACTER_STRING_identification::ALT_syntaxes: | |
1512 | single_value.field_syntaxes = new CHARACTER_STRING_identification_syntaxes_template; | |
1513 | single_value.field_syntaxes->decode_text(text_buf); | |
1514 | break; | |
1515 | case CHARACTER_STRING_identification::ALT_syntax: | |
1516 | single_value.field_syntax = new OBJID_template; | |
1517 | single_value.field_syntax->decode_text(text_buf); | |
1518 | break; | |
1519 | case CHARACTER_STRING_identification::ALT_presentation__context__id: | |
1520 | single_value.field_presentation__context__id = new INTEGER_template; | |
1521 | single_value.field_presentation__context__id->decode_text(text_buf); | |
1522 | break; | |
1523 | case CHARACTER_STRING_identification::ALT_context__negotiation: | |
1524 | single_value.field_context__negotiation = new CHARACTER_STRING_identification_context__negotiation_template; | |
1525 | single_value.field_context__negotiation->decode_text(text_buf); | |
1526 | break; | |
1527 | case CHARACTER_STRING_identification::ALT_transfer__syntax: | |
1528 | single_value.field_transfer__syntax = new OBJID_template; | |
1529 | single_value.field_transfer__syntax->decode_text(text_buf); | |
1530 | break; | |
1531 | case CHARACTER_STRING_identification::ALT_fixed: | |
1532 | single_value.field_fixed = new ASN_NULL_template; | |
1533 | single_value.field_fixed->decode_text(text_buf); | |
1534 | break; | |
1535 | default: | |
1536 | TTCN_error("Text decoder: Unrecognized union selector was received for a template of type CHARACTER STRING.identification."); | |
1537 | } | |
1538 | single_value.union_selection = new_selection; | |
1539 | } | |
1540 | break; | |
1541 | case OMIT_VALUE: | |
1542 | case ANY_VALUE: | |
1543 | case ANY_OR_OMIT: | |
1544 | break; | |
1545 | case VALUE_LIST: | |
1546 | case COMPLEMENTED_LIST: | |
1547 | value_list.n_values = text_buf.pull_int().get_val(); | |
1548 | value_list.list_value = new CHARACTER_STRING_identification_template[value_list.n_values]; | |
1549 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1550 | value_list.list_value[list_count].decode_text(text_buf); | |
1551 | break; | |
1552 | default: | |
1553 | TTCN_error("Text decoder: Unrecognized selector was received in a template of type CHARACTER STRING.identification."); | |
1554 | } | |
1555 | } | |
1556 | ||
3abe9331 | 1557 | boolean CHARACTER_STRING_identification_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
1558 | { |
1559 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 1560 | return !match_omit(legacy); |
970ed795 EL |
1561 | } |
1562 | ||
3abe9331 | 1563 | boolean CHARACTER_STRING_identification_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
1564 | { |
1565 | if (is_ifpresent) return TRUE; | |
1566 | switch (template_selection) { | |
1567 | case OMIT_VALUE: | |
1568 | case ANY_OR_OMIT: | |
1569 | return TRUE; | |
1570 | case VALUE_LIST: | |
1571 | case COMPLEMENTED_LIST: | |
3abe9331 | 1572 | if (legacy) { |
1573 | for (unsigned int i=0; i<value_list.n_values; i++) | |
1574 | if (value_list.list_value[i].match_omit()) | |
1575 | return template_selection==VALUE_LIST; | |
1576 | return template_selection==COMPLEMENTED_LIST; | |
1577 | } // else fall through | |
970ed795 EL |
1578 | default: |
1579 | return FALSE; | |
1580 | } | |
1581 | return FALSE; | |
1582 | } | |
1583 | ||
1584 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 1585 | void CHARACTER_STRING_identification_template::check_restriction(template_res t_res, const char* t_name, |
1586 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
1587 | { |
1588 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
1589 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
1590 | case TR_VALUE: | |
1591 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
1592 | break; | |
1593 | case TR_OMIT: | |
1594 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
1595 | template_selection==SPECIFIC_VALUE)) return; | |
1596 | break; | |
1597 | case TR_PRESENT: | |
3abe9331 | 1598 | if (!match_omit(legacy)) return; |
970ed795 EL |
1599 | break; |
1600 | default: | |
1601 | return; | |
1602 | } | |
1603 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
1604 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING.identification"); | |
1605 | } | |
1606 | #endif | |
1607 | ||
1608 | CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes() | |
1609 | { | |
1610 | } | |
1611 | ||
1612 | CHARACTER_STRING_identification_syntaxes::CHARACTER_STRING_identification_syntaxes(const OBJID& par_abstract, | |
1613 | const OBJID& par_transfer) | |
1614 | : field_abstract(par_abstract), | |
1615 | field_transfer(par_transfer) | |
1616 | { | |
1617 | } | |
1618 | ||
1619 | boolean CHARACTER_STRING_identification_syntaxes::operator==(const CHARACTER_STRING_identification_syntaxes& other_value) const | |
1620 | { | |
1621 | return field_abstract==other_value.field_abstract | |
1622 | && field_transfer==other_value.field_transfer; | |
1623 | } | |
1624 | ||
1625 | int CHARACTER_STRING_identification_syntaxes::size_of() const | |
1626 | { | |
1627 | int ret_val = 2; | |
1628 | return ret_val; | |
1629 | } | |
1630 | ||
1631 | void CHARACTER_STRING_identification_syntaxes::log() const | |
1632 | { | |
1633 | TTCN_Logger::log_event_str("{ abstract := "); | |
1634 | field_abstract.log(); | |
1635 | TTCN_Logger::log_event_str(", transfer := "); | |
1636 | field_transfer.log(); | |
1637 | TTCN_Logger::log_event_str(" }"); | |
1638 | } | |
1639 | ||
1640 | boolean CHARACTER_STRING_identification_syntaxes::is_bound() const | |
1641 | { | |
1642 | if(field_abstract.is_bound()) return TRUE; | |
1643 | if(field_transfer.is_bound()) return TRUE; | |
1644 | return FALSE; | |
1645 | } | |
1646 | ||
1647 | boolean CHARACTER_STRING_identification_syntaxes::is_value() const | |
1648 | { | |
1649 | if(!field_abstract.is_value()) return FALSE; | |
1650 | if(!field_transfer.is_value()) return FALSE; | |
1651 | return TRUE; | |
1652 | } | |
1653 | ||
1654 | void CHARACTER_STRING_identification_syntaxes::clean_up() | |
1655 | { | |
1656 | field_abstract.clean_up(); | |
1657 | field_transfer.clean_up(); | |
1658 | } | |
1659 | ||
1660 | void CHARACTER_STRING_identification_syntaxes::set_param(Module_Param& param) | |
1661 | { | |
1662 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 1663 | Module_Param_Ptr mp = ¶m; |
1664 | if (param.get_type() == Module_Param::MP_Reference) { | |
1665 | mp = param.get_referenced_param(); | |
1666 | } | |
1667 | switch (mp->get_type()) { | |
970ed795 | 1668 | case Module_Param::MP_Value_List: |
3abe9331 | 1669 | if (mp->get_size()==0) return; |
1670 | if (2!=mp->get_size()) { | |
1671 | param.error("record value of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 1672 | } |
3abe9331 | 1673 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0)); |
1674 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1)); | |
970ed795 EL |
1675 | break; |
1676 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 1677 | Vector<bool> value_used(mp->get_size()); |
1678 | value_used.resize(mp->get_size(), false); | |
1679 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1680 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
1681 | if (!strcmp(curr_param->get_id()->get_name(), "abstract")) { |
1682 | abstract().set_param(*curr_param); | |
1683 | value_used[val_idx]=true; | |
1684 | } | |
1685 | } | |
3abe9331 | 1686 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
1687 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
1688 | if (!strcmp(curr_param->get_id()->get_name(), "transfer")) { |
1689 | transfer().set_param(*curr_param); | |
1690 | value_used[val_idx]=true; | |
1691 | } | |
1692 | } | |
3abe9331 | 1693 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
1694 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
1695 | break; |
1696 | } | |
1697 | } break; | |
1698 | default: | |
1699 | param.type_error("record value", "CHARACTER STRING.identification.syntaxes"); | |
1700 | } | |
1701 | } | |
1702 | ||
3abe9331 | 1703 | Module_Param* CHARACTER_STRING_identification_syntaxes::get_param(Module_Param_Name& param_name) const |
970ed795 | 1704 | { |
3abe9331 | 1705 | if (!is_bound()) { |
1706 | return new Module_Param_Unbound(); | |
970ed795 | 1707 | } |
3abe9331 | 1708 | Module_Param* mp_field_abstract = field_abstract.get_param(param_name); |
1709 | mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract"))); | |
1710 | Module_Param* mp_field_transfer = field_transfer.get_param(param_name); | |
1711 | mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer"))); | |
1712 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
1713 | mp->add_elem(mp_field_abstract); | |
1714 | mp->add_elem(mp_field_transfer); | |
1715 | return mp; | |
970ed795 EL |
1716 | } |
1717 | ||
1718 | void CHARACTER_STRING_identification_syntaxes::encode_text(Text_Buf& text_buf) const | |
1719 | { | |
1720 | field_abstract.encode_text(text_buf); | |
1721 | field_transfer.encode_text(text_buf); | |
1722 | } | |
1723 | ||
1724 | void CHARACTER_STRING_identification_syntaxes::decode_text(Text_Buf& text_buf) | |
1725 | { | |
1726 | field_abstract.decode_text(text_buf); | |
1727 | field_transfer.decode_text(text_buf); | |
1728 | } | |
1729 | ||
1730 | /* not called | |
1731 | void CHARACTER_STRING_identification_syntaxes::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
1732 | void CHARACTER_STRING_identification_syntaxes::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
1733 | */ | |
1734 | ||
1735 | ASN_BER_TLV_t* CHARACTER_STRING_identification_syntaxes::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
1736 | { | |
1737 | BER_chk_descr(p_td); | |
1738 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
1739 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
1740 | TTCN_EncDec_ErrorContext ec_1; | |
1741 | ec_1.set_msg("abstract': "); | |
1742 | new_tlv->add_TLV(field_abstract.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_, p_coding)); | |
1743 | ec_1.set_msg("transfer': "); | |
1744 | new_tlv->add_TLV(field_transfer.BER_encode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_, p_coding)); | |
1745 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
1746 | return new_tlv; | |
1747 | } | |
1748 | ||
1749 | boolean CHARACTER_STRING_identification_syntaxes::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
1750 | { | |
1751 | BER_chk_descr(p_td); | |
1752 | ASN_BER_TLV_t stripped_tlv; | |
1753 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
1754 | TTCN_EncDec_ErrorContext ec_0("While decoding 'CHARACTER STRING.identification.syntaxes' type: "); | |
1755 | stripped_tlv.chk_constructed_flag(TRUE); | |
1756 | size_t V_pos=0; | |
1757 | ASN_BER_TLV_t tmp_tlv; | |
1758 | boolean tlv_present=FALSE; | |
1759 | { | |
1760 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
1761 | TTCN_EncDec_ErrorContext ec_2; | |
1762 | ec_2.set_msg("abstract': "); | |
1763 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
1764 | if(!tlv_present) return FALSE; | |
1765 | field_abstract.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_abstract_descr_, tmp_tlv, L_form); | |
1766 | tlv_present=FALSE; | |
1767 | ec_2.set_msg("transfer': "); | |
1768 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
1769 | if(!tlv_present) return FALSE; | |
1770 | field_transfer.BER_decode_TLV(CHARACTER_STRING_identification_syntaxes_transfer_descr_, tmp_tlv, L_form); | |
1771 | tlv_present=FALSE; | |
1772 | } | |
1773 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
1774 | return TRUE; | |
1775 | } | |
1776 | ||
1777 | int CHARACTER_STRING_identification_syntaxes::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 1778 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
1779 | { |
1780 | int encoded_length=(int)p_buf.get_len(); | |
1781 | ||
1782 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
1783 | ||
af710487 | 1784 | field_abstract.XER_encode(CHARACTER_STRING_identification_sxs_abs_xer_, p_buf, flavor, indent, 0); |
1785 | field_transfer.XER_encode(CHARACTER_STRING_identification_sxs_xfr_xer_, p_buf, flavor, indent, 0); | |
970ed795 EL |
1786 | |
1787 | end_xml(p_td, p_buf, flavor, --indent, false); | |
1788 | ||
1789 | return p_buf.get_len() - encoded_length; | |
1790 | } | |
1791 | ||
1792 | int CHARACTER_STRING_identification_syntaxes::XER_decode( | |
feade998 | 1793 | const XERdescriptor_t& /*p_td*/, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
1794 | { // we stand on <syntaxes>, move ahead first |
1795 | for (int success = reader.Read(); success == 1; success = reader.Read()) | |
1796 | { | |
1797 | int type = reader.NodeType(); | |
1798 | if (XML_READER_TYPE_ELEMENT == type) | |
1799 | // no verify_name for a CHOICE | |
1800 | break; | |
1801 | } | |
1802 | // FIXME this assumes the right element | |
feade998 | 1803 | field_abstract.XER_decode(EMBEDDED_PDV_identification_sxs_abs_xer_, reader, flavor, flavor2, 0); |
1804 | field_transfer.XER_decode(EMBEDDED_PDV_identification_sxs_xfr_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
1805 | for (int success = 1; success == 1; success = reader.Read()) |
1806 | { | |
1807 | int type = reader.NodeType(); | |
1808 | if (XML_READER_TYPE_END_ELEMENT == type) | |
1809 | break; | |
1810 | } | |
1811 | return 0; // TODO maybe return proper value | |
1812 | } | |
1813 | ||
1814 | ||
1815 | struct CHARACTER_STRING_identification_syntaxes_template::single_value_struct { | |
1816 | OBJID_template field_abstract; | |
1817 | OBJID_template field_transfer; | |
1818 | }; | |
1819 | ||
3abe9331 | 1820 | void CHARACTER_STRING_identification_syntaxes_template::set_param(Module_Param& param) |
1821 | { | |
1822 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
1823 | Module_Param_Ptr mp = ¶m; | |
1824 | if (param.get_type() == Module_Param::MP_Reference) { | |
1825 | mp = param.get_referenced_param(); | |
1826 | } | |
1827 | switch (mp->get_type()) { | |
1828 | case Module_Param::MP_Omit: | |
1829 | *this = OMIT_VALUE; | |
1830 | break; | |
1831 | case Module_Param::MP_Any: | |
1832 | *this = ANY_VALUE; | |
1833 | break; | |
1834 | case Module_Param::MP_AnyOrNone: | |
1835 | *this = ANY_OR_OMIT; | |
1836 | break; | |
1837 | case Module_Param::MP_List_Template: | |
1838 | case Module_Param::MP_ComplementList_Template: { | |
1839 | CHARACTER_STRING_identification_syntaxes_template temp; | |
1840 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
1841 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
1842 | for (size_t i=0; i<mp->get_size(); i++) { | |
1843 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
1844 | } | |
1845 | *this = temp; | |
1846 | break; } | |
1847 | case Module_Param::MP_Value_List: | |
1848 | if (mp->get_size()==0) break; | |
1849 | if (2!=mp->get_size()) { | |
1850 | param.error("record template of type CHARACTER STRING.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size()); | |
1851 | } | |
1852 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0)); | |
1853 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1)); | |
1854 | break; | |
1855 | case Module_Param::MP_Assignment_List: { | |
1856 | Vector<bool> value_used(mp->get_size()); | |
1857 | value_used.resize(mp->get_size(), false); | |
1858 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1859 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
1860 | if (!strcmp(curr_param->get_id()->get_name(), "abstract")) { | |
1861 | abstract().set_param(*curr_param); | |
1862 | value_used[val_idx]=true; | |
1863 | } | |
1864 | } | |
1865 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
1866 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
1867 | if (!strcmp(curr_param->get_id()->get_name(), "transfer")) { | |
1868 | transfer().set_param(*curr_param); | |
1869 | value_used[val_idx]=true; | |
1870 | } | |
1871 | } | |
1872 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
1873 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
1874 | break; | |
1875 | } | |
1876 | } break; | |
1877 | default: | |
1878 | param.type_error("record template", "CHARACTER STRING.identification.syntaxes"); | |
1879 | } | |
1880 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
1881 | } | |
1882 | ||
1883 | Module_Param* CHARACTER_STRING_identification_syntaxes_template::get_param(Module_Param_Name& param_name) const | |
1884 | { | |
1885 | Module_Param* mp = NULL; | |
1886 | switch (template_selection) { | |
1887 | case UNINITIALIZED_TEMPLATE: | |
1888 | mp = new Module_Param_Unbound(); | |
1889 | break; | |
1890 | case OMIT_VALUE: | |
1891 | mp = new Module_Param_Omit(); | |
1892 | break; | |
1893 | case ANY_VALUE: | |
1894 | mp = new Module_Param_Any(); | |
1895 | break; | |
1896 | case ANY_OR_OMIT: | |
1897 | mp = new Module_Param_AnyOrNone(); | |
1898 | break; | |
1899 | case SPECIFIC_VALUE: { | |
1900 | Module_Param* mp_field_abstract = single_value->field_abstract.get_param(param_name); | |
1901 | mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract"))); | |
1902 | Module_Param* mp_field_transfer = single_value->field_transfer.get_param(param_name); | |
1903 | mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer"))); | |
1904 | mp = new Module_Param_Assignment_List(); | |
1905 | mp->add_elem(mp_field_abstract); | |
1906 | mp->add_elem(mp_field_transfer); | |
1907 | break; } | |
1908 | case VALUE_LIST: | |
1909 | case COMPLEMENTED_LIST: { | |
1910 | if (template_selection == VALUE_LIST) { | |
1911 | mp = new Module_Param_List_Template(); | |
1912 | } | |
1913 | else { | |
1914 | mp = new Module_Param_ComplementList_Template(); | |
1915 | } | |
1916 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
1917 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
1918 | } | |
1919 | break; } | |
1920 | default: | |
1921 | break; | |
1922 | } | |
1923 | if (is_ifpresent) { | |
1924 | mp->set_ifpresent(); | |
1925 | } | |
1926 | return mp; | |
1927 | } | |
1928 | ||
970ed795 EL |
1929 | void CHARACTER_STRING_identification_syntaxes_template::clean_up() |
1930 | { | |
1931 | switch (template_selection) { | |
1932 | case SPECIFIC_VALUE: | |
1933 | delete single_value; | |
1934 | break; | |
1935 | case VALUE_LIST: | |
1936 | case COMPLEMENTED_LIST: | |
1937 | delete [] value_list.list_value; | |
1938 | break; | |
1939 | default: | |
1940 | break; | |
1941 | } | |
1942 | template_selection = UNINITIALIZED_TEMPLATE; | |
1943 | } | |
1944 | ||
1945 | void CHARACTER_STRING_identification_syntaxes_template::set_specific() | |
1946 | { | |
1947 | if (template_selection != SPECIFIC_VALUE) { | |
1948 | template_sel old_selection = template_selection; | |
1949 | clean_up(); | |
1950 | single_value = new single_value_struct; | |
1951 | set_selection(SPECIFIC_VALUE); | |
1952 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
1953 | single_value->field_abstract = ANY_VALUE; | |
1954 | single_value->field_transfer = ANY_VALUE; | |
1955 | } | |
1956 | } | |
1957 | } | |
1958 | ||
1959 | void CHARACTER_STRING_identification_syntaxes_template::copy_value(const CHARACTER_STRING_identification_syntaxes& other_value) | |
1960 | { | |
1961 | single_value = new single_value_struct; | |
1962 | single_value->field_abstract = other_value.abstract(); | |
1963 | single_value->field_transfer = other_value.transfer(); | |
1964 | set_selection(SPECIFIC_VALUE); | |
1965 | } | |
1966 | ||
1967 | void CHARACTER_STRING_identification_syntaxes_template::copy_template(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
1968 | { | |
1969 | switch (other_value.template_selection) { | |
1970 | case SPECIFIC_VALUE: | |
1971 | single_value = new single_value_struct(*other_value.single_value); | |
1972 | break; | |
1973 | case OMIT_VALUE: | |
1974 | case ANY_VALUE: | |
1975 | case ANY_OR_OMIT: | |
1976 | break; | |
1977 | case VALUE_LIST: | |
1978 | case COMPLEMENTED_LIST: | |
1979 | value_list.n_values = other_value.value_list.n_values; | |
1980 | value_list.list_value = new CHARACTER_STRING_identification_syntaxes_template[value_list.n_values]; | |
1981 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
1982 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
1983 | break; | |
1984 | default: | |
1985 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
1986 | } | |
1987 | set_selection(other_value); | |
1988 | } | |
1989 | ||
1990 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template() | |
1991 | { | |
1992 | } | |
1993 | ||
1994 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(template_sel other_value) | |
1995 | : Base_Template(other_value) | |
1996 | { | |
1997 | check_single_selection(other_value); | |
1998 | } | |
1999 | ||
2000 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes& other_value) | |
2001 | { | |
2002 | copy_value(other_value); | |
2003 | } | |
2004 | ||
2005 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const OPTIONAL<CHARACTER_STRING_identification_syntaxes>& other_value) | |
2006 | { | |
2007 | switch (other_value.get_selection()) { | |
2008 | case OPTIONAL_PRESENT: | |
2009 | copy_value((const CHARACTER_STRING_identification_syntaxes&)other_value); | |
2010 | break; | |
2011 | case OPTIONAL_OMIT: | |
2012 | set_selection(OMIT_VALUE); | |
2013 | break; | |
2014 | default: | |
2015 | TTCN_error("Creating a template of type CHARACTER STRING.identification.syntaxes from an unbound optional field."); | |
2016 | } | |
2017 | } | |
2018 | ||
2019 | CHARACTER_STRING_identification_syntaxes_template::CHARACTER_STRING_identification_syntaxes_template(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
2020 | : Base_Template() | |
2021 | { | |
2022 | copy_template(other_value); | |
2023 | } | |
2024 | ||
2025 | CHARACTER_STRING_identification_syntaxes_template::~CHARACTER_STRING_identification_syntaxes_template() | |
2026 | { | |
2027 | clean_up(); | |
2028 | } | |
2029 | ||
2030 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(template_sel other_value) | |
2031 | { | |
2032 | check_single_selection(other_value); | |
2033 | clean_up(); | |
2034 | set_selection(other_value); | |
2035 | return *this; | |
2036 | } | |
2037 | ||
2038 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes& other_value) | |
2039 | { | |
2040 | clean_up(); | |
2041 | copy_value(other_value); | |
2042 | return *this; | |
2043 | } | |
2044 | ||
2045 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const OPTIONAL<CHARACTER_STRING_identification_syntaxes>& other_value) | |
2046 | { | |
2047 | clean_up(); | |
2048 | switch (other_value.get_selection()) { | |
2049 | case OPTIONAL_PRESENT: | |
2050 | copy_value((const CHARACTER_STRING_identification_syntaxes&)other_value); | |
2051 | break; | |
2052 | case OPTIONAL_OMIT: | |
2053 | set_selection(OMIT_VALUE); | |
2054 | break; | |
2055 | default: | |
2056 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.syntaxes."); | |
2057 | } | |
2058 | return *this; | |
2059 | } | |
2060 | ||
2061 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::operator=(const CHARACTER_STRING_identification_syntaxes_template& other_value) | |
2062 | { | |
2063 | if (&other_value != this) { | |
2064 | clean_up(); | |
2065 | copy_template(other_value); | |
2066 | } | |
2067 | return *this; | |
2068 | } | |
2069 | ||
3abe9331 | 2070 | boolean CHARACTER_STRING_identification_syntaxes_template::match(const CHARACTER_STRING_identification_syntaxes& other_value, |
2071 | boolean /* legacy */) const | |
970ed795 EL |
2072 | { |
2073 | switch (template_selection) { | |
2074 | case ANY_VALUE: | |
2075 | case ANY_OR_OMIT: | |
2076 | return TRUE; | |
2077 | case OMIT_VALUE: | |
2078 | return FALSE; | |
2079 | case SPECIFIC_VALUE: | |
2080 | if (!other_value.abstract().is_bound()) return FALSE; | |
2081 | if (!single_value->field_abstract.match(other_value.abstract())) return FALSE; | |
2082 | if (!other_value.transfer().is_bound()) return FALSE; | |
2083 | if (!single_value->field_transfer.match(other_value.transfer())) return FALSE; | |
2084 | return TRUE; | |
2085 | case VALUE_LIST: | |
2086 | case COMPLEMENTED_LIST: | |
2087 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2088 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
2089 | return template_selection == COMPLEMENTED_LIST; | |
2090 | default: | |
2091 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2092 | } | |
2093 | return FALSE; | |
2094 | } | |
2095 | ||
2096 | CHARACTER_STRING_identification_syntaxes CHARACTER_STRING_identification_syntaxes_template::valueof() const | |
2097 | { | |
2098 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
2099 | TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.syntaxes."); | |
2100 | CHARACTER_STRING_identification_syntaxes ret_val; | |
2101 | ret_val.abstract() = single_value->field_abstract.valueof(); | |
2102 | ret_val.transfer() = single_value->field_transfer.valueof(); | |
2103 | return ret_val; | |
2104 | } | |
2105 | ||
2106 | void CHARACTER_STRING_identification_syntaxes_template::set_type(template_sel template_type, unsigned int list_length) | |
2107 | { | |
2108 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
2109 | TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.syntaxes."); | |
2110 | clean_up(); | |
2111 | set_selection(template_type); | |
2112 | value_list.n_values = list_length; | |
2113 | value_list.list_value = new CHARACTER_STRING_identification_syntaxes_template[list_length]; | |
2114 | } | |
2115 | ||
2116 | CHARACTER_STRING_identification_syntaxes_template& CHARACTER_STRING_identification_syntaxes_template::list_item(unsigned int list_index) const | |
2117 | { | |
2118 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
2119 | TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.syntaxes."); | |
2120 | if (list_index >= value_list.n_values) | |
2121 | TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.syntaxes."); | |
2122 | return value_list.list_value[list_index]; | |
2123 | } | |
2124 | ||
2125 | OBJID_template& CHARACTER_STRING_identification_syntaxes_template::abstract() | |
2126 | { | |
2127 | set_specific(); | |
2128 | return single_value->field_abstract; | |
2129 | } | |
2130 | ||
2131 | const OBJID_template& CHARACTER_STRING_identification_syntaxes_template::abstract() const | |
2132 | { | |
2133 | if (template_selection != SPECIFIC_VALUE) | |
2134 | TTCN_error("Accessing field abstract of a non-specific template of type CHARACTER STRING.identification.syntaxes."); | |
2135 | return single_value->field_abstract; | |
2136 | } | |
2137 | ||
2138 | OBJID_template& CHARACTER_STRING_identification_syntaxes_template::transfer() | |
2139 | { | |
2140 | set_specific(); | |
2141 | return single_value->field_transfer; | |
2142 | } | |
2143 | ||
2144 | const OBJID_template& CHARACTER_STRING_identification_syntaxes_template::transfer() const | |
2145 | { | |
2146 | if (template_selection != SPECIFIC_VALUE) | |
2147 | TTCN_error("Accessing field transfer of a non-specific template of type CHARACTER STRING.identification.syntaxes."); | |
2148 | return single_value->field_transfer; | |
2149 | } | |
2150 | ||
2151 | int CHARACTER_STRING_identification_syntaxes_template::size_of() const | |
2152 | { | |
2153 | switch (template_selection) | |
2154 | { | |
2155 | case SPECIFIC_VALUE: | |
2156 | { | |
2157 | int ret_val = 2; | |
2158 | return ret_val; | |
2159 | } | |
2160 | case VALUE_LIST: | |
2161 | { | |
2162 | if (value_list.n_values<1) | |
2163 | TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing an empty list."); | |
2164 | int item_size = value_list.list_value[0].size_of(); | |
2165 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
2166 | { | |
2167 | if (value_list.list_value[i].size_of()!=item_size) | |
2168 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing a value list with different sizes."); | |
2169 | } | |
2170 | return item_size; | |
2171 | } | |
2172 | case OMIT_VALUE: | |
2173 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing omit value."); | |
2174 | case ANY_VALUE: | |
2175 | case ANY_OR_OMIT: | |
2176 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing */? value."); | |
2177 | case COMPLEMENTED_LIST: | |
2178 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.syntaxes containing complemented list."); | |
2179 | default: | |
2180 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2181 | } | |
2182 | return 0; | |
2183 | } | |
2184 | ||
2185 | void CHARACTER_STRING_identification_syntaxes_template::log() const | |
2186 | { | |
2187 | switch (template_selection) { | |
2188 | case SPECIFIC_VALUE: | |
2189 | TTCN_Logger::log_event_str("{ abstract := "); | |
2190 | single_value->field_abstract.log(); | |
2191 | TTCN_Logger::log_event_str(", transfer := "); | |
2192 | single_value->field_transfer.log(); | |
2193 | TTCN_Logger::log_event_str(" }"); | |
2194 | break; | |
2195 | case COMPLEMENTED_LIST: | |
2196 | TTCN_Logger::log_event_str("complement "); | |
2197 | // no break | |
2198 | case VALUE_LIST: | |
2199 | TTCN_Logger::log_char('('); | |
2200 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
2201 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
2202 | value_list.list_value[list_count].log(); | |
2203 | } | |
2204 | TTCN_Logger::log_char(')'); | |
2205 | break; | |
2206 | default: | |
2207 | log_generic(); | |
2208 | break; | |
2209 | } | |
2210 | log_ifpresent(); | |
2211 | } | |
2212 | ||
3abe9331 | 2213 | void CHARACTER_STRING_identification_syntaxes_template::log_match(const CHARACTER_STRING_identification_syntaxes& match_value, |
2214 | boolean /* legacy */) const | |
970ed795 EL |
2215 | { |
2216 | if (template_selection == SPECIFIC_VALUE) { | |
2217 | TTCN_Logger::log_event_str("{ abstract := "); | |
2218 | single_value->field_abstract.log_match(match_value.abstract()); | |
2219 | TTCN_Logger::log_event_str(", transfer := "); | |
2220 | single_value->field_transfer.log_match(match_value.transfer()); | |
2221 | TTCN_Logger::log_event_str(" }"); | |
2222 | } else { | |
2223 | match_value.log(); | |
2224 | TTCN_Logger::log_event_str(" with "); | |
2225 | log(); | |
2226 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2227 | else TTCN_Logger::log_event_str(" unmatched"); | |
2228 | } | |
2229 | } | |
2230 | ||
2231 | void CHARACTER_STRING_identification_syntaxes_template::encode_text(Text_Buf& text_buf) const | |
2232 | { | |
2233 | encode_text_base(text_buf); | |
2234 | switch (template_selection) { | |
2235 | case SPECIFIC_VALUE: | |
2236 | single_value->field_abstract.encode_text(text_buf); | |
2237 | single_value->field_transfer.encode_text(text_buf); | |
2238 | break; | |
2239 | case OMIT_VALUE: | |
2240 | case ANY_VALUE: | |
2241 | case ANY_OR_OMIT: | |
2242 | break; | |
2243 | case VALUE_LIST: | |
2244 | case COMPLEMENTED_LIST: | |
2245 | text_buf.push_int(value_list.n_values); | |
2246 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2247 | value_list.list_value[list_count].encode_text(text_buf); | |
2248 | break; | |
2249 | default: | |
2250 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); | |
2251 | } | |
2252 | } | |
2253 | ||
2254 | void CHARACTER_STRING_identification_syntaxes_template::decode_text(Text_Buf& text_buf) | |
2255 | { | |
2256 | clean_up(); | |
2257 | decode_text_base(text_buf); | |
2258 | switch (template_selection) { | |
2259 | case SPECIFIC_VALUE: | |
2260 | single_value = new single_value_struct; | |
2261 | single_value->field_abstract.decode_text(text_buf); | |
2262 | single_value->field_transfer.decode_text(text_buf); | |
2263 | break; | |
2264 | case OMIT_VALUE: | |
2265 | case ANY_VALUE: | |
2266 | case ANY_OR_OMIT: | |
2267 | break; | |
2268 | case VALUE_LIST: | |
2269 | case COMPLEMENTED_LIST: | |
2270 | value_list.n_values = text_buf.pull_int().get_val(); | |
2271 | value_list.list_value = new CHARACTER_STRING_identification_syntaxes_template[value_list.n_values]; | |
2272 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2273 | value_list.list_value[list_count].decode_text(text_buf); | |
2274 | break; | |
2275 | default: | |
2276 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.syntaxes."); | |
2277 | } | |
2278 | } | |
2279 | ||
3abe9331 | 2280 | boolean CHARACTER_STRING_identification_syntaxes_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
2281 | { |
2282 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 2283 | return !match_omit(legacy); |
970ed795 EL |
2284 | } |
2285 | ||
3abe9331 | 2286 | boolean CHARACTER_STRING_identification_syntaxes_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
2287 | { |
2288 | if (is_ifpresent) return TRUE; | |
2289 | switch (template_selection) { | |
2290 | case OMIT_VALUE: | |
2291 | case ANY_OR_OMIT: | |
2292 | return TRUE; | |
2293 | case VALUE_LIST: | |
2294 | case COMPLEMENTED_LIST: | |
3abe9331 | 2295 | if (legacy) { |
2296 | for (unsigned int i=0; i<value_list.n_values; i++) | |
2297 | if (value_list.list_value[i].match_omit()) | |
2298 | return template_selection==VALUE_LIST; | |
2299 | return template_selection==COMPLEMENTED_LIST; | |
2300 | } // else fall through | |
970ed795 EL |
2301 | default: |
2302 | return FALSE; | |
2303 | } | |
2304 | return FALSE; | |
2305 | } | |
2306 | ||
2307 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 2308 | void CHARACTER_STRING_identification_syntaxes_template::check_restriction(template_res t_res, const char* t_name, |
2309 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
2310 | { |
2311 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
2312 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
2313 | case TR_VALUE: | |
2314 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
2315 | break; | |
2316 | case TR_OMIT: | |
2317 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
2318 | template_selection==SPECIFIC_VALUE)) return; | |
2319 | break; | |
2320 | case TR_PRESENT: | |
3abe9331 | 2321 | if (!match_omit(legacy)) return; |
970ed795 EL |
2322 | break; |
2323 | default: | |
2324 | return; | |
2325 | } | |
2326 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
2327 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING.identification.syntaxes"); | |
2328 | } | |
2329 | #endif | |
2330 | ||
2331 | CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation() | |
2332 | { | |
2333 | } | |
2334 | ||
2335 | CHARACTER_STRING_identification_context__negotiation::CHARACTER_STRING_identification_context__negotiation(const INTEGER& par_presentation__context__id, | |
2336 | const OBJID& par_transfer__syntax) | |
2337 | : field_presentation__context__id(par_presentation__context__id), | |
2338 | field_transfer__syntax(par_transfer__syntax) | |
2339 | { | |
2340 | } | |
2341 | ||
2342 | boolean CHARACTER_STRING_identification_context__negotiation::operator==(const CHARACTER_STRING_identification_context__negotiation& other_value) const | |
2343 | { | |
2344 | return field_presentation__context__id==other_value.field_presentation__context__id | |
2345 | && field_transfer__syntax==other_value.field_transfer__syntax; | |
2346 | } | |
2347 | ||
2348 | int CHARACTER_STRING_identification_context__negotiation::size_of() const | |
2349 | { | |
2350 | int ret_val = 2; | |
2351 | return ret_val; | |
2352 | } | |
2353 | ||
2354 | void CHARACTER_STRING_identification_context__negotiation::log() const | |
2355 | { | |
2356 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2357 | field_presentation__context__id.log(); | |
2358 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2359 | field_transfer__syntax.log(); | |
2360 | TTCN_Logger::log_event_str(" }"); | |
2361 | } | |
2362 | ||
2363 | boolean CHARACTER_STRING_identification_context__negotiation::is_bound() const | |
2364 | { | |
2365 | if(field_presentation__context__id.is_bound()) return TRUE; | |
2366 | if(field_transfer__syntax.is_bound()) return TRUE; | |
2367 | return FALSE; | |
2368 | } | |
2369 | ||
2370 | boolean CHARACTER_STRING_identification_context__negotiation::is_value() const | |
2371 | { | |
2372 | if(!field_presentation__context__id.is_value()) return FALSE; | |
2373 | if(!field_transfer__syntax.is_value()) return FALSE; | |
2374 | return TRUE; | |
2375 | } | |
2376 | ||
2377 | void CHARACTER_STRING_identification_context__negotiation::clean_up() | |
2378 | { | |
2379 | field_presentation__context__id.clean_up(); | |
2380 | field_transfer__syntax.clean_up(); | |
2381 | } | |
2382 | ||
2383 | void CHARACTER_STRING_identification_context__negotiation::set_param(Module_Param& param) | |
2384 | { | |
2385 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 2386 | Module_Param_Ptr mp = ¶m; |
2387 | if (param.get_type() == Module_Param::MP_Reference) { | |
2388 | mp = param.get_referenced_param(); | |
2389 | } | |
2390 | switch (mp->get_type()) { | |
970ed795 | 2391 | case Module_Param::MP_Value_List: |
3abe9331 | 2392 | if (mp->get_size()==0) return; |
2393 | if (2!=mp->get_size()) { | |
2394 | param.error("record value of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 2395 | } |
3abe9331 | 2396 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0)); |
2397 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1)); | |
970ed795 EL |
2398 | break; |
2399 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 2400 | Vector<bool> value_used(mp->get_size()); |
2401 | value_used.resize(mp->get_size(), false); | |
2402 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2403 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
2404 | if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) { |
2405 | presentation__context__id().set_param(*curr_param); | |
2406 | value_used[val_idx]=true; | |
2407 | } | |
2408 | } | |
3abe9331 | 2409 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
2410 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
2411 | if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) { |
2412 | transfer__syntax().set_param(*curr_param); | |
2413 | value_used[val_idx]=true; | |
2414 | } | |
2415 | } | |
3abe9331 | 2416 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
2417 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
2418 | break; |
2419 | } | |
2420 | } break; | |
2421 | default: | |
2422 | param.type_error("record value", "CHARACTER STRING.identification.context-negotiation"); | |
2423 | } | |
2424 | } | |
2425 | ||
3abe9331 | 2426 | Module_Param* CHARACTER_STRING_identification_context__negotiation::get_param(Module_Param_Name& param_name) const |
970ed795 | 2427 | { |
3abe9331 | 2428 | if (!is_bound()) { |
2429 | return new Module_Param_Unbound(); | |
970ed795 | 2430 | } |
3abe9331 | 2431 | Module_Param* mp_field_presentation_context_id = field_presentation__context__id.get_param(param_name); |
2432 | mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
2433 | Module_Param* mp_field_transfer_syntax = field_transfer__syntax.get_param(param_name); | |
2434 | mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
2435 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
2436 | mp->add_elem(mp_field_presentation_context_id); | |
2437 | mp->add_elem(mp_field_transfer_syntax); | |
2438 | return mp; | |
970ed795 EL |
2439 | } |
2440 | ||
2441 | void CHARACTER_STRING_identification_context__negotiation::encode_text(Text_Buf& text_buf) const | |
2442 | { | |
2443 | field_presentation__context__id.encode_text(text_buf); | |
2444 | field_transfer__syntax.encode_text(text_buf); | |
2445 | } | |
2446 | ||
2447 | void CHARACTER_STRING_identification_context__negotiation::decode_text(Text_Buf& text_buf) | |
2448 | { | |
2449 | field_presentation__context__id.decode_text(text_buf); | |
2450 | field_transfer__syntax.decode_text(text_buf); | |
2451 | } | |
2452 | ||
2453 | /* not called | |
2454 | void CHARACTER_STRING_identification_context__negotiation::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
2455 | void CHARACTER_STRING_identification_context__negotiation::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
2456 | */ | |
2457 | ||
2458 | ASN_BER_TLV_t* CHARACTER_STRING_identification_context__negotiation::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
2459 | { | |
2460 | BER_chk_descr(p_td); | |
2461 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
2462 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
2463 | TTCN_EncDec_ErrorContext ec_1; | |
2464 | ec_1.set_msg("presentation_context_id': "); | |
2465 | new_tlv->add_TLV(field_presentation__context__id.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_, p_coding)); | |
2466 | ec_1.set_msg("transfer_syntax': "); | |
2467 | new_tlv->add_TLV(field_transfer__syntax.BER_encode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_, p_coding)); | |
2468 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
2469 | return new_tlv; | |
2470 | } | |
2471 | ||
2472 | boolean CHARACTER_STRING_identification_context__negotiation::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
2473 | { | |
2474 | BER_chk_descr(p_td); | |
2475 | ASN_BER_TLV_t stripped_tlv; | |
2476 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
2477 | TTCN_EncDec_ErrorContext ec_0("While decoding 'CHARACTER STRING.identification.context-negotiation' type: "); | |
2478 | stripped_tlv.chk_constructed_flag(TRUE); | |
2479 | size_t V_pos=0; | |
2480 | ASN_BER_TLV_t tmp_tlv; | |
2481 | boolean tlv_present=FALSE; | |
2482 | { | |
2483 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
2484 | TTCN_EncDec_ErrorContext ec_2; | |
2485 | ec_2.set_msg("presentation_context_id': "); | |
2486 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
2487 | if(!tlv_present) return FALSE; | |
2488 | field_presentation__context__id.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_presentation__context__id_descr_, tmp_tlv, L_form); | |
2489 | tlv_present=FALSE; | |
2490 | ec_2.set_msg("transfer_syntax': "); | |
2491 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
2492 | if(!tlv_present) return FALSE; | |
2493 | field_transfer__syntax.BER_decode_TLV(CHARACTER_STRING_identification_context__negotiation_transfer__syntax_descr_, tmp_tlv, L_form); | |
2494 | tlv_present=FALSE; | |
2495 | } | |
2496 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
2497 | return TRUE; | |
2498 | } | |
2499 | ||
2500 | int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 2501 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const |
970ed795 EL |
2502 | { |
2503 | int encoded_length=(int)p_buf.get_len(); | |
2504 | ||
2505 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
2506 | ||
af710487 | 2507 | field_presentation__context__id.XER_encode(CHARACTER_STRING_identification_pci_xer_, p_buf, flavor, indent, 0); |
2508 | field_transfer__syntax .XER_encode(CHARACTER_STRING_identification_ts_xer_ , p_buf, flavor, indent, 0); | |
970ed795 EL |
2509 | |
2510 | end_xml(p_td, p_buf, flavor, --indent, false); | |
2511 | ||
2512 | return p_buf.get_len() - encoded_length; | |
2513 | } | |
2514 | ||
2515 | int CHARACTER_STRING_identification_context__negotiation::XER_decode( | |
feade998 | 2516 | const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
2517 | { |
2518 | int exer = is_exer(flavor); | |
2519 | int type = reader.NodeType(), depth = -1; | |
2520 | const char* name = (const char*)reader.Name(); | |
2521 | int success = reader.Ok(); | |
2522 | if (type==XML_READER_TYPE_ELEMENT && check_name(name, p_td, exer)) { | |
2523 | // we are in the right place | |
2524 | depth = reader.Depth(); | |
2525 | success = reader.Read(); | |
2526 | } | |
feade998 | 2527 | field_presentation__context__id.XER_decode(EMBEDDED_PDV_identification_cn_pci_xer_, reader, flavor, flavor2, 0); |
2528 | field_transfer__syntax .XER_decode(EMBEDDED_PDV_identification_cn_tsx_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
2529 | for (; success == 1; success = reader.Read()) { |
2530 | type = reader.NodeType(); | |
2531 | if (XML_READER_TYPE_END_ELEMENT == type) { | |
2532 | verify_end(reader, p_td, depth, exer); | |
2533 | reader.Read(); | |
2534 | break; | |
2535 | } | |
2536 | } | |
2537 | return 0; // TODO sensible return value | |
2538 | } | |
2539 | ||
2540 | struct CHARACTER_STRING_identification_context__negotiation_template::single_value_struct { | |
2541 | INTEGER_template field_presentation__context__id; | |
2542 | OBJID_template field_transfer__syntax; | |
2543 | }; | |
2544 | ||
3abe9331 | 2545 | void CHARACTER_STRING_identification_context__negotiation_template::set_param(Module_Param& param) |
2546 | { | |
2547 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
2548 | Module_Param_Ptr mp = ¶m; | |
2549 | if (param.get_type() == Module_Param::MP_Reference) { | |
2550 | mp = param.get_referenced_param(); | |
2551 | } | |
2552 | switch (mp->get_type()) { | |
2553 | case Module_Param::MP_Omit: | |
2554 | *this = OMIT_VALUE; | |
2555 | break; | |
2556 | case Module_Param::MP_Any: | |
2557 | *this = ANY_VALUE; | |
2558 | break; | |
2559 | case Module_Param::MP_AnyOrNone: | |
2560 | *this = ANY_OR_OMIT; | |
2561 | break; | |
2562 | case Module_Param::MP_List_Template: | |
2563 | case Module_Param::MP_ComplementList_Template: { | |
2564 | CHARACTER_STRING_identification_context__negotiation_template temp; | |
2565 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
2566 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
2567 | for (size_t i=0; i<mp->get_size(); i++) { | |
2568 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
2569 | } | |
2570 | *this = temp; | |
2571 | break; } | |
2572 | case Module_Param::MP_Value_List: | |
2573 | if (mp->get_size()==0) break; | |
2574 | if (2!=mp->get_size()) { | |
2575 | param.error("record template of type CHARACTER STRING.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size()); | |
2576 | } | |
2577 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0)); | |
2578 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1)); | |
2579 | break; | |
2580 | case Module_Param::MP_Assignment_List: { | |
2581 | Vector<bool> value_used(mp->get_size()); | |
2582 | value_used.resize(mp->get_size(), false); | |
2583 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2584 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
2585 | if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) { | |
2586 | presentation__context__id().set_param(*curr_param); | |
2587 | value_used[val_idx]=true; | |
2588 | } | |
2589 | } | |
2590 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
2591 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
2592 | if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) { | |
2593 | transfer__syntax().set_param(*curr_param); | |
2594 | value_used[val_idx]=true; | |
2595 | } | |
2596 | } | |
2597 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
2598 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
2599 | break; | |
2600 | } | |
2601 | } break; | |
2602 | default: | |
2603 | param.type_error("record template", "CHARACTER STRING.identification.context-negotiation"); | |
2604 | } | |
2605 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
2606 | } | |
2607 | ||
2608 | Module_Param* CHARACTER_STRING_identification_context__negotiation_template::get_param(Module_Param_Name& param_name) const | |
2609 | { | |
2610 | Module_Param* mp = NULL; | |
2611 | switch (template_selection) { | |
2612 | case UNINITIALIZED_TEMPLATE: | |
2613 | mp = new Module_Param_Unbound(); | |
2614 | break; | |
2615 | case OMIT_VALUE: | |
2616 | mp = new Module_Param_Omit(); | |
2617 | break; | |
2618 | case ANY_VALUE: | |
2619 | mp = new Module_Param_Any(); | |
2620 | break; | |
2621 | case ANY_OR_OMIT: | |
2622 | mp = new Module_Param_AnyOrNone(); | |
2623 | break; | |
2624 | case SPECIFIC_VALUE: { | |
2625 | Module_Param* mp_field_presentation_context_id = single_value->field_presentation__context__id.get_param(param_name); | |
2626 | mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id"))); | |
2627 | Module_Param* mp_field_transfer_syntax = single_value->field_transfer__syntax.get_param(param_name); | |
2628 | mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax"))); | |
2629 | mp = new Module_Param_Assignment_List(); | |
2630 | mp->add_elem(mp_field_presentation_context_id); | |
2631 | mp->add_elem(mp_field_transfer_syntax); | |
2632 | break; } | |
2633 | case VALUE_LIST: | |
2634 | case COMPLEMENTED_LIST: { | |
2635 | if (template_selection == VALUE_LIST) { | |
2636 | mp = new Module_Param_List_Template(); | |
2637 | } | |
2638 | else { | |
2639 | mp = new Module_Param_ComplementList_Template(); | |
2640 | } | |
2641 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
2642 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
2643 | } | |
2644 | break; } | |
2645 | default: | |
2646 | break; | |
2647 | } | |
2648 | if (is_ifpresent) { | |
2649 | mp->set_ifpresent(); | |
2650 | } | |
2651 | return mp; | |
2652 | } | |
2653 | ||
970ed795 EL |
2654 | void CHARACTER_STRING_identification_context__negotiation_template::clean_up() |
2655 | { | |
2656 | switch (template_selection) { | |
2657 | case SPECIFIC_VALUE: | |
2658 | delete single_value; | |
2659 | break; | |
2660 | case VALUE_LIST: | |
2661 | case COMPLEMENTED_LIST: | |
2662 | delete [] value_list.list_value; | |
2663 | break; | |
2664 | default: | |
2665 | break; | |
2666 | } | |
2667 | template_selection = UNINITIALIZED_TEMPLATE; | |
2668 | } | |
2669 | ||
2670 | void CHARACTER_STRING_identification_context__negotiation_template::set_specific() | |
2671 | { | |
2672 | if (template_selection != SPECIFIC_VALUE) { | |
2673 | template_sel old_selection = template_selection; | |
2674 | clean_up(); | |
2675 | single_value = new single_value_struct; | |
2676 | set_selection(SPECIFIC_VALUE); | |
2677 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
2678 | single_value->field_presentation__context__id = ANY_VALUE; | |
2679 | single_value->field_transfer__syntax = ANY_VALUE; | |
2680 | } | |
2681 | } | |
2682 | } | |
2683 | ||
2684 | void CHARACTER_STRING_identification_context__negotiation_template::copy_value(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2685 | { | |
2686 | single_value = new single_value_struct; | |
2687 | single_value->field_presentation__context__id = other_value.presentation__context__id(); | |
2688 | single_value->field_transfer__syntax = other_value.transfer__syntax(); | |
2689 | set_selection(SPECIFIC_VALUE); | |
2690 | } | |
2691 | ||
2692 | void CHARACTER_STRING_identification_context__negotiation_template::copy_template(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2693 | { | |
2694 | switch (other_value.template_selection) { | |
2695 | case SPECIFIC_VALUE: | |
2696 | single_value = new single_value_struct(*other_value.single_value); | |
2697 | break; | |
2698 | case OMIT_VALUE: | |
2699 | case ANY_VALUE: | |
2700 | case ANY_OR_OMIT: | |
2701 | break; | |
2702 | case VALUE_LIST: | |
2703 | case COMPLEMENTED_LIST: | |
2704 | value_list.n_values = other_value.value_list.n_values; | |
2705 | value_list.list_value = new CHARACTER_STRING_identification_context__negotiation_template[value_list.n_values]; | |
2706 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2707 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
2708 | break; | |
2709 | default: | |
2710 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2711 | } | |
2712 | set_selection(other_value); | |
2713 | } | |
2714 | ||
2715 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template() | |
2716 | { | |
2717 | } | |
2718 | ||
2719 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(template_sel other_value) | |
2720 | : Base_Template(other_value) | |
2721 | { | |
2722 | check_single_selection(other_value); | |
2723 | } | |
2724 | ||
2725 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2726 | { | |
2727 | copy_value(other_value); | |
2728 | } | |
2729 | ||
2730 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const OPTIONAL<CHARACTER_STRING_identification_context__negotiation>& other_value) | |
2731 | { | |
2732 | switch (other_value.get_selection()) { | |
2733 | case OPTIONAL_PRESENT: | |
2734 | copy_value((const CHARACTER_STRING_identification_context__negotiation&)other_value); | |
2735 | break; | |
2736 | case OPTIONAL_OMIT: | |
2737 | set_selection(OMIT_VALUE); | |
2738 | break; | |
2739 | default: | |
2740 | TTCN_error("Creating a template of type CHARACTER STRING.identification.context-negotiation from an unbound optional field."); | |
2741 | } | |
2742 | } | |
2743 | ||
2744 | CHARACTER_STRING_identification_context__negotiation_template::CHARACTER_STRING_identification_context__negotiation_template(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2745 | : Base_Template() | |
2746 | { | |
2747 | copy_template(other_value); | |
2748 | } | |
2749 | ||
2750 | CHARACTER_STRING_identification_context__negotiation_template::~CHARACTER_STRING_identification_context__negotiation_template() | |
2751 | { | |
2752 | clean_up(); | |
2753 | } | |
2754 | ||
2755 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(template_sel other_value) | |
2756 | { | |
2757 | check_single_selection(other_value); | |
2758 | clean_up(); | |
2759 | set_selection(other_value); | |
2760 | return *this; | |
2761 | } | |
2762 | ||
2763 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation& other_value) | |
2764 | { | |
2765 | clean_up(); | |
2766 | copy_value(other_value); | |
2767 | return *this; | |
2768 | } | |
2769 | ||
2770 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const OPTIONAL<CHARACTER_STRING_identification_context__negotiation>& other_value) | |
2771 | { | |
2772 | clean_up(); | |
2773 | switch (other_value.get_selection()) { | |
2774 | case OPTIONAL_PRESENT: | |
2775 | copy_value((const CHARACTER_STRING_identification_context__negotiation&)other_value); | |
2776 | break; | |
2777 | case OPTIONAL_OMIT: | |
2778 | set_selection(OMIT_VALUE); | |
2779 | break; | |
2780 | default: | |
2781 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING.identification.context-negotiation."); | |
2782 | } | |
2783 | return *this; | |
2784 | } | |
2785 | ||
2786 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::operator=(const CHARACTER_STRING_identification_context__negotiation_template& other_value) | |
2787 | { | |
2788 | if (&other_value != this) { | |
2789 | clean_up(); | |
2790 | copy_template(other_value); | |
2791 | } | |
2792 | return *this; | |
2793 | } | |
2794 | ||
3abe9331 | 2795 | boolean CHARACTER_STRING_identification_context__negotiation_template::match(const CHARACTER_STRING_identification_context__negotiation& other_value, |
2796 | boolean /* legacy */) const | |
970ed795 EL |
2797 | { |
2798 | switch (template_selection) { | |
2799 | case ANY_VALUE: | |
2800 | case ANY_OR_OMIT: | |
2801 | return TRUE; | |
2802 | case OMIT_VALUE: | |
2803 | return FALSE; | |
2804 | case SPECIFIC_VALUE: | |
2805 | if (!other_value.presentation__context__id().is_bound()) return FALSE; | |
2806 | if (!single_value->field_presentation__context__id.match(other_value.presentation__context__id())) return FALSE; | |
2807 | if (!other_value.transfer__syntax().is_bound()) return FALSE; | |
2808 | if (!single_value->field_transfer__syntax.match(other_value.transfer__syntax())) return FALSE; | |
2809 | return TRUE; | |
2810 | case VALUE_LIST: | |
2811 | case COMPLEMENTED_LIST: | |
2812 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2813 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
2814 | return template_selection == COMPLEMENTED_LIST; | |
2815 | default: | |
2816 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2817 | } | |
2818 | return FALSE; | |
2819 | } | |
2820 | ||
2821 | CHARACTER_STRING_identification_context__negotiation CHARACTER_STRING_identification_context__negotiation_template::valueof() const | |
2822 | { | |
2823 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
2824 | TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING.identification.context-negotiation."); | |
2825 | CHARACTER_STRING_identification_context__negotiation ret_val; | |
2826 | ret_val.presentation__context__id() = single_value->field_presentation__context__id.valueof(); | |
2827 | ret_val.transfer__syntax() = single_value->field_transfer__syntax.valueof(); | |
2828 | return ret_val; | |
2829 | } | |
2830 | ||
2831 | void CHARACTER_STRING_identification_context__negotiation_template::set_type(template_sel template_type, unsigned int list_length) | |
2832 | { | |
2833 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
2834 | TTCN_error("Setting an invalid list for a template of type CHARACTER STRING.identification.context-negotiation."); | |
2835 | clean_up(); | |
2836 | set_selection(template_type); | |
2837 | value_list.n_values = list_length; | |
2838 | value_list.list_value = new CHARACTER_STRING_identification_context__negotiation_template[list_length]; | |
2839 | } | |
2840 | ||
2841 | CHARACTER_STRING_identification_context__negotiation_template& CHARACTER_STRING_identification_context__negotiation_template::list_item(unsigned int list_index) const | |
2842 | { | |
2843 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
2844 | TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING.identification.context-negotiation."); | |
2845 | if (list_index >= value_list.n_values) | |
2846 | TTCN_error("Index overflow in a value list template of type CHARACTER STRING.identification.context-negotiation."); | |
2847 | return value_list.list_value[list_index]; | |
2848 | } | |
2849 | ||
2850 | INTEGER_template& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() | |
2851 | { | |
2852 | set_specific(); | |
2853 | return single_value->field_presentation__context__id; | |
2854 | } | |
2855 | ||
2856 | const INTEGER_template& CHARACTER_STRING_identification_context__negotiation_template::presentation__context__id() const | |
2857 | { | |
2858 | if (template_selection != SPECIFIC_VALUE) | |
2859 | TTCN_error("Accessing field presentation_context_id of a non-specific template of type CHARACTER STRING.identification.context-negotiation."); | |
2860 | return single_value->field_presentation__context__id; | |
2861 | } | |
2862 | ||
2863 | OBJID_template& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() | |
2864 | { | |
2865 | set_specific(); | |
2866 | return single_value->field_transfer__syntax; | |
2867 | } | |
2868 | ||
2869 | const OBJID_template& CHARACTER_STRING_identification_context__negotiation_template::transfer__syntax() const | |
2870 | { | |
2871 | if (template_selection != SPECIFIC_VALUE) | |
2872 | TTCN_error("Accessing field transfer_syntax of a non-specific template of type CHARACTER STRING.identification.context-negotiation."); | |
2873 | return single_value->field_transfer__syntax; | |
2874 | } | |
2875 | ||
2876 | int CHARACTER_STRING_identification_context__negotiation_template::size_of() const | |
2877 | { | |
2878 | switch (template_selection) | |
2879 | { | |
2880 | case SPECIFIC_VALUE: | |
2881 | { | |
2882 | int ret_val = 2; | |
2883 | return ret_val; | |
2884 | } | |
2885 | case VALUE_LIST: | |
2886 | { | |
2887 | if (value_list.n_values<1) | |
2888 | TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing an empty list."); | |
2889 | int item_size = value_list.list_value[0].size_of(); | |
2890 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
2891 | { | |
2892 | if (value_list.list_value[i].size_of()!=item_size) | |
2893 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing a value list with different sizes."); | |
2894 | } | |
2895 | return item_size; | |
2896 | } | |
2897 | case OMIT_VALUE: | |
2898 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing omit value."); | |
2899 | case ANY_VALUE: | |
2900 | case ANY_OR_OMIT: | |
2901 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing */? value."); | |
2902 | case COMPLEMENTED_LIST: | |
2903 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING.identification.context-negotiation containing complemented list."); | |
2904 | default: | |
2905 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2906 | } | |
2907 | return 0; | |
2908 | } | |
2909 | ||
2910 | void CHARACTER_STRING_identification_context__negotiation_template::log() const | |
2911 | { | |
2912 | switch (template_selection) { | |
2913 | case SPECIFIC_VALUE: | |
2914 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2915 | single_value->field_presentation__context__id.log(); | |
2916 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2917 | single_value->field_transfer__syntax.log(); | |
2918 | TTCN_Logger::log_event_str(" }"); | |
2919 | break; | |
2920 | case COMPLEMENTED_LIST: | |
2921 | TTCN_Logger::log_event_str("complement "); | |
2922 | // no break | |
2923 | case VALUE_LIST: | |
2924 | TTCN_Logger::log_char('('); | |
2925 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
2926 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
2927 | value_list.list_value[list_count].log(); | |
2928 | } | |
2929 | TTCN_Logger::log_char(')'); | |
2930 | break; | |
2931 | default: | |
2932 | log_generic(); | |
2933 | break; | |
2934 | } | |
2935 | log_ifpresent(); | |
2936 | } | |
2937 | ||
3abe9331 | 2938 | void CHARACTER_STRING_identification_context__negotiation_template::log_match(const CHARACTER_STRING_identification_context__negotiation& match_value, |
2939 | boolean /* legacy */) const | |
970ed795 EL |
2940 | { |
2941 | if (template_selection == SPECIFIC_VALUE) { | |
2942 | TTCN_Logger::log_event_str("{ presentation_context_id := "); | |
2943 | single_value->field_presentation__context__id.log_match(match_value.presentation__context__id()); | |
2944 | TTCN_Logger::log_event_str(", transfer_syntax := "); | |
2945 | single_value->field_transfer__syntax.log_match(match_value.transfer__syntax()); | |
2946 | TTCN_Logger::log_event_str(" }"); | |
2947 | } else { | |
2948 | match_value.log(); | |
2949 | TTCN_Logger::log_event_str(" with "); | |
2950 | log(); | |
2951 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
2952 | else TTCN_Logger::log_event_str(" unmatched"); | |
2953 | } | |
2954 | } | |
2955 | ||
2956 | void CHARACTER_STRING_identification_context__negotiation_template::encode_text(Text_Buf& text_buf) const | |
2957 | { | |
2958 | encode_text_base(text_buf); | |
2959 | switch (template_selection) { | |
2960 | case SPECIFIC_VALUE: | |
2961 | single_value->field_presentation__context__id.encode_text(text_buf); | |
2962 | single_value->field_transfer__syntax.encode_text(text_buf); | |
2963 | break; | |
2964 | case OMIT_VALUE: | |
2965 | case ANY_VALUE: | |
2966 | case ANY_OR_OMIT: | |
2967 | break; | |
2968 | case VALUE_LIST: | |
2969 | case COMPLEMENTED_LIST: | |
2970 | text_buf.push_int(value_list.n_values); | |
2971 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2972 | value_list.list_value[list_count].encode_text(text_buf); | |
2973 | break; | |
2974 | default: | |
2975 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); | |
2976 | } | |
2977 | } | |
2978 | ||
2979 | void CHARACTER_STRING_identification_context__negotiation_template::decode_text(Text_Buf& text_buf) | |
2980 | { | |
2981 | clean_up(); | |
2982 | decode_text_base(text_buf); | |
2983 | switch (template_selection) { | |
2984 | case SPECIFIC_VALUE: | |
2985 | single_value = new single_value_struct; | |
2986 | single_value->field_presentation__context__id.decode_text(text_buf); | |
2987 | single_value->field_transfer__syntax.decode_text(text_buf); | |
2988 | break; | |
2989 | case OMIT_VALUE: | |
2990 | case ANY_VALUE: | |
2991 | case ANY_OR_OMIT: | |
2992 | break; | |
2993 | case VALUE_LIST: | |
2994 | case COMPLEMENTED_LIST: | |
2995 | value_list.n_values = text_buf.pull_int().get_val(); | |
2996 | value_list.list_value = new CHARACTER_STRING_identification_context__negotiation_template[value_list.n_values]; | |
2997 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
2998 | value_list.list_value[list_count].decode_text(text_buf); | |
2999 | break; | |
3000 | default: | |
3001 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING.identification.context-negotiation."); | |
3002 | } | |
3003 | } | |
3004 | ||
3abe9331 | 3005 | boolean CHARACTER_STRING_identification_context__negotiation_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
3006 | { |
3007 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 3008 | return !match_omit(legacy); |
970ed795 EL |
3009 | } |
3010 | ||
3abe9331 | 3011 | boolean CHARACTER_STRING_identification_context__negotiation_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
3012 | { |
3013 | if (is_ifpresent) return TRUE; | |
3014 | switch (template_selection) { | |
3015 | case OMIT_VALUE: | |
3016 | case ANY_OR_OMIT: | |
3017 | return TRUE; | |
3018 | case VALUE_LIST: | |
3019 | case COMPLEMENTED_LIST: | |
3abe9331 | 3020 | if (legacy) { |
3021 | for (unsigned int i=0; i<value_list.n_values; i++) | |
3022 | if (value_list.list_value[i].match_omit()) | |
3023 | return template_selection==VALUE_LIST; | |
3024 | return template_selection==COMPLEMENTED_LIST; | |
3025 | } // else fall through | |
970ed795 EL |
3026 | default: |
3027 | return FALSE; | |
3028 | } | |
3029 | return FALSE; | |
3030 | } | |
3031 | ||
3032 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3033 | void CHARACTER_STRING_identification_context__negotiation_template::check_restriction(template_res t_res, const char* t_name, |
3034 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3035 | { |
3036 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3037 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3038 | case TR_VALUE: | |
3039 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3040 | break; | |
3041 | case TR_OMIT: | |
3042 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3043 | template_selection==SPECIFIC_VALUE)) return; | |
3044 | break; | |
3045 | case TR_PRESENT: | |
3abe9331 | 3046 | if (!match_omit(legacy)) return; |
970ed795 EL |
3047 | break; |
3048 | default: | |
3049 | return; | |
3050 | } | |
3051 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
3052 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING.identification.context-negotiation"); | |
3053 | } | |
3054 | #endif | |
3055 | ||
3056 | CHARACTER_STRING::CHARACTER_STRING() | |
3057 | { | |
3058 | } | |
3059 | ||
3060 | CHARACTER_STRING::CHARACTER_STRING(const CHARACTER_STRING_identification& par_identification, | |
3061 | const OPTIONAL<UNIVERSAL_CHARSTRING>& par_data__value__descriptor, | |
3062 | const OCTETSTRING& par_string__value) | |
3063 | : field_identification(par_identification), | |
3064 | field_data__value__descriptor(par_data__value__descriptor), | |
3065 | field_string__value(par_string__value) | |
3066 | { | |
3067 | } | |
3068 | ||
3069 | boolean CHARACTER_STRING::operator==(const CHARACTER_STRING& other_value) const | |
3070 | { | |
3071 | return field_identification==other_value.field_identification | |
3072 | && field_data__value__descriptor==other_value.field_data__value__descriptor | |
3073 | && field_string__value==other_value.field_string__value; | |
3074 | } | |
3075 | ||
3076 | int CHARACTER_STRING::size_of() const | |
3077 | { | |
3078 | int ret_val = 2; | |
3079 | if (field_data__value__descriptor.ispresent()) ret_val++; | |
3080 | return ret_val; | |
3081 | } | |
3082 | ||
3083 | boolean CHARACTER_STRING::is_bound() const | |
3084 | { | |
3085 | if(field_identification.is_bound()) return TRUE; | |
3086 | if(OPTIONAL_OMIT == field_data__value__descriptor.get_selection() || field_data__value__descriptor.is_bound()) return TRUE; | |
3087 | if(field_string__value.is_bound()) return TRUE; | |
3088 | return FALSE; | |
3089 | } | |
3090 | ||
3091 | boolean CHARACTER_STRING::is_value() const | |
3092 | { | |
3093 | if(!field_identification.is_value()) return FALSE; | |
3094 | if(OPTIONAL_OMIT != field_data__value__descriptor.get_selection() && !field_data__value__descriptor.is_value()) return FALSE; | |
3095 | if(!field_string__value.is_value()) return FALSE; | |
3096 | return TRUE; | |
3097 | } | |
3098 | ||
3099 | void CHARACTER_STRING::clean_up() | |
3100 | { | |
3101 | field_identification.clean_up(); | |
3102 | field_data__value__descriptor.clean_up(); | |
3103 | field_string__value.clean_up(); | |
3104 | } | |
3105 | ||
3106 | void CHARACTER_STRING::log() const | |
3107 | { | |
3108 | TTCN_Logger::log_event_str("{ identification := "); | |
3109 | field_identification.log(); | |
3110 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3111 | field_data__value__descriptor.log(); | |
3112 | TTCN_Logger::log_event_str(", string_value := "); | |
3113 | field_string__value.log(); | |
3114 | TTCN_Logger::log_event_str(" }"); | |
3115 | } | |
3116 | ||
3117 | void CHARACTER_STRING::set_param(Module_Param& param) | |
3118 | { | |
3119 | param.basic_check(Module_Param::BC_VALUE, "record value"); | |
3abe9331 | 3120 | Module_Param_Ptr mp = ¶m; |
3121 | if (param.get_type() == Module_Param::MP_Reference) { | |
3122 | mp = param.get_referenced_param(); | |
3123 | } | |
3124 | switch (mp->get_type()) { | |
970ed795 | 3125 | case Module_Param::MP_Value_List: |
3abe9331 | 3126 | if (mp->get_size()==0) return; |
3127 | if (3!=mp->get_size()) { | |
3128 | param.error("record value of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp->get_size()); | |
970ed795 | 3129 | } |
3abe9331 | 3130 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0)); |
3131 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1)); | |
3132 | if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) string__value().set_param(*mp->get_elem(2)); | |
970ed795 EL |
3133 | break; |
3134 | case Module_Param::MP_Assignment_List: { | |
3abe9331 | 3135 | Vector<bool> value_used(mp->get_size()); |
3136 | value_used.resize(mp->get_size(), false); | |
3137 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3138 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3139 | if (!strcmp(curr_param->get_id()->get_name(), "identification")) { |
3140 | identification().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++) { |
3145 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3146 | if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) { |
3147 | data__value__descriptor().set_param(*curr_param); | |
3148 | value_used[val_idx]=true; | |
3149 | } | |
3150 | } | |
3abe9331 | 3151 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { |
3152 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
970ed795 EL |
3153 | if (!strcmp(curr_param->get_id()->get_name(), "string_value")) { |
3154 | string__value().set_param(*curr_param); | |
3155 | value_used[val_idx]=true; | |
3156 | } | |
3157 | } | |
3abe9331 | 3158 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { |
3159 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
970ed795 EL |
3160 | break; |
3161 | } | |
3162 | } break; | |
3163 | default: | |
3164 | param.type_error("record value", "CHARACTER STRING"); | |
3165 | } | |
3166 | } | |
3167 | ||
3abe9331 | 3168 | Module_Param* CHARACTER_STRING::get_param(Module_Param_Name& param_name) const |
970ed795 | 3169 | { |
3abe9331 | 3170 | if (!is_bound()) { |
3171 | return new Module_Param_Unbound(); | |
970ed795 | 3172 | } |
3abe9331 | 3173 | Module_Param* mp_field_identification = field_identification.get_param(param_name); |
3174 | mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification"))); | |
3175 | Module_Param* mp_field_data_value_descriptor = field_data__value__descriptor.get_param(param_name); | |
3176 | mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor"))); | |
3177 | Module_Param* mp_field_string_value = field_string__value.get_param(param_name); | |
3178 | mp_field_string_value->set_id(new Module_Param_FieldName(mcopystr("string_value"))); | |
3179 | Module_Param_Assignment_List* mp = new Module_Param_Assignment_List(); | |
3180 | mp->add_elem(mp_field_identification); | |
3181 | mp->add_elem(mp_field_data_value_descriptor); | |
3182 | mp->add_elem(mp_field_string_value); | |
3183 | return mp; | |
970ed795 EL |
3184 | } |
3185 | ||
3186 | void CHARACTER_STRING::encode_text(Text_Buf& text_buf) const | |
3187 | { | |
3188 | field_identification.encode_text(text_buf); | |
3189 | field_data__value__descriptor.encode_text(text_buf); | |
3190 | field_string__value.encode_text(text_buf); | |
3191 | } | |
3192 | ||
3193 | void CHARACTER_STRING::decode_text(Text_Buf& text_buf) | |
3194 | { | |
3195 | field_identification.decode_text(text_buf); | |
3196 | field_data__value__descriptor.decode_text(text_buf); | |
3197 | field_string__value.decode_text(text_buf); | |
3198 | } | |
3199 | ||
3200 | void CHARACTER_STRING::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const | |
3201 | { | |
3202 | va_list pvar; | |
3203 | va_start(pvar, p_coding); | |
3204 | switch(p_coding) { | |
3205 | case TTCN_EncDec::CT_BER: { | |
3206 | TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name); | |
3207 | unsigned BER_coding=va_arg(pvar, unsigned); | |
3208 | BER_encode_chk_coding(BER_coding); | |
3209 | ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding); | |
3210 | tlv->put_in_buffer(p_buf); | |
3211 | ASN_BER_TLV_t::destruct(tlv); | |
3212 | break;} | |
3213 | case TTCN_EncDec::CT_RAW: { | |
3214 | TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name); | |
3215 | TTCN_EncDec_ErrorContext::error_internal | |
3216 | ("No RAW descriptor available for type '%s'.", p_td.name); | |
3217 | break;} | |
3218 | case TTCN_EncDec::CT_TEXT: { | |
3219 | TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name); | |
3220 | TTCN_EncDec_ErrorContext::error_internal | |
3221 | ("No TEXT descriptor available for type '%s'.", p_td.name); | |
3222 | break;} | |
3223 | case TTCN_EncDec::CT_XER: { | |
3224 | TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name); | |
3225 | unsigned XER_coding=va_arg(pvar, unsigned); | |
af710487 | 3226 | XER_encode(*p_td.xer,p_buf, XER_coding, 0, 0); |
970ed795 EL |
3227 | p_buf.put_c('\n'); |
3228 | break;} | |
3229 | case TTCN_EncDec::CT_JSON: { | |
3230 | TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name); | |
3231 | TTCN_EncDec_ErrorContext::error_internal | |
3232 | ("No JSON descriptor available for type '%s'.", p_td.name); | |
3233 | break;} | |
3234 | default: | |
3235 | TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name); | |
3236 | } | |
3237 | va_end(pvar); | |
3238 | } | |
3239 | ||
3240 | void CHARACTER_STRING::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) | |
3241 | { | |
3242 | va_list pvar; | |
3243 | va_start(pvar, p_coding); | |
3244 | switch(p_coding) { | |
3245 | case TTCN_EncDec::CT_BER: { | |
3246 | TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name); | |
3247 | unsigned L_form=va_arg(pvar, unsigned); | |
3248 | ASN_BER_TLV_t tlv; | |
3249 | BER_decode_str2TLV(p_buf, tlv, L_form); | |
3250 | BER_decode_TLV(p_td, tlv, L_form); | |
3251 | if(tlv.isComplete) p_buf.increase_pos(tlv.get_len()); | |
3252 | break;} | |
3253 | case TTCN_EncDec::CT_RAW: { | |
3254 | TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name); | |
3255 | TTCN_EncDec_ErrorContext::error_internal | |
3256 | ("No RAW descriptor available for type '%s'.", p_td.name); | |
3257 | break;} | |
3258 | case TTCN_EncDec::CT_TEXT: { | |
3259 | TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name); | |
3260 | TTCN_EncDec_ErrorContext::error_internal | |
3261 | ("No TEXT descriptor available for type '%s'.", p_td.name); | |
3262 | break;} | |
3263 | case TTCN_EncDec::CT_XER: { | |
3264 | TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name); | |
3265 | unsigned XER_coding=va_arg(pvar, unsigned); | |
3266 | XmlReaderWrap reader(p_buf); | |
3267 | int success = reader.Read(); | |
3268 | for (; success==1; success=reader.Read()) { | |
3269 | int type = reader.NodeType(); | |
3270 | if (type==XML_READER_TYPE_ELEMENT) | |
3271 | break; | |
3272 | } | |
feade998 | 3273 | XER_decode(*p_td.xer, reader, XER_coding, XER_NONE, 0); |
970ed795 EL |
3274 | size_t bytes = reader.ByteConsumed(); |
3275 | p_buf.set_pos(bytes); | |
3276 | break;} | |
3277 | case TTCN_EncDec::CT_JSON: { | |
3278 | TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name); | |
3279 | TTCN_EncDec_ErrorContext::error_internal | |
3280 | ("No JSON descriptor available for type '%s'.", p_td.name); | |
3281 | break;} | |
3282 | default: | |
3283 | TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name); | |
3284 | } | |
3285 | va_end(pvar); | |
3286 | } | |
3287 | ||
3288 | ASN_BER_TLV_t* CHARACTER_STRING::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, unsigned p_coding) const | |
3289 | { | |
3290 | BER_chk_descr(p_td); | |
3291 | ASN_BER_TLV_t *new_tlv=ASN_BER_TLV_t::construct(NULL); | |
3292 | TTCN_EncDec_ErrorContext ec_0("Component '"); | |
3293 | TTCN_EncDec_ErrorContext ec_1; | |
3294 | ec_1.set_msg("identification': "); | |
3295 | new_tlv->add_TLV(field_identification.BER_encode_TLV(CHARACTER_STRING_identification_descr_, p_coding)); | |
3296 | ec_1.set_msg("data_value_descriptor': "); | |
3297 | new_tlv->add_TLV(field_data__value__descriptor.BER_encode_TLV(CHARACTER_STRING_data__value__descriptor_descr_, p_coding)); | |
3298 | ec_1.set_msg("string_value': "); | |
3299 | new_tlv->add_TLV(field_string__value.BER_encode_TLV(CHARACTER_STRING_string__value_descr_, p_coding)); | |
3300 | new_tlv=ASN_BER_V2TLV(new_tlv, p_td, p_coding); | |
3301 | return new_tlv; | |
3302 | } | |
3303 | ||
3304 | boolean CHARACTER_STRING::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, const ASN_BER_TLV_t& p_tlv, unsigned L_form) | |
3305 | { | |
3306 | BER_chk_descr(p_td); | |
3307 | ASN_BER_TLV_t stripped_tlv; | |
3308 | BER_decode_strip_tags(*p_td.ber, p_tlv, L_form, stripped_tlv); | |
3309 | TTCN_EncDec_ErrorContext ec_0("While decoding 'CHARACTER STRING' type: "); | |
3310 | stripped_tlv.chk_constructed_flag(TRUE); | |
3311 | size_t V_pos=0; | |
3312 | ASN_BER_TLV_t tmp_tlv; | |
3313 | boolean tlv_present=FALSE; | |
3314 | { | |
3315 | TTCN_EncDec_ErrorContext ec_1("Component '"); | |
3316 | TTCN_EncDec_ErrorContext ec_2; | |
3317 | ec_2.set_msg("identification': "); | |
3318 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3319 | if(!tlv_present) return FALSE; | |
3320 | field_identification.BER_decode_TLV(CHARACTER_STRING_identification_descr_, tmp_tlv, L_form); | |
3321 | tlv_present=FALSE; | |
3322 | ec_2.set_msg("data_value_descriptor': "); | |
3323 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3324 | if(!tlv_present) field_data__value__descriptor=OMIT_VALUE; | |
3325 | else { | |
3326 | field_data__value__descriptor.BER_decode_TLV(CHARACTER_STRING_data__value__descriptor_descr_, tmp_tlv, L_form); | |
3327 | if(field_data__value__descriptor.ispresent()) tlv_present=FALSE; | |
3328 | } | |
3329 | ec_2.set_msg("string_value': "); | |
3330 | if(!tlv_present) tlv_present=BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, tmp_tlv); | |
3331 | if(!tlv_present) return FALSE; | |
3332 | field_string__value.BER_decode_TLV(CHARACTER_STRING_string__value_descr_, tmp_tlv, L_form); | |
3333 | tlv_present=FALSE; | |
3334 | } | |
3335 | BER_decode_constdTLV_end(stripped_tlv, V_pos, L_form, tmp_tlv, tlv_present); | |
3336 | return TRUE; | |
3337 | } | |
3338 | ||
af710487 | 3339 | int CHARACTER_STRING::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, |
3340 | unsigned int flavor, int indent, embed_values_enc_struct_t*) const | |
970ed795 EL |
3341 | { |
3342 | if(!is_bound()) { | |
3343 | TTCN_EncDec_ErrorContext::error | |
3344 | (TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value."); | |
3345 | } | |
3346 | int encoded_length=(int)p_buf.get_len(); | |
3347 | ||
3348 | flavor &= ~XER_RECOF; // ASN.1 character string doesn't care | |
3349 | begin_xml(p_td, p_buf, flavor, indent++, false); | |
3350 | ||
af710487 | 3351 | field_identification.XER_encode(CHARACTER_STRING_identification_xer_, p_buf, flavor, indent, 0); |
970ed795 EL |
3352 | // data-value-descriptor is OPTIONAL and can never be present. |
3353 | // Its encoding is empty. | |
af710487 | 3354 | field_string__value .XER_encode(CHARACTER_STRING_data_value_xer_ , p_buf, flavor, indent, 0); |
970ed795 EL |
3355 | |
3356 | end_xml(p_td, p_buf, flavor, --indent, false); | |
3357 | ||
3358 | return (int)p_buf.get_len() - encoded_length; | |
3359 | } | |
3360 | ||
3361 | int CHARACTER_STRING::XER_decode(const XERdescriptor_t& p_td, | |
feade998 | 3362 | XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*) |
970ed795 EL |
3363 | { |
3364 | int exer = is_exer(flavor); | |
3365 | int success = reader.Ok(), depth = -1, type; | |
3366 | for (; success == 1; success = reader.Read()) { | |
3367 | type = reader.NodeType(); | |
3368 | if (XML_READER_TYPE_ELEMENT == type) { | |
3369 | verify_name(reader, p_td, exer); | |
3370 | depth = reader.Depth(); | |
3371 | reader.Read(); | |
3372 | break; | |
3373 | } | |
3374 | } | |
feade998 | 3375 | field_identification .XER_decode(CHARACTER_STRING_identification_xer_ , reader, flavor, flavor2, 0); |
3376 | field_data__value__descriptor.XER_decode(CHARACTER_STRING_data_value_descriptor_xer_, reader, flavor, flavor2, 0); | |
970ed795 EL |
3377 | if (field_data__value__descriptor.is_value()) { |
3378 | TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG, | |
3379 | "data-value-descriptor not allowed for EMBEDDED PDV"); | |
3380 | } | |
feade998 | 3381 | field_string__value .XER_decode(CHARACTER_STRING_data_value_xer_ , reader, flavor, flavor2, 0); |
970ed795 EL |
3382 | for (success = reader.Read(); success == 1; success = reader.Read()) { |
3383 | type = reader.NodeType(); | |
3384 | if (XML_READER_TYPE_END_ELEMENT == type) { | |
3385 | verify_end(reader, p_td, depth, exer); | |
3386 | reader.Read(); | |
3387 | break; | |
3388 | } | |
3389 | } | |
3390 | return 1; | |
3391 | ||
3392 | } | |
3393 | ||
3394 | ||
3395 | struct CHARACTER_STRING_template::single_value_struct { | |
3396 | CHARACTER_STRING_identification_template field_identification; | |
3397 | UNIVERSAL_CHARSTRING_template field_data__value__descriptor; | |
3398 | OCTETSTRING_template field_string__value; | |
3399 | }; | |
3400 | ||
3abe9331 | 3401 | void CHARACTER_STRING_template::set_param(Module_Param& param) |
3402 | { | |
3403 | param.basic_check(Module_Param::BC_TEMPLATE, "record template"); | |
3404 | Module_Param_Ptr mp = ¶m; | |
3405 | if (param.get_type() == Module_Param::MP_Reference) { | |
3406 | mp = param.get_referenced_param(); | |
3407 | } | |
3408 | switch (mp->get_type()) { | |
3409 | case Module_Param::MP_Omit: | |
3410 | *this = OMIT_VALUE; | |
3411 | break; | |
3412 | case Module_Param::MP_Any: | |
3413 | *this = ANY_VALUE; | |
3414 | break; | |
3415 | case Module_Param::MP_AnyOrNone: | |
3416 | *this = ANY_OR_OMIT; | |
3417 | break; | |
3418 | case Module_Param::MP_List_Template: | |
3419 | case Module_Param::MP_ComplementList_Template: { | |
3420 | CHARACTER_STRING_template temp; | |
3421 | temp.set_type(mp->get_type() == Module_Param::MP_List_Template ? | |
3422 | VALUE_LIST : COMPLEMENTED_LIST, mp->get_size()); | |
3423 | for (size_t i=0; i<mp->get_size(); i++) { | |
3424 | temp.list_item(i).set_param(*mp->get_elem(i)); | |
3425 | } | |
3426 | *this = temp; | |
3427 | break; } | |
3428 | case Module_Param::MP_Value_List: | |
3429 | if (mp->get_size()==0) break; | |
3430 | if (3!=mp->get_size()) { | |
3431 | param.error("record template of type CHARACTER STRING has 3 fields but list value has %d fields", (int)mp->get_size()); | |
3432 | } | |
3433 | if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0)); | |
3434 | if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1)); | |
3435 | if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) string__value().set_param(*mp->get_elem(2)); | |
3436 | break; | |
3437 | case Module_Param::MP_Assignment_List: { | |
3438 | Vector<bool> value_used(mp->get_size()); | |
3439 | value_used.resize(mp->get_size(), false); | |
3440 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3441 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3442 | if (!strcmp(curr_param->get_id()->get_name(), "identification")) { | |
3443 | identification().set_param(*curr_param); | |
3444 | value_used[val_idx]=true; | |
3445 | } | |
3446 | } | |
3447 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3448 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3449 | if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) { | |
3450 | data__value__descriptor().set_param(*curr_param); | |
3451 | value_used[val_idx]=true; | |
3452 | } | |
3453 | } | |
3454 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) { | |
3455 | Module_Param* const curr_param = mp->get_elem(val_idx); | |
3456 | if (!strcmp(curr_param->get_id()->get_name(), "string_value")) { | |
3457 | string__value().set_param(*curr_param); | |
3458 | value_used[val_idx]=true; | |
3459 | } | |
3460 | } | |
3461 | for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) { | |
3462 | mp->get_elem(val_idx)->error("Non existent field name in type CHARACTER STRING: %s", mp->get_elem(val_idx)->get_id()->get_name()); | |
3463 | break; | |
3464 | } | |
3465 | } break; | |
3466 | default: | |
3467 | param.type_error("record template", "CHARACTER STRING"); | |
3468 | } | |
3469 | is_ifpresent = param.get_ifpresent() || mp->get_ifpresent(); | |
3470 | } | |
3471 | ||
3472 | Module_Param* CHARACTER_STRING_template::get_param(Module_Param_Name& param_name) const | |
3473 | { | |
3474 | Module_Param* mp = NULL; | |
3475 | switch (template_selection) { | |
3476 | case UNINITIALIZED_TEMPLATE: | |
3477 | mp = new Module_Param_Unbound(); | |
3478 | break; | |
3479 | case OMIT_VALUE: | |
3480 | mp = new Module_Param_Omit(); | |
3481 | break; | |
3482 | case ANY_VALUE: | |
3483 | mp = new Module_Param_Any(); | |
3484 | break; | |
3485 | case ANY_OR_OMIT: | |
3486 | mp = new Module_Param_AnyOrNone(); | |
3487 | break; | |
3488 | case SPECIFIC_VALUE: { | |
3489 | Module_Param* mp_field_identification = single_value->field_identification.get_param(param_name); | |
3490 | mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification"))); | |
3491 | Module_Param* mp_field_data_value_descriptor = single_value->field_data__value__descriptor.get_param(param_name); | |
3492 | mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor"))); | |
3493 | Module_Param* mp_field_string_value = single_value->field_string__value.get_param(param_name); | |
3494 | mp_field_string_value->set_id(new Module_Param_FieldName(mcopystr("string_value"))); | |
3495 | mp = new Module_Param_Assignment_List(); | |
3496 | mp->add_elem(mp_field_identification); | |
3497 | mp->add_elem(mp_field_data_value_descriptor); | |
3498 | mp->add_elem(mp_field_string_value); | |
3499 | break; } | |
3500 | case VALUE_LIST: | |
3501 | case COMPLEMENTED_LIST: { | |
3502 | if (template_selection == VALUE_LIST) { | |
3503 | mp = new Module_Param_List_Template(); | |
3504 | } | |
3505 | else { | |
3506 | mp = new Module_Param_ComplementList_Template(); | |
3507 | } | |
3508 | for (size_t i = 0; i < value_list.n_values; ++i) { | |
3509 | mp->add_elem(value_list.list_value[i].get_param(param_name)); | |
3510 | } | |
3511 | break; } | |
3512 | default: | |
3513 | break; | |
3514 | } | |
3515 | if (is_ifpresent) { | |
3516 | mp->set_ifpresent(); | |
3517 | } | |
3518 | return mp; | |
3519 | } | |
3520 | ||
970ed795 EL |
3521 | void CHARACTER_STRING_template::clean_up() |
3522 | { | |
3523 | switch (template_selection) { | |
3524 | case SPECIFIC_VALUE: | |
3525 | delete single_value; | |
3526 | break; | |
3527 | case VALUE_LIST: | |
3528 | case COMPLEMENTED_LIST: | |
3529 | delete [] value_list.list_value; | |
3530 | break; | |
3531 | default: | |
3532 | break; | |
3533 | } | |
3534 | template_selection = UNINITIALIZED_TEMPLATE; | |
3535 | } | |
3536 | ||
3537 | void CHARACTER_STRING_template::set_specific() | |
3538 | { | |
3539 | if (template_selection != SPECIFIC_VALUE) { | |
3540 | template_sel old_selection = template_selection; | |
3541 | clean_up(); | |
3542 | single_value = new single_value_struct; | |
3543 | set_selection(SPECIFIC_VALUE); | |
3544 | if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { | |
3545 | single_value->field_identification = ANY_VALUE; | |
3546 | single_value->field_data__value__descriptor = ANY_OR_OMIT; | |
3547 | single_value->field_string__value = ANY_VALUE; | |
3548 | } | |
3549 | } | |
3550 | } | |
3551 | ||
3552 | void CHARACTER_STRING_template::copy_value(const CHARACTER_STRING& other_value) | |
3553 | { | |
3554 | single_value = new single_value_struct; | |
3555 | single_value->field_identification = other_value.identification(); | |
3556 | if (other_value.data__value__descriptor().ispresent()) single_value->field_data__value__descriptor = (const UNIVERSAL_CHARSTRING&)(other_value.data__value__descriptor()); | |
3557 | else single_value->field_data__value__descriptor = OMIT_VALUE; | |
3558 | single_value->field_string__value = other_value.string__value(); | |
3559 | set_selection(SPECIFIC_VALUE); | |
3560 | } | |
3561 | ||
3562 | void CHARACTER_STRING_template::copy_template(const CHARACTER_STRING_template& other_value) | |
3563 | { | |
3564 | switch (other_value.template_selection) { | |
3565 | case SPECIFIC_VALUE: | |
3566 | single_value = new single_value_struct(*other_value.single_value); | |
3567 | break; | |
3568 | case OMIT_VALUE: | |
3569 | case ANY_VALUE: | |
3570 | case ANY_OR_OMIT: | |
3571 | break; | |
3572 | case VALUE_LIST: | |
3573 | case COMPLEMENTED_LIST: | |
3574 | value_list.n_values = other_value.value_list.n_values; | |
3575 | value_list.list_value = new CHARACTER_STRING_template[value_list.n_values]; | |
3576 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3577 | value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); | |
3578 | break; | |
3579 | default: | |
3580 | TTCN_error("Copying an uninitialized/unsupported template of type CHARACTER STRING."); | |
3581 | } | |
3582 | set_selection(other_value); | |
3583 | } | |
3584 | ||
3585 | CHARACTER_STRING_template::CHARACTER_STRING_template() | |
3586 | { | |
3587 | } | |
3588 | ||
3589 | CHARACTER_STRING_template::CHARACTER_STRING_template(template_sel other_value) | |
3590 | : Base_Template(other_value) | |
3591 | { | |
3592 | check_single_selection(other_value); | |
3593 | } | |
3594 | ||
3595 | CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING& other_value) | |
3596 | { | |
3597 | copy_value(other_value); | |
3598 | } | |
3599 | ||
3600 | CHARACTER_STRING_template::CHARACTER_STRING_template(const OPTIONAL<CHARACTER_STRING>& other_value) | |
3601 | { | |
3602 | switch (other_value.get_selection()) { | |
3603 | case OPTIONAL_PRESENT: | |
3604 | copy_value((const CHARACTER_STRING&)other_value); | |
3605 | break; | |
3606 | case OPTIONAL_OMIT: | |
3607 | set_selection(OMIT_VALUE); | |
3608 | break; | |
3609 | default: | |
3610 | TTCN_error("Creating a template of type CHARACTER STRING from an unbound optional field."); | |
3611 | } | |
3612 | } | |
3613 | ||
3614 | CHARACTER_STRING_template::CHARACTER_STRING_template(const CHARACTER_STRING_template& other_value) | |
3615 | : Base_Template() | |
3616 | { | |
3617 | copy_template(other_value); | |
3618 | } | |
3619 | ||
3620 | CHARACTER_STRING_template::~CHARACTER_STRING_template() | |
3621 | { | |
3622 | clean_up(); | |
3623 | } | |
3624 | ||
3625 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(template_sel other_value) | |
3626 | { | |
3627 | check_single_selection(other_value); | |
3628 | clean_up(); | |
3629 | set_selection(other_value); | |
3630 | return *this; | |
3631 | } | |
3632 | ||
3633 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const CHARACTER_STRING& other_value) | |
3634 | { | |
3635 | clean_up(); | |
3636 | copy_value(other_value); | |
3637 | return *this; | |
3638 | } | |
3639 | ||
3640 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const OPTIONAL<CHARACTER_STRING>& other_value) | |
3641 | { | |
3642 | clean_up(); | |
3643 | switch (other_value.get_selection()) { | |
3644 | case OPTIONAL_PRESENT: | |
3645 | copy_value((const CHARACTER_STRING&)other_value); | |
3646 | break; | |
3647 | case OPTIONAL_OMIT: | |
3648 | set_selection(OMIT_VALUE); | |
3649 | break; | |
3650 | default: | |
3651 | TTCN_error("Assignment of an unbound optional field to a template of type CHARACTER STRING."); | |
3652 | } | |
3653 | return *this; | |
3654 | } | |
3655 | ||
3656 | CHARACTER_STRING_template& CHARACTER_STRING_template::operator=(const CHARACTER_STRING_template& other_value) | |
3657 | { | |
3658 | if (&other_value != this) { | |
3659 | clean_up(); | |
3660 | copy_template(other_value); | |
3661 | } | |
3662 | return *this; | |
3663 | } | |
3664 | ||
3abe9331 | 3665 | boolean CHARACTER_STRING_template::match(const CHARACTER_STRING& other_value, |
3666 | boolean /* legacy */) const | |
970ed795 EL |
3667 | { |
3668 | switch (template_selection) { | |
3669 | case ANY_VALUE: | |
3670 | case ANY_OR_OMIT: | |
3671 | return TRUE; | |
3672 | case OMIT_VALUE: | |
3673 | return FALSE; | |
3674 | case SPECIFIC_VALUE: | |
3675 | if (!other_value.identification().is_bound()) return FALSE; | |
3676 | if (!single_value->field_identification.match(other_value.identification())) return FALSE; | |
3677 | if (!other_value.data__value__descriptor().is_bound()) return FALSE; | |
3678 | if (other_value.data__value__descriptor().ispresent() ? !single_value->field_data__value__descriptor.match((const UNIVERSAL_CHARSTRING&)other_value.data__value__descriptor()) : !single_value->field_data__value__descriptor.match_omit()) return FALSE; | |
3679 | if (!other_value.string__value().is_bound()) return FALSE; | |
3680 | if (!single_value->field_string__value.match(other_value.string__value())) return FALSE; | |
3681 | return TRUE; | |
3682 | case VALUE_LIST: | |
3683 | case COMPLEMENTED_LIST: | |
3684 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3685 | if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; | |
3686 | return template_selection == COMPLEMENTED_LIST; | |
3687 | default: | |
3688 | TTCN_error("Matching an uninitialized/unsupported template of type CHARACTER STRING."); | |
3689 | } | |
3690 | return FALSE; | |
3691 | } | |
3692 | ||
3693 | CHARACTER_STRING CHARACTER_STRING_template::valueof() const | |
3694 | { | |
3695 | if (template_selection != SPECIFIC_VALUE || is_ifpresent) | |
3696 | TTCN_error("Performing valueof or send operation on a non-specific template of type CHARACTER STRING."); | |
3697 | CHARACTER_STRING ret_val; | |
3698 | ret_val.identification() = single_value->field_identification.valueof(); | |
3699 | if (single_value->field_data__value__descriptor.is_omit()) ret_val.data__value__descriptor() = OMIT_VALUE; | |
3700 | else ret_val.data__value__descriptor() = single_value->field_data__value__descriptor.valueof(); | |
3701 | ret_val.string__value() = single_value->field_string__value.valueof(); | |
3702 | return ret_val; | |
3703 | } | |
3704 | ||
3705 | void CHARACTER_STRING_template::set_type(template_sel template_type, unsigned int list_length) | |
3706 | { | |
3707 | if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) | |
3708 | TTCN_error("Setting an invalid list for a template of type CHARACTER STRING."); | |
3709 | clean_up(); | |
3710 | set_selection(template_type); | |
3711 | value_list.n_values = list_length; | |
3712 | value_list.list_value = new CHARACTER_STRING_template[list_length]; | |
3713 | } | |
3714 | ||
3715 | CHARACTER_STRING_template& CHARACTER_STRING_template::list_item(unsigned int list_index) const | |
3716 | { | |
3717 | if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) | |
3718 | TTCN_error("Accessing a list element of a non-list template of type CHARACTER STRING."); | |
3719 | if (list_index >= value_list.n_values) | |
3720 | TTCN_error("Index overflow in a value list template of type CHARACTER STRING."); | |
3721 | return value_list.list_value[list_index]; | |
3722 | } | |
3723 | ||
3724 | CHARACTER_STRING_identification_template& CHARACTER_STRING_template::identification() | |
3725 | { | |
3726 | set_specific(); | |
3727 | return single_value->field_identification; | |
3728 | } | |
3729 | ||
3730 | const CHARACTER_STRING_identification_template& CHARACTER_STRING_template::identification() const | |
3731 | { | |
3732 | if (template_selection != SPECIFIC_VALUE) | |
3733 | TTCN_error("Accessing field identification of a non-specific template of type CHARACTER STRING."); | |
3734 | return single_value->field_identification; | |
3735 | } | |
3736 | ||
3737 | UNIVERSAL_CHARSTRING_template& CHARACTER_STRING_template::data__value__descriptor() | |
3738 | { | |
3739 | set_specific(); | |
3740 | return single_value->field_data__value__descriptor; | |
3741 | } | |
3742 | ||
3743 | const UNIVERSAL_CHARSTRING_template& CHARACTER_STRING_template::data__value__descriptor() const | |
3744 | { | |
3745 | if (template_selection != SPECIFIC_VALUE) | |
3746 | TTCN_error("Accessing field data_value_descriptor of a non-specific template of type CHARACTER STRING."); | |
3747 | return single_value->field_data__value__descriptor; | |
3748 | } | |
3749 | ||
3750 | OCTETSTRING_template& CHARACTER_STRING_template::string__value() | |
3751 | { | |
3752 | set_specific(); | |
3753 | return single_value->field_string__value; | |
3754 | } | |
3755 | ||
3756 | const OCTETSTRING_template& CHARACTER_STRING_template::string__value() const | |
3757 | { | |
3758 | if (template_selection != SPECIFIC_VALUE) | |
3759 | TTCN_error("Accessing field string_value of a non-specific template of type CHARACTER STRING."); | |
3760 | return single_value->field_string__value; | |
3761 | } | |
3762 | ||
3763 | int CHARACTER_STRING_template::size_of() const | |
3764 | { | |
3765 | switch (template_selection) | |
3766 | { | |
3767 | case SPECIFIC_VALUE: | |
3768 | { | |
3769 | int ret_val = 2; | |
3770 | if (single_value->field_data__value__descriptor.is_present()) ret_val++; | |
3771 | return ret_val; | |
3772 | } | |
3773 | case VALUE_LIST: | |
3774 | { | |
3775 | if (value_list.n_values<1) | |
3776 | TTCN_error("Internal error: Performing sizeof() operation on a template of type CHARACTER STRING containing an empty list."); | |
3777 | int item_size = value_list.list_value[0].size_of(); | |
3778 | for (unsigned int i = 1; i < value_list.n_values; i++) | |
3779 | { | |
3780 | if (value_list.list_value[i].size_of()!=item_size) | |
3781 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing a value list with different sizes."); | |
3782 | } | |
3783 | return item_size; | |
3784 | } | |
3785 | case OMIT_VALUE: | |
3786 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing omit value."); | |
3787 | case ANY_VALUE: | |
3788 | case ANY_OR_OMIT: | |
3789 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing */? value."); | |
3790 | case COMPLEMENTED_LIST: | |
3791 | TTCN_error("Performing sizeof() operation on a template of type CHARACTER STRING containing complemented list."); | |
3792 | default: | |
3793 | TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type CHARACTER STRING."); | |
3794 | } | |
3795 | return 0; | |
3796 | } | |
3797 | ||
3798 | void CHARACTER_STRING_template::log() const | |
3799 | { | |
3800 | switch (template_selection) { | |
3801 | case SPECIFIC_VALUE: | |
3802 | TTCN_Logger::log_event_str("{ identification := "); | |
3803 | single_value->field_identification.log(); | |
3804 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3805 | single_value->field_data__value__descriptor.log(); | |
3806 | TTCN_Logger::log_event_str(", string_value := "); | |
3807 | single_value->field_string__value.log(); | |
3808 | TTCN_Logger::log_event_str(" }"); | |
3809 | break; | |
3810 | case COMPLEMENTED_LIST: | |
3811 | TTCN_Logger::log_event_str("complement "); | |
3812 | // no break | |
3813 | case VALUE_LIST: | |
3814 | TTCN_Logger::log_char('('); | |
3815 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { | |
3816 | if (list_count > 0) TTCN_Logger::log_event_str(", "); | |
3817 | value_list.list_value[list_count].log(); | |
3818 | } | |
3819 | TTCN_Logger::log_char(')'); | |
3820 | break; | |
3821 | default: | |
3822 | log_generic(); | |
3823 | break; | |
3824 | } | |
3825 | log_ifpresent(); | |
3826 | } | |
3827 | ||
3abe9331 | 3828 | void CHARACTER_STRING_template::log_match(const CHARACTER_STRING& match_value, |
3829 | boolean /* legacy */) const | |
970ed795 EL |
3830 | { |
3831 | if (template_selection == SPECIFIC_VALUE) { | |
3832 | TTCN_Logger::log_event_str("{ identification := "); | |
3833 | single_value->field_identification.log_match(match_value.identification()); | |
3834 | TTCN_Logger::log_event_str(", data_value_descriptor := "); | |
3835 | if (match_value.data__value__descriptor().ispresent()) single_value->field_data__value__descriptor.log_match(match_value.data__value__descriptor()); | |
3836 | else { | |
3837 | single_value->field_data__value__descriptor.log(); | |
3838 | if (single_value->field_data__value__descriptor.match_omit()) TTCN_Logger::log_event_str(" matched"); | |
3839 | else TTCN_Logger::log_event_str(" unmatched"); | |
3840 | } | |
3841 | TTCN_Logger::log_event_str(", string_value := "); | |
3842 | single_value->field_string__value.log_match(match_value.string__value()); | |
3843 | TTCN_Logger::log_event_str(" }"); | |
3844 | } else { | |
3845 | match_value.log(); | |
3846 | TTCN_Logger::log_event_str(" with "); | |
3847 | log(); | |
3848 | if (match(match_value)) TTCN_Logger::log_event_str(" matched"); | |
3849 | else TTCN_Logger::log_event_str(" unmatched"); | |
3850 | } | |
3851 | } | |
3852 | ||
3853 | void CHARACTER_STRING_template::encode_text(Text_Buf& text_buf) const | |
3854 | { | |
3855 | encode_text_base(text_buf); | |
3856 | switch (template_selection) { | |
3857 | case SPECIFIC_VALUE: | |
3858 | single_value->field_identification.encode_text(text_buf); | |
3859 | single_value->field_data__value__descriptor.encode_text(text_buf); | |
3860 | single_value->field_string__value.encode_text(text_buf); | |
3861 | break; | |
3862 | case OMIT_VALUE: | |
3863 | case ANY_VALUE: | |
3864 | case ANY_OR_OMIT: | |
3865 | break; | |
3866 | case VALUE_LIST: | |
3867 | case COMPLEMENTED_LIST: | |
3868 | text_buf.push_int(value_list.n_values); | |
3869 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3870 | value_list.list_value[list_count].encode_text(text_buf); | |
3871 | break; | |
3872 | default: | |
3873 | TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type CHARACTER STRING."); | |
3874 | } | |
3875 | } | |
3876 | ||
3877 | void CHARACTER_STRING_template::decode_text(Text_Buf& text_buf) | |
3878 | { | |
3879 | clean_up(); | |
3880 | decode_text_base(text_buf); | |
3881 | switch (template_selection) { | |
3882 | case SPECIFIC_VALUE: | |
3883 | single_value = new single_value_struct; | |
3884 | single_value->field_identification.decode_text(text_buf); | |
3885 | single_value->field_data__value__descriptor.decode_text(text_buf); | |
3886 | single_value->field_string__value.decode_text(text_buf); | |
3887 | break; | |
3888 | case OMIT_VALUE: | |
3889 | case ANY_VALUE: | |
3890 | case ANY_OR_OMIT: | |
3891 | break; | |
3892 | case VALUE_LIST: | |
3893 | case COMPLEMENTED_LIST: | |
3894 | value_list.n_values = text_buf.pull_int().get_val(); | |
3895 | value_list.list_value = new CHARACTER_STRING_template[value_list.n_values]; | |
3896 | for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) | |
3897 | value_list.list_value[list_count].decode_text(text_buf); | |
3898 | break; | |
3899 | default: | |
3900 | TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type CHARACTER STRING."); | |
3901 | } | |
3902 | } | |
3903 | ||
3abe9331 | 3904 | boolean CHARACTER_STRING_template::is_present(boolean legacy /* = FALSE */) const |
970ed795 EL |
3905 | { |
3906 | if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; | |
3abe9331 | 3907 | return !match_omit(legacy); |
970ed795 EL |
3908 | } |
3909 | ||
3abe9331 | 3910 | boolean CHARACTER_STRING_template::match_omit(boolean legacy /* = FALSE */) const |
970ed795 EL |
3911 | { |
3912 | if (is_ifpresent) return TRUE; | |
3913 | switch (template_selection) { | |
3914 | case OMIT_VALUE: | |
3915 | case ANY_OR_OMIT: | |
3916 | return TRUE; | |
3917 | case VALUE_LIST: | |
3918 | case COMPLEMENTED_LIST: | |
3abe9331 | 3919 | if (legacy) { |
3920 | // legacy behavior: 'omit' can appear in the value/complement list | |
3921 | for (unsigned int i=0; i<value_list.n_values; i++) | |
3922 | if (value_list.list_value[i].match_omit()) | |
3923 | return template_selection==VALUE_LIST; | |
3924 | return template_selection==COMPLEMENTED_LIST; | |
3925 | } | |
3926 | // else fall through | |
970ed795 EL |
3927 | default: |
3928 | return FALSE; | |
3929 | } | |
3930 | return FALSE; | |
3931 | } | |
3932 | ||
3933 | #ifndef TITAN_RUNTIME_2 | |
3abe9331 | 3934 | void CHARACTER_STRING_template::check_restriction(template_res t_res, const char* t_name, |
3935 | boolean legacy /* = FALSE */) const | |
970ed795 EL |
3936 | { |
3937 | if (template_selection==UNINITIALIZED_TEMPLATE) return; | |
3938 | switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { | |
3939 | case TR_VALUE: | |
3940 | if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; | |
3941 | break; | |
3942 | case TR_OMIT: | |
3943 | if (!is_ifpresent && (template_selection==OMIT_VALUE || | |
3944 | template_selection==SPECIFIC_VALUE)) return; | |
3945 | break; | |
3946 | case TR_PRESENT: | |
3abe9331 | 3947 | if (!match_omit(legacy)) return; |
970ed795 EL |
3948 | break; |
3949 | default: | |
3950 | return; | |
3951 | } | |
3952 | TTCN_error("Restriction `%s' on template of type %s violated.", | |
3953 | get_res_name(t_res), t_name ? t_name : "CHARACTER STRING"); | |
3954 | } | |
3955 | #endif |