org.sourceflow.c
Class CFile

java.lang.Object
  extended byorg.sourceflow.CodeElement
      extended byorg.sourceflow.CodeContainer
          extended byorg.sourceflow.CodeFile
              extended byorg.sourceflow.c.CFile
All Implemented Interfaces:
java.lang.Comparable

public class CFile
extends CodeFile

A class generating a C code file.


Constructor Summary
CFile(java.io.File dir, java.lang.String name, boolean header)
          Creates a new C code file in the specified base directory.
 
Method Summary
 void addComment(CComment comment)
          Adds a comment to this file.
 void addFunction(CFunction function)
          Adds a function to the file.
 void addInclude(CInclude include)
          Adds an include to the file.
 void addTypedef(CTypedef typedef)
          Adds a typedef declaration to the file.
 void addVariable(CVariable variable)
          Adds a variable to the file.
 int category()
          Returns a numeric category number for the code element.
 java.lang.String getName()
          Returns the file name.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the file contents to the specified output stream.
 
Methods inherited from class org.sourceflow.CodeFile
getFile, toString, write
 
Methods inherited from class org.sourceflow.CodeContainer
addElement, printContents, size
 
Methods inherited from class org.sourceflow.CodeElement
compareTo, printSeparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CFile

public CFile(java.io.File dir,
             java.lang.String name,
             boolean header)
Creates a new C code file in the specified base directory.

Parameters:
dir - the output directory
name - the base file name (no extension)
header - the header file flag
Method Detail

getName

public java.lang.String getName()
Returns the file name.

Specified by:
getName in class CodeFile
Returns:
the file name

addComment

public void addComment(CComment comment)
Adds a comment to this file.

Parameters:
comment - the new file comment

addInclude

public void addInclude(CInclude include)
Adds an include to the file.

Parameters:
include - the include to add

addTypedef

public void addTypedef(CTypedef typedef)
Adds a typedef declaration to the file.

Parameters:
typedef - the typedef to add

addVariable

public void addVariable(CVariable variable)
Adds a variable to the file.

Parameters:
variable - the variable to add

addFunction

public void addFunction(CFunction function)
Adds a function to the file.

Parameters:
function - the function to add

category

public int category()
Returns a numeric category number for the code element. A lower category number implies that the code element should be placed before code elements with a higher category number within a declaration.

Specified by:
category in class CodeElement
Returns:
the category number

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the file contents to the specified output stream.

Specified by:
print in class CodeElement
Parameters:
out - the output stream
style - the code style to use
indent - the indentation level