blob: 1a27f914bda75ff64b7b35c16029f4ef237a903f [file] [log] [blame]
ss412g1a79bdf2019-10-24 12:03:05 +03001
2/*
3 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
4 * Redistribution and modifications are permitted subject to BSD license.
5 */
6#ifndef _CONSTR_CHOICE_H_
7#define _CONSTR_CHOICE_H_
8
9#include <asn_application.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15typedef struct asn_CHOICE_specifics_s {
16 /*
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) */
23
24 /*
25 * Tags to members mapping table.
26 */
27 const asn_TYPE_tag2member_t *tag2el;
28 unsigned tag2el_count;
29
30 /* Canonical ordering of CHOICE elements, for PER */
31 const unsigned *to_canonical_order;
32 const unsigned *from_canonical_order;
33
34 /*
35 * Extensions-related stuff.
36 */
37 signed ext_start; /* First member of extensions, or -1 */
38} asn_CHOICE_specifics_t;
39
40/*
41 * A set specialized functions dealing with the CHOICE type.
42 */
43asn_struct_free_f CHOICE_free;
44asn_struct_print_f CHOICE_print;
45asn_struct_compare_f CHOICE_compare;
46asn_constr_check_f CHOICE_constraint;
47ber_type_decoder_f CHOICE_decode_ber;
48der_type_encoder_f CHOICE_encode_der;
49xer_type_decoder_f CHOICE_decode_xer;
50xer_type_encoder_f CHOICE_encode_xer;
51oer_type_decoder_f CHOICE_decode_oer;
52oer_type_encoder_f CHOICE_encode_oer;
53per_type_decoder_f CHOICE_decode_uper;
54per_type_encoder_f CHOICE_encode_uper;
55per_type_decoder_f CHOICE_decode_aper;
56per_type_encoder_f CHOICE_encode_aper;
57asn_outmost_tag_f CHOICE_outmost_tag;
58asn_random_fill_f CHOICE_random_fill;
59extern asn_TYPE_operation_t asn_OP_CHOICE;
60
61/*
62 * Return the 1-based choice variant presence index.
63 * Returns 0 in case of error.
64 */
65unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td,
66 const void *structure_ptr);
67
68/*
69 * Sets or resets the 1-based choice variant presence index.
70 * In case a previous index is not zero, the currently selected structure
71 * member is freed and zeroed-out first.
72 * Returns 0 on success and -1 on error.
73 */
74int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td,
75 void *structure_ptr, unsigned present);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* _CONSTR_CHOICE_H_ */