The concepts of ASN.1 sequences-of and sets-of are not inherent in C. Arrays are adequate for static usage. Dynamic usage is often implemented through the usage of linked lists. For implementation purposes set-of and sequence-of are considered the same. Relevance of order is the user's view and not an implementation issue. Only the implementation of sequence-of is described here.
ASN.1 sequence concept maps to struct in C. With this understanding, for design purposes a shorthand notation is adapted to make the concept of sequence-of more natural to C. The following keyword extension are made:
sequence
sequenceof
Their usage is similar to struct and union.
sequence specifies an element of a list.
sequenceof specifies the head of a list.
These are based on the QU_ and SEQ_ module.
sequence and sequenceof can be used for data or instance declaration.
Consider the following example:
typedef sequence SomeInfo {
Int someField;
} SomeInfo;
Which is equivalent to:
typedef struct SomeInfo {
struct SomeInfo *next;
struct SomeInfo *prev;
Int someField;
} SomeInfo;
For a sequenceof instance declaration, consider:
sequenceof SomeInfo someInfoSeq;
Which is equivalent to:
struct {
SomeInfo *first;
SomeInfo *last;
} someInfoSeq;
For a sequenceof type declaration, consider:
typedef sequenceof SomeInfo {
Int nuOfElems;
} SomeInfoSeq;
SomeInfoSeq someInfoSeq;
Which is equivalent to:
typedef struct {
SomeInfo *first;
SomeInfo *last;
Int nuOfElems;
} SomeInfoSeq;
SomeInfoSeq someInfoSeq;
Implementation of sets-of can be done as sequences-of. The user may convey the irrelevance of order through the usage of:
set
setof
reserved word extensions.