sjana | 464f907 | 2020-11-13 10:19:53 -0800 | [diff] [blame^] | 1 | /*- |
| 2 | * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef ASN_SEQUENCE_OF_H |
| 6 | #define ASN_SEQUENCE_OF_H |
| 7 | |
| 8 | #include <asn_SET_OF.h> |
| 9 | |
| 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | /* |
| 15 | * SEQUENCE OF is the same as SET OF with a tiny difference: |
| 16 | * the delete operation preserves the initial order of elements |
| 17 | * and thus MAY operate in non-constant time. |
| 18 | */ |
| 19 | #define A_SEQUENCE_OF(type) A_SET_OF(type) |
| 20 | |
| 21 | #define ASN_SEQUENCE_ADD(headptr, ptr) \ |
| 22 | asn_sequence_add((headptr), (ptr)) |
| 23 | |
| 24 | /*********************************************** |
| 25 | * Implementation of the SEQUENCE OF structure. |
| 26 | */ |
| 27 | |
| 28 | #define asn_sequence_add asn_set_add |
| 29 | #define asn_sequence_empty asn_set_empty |
| 30 | |
| 31 | /* |
| 32 | * Delete the element from the set by its number (base 0). |
| 33 | * This is NOT a constant-time operation. |
| 34 | * The order of elements is preserved. |
| 35 | * If _do_free is given AND the (*free) is initialized, the element |
| 36 | * will be freed using the custom (*free) function as well. |
| 37 | */ |
| 38 | void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free); |
| 39 | |
| 40 | /* |
| 41 | * Cope with different conversions requirements to/from void in C and C++. |
| 42 | * This is mostly useful for support library. |
| 43 | */ |
| 44 | typedef A_SEQUENCE_OF(void) asn_anonymous_sequence_; |
| 45 | #define _A_SEQUENCE_FROM_VOID(ptr) ((asn_anonymous_sequence_ *)(ptr)) |
| 46 | #define _A_CSEQUENCE_FROM_VOID(ptr) ((const asn_anonymous_sequence_ *)(ptr)) |
| 47 | |
| 48 | #ifdef __cplusplus |
| 49 | } |
| 50 | #endif |
| 51 | |
| 52 | #endif /* ASN_SEQUENCE_OF_H */ |