blob: 8dd547b8523c501dcde575174712f9984061b58b [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*
2 * Type constraints.
3 */
4#ifndef ASN1_PARSER_CONSTRAINT_H
5#define ASN1_PARSER_CONSTRAINT_H
6
7typedef struct asn1p_constraint_s {
8
9 enum asn1p_constraint_type_e {
10 ACT_INVALID, /* for assertions */
11 /*
12 * Constraint elements.
13 */
vlma6a12e32005-03-20 12:58:00 +000014 ACT_EL_TYPE, /* T (contained subtype) */
15 ACT_EL_VALUE, /* 123, "A", (elementary value) */
vlmfa67ddc2004-06-03 03:38:44 +000016 ACT_EL_RANGE, /* 1..2 (elementary range) */
17 ACT_EL_LLRANGE, /* 1<..2 (elementary range) */
18 ACT_EL_RLRANGE, /* 1..<2 (elementary range) */
19 ACT_EL_ULRANGE, /* 1<..<2 (elementary range) */
20 ACT_EL_EXT, /* ... (extensibility mark) */
21 /*
22 * Constraint types.
23 */
24 ACT_CT_SIZE, /* SIZE constraint type */
25 ACT_CT_FROM, /* FROM constraint type */
26 ACT_CT_WCOMP, /* WITH COMPONENT */
27 ACT_CT_WCOMPS, /* WITH COMPONENTS */
vlm6611add2005-03-20 14:28:32 +000028 ACT_CT_CTDBY, /* CONSTRAINED BY */
vlmfa67ddc2004-06-03 03:38:44 +000029 /*
30 * Arrays of constraints.
31 */
32 ACT_CA_SET, /* A set of constraints: (c1)(c2) */
33 ACT_CA_CRC, /* Comp. relation c-t: ({a})({@b}) */
34 ACT_CA_CSV, /* Comma-separated constraints array */
35 ACT_CA_UNI, /* UNION (|) */
36 ACT_CA_INT, /* INTERSECTION (^) */
37 ACT_CA_EXC, /* EXCEPT */
vlme1e6ed82005-03-24 14:26:38 +000038 ACT_CA_AEX, /* ALL EXCEPT */
vlmfa67ddc2004-06-03 03:38:44 +000039 } type;
40
41 enum asn1p_constr_pres_e {
42 ACPRES_DEFAULT,
43 ACPRES_PRESENT,
44 ACPRES_ABSENT,
45 ACPRES_OPTIONAL,
46 } presence;
47
48 /*
vlma6a12e32005-03-20 12:58:00 +000049 * Separate types and values.
vlmfa67ddc2004-06-03 03:38:44 +000050 */
vlma6a12e32005-03-20 12:58:00 +000051 asn1p_value_t *containedSubtype;
vlmfa67ddc2004-06-03 03:38:44 +000052 asn1p_value_t *value;
53 asn1p_value_t *range_start;
54 asn1p_value_t *range_stop;
55
56 /*
57 * A collection of constraint elements.
58 */
59 struct asn1p_constraint_s **elements;
vlm36a76d62004-09-05 10:40:28 +000060 unsigned int el_count; /* Number of meaningful elements */
61 unsigned int el_size; /* Size of the allocated (elements) */
vlmfa67ddc2004-06-03 03:38:44 +000062
63 int _lineno; /* Position in a source file */
64} asn1p_constraint_t;
65
vlm9283dbe2004-08-18 04:59:12 +000066/* Human-readable constraint type description */
67char *asn1p_constraint_type2str(enum asn1p_constraint_type_e);
vlmfa67ddc2004-06-03 03:38:44 +000068
69/*
70 * Constructors and a recursive destructor.
71 */
72asn1p_constraint_t *asn1p_constraint_new(int _lineno);
73void asn1p_constraint_free(asn1p_constraint_t *);
74
75/*
76 * Clone the constraint and all its children.
77 */
78asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone);
79
80/*
81 * Insert additional element into the element array of a (to) constraint.
82 */
83int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what);
84
85#endif /* ASN1_PARSER_CONSTRAINT_H */