Reputation: 762
I would like to develop a application (i prefer c++), which will take C header file with lot of nested structures as input and generate a html page where the data will be presented as Hierarchial tree structures, which can be collapsed..
struct level1
{
struct level2
{
struct level3
{
}
}
};
[+] level1
I can collapse the level1 as below
[-] level1
[-] level2
[+] level3
Its for Learning purpose..and i am not sure where to start. Few pointers will be really helpful.
Upvotes: 0
Views: 688
Reputation: 3939
You could use Clang's parser. It's supposed to have a pretty nice API.
Upvotes: 1
Reputation: 8000
when you view an XML page in IE it uses an XSLT to turn it into this kind of collapsible tree structure. This XSL can be viewed by entering this in the address bar:
res://msxml.dll/DEFAULTSS.XSL
Personally I would use a similar method for your problem but if you must use C++ you can use the above to get an idea of what markup is required.
EDIT - I should have mentioned this before, that if you wanted to use the XSL method, you'll need to pre-process the header file into xml. This might sound long-winded but the two layers mean you can switch the xsl out to change the way it looks on screen whilst keeping the code that arranges what you want displayed separate. Over-engineering for a simple test project - maybe.
Upvotes: 1
Reputation: 281875
The hardest part will be parsing the C header files. GCCXML will do that for you, outputting an XML structure that's then trivial to parse.
Upvotes: 6
Reputation: 28384
You might want to checkout ctags and DOxygen because they create HTML from various source code files for documentation purposes. Probably has what you need, and ctags I am sure will have C++ bindings.
Upvotes: 2