Retry
Retry

Reputation: 159

Nested Structures/Unions defined in C/C++ header files in XML by Reflection

I have a structure represented as follows: (Example)

struct struct3
{
   struct structchild4
   {  
      float child5;
   } child6;
   unsigned int child7;
};

I want this to be represented as follows in XML:

<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.

Could anyone suggest how to go about doing this? A gentle bounce on this. Is there anyway I can send my code? Its huge and exceeds the character limit. Thanks!

Upvotes: 0

Views: 647

Answers (1)

Gearoid Murphy
Gearoid Murphy

Reputation: 12116

As you're already aware, gccXML has some significant limitations, there are a number of open source C++ parsers described here. Unfortunately, relfection in C++ is a lot of work for the coder (but an excellent exercise nonetheless), my favoured approach is to use the clang python API, clang is an excellent C++ parser but it's up to you to decide how to process that information (by outputting to XML or JSON). There used to be an XML printer for Clang but unfortunately I don't believe it's still active, you may be able to use an earlier build though. Best of luck!

Upvotes: 1

Related Questions