Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
3 | // All rights reserved. This program and the accompanying materials |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef XER_HH_ | |
9 | #define XER_HH_ | |
10 | ||
11 | #include "Types.h" | |
12 | #include "Encdec.hh" | |
13 | #include <stddef.h> // for size_t | |
14 | #include <string.h> // strncmp for the inline function | |
15 | ||
16 | class XmlReaderWrap; | |
17 | ||
18 | class Base_Type; | |
af710487 | 19 | #ifdef TITAN_RUNTIME_2 |
20 | class Record_Of_Type; | |
21 | class Erroneous_descriptor_t; | |
a38c6d4c | 22 | #else |
23 | namespace PreGenRecordOf { | |
24 | class PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING; | |
25 | class PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING__OPTIMIZED; | |
26 | } | |
af710487 | 27 | #endif |
970ed795 EL |
28 | class TTCN_Module; |
29 | ||
30 | /** @defgroup XER XER codec | |
31 | * @{ | |
32 | * | |
33 | * @brief ASN.1 XML Encoding Rules, ITU-T Rec X.693 and amd1 | |
34 | */ | |
35 | ||
36 | /** XER flags for various uses. | |
37 | * | |
38 | * Low values specify the XML encoding variant (Basic, Canonical, Extended) | |
39 | * Other bits have dual uses: | |
40 | * - set in XERdescriptor_t::xer_bits, according to XML encoding attributes | |
41 | * - passed in as additional flags in the \c flavor parameter, usually | |
42 | * to XER_encode. These are used when encoding attributes in a parent type | |
43 | * influence the encoding of its components (e.g. EMBED-VALUES on a record | |
44 | * change the encoding of all components). | |
45 | */ | |
46 | enum XER_flavor { | |
3f84031e | 47 | XER_NONE = 0, |
970ed795 EL |
48 | XER_BASIC = 1U << 0, /**< Basic XER with indentation */ |
49 | XER_CANONICAL = 1U << 1, /**< Canonical XER, no indentation */ | |
50 | XER_EXTENDED = 1U << 2, /**< Extended XER */ | |
51 | DEF_NS_PRESENT = 1U << 3, // 0x08 | |
52 | DEF_NS_SQUASHED = 1U << 4, // 0x10 | |
53 | XER_MASK = 0x1FU, /**< All the "real" XER flavors plus DEF_NS */ | |
54 | ||
55 | /* Additional flags, for the parent to pass information to its children | |
56 | * (when the parent affects the child, e.g. LIST) */ | |
57 | XER_ESCAPE_ENTITIES = 1U << 5, /**< Escape according to X.680/2002, 11.15.8, | |
58 | used internally by UNIVERSAL_CHARSTRING. */ | |
59 | XER_RECOF = 1U << 6, /**< Generating code for the contained type | |
60 | of a record-of/set-of. Only affects BOOLEAN, CHOICE, ENUMERATED and NULL | |
61 | (see Table 5 in X.680 (11/2008) clause 26.5) */ | |
62 | ||
63 | /* More flags for XERdescriptor_t::xer_bits */ | |
64 | ANY_ATTRIBUTES = 1U << 7, // 0xooo80 | |
65 | ANY_ELEMENT = 1U << 8, // 0xoo100 | |
66 | XER_ATTRIBUTE = 1U << 9, // 0xoo200 | |
67 | BASE_64 = 1U << 10, // 0xoo400 | |
68 | XER_DECIMAL = 1U << 11, // 0xoo800 | |
69 | // DEFAULT-FOR-EMPTY has its own field | |
70 | EMBED_VALUES = 1U << 12, // 0xo1000 | |
71 | /** LIST encoding instruction for record-of/set-of. */ | |
72 | XER_LIST = 1U << 13, // 0xo2000 | |
73 | // NAME is stored in the descriptor | |
74 | // NAMESPACE is folded into the name | |
75 | XER_TEXT = 1U << 14, // 0xo4000 | |
76 | UNTAGGED = 1U << 15, // 0xo8000 | |
77 | USE_NIL = 1U << 16, // 0x10000 | |
78 | USE_NUMBER = 1U << 17, // 0x20000 | |
79 | USE_ORDER = 1U << 18, // 0x40000 | |
80 | USE_QNAME = 1U << 19, // 0x80000 | |
81 | USE_TYPE_ATTR = 1U << 20, // 0x100000, either USE-TYPE or USE-UNION | |
82 | HAS_1UNTAGGED = 1U << 21, // 0x200000 member, and it's character-encodable | |
83 | // another hint to pass down to the children: | |
84 | PARENT_CLOSED = 1U << 22, // 0x400000 | |
85 | FORM_UNQUALIFIED=1U << 23, // 0X800000 (qualified is more frequent) | |
86 | XER_TOPLEVEL = 1U << 24, //0X1000000 (toplevel, for decoding) | |
87 | SIMPLE_TYPE = 1U << 25, /*0X2000000 always encode on one line: | |
88 | <foo>content</foo>, never <foo>\ncontent\n</foo> */ | |
89 | BXER_EMPTY_ELEM= 1U << 26, /*0X4000000 boolean and enum encode themselves | |
90 | as empty elements in BXER only. This also influences them in record-of */ | |
91 | ANY_FROM = 1U << 27, // 0x8000000 anyElement from ... or anyAttributes from ... | |
92 | ANY_EXCEPT = 1U << 28, // 0x10000000 anyElement except ... or anyAttributes except ... | |
51fa56b9 | 93 | EXIT_ON_ERROR = 1U << 29, /* 0x20000000 clean up and exit instead of throwing |
970ed795 | 94 | a decoding error, used on alternatives of a union with USE-UNION */ |
51fa56b9 | 95 | XER_OPTIONAL = 1U << 30, // 0x40000000 is an optional field of a record or set |
96 | BLOCKED = 1U << 31 // 0x80000000 either ABSTRACT or BLOCK | |
970ed795 EL |
97 | }; |
98 | ||
99 | /** WHITESPACE actions. | |
100 | * Note that WHITESPACE_COLLAPSE includes the effect of WHITESPACE_REPLACE | |
101 | * and the code relies on WHITESPACE_COLLAPSE having the higher value. */ | |
102 | enum XER_whitespace_action { | |
103 | WHITESPACE_PRESERVE, | |
104 | WHITESPACE_REPLACE, | |
105 | WHITESPACE_COLLAPSE | |
106 | }; | |
107 | ||
108 | /// Check that \p f has the canonical flavor. | |
109 | inline bool is_canonical(unsigned int f) | |
110 | { | |
111 | return (f & XER_CANONICAL) != 0; | |
112 | } | |
113 | ||
114 | inline bool is_exer(unsigned int f) | |
115 | { | |
116 | return (f & XER_EXTENDED) != 0; | |
117 | } | |
118 | ||
119 | /** Is this a member of a SEQUENCE OF | |
120 | * | |
121 | * @param f XER flavor | |
122 | * @return \c true if \p contains \c XER_RECOF, \c false otherwise | |
123 | */ | |
124 | inline bool is_record_of(unsigned int f) | |
125 | { | |
126 | return (f & XER_RECOF) != 0; | |
127 | } | |
128 | ||
129 | /** Do list encoding | |
130 | * | |
131 | * This is now hijacked to mean "the enclosing type told us to omit our tag". | |
132 | * Hence the check for USE-NIL too. | |
133 | * | |
134 | * @param f XER flavor | |
135 | * @return \c true if \c XER_EXTENDED and either \c XER_LIST or \c USE_NIL is set. | |
136 | */ | |
137 | inline bool is_exerlist(unsigned int f) | |
138 | { | |
139 | return (f & XER_EXTENDED) && ((f & (XER_LIST|USE_NIL|USE_TYPE_ATTR)) != 0); | |
140 | } | |
141 | ||
142 | /** Descriptor for XER encoding/decoding during runtime. | |
143 | * | |
144 | * This structure contains XER enc/dec information for the runtime. | |
145 | * | |
146 | * There is an instance of this struct for most TTCN3/ASN1 types. | |
147 | * Because TITAN generates type aliases (typedefs) when one type references | |
148 | * another (e.g. "type integer i1" results in "typedef INTEGER i1"), | |
149 | * this struct holds information to distinguish them during encoding. | |
150 | * | |
151 | * Only those encoding instructions need to be recorded which can apply to | |
152 | * scalar types (e.g. BOOLEAN, REAL, etc., usually implemented by classes in core/) | |
153 | * because the same code needs to handle all varieties. | |
154 | * | |
155 | * - ANY-ELEMENT : UFT8String | |
156 | * - BASE64 : OCTET STRING, open type, restricted character string | |
157 | * - DECIMAL : REAL | |
158 | * - NAME : anything (this is already present as \c name) | |
159 | * - NAMESPACE : hmm | |
160 | * - TEXT : INTEGER, enum | |
161 | * - USE-NUMBER : enum | |
162 | * - WHITESPACE : restricted character string | |
163 | * | |
164 | * ANY-ATTRIBUTE, EMBED-VALUES, LIST, USE-TYPE, USE-UNION apply to sequence/choice types; | |
165 | * their effect will be resolved by the compiler. | |
166 | * | |
167 | * Instances of this type are written by the compiler into the generated code, | |
168 | * one for each type. For a TTCN3 type foo_bar, there will be a class | |
169 | * foo__bar and a XERdescriptor_t instance named foo__bar_xer_. | |
170 | * | |
171 | * Each built-in type has a descriptor (e.g. INTEGER_xer_) in the runtime. | |
172 | * | |
173 | * The \a name field contains the closing tag including a newline, e.g. | |
174 | * \c "</INTEGER>\n". This allows for a more efficient output of the tags, | |
175 | * minimizing the number of one-character inserts into the buffer. | |
176 | * | |
177 | * The start tag is written as an 'open angle bracket' character, | |
178 | * followed by the \a name field without its first two characters (\c "</" ). | |
179 | * | |
180 | * In case of the canonical encoding (\c CXER ) there is no indenting, | |
181 | * so the final newline is omitted by reducing the length by one. | |
182 | * | |
183 | * Example: | |
184 | * @code | |
185 | * int Foo::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 186 | * TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const { |
970ed795 EL |
187 | * int canon = is_canonical(flavor); |
188 | * if (!canon) do_indent(p_buf, indent); | |
189 | * // output the start tag | |
190 | * p_buf.put_c('<'); | |
191 | * p_buf.put_s((size_t)p_td.namelen-2-canon, (const unsigned char*)p_td.name+2); | |
192 | * // this is not right if Foo has attributes :( | |
193 | * // we'll need to reduce namelen further (or just get rid of this hackery altogether) | |
194 | * | |
195 | * // output actual content | |
196 | * p_buf.put_..... | |
197 | * | |
198 | * // output the closing tag | |
199 | * if (!canon) do_indent(p_buf, indent); | |
200 | * p_buf.put_s((size_t)p_td.namelen-canon, (const unsigned char*)p_td.name); | |
201 | * } | |
202 | * @endcode | |
203 | * | |
204 | * Empty element tag: | |
205 | * | |
206 | * @code | |
207 | * int Foo::XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 208 | * TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const { |
970ed795 EL |
209 | * int canon = is_canonical(flavor); |
210 | * if (!canon) do_indent(p_buf, indent); | |
211 | * // output an empty element tag | |
212 | * p_buf.put_c('<'); | |
213 | * p_buf.put_s((size_t)p_td.namelen-4, (const unsigned char*)p_td.name+2); | |
214 | * p_buf.put_s(3 - canon, (const unsigned char*)"/>\n"); | |
215 | * } | |
216 | * @endcode | |
217 | * | |
218 | * @note We don't generate the XML prolog. This is required for Canonical XER | |
219 | * (X.693 9.1.1) and permitted for Basic-XER (8.2.1). | |
220 | * | |
221 | * @note X.693 amd1 (EXER) 10.3.5 states: If an "ExtendedXMLValue" is empty, | |
222 | * and its associated tags have not been removed by the use of an UNTAGGED | |
223 | * encoding instruction, then the associated preceding and following tags | |
224 | * <b>can (as an encoder's option)</b> be replaced with | |
225 | * an XML empty-element tag (see ITU-T Rec. X.680 | ISO/IEC 8824-1, 16.8). | |
226 | * This is called the associated empty-element tag. | |
227 | * | |
228 | * @note X.693 (XER) 9.1.4 states: (for Canonical XER) | |
229 | * If the XML value notation permits the use of an XML empty-element tag | |
230 | * (see ITU-T Rec. X.680 |ISO/IEC 8824-1, 15.5 and 16.8), | |
231 | * then this empty-element tag @b shall be used. | |
232 | * | |
233 | * @note After editing XERdescriptor_t, make sure to change XER_STRUCT2 here | |
234 | * and generate_code_xerdescriptor() in Type.cc. | |
235 | * */ | |
236 | struct XERdescriptor_t | |
237 | { | |
238 | /** (closing) Tag name, including a newline. | |
239 | * First is for basic and canonical XER, second for EXER */ | |
240 | const char *names[2]; | |
241 | /** Length of closing tag string (strlen of names[i]) */ | |
242 | const unsigned short namelens[2]; | |
243 | /** Various EXER flags */ | |
244 | const unsigned long xer_bits; | |
245 | /** Whitespace handling */ | |
246 | const XER_whitespace_action whitespace; | |
247 | /** value to compare for DEFAULT-FOR-EMPTY */ | |
248 | const Base_Type* dfeValue; | |
249 | /** The module to which the type belongs. May be NULL in a descriptor | |
250 | * for a built-in type, e.g. in INTEGER_xer_ */ | |
251 | const TTCN_Module* my_module; | |
252 | /** Index into the module's namespace list. | |
253 | * -1 means no namespace. | |
254 | * >=+0 and FORM_UNQUALIFIED means that there IS a namespace, | |
255 | * it just doesn't show up in the XML (but libxml2 will return it). */ | |
256 | const int ns_index; | |
257 | ||
258 | /** Number of namespace URIs*/ | |
259 | const unsigned short nof_ns_uris; | |
260 | ||
261 | /** List of namespace URIs | |
262 | * In case of "anyElement" variants this list contains the valid ("anyElement from ...") | |
263 | * or invalid ("anyElement except ...") namespace URIs. | |
264 | * The unqualified namespace is marked by an empty string ("").*/ | |
265 | const char** ns_uris; | |
a38c6d4c | 266 | |
267 | /** Points to the element type's XER descriptor in case of 'record of' and 'set of' types */ | |
268 | const XERdescriptor_t* oftype_descr; | |
970ed795 EL |
269 | }; |
270 | ||
af710487 | 271 | /** Information related to the embedded values in XML encoding |
272 | * | |
273 | * Used when a record/set with the EMBED-VALUES coding instruction contains | |
274 | * one or more record of/set of fields. */ | |
275 | struct embed_values_enc_struct_t | |
276 | { | |
277 | #ifdef TITAN_RUNTIME_2 | |
278 | /** Stores the array of embedded values */ | |
279 | const Record_Of_Type* embval_array; | |
280 | /** Stores the erroneous descriptor of the embedded values field (for negative tests) */ | |
281 | const Erroneous_descriptor_t* embval_err; | |
282 | /** Error value index for the embedded values (for negative tests) */ | |
283 | int embval_err_val_idx; | |
284 | /** Erroneous descriptor index for the embedded values (for negative tests) */ | |
285 | int embval_err_descr_idx; | |
286 | #else | |
a38c6d4c | 287 | /** Stores the array of embedded values (regular record-of) */ |
288 | const PreGenRecordOf::PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING* embval_array_reg; | |
289 | /** Stores the array of embedded values (optimized record-of) */ | |
290 | const PreGenRecordOf::PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING__OPTIMIZED* embval_array_opt; | |
af710487 | 291 | #endif |
292 | /** Stores the index of the next embedded value to be read */ | |
293 | int embval_index; | |
294 | }; | |
295 | ||
296 | /** Information related to the embedded values in XML decoding | |
297 | * | |
298 | * Used when a record/set with the EMBED-VALUES coding instruction contains | |
299 | * one or more record of/set of fields. */ | |
300 | struct embed_values_dec_struct_t | |
301 | { | |
302 | #ifdef TITAN_RUNTIME_2 | |
303 | /** Stores the array of embedded values */ | |
304 | Record_Of_Type* embval_array; | |
305 | #else | |
a38c6d4c | 306 | /** Stores the array of embedded values (regular record-of) */ |
307 | PreGenRecordOf::PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING* embval_array_reg; | |
308 | /** Stores the array of embedded values (optimized record-of) */ | |
309 | PreGenRecordOf::PREGEN__RECORD__OF__UNIVERSAL__CHARSTRING__OPTIMIZED* embval_array_opt; | |
af710487 | 310 | #endif |
311 | /** Stores the number of embedded values that are currently in the array, | |
312 | * and the index where the next one should be inserted */ | |
313 | int embval_index; | |
314 | }; | |
315 | ||
970ed795 EL |
316 | /** Check the name of an XML node against a XER type descriptor. |
317 | * | |
318 | * @param name the (local, unqualified) name of the XML element | |
319 | * @param p_td the type descriptor | |
320 | * @param exer \c true if Extended XER decoding, \c false for Basic and Canonical XER | |
321 | * @return \c true if \p name corresponds to the type descriptor, \c false otherwise. | |
322 | */ | |
323 | inline bool check_name(const char *name, const XERdescriptor_t& p_td, int exer) | |
324 | { | |
325 | return strncmp(name, p_td.names[exer], p_td.namelens[exer]-2) == 0 | |
326 | && name[p_td.namelens[exer]-2] == '\0'; | |
327 | } | |
328 | ||
329 | /** Verify the namespace of an XML node against a XER type descriptor. | |
330 | * | |
331 | * @pre EXER decoding is in progress | |
332 | * | |
333 | * @param ns_uri the URI of the current node | |
334 | * @param p_td the type descriptor | |
335 | * @return \c true if \p ns_uri is NULL and the type has no namespace | |
336 | * or it's the default namespace. | |
337 | * @return \c true if \p ns_uri is not NULL and it matches the one referenced | |
338 | * by \p p_td. | |
339 | * @return \c false otherwise. | |
340 | */ | |
341 | bool check_namespace(const char *ns_uri, const XERdescriptor_t& p_td); | |
342 | ||
343 | /** Check that the current element matches the XER descriptor | |
344 | * | |
345 | * Calls TTCN_EncDec_ErrorContext::error() if it doesn't. | |
346 | * | |
347 | * @param reader XML reader | |
348 | * @param p_td XER descriptor | |
349 | * @param exer 0 for Basic/Canonical XER, 1 for EXER | |
350 | * @return the name of the current element | |
351 | */ | |
352 | const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int exer); | |
353 | ||
354 | /** Check the end tag | |
355 | * | |
356 | * Calls verify_name(), then compares \a depth with the current XML depth | |
357 | * and calls TTCN_EncDec_ErrorContext::error() if they don't match. | |
358 | * | |
359 | * @param reader XML reader | |
360 | * @param p_td XER descriptor | |
361 | * @param depth XML tag depth (0 for top-level element) | |
362 | * @param exer 0 for Basic/Canonical XER, 1 for EXER | |
363 | */ | |
364 | void verify_end(XmlReaderWrap& reader, const XERdescriptor_t& p_td, const int depth, int exer); | |
365 | ||
366 | class TTCN_Buffer; | |
367 | ||
368 | /** Output the namespace prefix | |
369 | * | |
370 | * The namespace prefix is determined by the XER descriptor (@a my_module | |
371 | * and @a ns_index fields). It is not written if p_td.xer_bits has | |
372 | * FORM_UNQUALIFIED. | |
373 | * | |
374 | * @param p_td XER descriptor | |
375 | * @param p_buf buffer to write into | |
376 | * | |
377 | * @pre the caller should check that E-XER encoding is in effect. | |
378 | */ | |
379 | void write_ns_prefix(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf); | |
380 | ||
51fa56b9 | 381 | /** Return the namespace referred to by a prefix |
382 | * | |
383 | * Finds the namespace specified by \a prefix in the module's namespace table | |
384 | * and returns its URI. Returns NULL if the namespace is not found. | |
385 | * | |
386 | * @param prefix namespace prefix to be found | |
387 | * @param p_td XER descriptor (contains the module to search in) | |
388 | */ | |
389 | const char* get_ns_uri_from_prefix(const char *prefix, const XERdescriptor_t& p_td); | |
390 | ||
970ed795 EL |
391 | /** Output the beginning of an XML attribute. |
392 | * | |
393 | * Writes a space, the attribute name (from \p p_td), and the string "='". | |
394 | * @post the buffer is ready to receive the actual value | |
395 | * | |
396 | * @param p_td XER descriptor (contains the attribute name) | |
397 | * @param p_buf buffer to write into | |
398 | */ | |
399 | inline void begin_attribute(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf) | |
400 | { | |
401 | p_buf.put_c(' '); | |
402 | write_ns_prefix(p_td, p_buf); | |
403 | p_buf.put_s((size_t)p_td.namelens[1]-2, (const unsigned char*)p_td.names[1]); | |
404 | p_buf.put_s((size_t)2, (const unsigned char*)"='"); | |
405 | } | |
406 | ||
407 | /** Indent. | |
408 | * | |
409 | * @param buf buffer to write into. | |
410 | * @param level indent level | |
411 | * | |
412 | * Writes the appropriate amount of indentation into \p buf. | |
413 | * | |
414 | * Indentation is currently done with with tabs. | |
415 | * */ | |
416 | int do_indent(TTCN_Buffer& buf, int level); | |
417 | ||
418 | /** Ensures that the anyElement or anyAttribute field respects its namespace | |
419 | * restrictions. | |
420 | * In case of "anyElement from ..." or "anyAttributes from ..." the namespace | |
421 | * needs to be in the specified list. | |
422 | * In case of "anyElement except ..." or "anyAttributes except ..." it cannot | |
423 | * match any of the namespaces from the list. | |
424 | * An invalid namespace causes a dynamic test case error. | |
425 | * | |
426 | * @param p_td type descriptor of the field in question, contains the list of | |
427 | * valid or invalid namespaces | |
428 | * @param p_xmlns constains the namespace in question | |
429 | */ | |
430 | void check_namespace_restrictions(const XERdescriptor_t& p_td, const char* p_xmlns); | |
431 | ||
432 | ||
433 | #ifdef DEFINE_XER_STRUCT | |
434 | # define XER_STRUCT2(type_name,xmlname) \ | |
435 | extern const XERdescriptor_t type_name##_xer_ = { \ | |
436 | { xmlname ">\n", xmlname ">\n" }, \ | |
437 | { 2+sizeof(xmlname)-1, 2+sizeof(xmlname)-1 }, \ | |
a38c6d4c | 438 | 0UL, WHITESPACE_PRESERVE, NULL, NULL, 0, 0, NULL, NULL } |
970ed795 EL |
439 | // The compiler should fold the two identical strings into one |
440 | ||
441 | # define XER_STRUCT_COPY(cpy,original) \ | |
442 | const XERdescriptor_t& cpy##_xer_ = original##_xer_ | |
443 | #else | |
444 | /** Declare a XER structure. | |
445 | * @param type_name the name of a Titan runtime class | |
446 | * @param xmlname the XML tag name | |
447 | */ | |
448 | # define XER_STRUCT2(type_name,xmlname) extern const XERdescriptor_t type_name##_xer_ | |
449 | # define XER_STRUCT_COPY(cpy,original) extern const XERdescriptor_t& cpy##_xer_ | |
450 | #endif | |
451 | ||
452 | /** Declare a XER structure where the name of the type matches the tag */ | |
453 | # define XER_STRUCT(name) XER_STRUCT2(name, #name) | |
454 | ||
455 | /* XER descriptors for built-in types. | |
456 | * The XML tag names are defined in Table 4, referenced by clause | |
457 | * 11.25.2 (X.680/2002) or 12.36.2 (X.680/2008) */ | |
458 | ||
459 | // Types shared between ASN.1 and TTCN-3 | |
460 | XER_STRUCT2(BITSTRING, "BIT_STRING"); | |
461 | XER_STRUCT (BOOLEAN); | |
462 | XER_STRUCT (CHARSTRING); | |
463 | XER_STRUCT2(FLOAT, "REAL"); | |
464 | XER_STRUCT (INTEGER); | |
465 | XER_STRUCT2(OBJID, "OBJECT_IDENTIFIER"); | |
466 | XER_STRUCT2(OCTETSTRING, "OCTET_STRING"); | |
467 | XER_STRUCT (UNIVERSAL_CHARSTRING); | |
468 | ||
469 | XER_STRUCT(RELATIVE_OID); | |
470 | ||
471 | // ASN.1 types | |
472 | ||
473 | XER_STRUCT2(EMBEDDED_PDV, "SEQUENCE"); | |
474 | XER_STRUCT2(EMBEDDED_PDV_identification, "identification"); | |
475 | XER_STRUCT2(EMBEDDED_PDV_identification_sxs, "syntaxes"); | |
476 | XER_STRUCT2(EMBEDDED_PDV_identification_sxs_abs, "abstract"); | |
477 | XER_STRUCT2(EMBEDDED_PDV_identification_sxs_xfr, "transfer"); | |
478 | XER_STRUCT2(EMBEDDED_PDV_identification_sx , "syntax"); | |
479 | XER_STRUCT2(EMBEDDED_PDV_identification_pci, "presentation-context-id"); | |
480 | XER_STRUCT2(EMBEDDED_PDV_identification_cn , "context-negotiation"); | |
481 | XER_STRUCT2(EMBEDDED_PDV_identification_cn_pci , "presentation-context-id"); | |
482 | XER_STRUCT2(EMBEDDED_PDV_identification_cn_tsx , "transfer-syntax"); | |
483 | XER_STRUCT2(EMBEDDED_PDV_identification_ts , "transfer-syntax"); | |
484 | XER_STRUCT2(EMBEDDED_PDV_identification_fix, "fixed"); | |
485 | XER_STRUCT2(EMBEDDED_PDV_data_value_descriptor, "data-value-descriptor"); | |
486 | XER_STRUCT2(EMBEDDED_PDV_data_value, "data-value"); | |
487 | ||
488 | ||
489 | XER_STRUCT2(EXTERNAL, "SEQUENCE"); | |
490 | XER_STRUCT2(EXTERNAL_direct_reference , "direct-reference"); | |
491 | XER_STRUCT2(EXTERNAL_indirect_reference, "indirect-reference"); | |
492 | XER_STRUCT2(EXTERNAL_data_value_descriptor, "data-value-descriptor"); | |
493 | XER_STRUCT2(EXTERNAL_encoding, "encoding"); | |
494 | XER_STRUCT2(EXTERNAL_encoding_singleASN , "single-ASN1-type"); | |
495 | XER_STRUCT2(EXTERNAL_encoding_octet_aligned, "octet-aligned"); | |
496 | XER_STRUCT2(EXTERNAL_encoding_arbitrary , "arbitrary"); | |
497 | ||
498 | // The big, scary ASN.1 unrestricted character string | |
499 | XER_STRUCT2(CHARACTER_STRING, "SEQUENCE"); | |
500 | XER_STRUCT_COPY(CHARACTER_STRING_identification, EMBEDDED_PDV_identification); | |
501 | XER_STRUCT_COPY(CHARACTER_STRING_identification_sxs, EMBEDDED_PDV_identification_sxs); | |
502 | XER_STRUCT_COPY(CHARACTER_STRING_identification_sxs_abs, EMBEDDED_PDV_identification_sxs_abs); | |
503 | XER_STRUCT_COPY(CHARACTER_STRING_identification_sxs_xfr, EMBEDDED_PDV_identification_sxs_xfr); | |
504 | XER_STRUCT_COPY(CHARACTER_STRING_identification_sx , EMBEDDED_PDV_identification_sx); | |
505 | XER_STRUCT_COPY(CHARACTER_STRING_identification_pci, EMBEDDED_PDV_identification_pci); | |
506 | XER_STRUCT_COPY(CHARACTER_STRING_identification_cn , EMBEDDED_PDV_identification_cn); | |
507 | XER_STRUCT_COPY(CHARACTER_STRING_identification_cn_pci , EMBEDDED_PDV_identification_cn_pci); | |
508 | XER_STRUCT_COPY(CHARACTER_STRING_identification_cn_tsx , EMBEDDED_PDV_identification_cn_tsx); | |
509 | XER_STRUCT_COPY(CHARACTER_STRING_identification_ts , EMBEDDED_PDV_identification_ts); | |
510 | XER_STRUCT_COPY(CHARACTER_STRING_identification_fix, EMBEDDED_PDV_identification_fix); | |
511 | // this one is used for decoding only (only to check that it's absent) | |
512 | XER_STRUCT2(CHARACTER_STRING_data_value_descriptor, "data-value-descriptor"); | |
513 | // this can not be folded with EMBEDDED-PDV | |
514 | XER_STRUCT2(CHARACTER_STRING_data_value, "string-value"); | |
515 | ||
516 | // ASN.1 restricted character strings | |
517 | XER_STRUCT(GeneralString); | |
518 | XER_STRUCT(NumericString); | |
519 | XER_STRUCT(UTF8String); | |
520 | XER_STRUCT(PrintableString); | |
521 | XER_STRUCT(UniversalString); | |
522 | ||
523 | XER_STRUCT(BMPString); | |
524 | XER_STRUCT(GraphicString); | |
525 | XER_STRUCT(IA5String); | |
526 | XER_STRUCT(TeletexString); | |
527 | XER_STRUCT(VideotexString); | |
528 | XER_STRUCT(VisibleString); | |
529 | ||
530 | XER_STRUCT2(ASN_NULL, "NULL"); | |
531 | XER_STRUCT2(ASN_ROID, "RELATIVE_OID"); | |
532 | XER_STRUCT (ASN_ANY); // obsoleted by 2002 | |
533 | ||
534 | // TTCN-3 types | |
535 | XER_STRUCT2(HEXSTRING, "hexstring"); | |
536 | XER_STRUCT2(VERDICTTYPE, "verdicttype"); | |
537 | ||
538 | /** @} */ | |
539 | ||
540 | #endif /*XER_HH_*/ |