2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
5 #ifndef _CONSTR_CHOICE_H_
6 #define _CONSTR_CHOICE_H_
8 #include <asn_application.h>
14 typedef struct asn_CHOICE_specifics_s {
16 * Target structure description.
18 unsigned struct_size; /* Size of the target structure. */
19 unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */
20 unsigned pres_offset; /* Identifier of the present member */
21 unsigned pres_size; /* Size of the identifier (enum) */
24 * Tags to members mapping table.
26 const asn_TYPE_tag2member_t *tag2el;
27 unsigned tag2el_count;
29 /* Canonical ordering of CHOICE elements, for PER */
30 const unsigned *to_canonical_order;
31 const unsigned *from_canonical_order;
34 * Extensions-related stuff.
36 signed ext_start; /* First member of extensions, or -1 */
37 } asn_CHOICE_specifics_t;
40 * A set specialized functions dealing with the CHOICE type.
42 asn_struct_free_f CHOICE_free;
44 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
45 asn_struct_print_f CHOICE_print;
46 #endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
48 asn_struct_compare_f CHOICE_compare;
50 asn_constr_check_f CHOICE_constraint;
52 #if !defined(ASN_DISABLE_BER_SUPPORT)
53 ber_type_decoder_f CHOICE_decode_ber;
54 der_type_encoder_f CHOICE_encode_der;
55 #endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
57 #if !defined(ASN_DISABLE_XER_SUPPORT)
58 xer_type_decoder_f CHOICE_decode_xer;
59 xer_type_encoder_f CHOICE_encode_xer;
60 #endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
62 #if !defined(ASN_DISABLE_JER_SUPPORT)
63 jer_type_encoder_f CHOICE_encode_jer;
64 #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
66 #if !defined(ASN_DISABLE_OER_SUPPORT)
67 oer_type_decoder_f CHOICE_decode_oer;
68 oer_type_encoder_f CHOICE_encode_oer;
69 #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
71 #if !defined(ASN_DISABLE_UPER_SUPPORT)
72 per_type_decoder_f CHOICE_decode_uper;
73 per_type_encoder_f CHOICE_encode_uper;
74 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
75 #if !defined(ASN_DISABLE_APER_SUPPORT)
76 per_type_decoder_f CHOICE_decode_aper;
77 per_type_encoder_f CHOICE_encode_aper;
78 #endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
80 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
81 asn_random_fill_f CHOICE_random_fill;
82 #endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
84 asn_outmost_tag_f CHOICE_outmost_tag;
86 extern asn_TYPE_operation_t asn_OP_CHOICE;
88 unsigned _fetch_present_idx(
89 const void *struct_ptr,
93 void _set_present_idx(
100 * Return the 1-based choice variant presence index.
101 * Returns 0 in case of error.
103 unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td,
104 const void *structure_ptr);
107 * Sets or resets the 1-based choice variant presence index.
108 * In case a previous index is not zero, the currently selected structure
109 * member is freed and zeroed-out first.
110 * Returns 0 on success and -1 on error.
112 int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td,
113 void *structure_ptr, unsigned present);
119 #endif /* _CONSTR_CHOICE_H_ */