blob: 7649480942d3c5a8cf391eaa2e90ea27e94fb935 [file] [log] [blame]
Lev Walkin20696a42017-10-17 21:27:33 -07001/*
2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
Lev Walkinf15320b2004-06-03 03:38:44 +00003 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _CONSTR_CHOICE_H_
6#define _CONSTR_CHOICE_H_
7
Lev Walkin11c3e172004-09-24 21:00:50 +00008#include <asn_application.h>
Lev Walkinf15320b2004-06-03 03:38:44 +00009
Lev Walkin21b41ac2005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
Lev Walkind84f6032017-10-03 16:33:59 -070014typedef struct asn_CHOICE_specifics_s {
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080015 /*
16 * Target structure description.
17 */
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) */
Lev Walkinf15320b2004-06-03 03:38:44 +000022
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080023 /*
24 * Tags to members mapping table.
25 */
26 const asn_TYPE_tag2member_t *tag2el;
27 unsigned tag2el_count;
Lev Walkinf15320b2004-06-03 03:38:44 +000028
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080029 /* Canonical ordering of CHOICE elements, for PER */
Lev Walkin20696a42017-10-17 21:27:33 -070030 const unsigned *to_canonical_order;
31 const unsigned *from_canonical_order;
Lev Walkin59b176e2005-11-26 11:25:14 +000032
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080033 /*
34 * Extensions-related stuff.
35 */
36 signed ext_start; /* First member of extensions, or -1 */
Lev Walkin5e033762004-09-29 13:26:15 +000037} asn_CHOICE_specifics_t;
Lev Walkinf15320b2004-06-03 03:38:44 +000038
39/*
40 * A set specialized functions dealing with the CHOICE type.
41 */
Lev Walkina9cc46e2004-09-22 16:06:28 +000042asn_struct_free_f CHOICE_free;
43asn_struct_print_f CHOICE_print;
Lev Walkincd2f48e2017-08-10 02:14:59 -070044asn_struct_compare_f CHOICE_compare;
Lev Walkinf15320b2004-06-03 03:38:44 +000045asn_constr_check_f CHOICE_constraint;
46ber_type_decoder_f CHOICE_decode_ber;
47der_type_encoder_f CHOICE_encode_der;
Lev Walkin8d01b4c2004-10-23 14:57:50 +000048xer_type_decoder_f CHOICE_decode_xer;
Lev Walkina9cc46e2004-09-22 16:06:28 +000049xer_type_encoder_f CHOICE_encode_xer;
Lev Walkin9a1736d2017-08-27 23:46:34 -070050oer_type_decoder_f CHOICE_decode_oer;
51oer_type_encoder_f CHOICE_encode_oer;
Lev Walkin59b176e2005-11-26 11:25:14 +000052per_type_decoder_f CHOICE_decode_uper;
Lev Walkin523de9e2006-08-18 01:34:18 +000053per_type_encoder_f CHOICE_encode_uper;
Lev Walkinf15320b2004-06-03 03:38:44 +000054asn_outmost_tag_f CHOICE_outmost_tag;
Lev Walkina5972be2017-09-29 23:15:58 -070055asn_random_fill_f CHOICE_random_fill;
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080056extern asn_TYPE_operation_t asn_OP_CHOICE;
Lev Walkinf15320b2004-06-03 03:38:44 +000057
Lev Walkinf6853ce2017-08-11 00:50:27 -070058/*
59 * Return the 1-based choice variant presence index.
60 * Returns 0 in case of error.
61 */
62unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td,
63 const void *structure_ptr);
64
65/*
66 * Sets or resets the 1-based choice variant presence index.
67 * In case a previous index is not zero, the currently selected structure
68 * member is freed and zeroed-out first.
69 * Returns 0 on success and -1 on error.
70 */
71int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td,
72 void *structure_ptr, unsigned present);
73
Lev Walkin21b41ac2005-07-24 09:03:44 +000074#ifdef __cplusplus
75}
76#endif
77
Lev Walkinf15320b2004-06-03 03:38:44 +000078#endif /* _CONSTR_CHOICE_H_ */