tags:

views:

126

answers:

4

hi

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

file.h

struct level1
{
  struct level2
  {
     struct level3
     {

     }
  }
};

file.html

[+] 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.

+1  A: 

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.

Chris Simpson
hi chris, i am getting page cant be found error when i enter res://msxml.dll/DEFAULTSS.XSL in address bar
Warrior
interesting. what version of IE? I'm using 7. Are you on 8? There's a few other ways to get at this - here: http://forums.devx.com/archive/index.php/t-4702.html
Chris Simpson
Also, I need to add that you would need to do a little preprocessing on your header file to make it readable by the XSL. I should have pointed that out before.
Chris Simpson
Will it work with all the browsers or only IE ?
Warrior
That link I posted to view the source XSL will only work in IE. Converting XML into HTML with an XSLT will work in any browser (browser differences aside)
Chris Simpson
+2  A: 

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.

Aiden Bell
+6  A: 

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.

RichieHindle
And then you can use XSLT. :::Laughs evilly:::
Brian
+1 .. Nice, didn't know that existed. Might be useful to incorporate into a bug reporting system for a C codebase.
Aiden Bell
+1  A: 

You could use Clang's parser. It's supposed to have a pretty nice API.

Daniel James