<div dir="ltr">Hi,<div><br></div><div style>I made something like that in the past, but with gccxml, and I more or less achieved the same thing with pyclang.</div><div style>I made a free function called encode() and a decode() for usual data types, and then I use my small script (<a href="https://github.com/mbrucher/clang2xml">https://github.com/mbrucher/clang2xml</a>) to help me generate a encode(const MyClass&) decode(MyClass&) that calls the appropriate encode and decode functions, depending on what I scanned. In my case, I also added wrappers for each public function (which actually was my main goal, clang2xml is not as advanced as what I did in the past <a href="http://matt.eifelle.com/2009/07/21/using-gccxml-to-automate-c-wrappers-creation/">http://matt.eifelle.com/2009/07/21/using-gccxml-to-automate-c-wrappers-creation/</a> ), but you can keep it simpler and only serialize and unserialize your data.</div>
<div style>With both libclang and the steps I used with gccxml, I think you will be able to achieve your goal ;)</div><div style><br></div><div style>Cheers,</div><div style><br></div><div style>Matthieu</div><div style><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/29 Raghavendra Keshav <span dir="ltr"><<a href="mailto:ragavendrakk@gmail.com" target="_blank">ragavendrakk@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div>Problem: Want to parse C++ classes in a header file and generate</div><div>              serialize and deserialize methods for this class.</div><div>              example:</div>
<div>              sample.h</div><div>               #include ....</div><div>                class Test</div><div>                {</div><div>                    std::map<int,string> myMap;</div>
<div>                    int i;</div><div>                    string s;</div><div>                    A obj;</div><div>                };</div><div><br></div><div>==>Transform it as below</div>
<div><div>                class Test</div><div>                {</div><div>                    std::map<int,string> myMap;</div><div>                    int i;</div><div>                    string s;</div><div>
                    A obj;</div><div>                   public:</div><div>                    void* encode();</div><div>                };</div><div><br></div><div>            void*     Test::encode()</div>
<div>            {</div><div>                for( i- 0; i<myMap.size(); i++)</div><div>                encodeString();</div><div><br></div><div>                 encodeInt();</div><div>
<br></div><div>                 encodeString();</div><div>                 obj.encode();</div><div><br></div><div>               return buf;</div><div>            }</div><div>            </div>
<div>With the tutotials around i could setup the compiler instance<br></div></div><div>and ASTConsumer and ASTVisitor/</div><div>In the ASTRecursive visitor... i could overload visitRecordDecl(...);</div><div>
On getting a CXXRecordDecl...i have iterated through FieldDecl</div><div>Now From FieldDecl...i want to extract information like</div><div>it is map made from int and string...</div><div>Am not able get the relationship of FieldDecl to CTemplateDecl...</div>

<div>and from CTemplateDecl how to extract the params?</div><div><br></div><div>Pls provide direction how to proceed further...</div><div><br></div><div>regards</div><div>ragha</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Information System Engineer, Ph.D.<br>Blog: <a href="http://matt.eifelle.com" target="_blank">http://matt.eifelle.com</a><span style="padding-right:16px;width:16px;height:16px"></span><span style="padding-right:16px;width:16px;height:16px"></span><br>
LinkedIn: <a href="http://www.linkedin.com/in/matthieubrucher" target="_blank">http://www.linkedin.com/in/matthieubrucher</a><span style="padding-right:16px;width:16px;height:16px"></span><br>Music band: <a href="http://liliejay.com/" target="_blank">http://liliejay.com/</a><span style="padding-right:16px;width:16px;height:16px"></span><br>
<span style="padding-right:16px;width:16px;height:16px"></span>
</div>