Parsing Nested Structures/Unions defined in C/C++ header files in XML

I have a structure represented as follows: (Example)

1
2
3
4
5
6
7
8
struct struct3
{
   struct structchild4
   {  
      float child5;
   } child6;
   unsigned int child7;
};


I want this to be represented as follows in XML:

1
2
3
4
5
6
7
8
9
10
11
12
13
<tag1= "struct3">
        <name>struct3</name>
        <input_type>byte</input_type>
        <method></method>
        <tag_ref = "structchild4">
            <name>child6</name>
        </tag_ref>
        <tag2= "child7">
            <name>child7</name>
            <len>4</len>
            <value> </value>
        </tag2>
    </tag1>


The method I'm following is that I'm converting this into a gccXML format and I then parse it using Visual C++. I use the xerces-c DOM parser. Also, my project demands are such that I have to use the xerces-c DOM parser and gccXML.

Could anyone suggest how to go about doing this? I'm really stuck on this. Thanks!
closed account (o3hC5Di1)
Hi there,

This is not really a beginner question, if you don't get sufficient response on this it may be worth trying to ask the question in the "general c++ programming" forum.

As to your question, you will need to perform reflection on your struct as to get its name etc.
Here's some info to get you started, but a google for "c++ reflection" will turn up much more results.

http://stackoverflow.com/questions/41453/how-can-i-add-reflection-to-a-c-application

Hope that helps.

All the best,
NwN
Thank you NwN
Topic archived. No new replies allowed.