J
jacob navia
Hi
I have succeeded in making a completely general value lists
in a single file. This template file is given its
parameters by a small parameter file that looks
like this:
#define DATA_TYPE int
#define LIST_TYPE intList
#define LIST_ELEMENT intListElement
#define INTERFACE intListInterface
#define INTERFACE_NAME iintList
#define ITERATOR intListIterator
As you cansee, all those names are derived from the name of
the underlying listdata type, in this case "int"
Does anyone here see a way of generating those names
automatically given ONLY the "int" parameter?
The naive approach will not work since in
#define LIST_TYPE(t) t##List
the "t" parameter is NOT evaluated so
LIST_TYPE(DATA_TYPE) will produce
DATA_TYPEList and NOT intList
even if I #defined DATA_TYPE to int.
Any ideas?
Thanks
P.S. I will explain the template file approach in another message
That will allow you to produce automatically a list interface
for ANY datatype without having to loose compiler checking
and use void pointers at all.
I have succeeded in making a completely general value lists
in a single file. This template file is given its
parameters by a small parameter file that looks
like this:
#define DATA_TYPE int
#define LIST_TYPE intList
#define LIST_ELEMENT intListElement
#define INTERFACE intListInterface
#define INTERFACE_NAME iintList
#define ITERATOR intListIterator
As you cansee, all those names are derived from the name of
the underlying listdata type, in this case "int"
Does anyone here see a way of generating those names
automatically given ONLY the "int" parameter?
The naive approach will not work since in
#define LIST_TYPE(t) t##List
the "t" parameter is NOT evaluated so
LIST_TYPE(DATA_TYPE) will produce
DATA_TYPEList and NOT intList
even if I #defined DATA_TYPE to int.
Any ideas?
Thanks
P.S. I will explain the template file approach in another message
That will allow you to produce automatically a list interface
for ANY datatype without having to loose compiler checking
and use void pointers at all.