You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
4.4 KiB
186 lines
4.4 KiB
#ifndef STRUCTS_H
|
|
#define STRUCTS_H
|
|
|
|
// Structs
|
|
// -------
|
|
// For structs, a combination is needed to define the type of struct
|
|
// IS = Struct (Empty or incomplete, neither primitive nor complex)
|
|
// PS = Primitive struct (struct containing only primitive types)
|
|
// CS = Complex struct (struct containing other structs and primitive)
|
|
// NPS = Nested primitive struct
|
|
|
|
|
|
// Some Possible combinations
|
|
// ==========================
|
|
//
|
|
// _IS = incomplete struct without a typedef (forward decl)
|
|
// IS = incomplete struct
|
|
// AIS = alias of an incomplete struct
|
|
|
|
// (aliased) struct [ primitive | complex ]
|
|
// ----------------------------------------
|
|
// _PS = primitive struct without a an alias
|
|
// PS = primitive struct
|
|
// APS = Alias of primitive struct
|
|
// _CS = complex struct without a an alias
|
|
// CS = complex struct
|
|
// ACS = alias of a complex struct
|
|
// _CCS = complex complex struct without an alias
|
|
// CCS = complex complex struct
|
|
// ACCS = alias of a complex complex struct
|
|
//
|
|
// Nested structs
|
|
// --------------
|
|
// there is always a hosting struct and a nesting struct
|
|
// in case of double nesting it can be both
|
|
//
|
|
// simply nested struct [ primitive | complex ]
|
|
// --------------------------------------------
|
|
// (aliased) hosting struct (complex always)
|
|
// _HS = hosting struct without an alias
|
|
// HS = hosting struct
|
|
// AHS = alias of a hosting struct
|
|
// _NPS = nested primitive struct without an alias
|
|
// _NCS = nested complex struct without an alias
|
|
//
|
|
// doubly nested struct (complex always)
|
|
// -------------------------------------
|
|
// _HHS = hosting hosting struct without an alias
|
|
// HHS = hosting hosting struct
|
|
// AHHS = alias of a hosting hosting struct
|
|
// _NHS = nested hosting struct
|
|
// _NNPS = nested nested struct
|
|
// _NNCS = nested nested complex struct
|
|
//
|
|
// enums in structs
|
|
// _NEHS = nested enum in hosting struct
|
|
// _NENHS = nested enum in nested hosting struct
|
|
|
|
|
|
// Covered combinations
|
|
// =====================
|
|
// _IS = incomplete struct without a typedef (forward decl)
|
|
struct _IS;
|
|
|
|
// IS = incomplete struct
|
|
// AIS = alias of an incomplete struct
|
|
typedef struct IS AIS;
|
|
|
|
//
|
|
// (aliased) struct [ primitive | complex ]
|
|
// ----------------------------------------
|
|
// _PS = primitive struct without a an alias
|
|
|
|
struct _PS {
|
|
int x, y;
|
|
};
|
|
|
|
// PS = primitive struct
|
|
// APS = Alias of primitive struct
|
|
typedef struct PS {
|
|
int x, y;
|
|
} APS;
|
|
|
|
// _CS = complex struct without a an alias
|
|
struct _CS {
|
|
struct _PS *x;
|
|
APS *y;
|
|
};
|
|
|
|
// CS = complex struct
|
|
// ACS = alias of a complex struct
|
|
typedef struct CS {
|
|
APS *y;
|
|
struct _PS *x;
|
|
} ACS;
|
|
|
|
// _CCS = complex complex struct without an alias
|
|
struct _CCS {
|
|
ACS *x;
|
|
};
|
|
|
|
// CCS = complex complex struct
|
|
// ACCS = alias of a complex complex struct
|
|
typedef struct CCS {
|
|
ACS *x;
|
|
} ACCS;
|
|
|
|
// Nested structs
|
|
// --------------
|
|
// there is always a hosting struct and a nesting struct
|
|
// in case of double nesting it can be both
|
|
//
|
|
// simply nested struct [ primitive | complex ]
|
|
// --------------------------------------------
|
|
|
|
// _HS = hosting struct without an alias
|
|
// _NCS = nested primitive struct without an alias
|
|
struct _HS {
|
|
int x, y;
|
|
struct _NCS {
|
|
ACS *x;
|
|
} _ncs;
|
|
};
|
|
|
|
// (aliased) hosting struct (complex always)
|
|
// HS = hosting struct
|
|
// AHS = alias of a hosting struct
|
|
// _NPS = nested primitive struct (never has alias)
|
|
typedef struct HS {
|
|
struct _NPS {
|
|
int x, y;
|
|
} _nps;
|
|
int x, y;
|
|
} AHS;
|
|
|
|
|
|
// doubly nested struct (complex always)
|
|
// -------------------------------------
|
|
// (And enums in struct)
|
|
//
|
|
// _HHS = hosting hosting struct without an alias
|
|
// _NHS = nested hosting struct
|
|
// _NNPS = nested nested primitve struct
|
|
struct _HHS {
|
|
int x, y;
|
|
struct _NHS {
|
|
int x, y;
|
|
struct _NNPS {
|
|
int x,y;
|
|
} _nnps;
|
|
} _nhs;
|
|
};
|
|
|
|
// HHS = hosting hosting struct
|
|
// AHHS = alias of a hosting hosting struct
|
|
// _NNCS = nested nested complex struct
|
|
// _NENHS = nested enum in nested hosting struct
|
|
typedef struct HHS {
|
|
int x, y;
|
|
struct _NHS1 {
|
|
int x, y;
|
|
struct _NNCS {
|
|
struct _CS *a;
|
|
} _nncs;
|
|
enum _NENHS {
|
|
_NENHS1,
|
|
_NENHS2,
|
|
_NENHS3
|
|
};
|
|
} _nhs1;
|
|
} AHHS;
|
|
|
|
|
|
// _NEHS = nested enum in hosting struct
|
|
struct _HS1 {
|
|
int x, y;
|
|
enum _NEHS {
|
|
_NEHS1,
|
|
_NEHS2,
|
|
_NEHS3
|
|
} _nehs;
|
|
};
|
|
|
|
|
|
#endif //STRUCTS_H
|
|
|
|
|