blob: c23d8e118b8f2b2742f731506ab7c2f25cc0668f [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
Lev Walkin59b176e2005-11-26 11:25:14 +00002 * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
3 * All rights reserved.
Lev Walkinf15320b2004-06-03 03:38:44 +00004 * Redistribution and modifications are permitted subject to BSD license.
5 */
6#ifndef _CONSTR_CHOICE_H_
7#define _CONSTR_CHOICE_H_
8
Lev Walkin11c3e172004-09-24 21:00:50 +00009#include <asn_application.h>
Lev Walkinf15320b2004-06-03 03:38:44 +000010
Lev Walkin21b41ac2005-07-24 09:03:44 +000011#ifdef __cplusplus
12extern "C" {
13#endif
14
Wim Lewisfb6344e2014-07-28 12:16:01 -070015typedef const struct asn_CHOICE_specifics_s {
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080016 /*
17 * Target structure description.
18 */
19 unsigned struct_size; /* Size of the target structure. */
20 unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */
21 unsigned pres_offset; /* Identifier of the present member */
22 unsigned pres_size; /* Size of the identifier (enum) */
Lev Walkinf15320b2004-06-03 03:38:44 +000023
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080024 /*
25 * Tags to members mapping table.
26 */
27 const asn_TYPE_tag2member_t *tag2el;
28 unsigned tag2el_count;
Lev Walkinf15320b2004-06-03 03:38:44 +000029
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080030 /* Canonical ordering of CHOICE elements, for PER */
31 const unsigned *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_ */