1#!/usr/bin/perl 2 3# 4# This PERL script builds a Diagram of a C++ Class Hierarchy. 5# Contributed by: Hans Elbers (elbers@dsv.nl) 6# 7# usage: maketree FullDirectoryNameOfFoxIncludes/*.h >tree.html 8 9 10foreach $file (@ARGV) { 11 open (FILE, "<$file"); 12 while (<FILE>) { 13 next unless (/class\s+FXAPI\s+(\w+)\s*:\s*public\s*(\w+).*{/); 14 $parent = $2; 15 $child = $1; 16 $children{$parent} = $children{$parent}.",".$child; 17 $file{$child} = $file; 18 } 19 close FILE; 20} 21 22print <<END; 23<HTML> 24<HEAD><TITLE>FOX Class Hierarchy</TITLE></HEAD> 25<BODY> 26<H1>FOX Class Hierarchy</H1> 27<PRE> 28END 29 30showChildren ('FXObject', 0); 31 32print "</PRE></BODY></HTML>\n"; 33 34sub showChildren() { 35 my $class=shift; 36 my $indent=shift; 37 my $tab = "| " x $indent; 38 print "$tab<A HREF=file://$file{$class}>$class</A>\n"; 39 my @child = split (/,/, $children{$class}); 40 shift @child; 41 sort @child; 42 for (my $i=0; $i<@child; $i++) { 43 showChildren($child[$i], $indent+1); 44 } 45} 46