cxxDocument derived from none

Description: the main class that analyzes and generates documentation for a class

notes:
Category: cxxDocumentor
Author: Alex Hill
11/01/01
Revision: 12/02/4 Alex Hill - added debuging and commenting

    Source

cxxDocument.cxx
cxxDocument.h

    Comments

constructor cxxDocument

1 set the default class template file
2 create a root object for the object tree
3 register the following variable types "int,short,long,float,double,bool"
4 register the following document tags "author,description,revision,category"
5 set the degault category tag to "none"
6 set the default parentname tag to "none"
7 evaluate CXXDOCUMENTOR_DEBUG environmental variable

destructor ~cxxDocument

1 delete all object tree nodes

method setTemplate

1 the template file to generate the class page

method analyze

1 open the given file
2 parse the filename and directory
3 set the fiename and directory tags
4 for each token in the file
4.1 if the token contains "::" and we are at a depth of zero then
4.1.1 extract the class name and fuction name
4.1.2 create a cxxFunction object
4.1.3 if the function name and class name are the same then
4.1.3.1 set the function style as constructor
4.1.3.1.1 extract the parent class
4.1.3.1 set the function style as destructor
4.1.3.1 extract the function return type
4.1.3.2 set the function style as normal
4.1.4 add the function object as a child of the root
4.2 else if the token is "{" then increment the nesting depth
4.3 else if the token is "}" then decrement the nesting depth
4.4 else if the token begins with "//" then
4.4.1 create a cxxComment object
4.4.2 set the comment style to C++
4.4.3 add the object as a child of the current object
4.5 else if the token begins with "/*" then
4.5.1 create a cxxComment object
4.5.2 set the comment style to C
4.5.3 add the object as a child of the current object
4.6 ele if the current object is the root then break
4.7 else if the token if one of "if,else,elseif,while,for,do" then
4.7.1 create a new cxxStatement object
4.7.2 if the token is "else" then
4.7.2.1 if the next token is "if" then
4.7.2.1.1 set the statement name to "elseif"
4.7.2.1.2 get the next token and parse the conditionals
4.7.2.1.1 else set the statement name to "else"
4.7.3 else get the next token and parse the conditionals
4.7.4 add the object as a child of the current object
4.8 else if the token begins with "(" then
4.8.1 if the last variable created has the same name as token then
4.8.1.1 if the last variable was "identifier" then set it as "fuctioncall"
4.8.1.2 parse the functioncall arguments
4.8.2 else
4.8.2.1 create a new cxxVariable object
4.8.2.2 set the variable type as "functioncall"
4.8.2.3 add the object as a child of the current object
4.9 else if the token matches one of the registered data types (i.e. float, int, etc.) then
4.9.1 create a new cxxVariable object
4.9.2 parse the type by checking the last two tokens
4.9.3 add the object as a child of the current object
4.10 else if the token is one of "=,+=,-=" then
4.10.1 create a new cxxVariable object
4.10.2 set the variable type to "assignment"
4.10.3 add the object as a child of the current object
4.11 if the token ends with ";" then set the current object to the parent object

method addVariable

1 add a variable to the variables list
2 call recursively on all variable children

method findTag

1 parse a comment string for instances of registered document tags
2 while there are tokens in the comment string
2.1 for each registered tag
2.1.1 add ":" to the document tag
2.1.2 if the tag matches the token then
2.1.2.1 parse out the rest of the comment string
2.1.2.2 set the associated document tag to the parsed string

method replaceTags

1 search for document tags in a string and replace with the registered data

method getTag

1 return the document tag mapped to the given string

method printVariables

1 print out all variables from the variables list

method printFunctions

1 print out all functions from the functions list

method printStatements

1 print out all statements from the statements list

method printComments

1 print out all comments from the comments list

method print

1 print all variables, fucntions, statements, and comments

method getFunctionCall

method printHeaderHTML

1 print out the first comment child of the root of the object tree

method printCommentsHTML

1 traverse the object tree and print out each comment with associated indention and labels

method printHTML

1 attempt to recreate the source code by traversing the object tree and printing each C++ element

method report

1 open the class template file
2 if file is not found then
2.1 open the file at /usr/local/cxxDocuemtor_0.2
3 if file is not found then error and return
4 open the class output file
5 while not at the end of the file
5.1 get a line from the stream
5.2 output the line to the output file
5.3 if the line contains "
5.3.1 extract the first meta tag parameter from the line
5.3.2 extract the second meta tag parameter from the line
5.3.3 if the name meta tag parameter equals "cxxDocument" then
5.3.3.1 if the meta tag content parameter equals "header" then
5.3.3.1.1 print out the header HTML
5.3.3.2 else if the meta tag content parameter equals "print" then
5.3.3.2.1 print out the source code in HTML
5.3.3.3 else if the meta tag content parameter equals "comments" then
5.3.3.3.1 print out the comments in HTML
6 close the input stream
7 close the output stream