4a214093a2611a7f883ebecfa23dd6a154d99eeb
[ric-app/kpimon.git] / asn1c_defs / all-defs / asn_SET_OF.h
1 /*-\r
2  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
3  * Redistribution and modifications are permitted subject to BSD license.\r
4  */\r
5 #ifndef ASN_SET_OF_H\r
6 #define ASN_SET_OF_H\r
7 \r
8 #ifdef __cplusplus\r
9 #define A_SET_OF(type)                   \\r
10     struct {                             \\r
11         type **array;                    \\r
12         int count; /* Meaningful size */ \\r
13         int size;  /* Allocated size */  \\r
14         void (*free)(decltype(*array));  \\r
15     }\r
16 #else   /* C */\r
17 #define A_SET_OF(type)                   \\r
18     struct {                             \\r
19         type **array;                    \\r
20         int count; /* Meaningful size */ \\r
21         int size;  /* Allocated size */  \\r
22         void (*free)(type *);    \\r
23     }\r
24 #endif\r
25 \r
26 #ifdef __cplusplus\r
27 extern "C" {\r
28 #endif\r
29 \r
30 #define ASN_SET_ADD(headptr, ptr)               \\r
31         asn_set_add((headptr), (ptr))\r
32 \r
33 /*******************************************\r
34  * Implementation of the SET OF structure.\r
35  */\r
36 \r
37 /*\r
38  * Add another structure into the set by its pointer.\r
39  * RETURN VALUES:\r
40  * 0 for success and -1/errno for failure.\r
41  */\r
42 int  asn_set_add(void *asn_set_of_x, void *ptr);\r
43 \r
44 /*\r
45  * Delete the element from the set by its number (base 0).\r
46  * This is a constant-time operation. The order of elements before the\r
47  * deleted ones is guaranteed, the order of elements after the deleted\r
48  * one is NOT guaranteed.\r
49  * If _do_free is given AND the (*free) is initialized, the element\r
50  * will be freed using the custom (*free) function as well.\r
51  */\r
52 void asn_set_del(void *asn_set_of_x, int number, int _do_free);\r
53 \r
54 /*\r
55  * Empty the contents of the set. Will free the elements, if (*free) is given.\r
56  * Will NOT free the set itself.\r
57  */\r
58 void asn_set_empty(void *asn_set_of_x);\r
59 \r
60 /*\r
61  * Cope with different conversions requirements to/from void in C and C++.\r
62  * This is mostly useful for support library.\r
63  */\r
64 typedef A_SET_OF(void) asn_anonymous_set_;\r
65 #define _A_SET_FROM_VOID(ptr)           ((asn_anonymous_set_ *)(ptr))\r
66 #define _A_CSET_FROM_VOID(ptr)          ((const asn_anonymous_set_ *)(ptr))\r
67 \r
68 #ifdef __cplusplus\r
69 }\r
70 #endif\r
71 \r
72 #endif  /* ASN_SET_OF_H */\r