TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class SourceCodeWriter in Tinman.Core.Parsing

sealed class SourceCodeWriter extends Disposable
  implements IFlushable

Public / Attributes

AutoBreakColumns

The maximum number of columns (inclusive indentation) to write per source code line before emitting an automatic line break.

public property AutoBreakColumns { get }
type int32
value [>=0] The maximum number of columns before auto-breaking occurs.

Column

Returns the current column number (zero-based).

public property Column { get }
type int32
value [>=0] The current column number.

Indent

The current line indent level.

public property Indent { get set }
type int32
value [>=0] The current line indent level.

IndentToken

The string token that represents a single indentation level.

public property IndentToken { get }
type string
value [not-null] The indent token string.

IsFreshLine

Is the current line fresh (i.e. no characters have been output yet)?

public property IsFreshLine { get }
type bool
value true if the current line is fresh, false if not.

LifecycleState

Returns the lifecycle state of this object.

public virtual property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited Disposable.LifecycleState

Line

Returns the current line number (zero-based).

public property Line { get }
type int32
value [>=0] The current line number.

LinePrefix

public property LinePrefix { get set }
type string
value

Public / Constructors

SourceCodeWriter

Creates a new instance of SourceCodeWriter.

public constructor SourceCodeWriter ([Owner] ITextStream stream, int32 autoBreakColumns = 100, string indentToken = " ", LineEnding newlineToken = LineEnding.Native)
params stream [not-null] The output text stream.
  autoBreakColumns [>=0] The maximum number of columns (inclusive indentation) to write per source code line before emitting an automatic line break.
  indentToken [not-null] The string token that represents a single indentation level. Defaults to two whitespace characters.
  newlineToken The string token that represents a line break. Defaults to Native.

Public / Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
public method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited Disposable.AcquireTry

Remarks:

The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

Angle

Begins a nested pair of angle brackets: < >

public method Angle ()
type SourceCodeWriter
returns [not-null] this

See also:

Close

Braces

Begins a nested pair of braces: ( )

public method Braces ()
type SourceCodeWriter
returns [not-null] this

See also:

Close

Brackets

Begins a nested pair of square brackets: [ ]

public method Brackets ()
type SourceCodeWriter
returns [not-null] this

See also:

Close

Close

Closes the current nested tag by writing the end tag that has been specified by the corresponding call to Open.

public method Close ()
type SourceCodeWriter
returns [not-null] this

See also:

Open
Angle
Braces
Brackets
Curly

Colon

Writes a token: ':'

public method Colon ()
type SourceCodeWriter
returns [not-null] this

See also:

Token

Comma

Writes a token: ','

public method Comma ()
type SourceCodeWriter
returns [not-null] this

See also:

Token

Curly

Begins a nested pair of curly braces: { }

public method Curly ()
type SourceCodeWriter
returns [not-null] this

See also:

Close

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
public method Dispose ()
inherited Disposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

Flush

Flushes all cached data.

public method Flush ()
implements IFlushable.Flush

Remarks:

Performing a flush may result in I/O work. Depending on the semantics of the implementing class, this work may need to be wrapped in special Begin / End method calls. See the documentation of the implementing classes for details.

In case this object represents a read-only resource, calling the Flush method has no effect.

IndentLeft

Decreases the indentation level.

public method IndentLeft (int32 n = 1)
type SourceCodeWriter
params n [>=0] Number of indentation levels to remove.
returns [not-null] this

Remarks:

The new indentation level will be taken into account when the next line break is emitted.

IndentRight

Increases the indentation level.

public method IndentRight (int32 n = 1)
type SourceCodeWriter
params n [>=0] Number of indentation levels to add.
returns [not-null] this

Remarks:

The new indentation level will be taken into account when the next line break is emitted.

Newline

Appends a line break and begins a fresh line.

public method Newline (int32 n = 1)
type SourceCodeWriter
params n [>=0] Number of line breaks to emit.
returns [not-null] this

Writes the given token, followed by a line break.

public method Newline (string token)
type SourceCodeWriter
params token [not-null] The string token to write.
returns [not-null] this

NewlineIfNotFresh

Ensures that the current write cursor is located at the beginning of a fresh source code line.

public method NewlineIfNotFresh ()
type SourceCodeWriter
returns [not-null] this

Remarks:

This method emits a line break when characters have been written to the current code line.

Node

Writes a node that itself is producing source code.

public method Node (ICodeOutput node, Context context)
type SourceCodeWriter
params node [not-null] The source code producing node.
  context [not-null] Context object.
returns [not-null] this

Open

Begins a nested tag by writing the opening tag now and the end tag when the corresponding call to Close is made.

public method Open (string openTag, string endTag, bool autoBreak = true)
type SourceCodeWriter
params openTag [not-null] The opening tag.
  endTag [not-null] The end tag.
  autoBreak true if openTag and endTag count for auto-breaking lines, false if not (i.e. they represent markup and no actual content).
returns [not-null] this

See also:

Close

Period

Writes a token: '.'

public method Period ()
type SourceCodeWriter
returns [not-null] this

See also:

Token

Semicolon

Writes a token: '.'

public method Semicolon ()
type SourceCodeWriter
returns [not-null] this

See also:

Token

Tag

Begins an XML element pair: <name> </name>

public method Tag (string name, bool autoBreak = true)
type SourceCodeWriter
params name [not-empty] The tag name.
  autoBreak true if name counts for auto-breaking lines, false if not (i.e. they represent markup and no actual content).
returns [not-null] this

See also:

Close

Text

Writes the given text.

public method Text (string text, TrimBehaviour behaviour = TrimBehaviour.WhitespaceAndLineBreak)
type SourceCodeWriter
params text [not-null] The text to write.
  behaviour The trim behaviour to use. Defaults to WhitespaceAndLineBreak.
returns [not-null] this

Remarks:

The text will be split at the whitespaces and the resulting tokens will be emitted in order.

Token

Writes a token on the current source code line.

public method Token (string token)
type SourceCodeWriter
params token [not-null] The token to write.
returns [not-null] this

Remarks:

A token is considered to be atomic, i.e. it will never be split because of automatic line breaks.

See also:

Colon
Comma
Period
Semicolon
White

Writes a token on the current source code line.

public method Token (char token, int32 n = 1)
type SourceCodeWriter
params token The token character to write.
  n Number of times to repeat token. Defaults to 1.
returns [not-null] this

Remarks:

A token is considered to be atomic, i.e. it will never be split because of automatic line breaks.

Underline

Underlines the current line using the given character.

public method Underline (char character = ''-'')
type SourceCodeWriter
params character The underline character. Defaults to '-'.
returns [not-null] this

Remarks:

A line break is emitted after the underline. If the current line is still fresh, the method silently returns.

White

Writes a whitespace token.

public method White ()
type SourceCodeWriter
returns [not-null] this

WillAutoBreak

Will an automatic line-break occur when the next token is output?

public method WillAutoBreak (int32 n = 1)
type bool
params n [>=0] Length of next token, in characters.
returns true if a line-break will occur, false if not.