CodeWriter class

The abstract base class for all code writers. This writer implements the TextWriter interface by decorating the TextWriter provided in the constructor.

Interface Realizations

Attributes

NameTypeDescription
endOfLineStringvoid Gets or sets the end of line string. The default value is platform dependent. 
indentStringvoid Gets or sets the indent string. The default value is a '\t' (tab character). 

Operations

NameReturnsDescription
clearIndent()

CodeWriter.clearIndent

X

Resets any indentation, causing new line writes to start at the first character position.

Return value
Type: this 
this Resets any indentation, causing new line writes to start at the first character position. 
constructor(writer)

CodeWriter.constructor

X

Constructor. Creates a new CodeWriter that uses the provided TextWriter internally.

Parameters
NameTypeDescription
writerTextWriter A TextWriter object. In a code generation template, a TextWriter instance can be obtained by calling any of the generate...() functions on the current CodeGenerator.
Return value
Type: CodeWriter 
CodeWriter Constructor. Creates a new CodeWriter that uses the provided TextWriter internally. 
decreaseIndent()

CodeWriter.decreaseIndent

X

Decreases the current indent, which is prefixed to each line of the output.

Return value
Type: this 
this Decreases the current indent, which is prefixed to each line of the output. 
increaseIndent()

CodeWriter.increaseIndent

X

Increases the current indent, which is prefixed to each line of the output.

Return value
Type: this 
this Increases the current indent, which is prefixed to each line of the output.  
write(value)

CodeWriter.write

X

Writes a string value to the output.

Parameters
NameTypeDescription
valuestring The string value to be written.
Return value
Type: this 
this Writes a string value to the output. 
writeEndOfLine(value)

CodeWriter.writeEndOfLine

X

Writes the endOfLineString to the output.

Parameters
NameTypeDescription
valuestring [0..1]Any value to write before the endOfLineString string is written.
Return value
Type: this 
this Writes the endOfLineString to the output. 
writeFile(path, encoding)

CodeWriter.writeFile

X

Writes the contents of the specified file to the output.

Parameters
NameTypeDescription
pathstring 
encodingstring [0..1]Optional: the encoding that is used for the file. The default is 'utf-8'.
Return value
Type: this 
this Writes the contents of the specified file to the output.  
writeFileRegion(regionName, path, encoding)

CodeWriter.writeFileRegion

X

Writes the contents of the specified file region to the output.

Parameters
NameTypeDescription
regionNamestring The name of the region to write. The region should be marked using "/// code goes here...".
pathstring 
encodingstring [0..1]The encoding that is used for the file. The default is 'utf-8'.
Return value
Type: boolean 
boolean Writes the contents of the specified file region to the output.  
writeIndent()

CodeWriter.writeIndent

X

Writes the current indentString to the output.

Return value
Type: this 
this Writes the current indentString to the output.  
writeLine(value)

CodeWriter.writeLine

X

Writes a new line to the output. The line is indented automatically. The line is ended with the endOfLineString.

Parameters
NameTypeDescription
valuestring [0..1]The line to write. When omitted, only the endOfLineString is written.
Return value
Type: this 
this Writes a new line to the output. The line is indented automatically. The line is ended with the endOfLineString. 
writeLineIndented(value)

CodeWriter.writeLineIndented

X

Writes a new line to the output while temporarily increasing the indent. The line is ended with the endOfLineString.

Parameters
NameTypeDescription
valuestring The line to write.
Return value
Type: this 
this Writes a new line to the output while temporarily increasing the indent. The line is ended with the endOfLineString. 
writeLines(values, delimiter)

CodeWriter.writeLines

X

Writes a collection of lines to the output. Each line is indented automatically and ended with the endOfLineString.

Parameters
NameTypeDescription
valuesstring [*]The lines to write.
delimiterstring [0..1]An optional delimiter to be written at the end of each line, except for the last one.
Return value
Type: this 
this Writes a collection of lines to the output. Each line is indented automatically and ended with the endOfLineString. 
writeWhiteSpace()

CodeWriter.writeWhiteSpace

X

Writes a single whitespace character to the output.

Return value
Type: this 
this Writes a single whitespace character to the output.