blob: 0aedcf79c83106883fd8fbbfe4e56699a89191bc [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 {
Lev Walkin63a35232017-08-10 19:59:47 -070016 /*
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
Lev Walkin63a35232017-08-10 19:59:47 -070024 /*
25 * Tags to members mapping table.
26 */
27 const asn_TYPE_tag2member_t *tag2el;
Lev Walkin494fb702017-08-07 20:07:00 -070028 unsigned tag2el_count;
Lev Walkinf15320b2004-06-03 03:38:44 +000029
Lev Walkin494fb702017-08-07 20:07:00 -070030 /* Canonical ordering of CHOICE elements, for PER */
Lev Walkinf6853ce2017-08-11 00:50:27 -070031 const unsigned *canonical_order;
Lev Walkin59b176e2005-11-26 11:25:14 +000032
Lev Walkin63a35232017-08-10 19:59:47 -070033 /*
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 Walkin59b176e2005-11-26 11:25:14 +000050per_type_decoder_f CHOICE_decode_uper;
Lev Walkin523de9e2006-08-18 01:34:18 +000051per_type_encoder_f CHOICE_encode_uper;
Lev Walkinf15320b2004-06-03 03:38:44 +000052asn_outmost_tag_f CHOICE_outmost_tag;
Lev Walkinf15320b2004-06-03 03:38:44 +000053
Lev Walkinf6853ce2017-08-11 00:50:27 -070054/*
55 * Return the 1-based choice variant presence index.
56 * Returns 0 in case of error.
57 */
58unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td,
59 const void *structure_ptr);
60
61/*
62 * Sets or resets the 1-based choice variant presence index.
63 * In case a previous index is not zero, the currently selected structure
64 * member is freed and zeroed-out first.
65 * Returns 0 on success and -1 on error.
66 */
67int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td,
68 void *structure_ptr, unsigned present);
69
Lev Walkin21b41ac2005-07-24 09:03:44 +000070#ifdef __cplusplus
71}
72#endif
73
Lev Walkinf15320b2004-06-03 03:38:44 +000074#endif /* _CONSTR_CHOICE_H_ */