org.sourceflow.c
Class CVariable

java.lang.Object
  extended byorg.sourceflow.CodeElement
      extended byorg.sourceflow.c.CVariable
All Implemented Interfaces:
java.lang.Comparable

public class CVariable
extends CodeElement

A class generating a C variable declaration.


Field Summary
static int CONST
          The const modifier constant.
static int EXTERN
          The extern modifier constant.
static int STATIC
          The static modifier constant.
 
Constructor Summary
CVariable(int modifiers, java.lang.String type, boolean array, java.lang.String name)
          Creates a new variable with the specified type and name.
CVariable(java.lang.String type, boolean array, java.lang.String name)
          Creates a new variable with the specified type and name.
CVariable(java.lang.String type, java.lang.String name)
          Creates a new variable with the specified type and name.
 
Method Summary
 void addComment(CComment comment)
          Adds a comment to this variable.
 void addInitValue(java.lang.String value)
          Adds an initialization value.
 int category()
          Returns a numeric category number for the code element.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the code element to the specified output stream.
 java.lang.String toString()
          Returns the variable name.
 
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
 

Field Detail

STATIC

public static final int STATIC
The static modifier constant.

See Also:
Constant Field Values

EXTERN

public static final int EXTERN
The extern modifier constant.

See Also:
Constant Field Values

CONST

public static final int CONST
The const modifier constant.

See Also:
Constant Field Values
Constructor Detail

CVariable

public CVariable(java.lang.String type,
                 java.lang.String name)
Creates a new variable with the specified type and name.

Parameters:
type - the variable type
name - the variable name

CVariable

public CVariable(java.lang.String type,
                 boolean array,
                 java.lang.String name)
Creates a new variable with the specified type and name.

Parameters:
type - the variable type
array - the array type flag
name - the variable name

CVariable

public CVariable(int modifiers,
                 java.lang.String type,
                 boolean array,
                 java.lang.String name)
Creates a new variable with the specified type and name.

Parameters:
modifiers - the modifier flags to use (or zero)
type - the variable type
array - the array type flag
name - the variable name
Method Detail

toString

public java.lang.String toString()
Returns the variable name.

Returns:
the variable name

addInitValue

public void addInitValue(java.lang.String value)
Adds an initialization value. For array types several initialization values can be added.

Parameters:
value - the value

addComment

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

Parameters:
comment - the comment 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 code element 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