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