J
Jérôme de Lagausie
Hello,
In one hand, I've got a set of more than 130 different structures,
mostly rather simple (a set of simple data members such as int, long, char
[], float ...)
sample :
[h2.h]
#ifndef _H2_H_
#define _H2_H_
#define MEMBER3_LENGTH 100
struct h2 {
int member1 ;
long member2 ;
char member3[MEMBER3_LENGTH] ;
....
} t_h2 ;
#endif
sometimes more complex :
sample :
[h3.h]
#ifndef _H3_H_
#define _H3_H_
struct h3_part {
int member1 ;
long member2 ;
....
} t_h3_part ;
struct h3 {
int memberx ;
t_h3_part innerstruct[3] ;
...
}
#endif
And I need to display the content of any structure, with a function looking
like something like this proto :
void display_content_of (void * data, const char which_structure[])
{
...
if (strcmp (which_structure, "t_h2") == 0)
{
t_h2 *p_h2 = (t_h2 *)data ;
show_all_members_of_h2 (p_h2) ;
}
...
}
I suppose the solution to my quest is something like what does a compiler do
(indeed, my solution is not supposed to work just at run time... It can use
include files, process them, to form a new set of files, compile them and
build the tool I need...)
Maybe yacc & lex would be helpfull, but I need some hints 'cause I don't
know them.
Maye be a solution based on "indexof" and macros exists, too, but I'm not
that confident...
Any help would be much appreciated.
Thank you.
Jerome de Lagausie
In one hand, I've got a set of more than 130 different structures,
mostly rather simple (a set of simple data members such as int, long, char
[], float ...)
sample :
[h2.h]
#ifndef _H2_H_
#define _H2_H_
#define MEMBER3_LENGTH 100
struct h2 {
int member1 ;
long member2 ;
char member3[MEMBER3_LENGTH] ;
....
} t_h2 ;
#endif
sometimes more complex :
sample :
[h3.h]
#ifndef _H3_H_
#define _H3_H_
struct h3_part {
int member1 ;
long member2 ;
....
} t_h3_part ;
struct h3 {
int memberx ;
t_h3_part innerstruct[3] ;
...
}
#endif
And I need to display the content of any structure, with a function looking
like something like this proto :
void display_content_of (void * data, const char which_structure[])
{
...
if (strcmp (which_structure, "t_h2") == 0)
{
t_h2 *p_h2 = (t_h2 *)data ;
show_all_members_of_h2 (p_h2) ;
}
...
}
I suppose the solution to my quest is something like what does a compiler do
(indeed, my solution is not supposed to work just at run time... It can use
include files, process them, to form a new set of files, compile them and
build the tool I need...)
Maybe yacc & lex would be helpfull, but I need some hints 'cause I don't
know them.
Maye be a solution based on "indexof" and macros exists, too, but I'm not
that confident...
Any help would be much appreciated.
Thank you.
Jerome de Lagausie