1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
5 # Licensed under the Apache License, Version 2.0 (the "License"); *
6 # you may not use this file except in compliance with the License. *
7 # You may obtain a copy of the License at *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
11 # Unless required by applicable law or agreed to in writing, software *
12 # distributed under the License is distributed on an "AS IS" BASIS, *
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 # See the License for the specific language governing permissions and *
15 # limitations under the License. *
17 ******************************************************************************/
20 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
21 * Redistribution and modifications are permitted subject to BSD license.
23 #ifndef _CONSTR_CHOICE_H_
24 #define _CONSTR_CHOICE_H_
26 #include <asn_application.h>
32 typedef struct asn_CHOICE_specifics_s {
34 * Target structure description.
36 unsigned struct_size; /* Size of the target structure. */
37 unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */
38 unsigned pres_offset; /* Identifier of the present member */
39 unsigned pres_size; /* Size of the identifier (enum) */
42 * Tags to members mapping table.
44 const asn_TYPE_tag2member_t *tag2el;
45 unsigned tag2el_count;
47 /* Canonical ordering of CHOICE elements, for PER */
48 const unsigned *to_canonical_order;
49 const unsigned *from_canonical_order;
52 * Extensions-related stuff.
54 signed ext_start; /* First member of extensions, or -1 */
55 } asn_CHOICE_specifics_t;
58 * A set specialized functions dealing with the CHOICE type.
60 asn_struct_free_f CHOICE_free;
61 asn_struct_print_f CHOICE_print;
62 asn_struct_compare_f CHOICE_compare;
63 asn_constr_check_f CHOICE_constraint;
64 ber_type_decoder_f CHOICE_decode_ber;
65 der_type_encoder_f CHOICE_encode_der;
66 xer_type_decoder_f CHOICE_decode_xer;
67 xer_type_encoder_f CHOICE_encode_xer;
68 oer_type_decoder_f CHOICE_decode_oer;
69 oer_type_encoder_f CHOICE_encode_oer;
70 per_type_decoder_f CHOICE_decode_uper;
71 per_type_encoder_f CHOICE_encode_uper;
72 per_type_decoder_f CHOICE_decode_aper;
73 per_type_encoder_f CHOICE_encode_aper;
74 asn_outmost_tag_f CHOICE_outmost_tag;
75 asn_random_fill_f CHOICE_random_fill;
76 extern asn_TYPE_operation_t asn_OP_CHOICE;
79 * Return the 1-based choice variant presence index.
80 * Returns 0 in case of error.
82 unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td,
83 const void *structure_ptr);
86 * Sets or resets the 1-based choice variant presence index.
87 * In case a previous index is not zero, the currently selected structure
88 * member is freed and zeroed-out first.
89 * Returns 0 on success and -1 on error.
91 int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td,
92 void *structure_ptr, unsigned present);
98 #endif /* _CONSTR_CHOICE_H_ */