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.

AutoBreakPause

Suspends resp. resumes automatic line breaking.

public property AutoBreakPause { get set }
type bool
value true to suspend automatic line breaking,
false to resume it.

Remarks:

Defaults to false.

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.

IsSoleOwnership

Will this object be disposed upon the next call to Dispose?

[ThreadSafe]
public property IsSoleOwnership { get }
type bool
value true if the object will be disposed when Dispose is called,
false if the object will not be disposed, because some other code is still holding shared ownership (see AcquireThrow).
inherited Disposable.IsSoleOwnership

LifecycleState

Returns the lifecycle state of this object.

public 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.

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

AcquireBase

Acquires a strong reference to this disposable object.

[OwnerReturn, Pure]
public method AcquireBase ()
type IDisposable
returns The strong reference to this disposable object or null iff this object is no longer valid.
inherited Disposable.AcquireBase

Remarks:

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

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

Using this method usually requires type casting. Subclasses may additionally implement IDisposableGeneric, in order to provide some syntactic sugar for that.

AcquireThrow

Acquires a strong reference to this disposable object.

[OwnerReturn, Pure]
public method AcquireThrow ()
type IDisposable
returns [not-null] The strong reference to this disposable object.
inherited Disposable.AcquireThrow

Remarks:

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

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

Exceptions:

Angle

Begins a nested pair of angle brackets: < >

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

See also:

Close

Exceptions:

Braces

Begins a nested pair of braces: ( )

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

See also:

Close

Exceptions:

Brackets

Begins a nested pair of square brackets: [ ]

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

See also:

Close

Exceptions:

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

Exceptions:

Colon

Writes a token: ':'

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

See also:

Token

Exceptions:

Comma

Writes a token: ','

public method Comma (bool autoBreakPause = true)
type SourceCodeWriter
params autoBreakPause Set AutoBreakPause to true while writing the token? Defaults to true.
returns [not-null] this

See also:

Token

Exceptions:

Curly

Begins a nested pair of curly braces: { }

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

See also:

Close

Exceptions:

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.

Implementing methods must not throw any exceptions.

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.

Exceptions:

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.

LinePrefix

Specifies the line prefix to use for subsequent text.

public method LinePrefix (string value)
params value The line prefix value or null.

Remarks:

The given line prefix will be written immediately if on a fresh line (see IsFreshLine). Additional line prefixes will be written after each line break.

Exceptions:

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

Exceptions:


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

Exceptions:

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.

Exceptions:

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

Exceptions:

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)
type SourceCodeWriter
params openTag [not-null] The opening tag.
  endTag [not-null] The end tag.
returns [not-null] this

See also:

Close

Exceptions:

Period

Writes a token: '.'

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

See also:

Token

Exceptions:

Semicolon

Writes a token: '.'

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

See also:

Token

Exceptions:

Tag

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

public method Tag (string name)
type SourceCodeWriter
params name [not-empty] The tag name.
returns [not-null] this

See also:

Close

Exceptions:

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.

Exceptions:

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

Exceptions:


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.

Exceptions:

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.

Exceptions:

White

Writes a whitespace token.

public method White (bool deferred = false)
type SourceCodeWriter
params deferred false to write a whitespace token immediately, true to defer writing until the subsequent token is output: the whitespace will only be output if the subsequent token does not start with a whitespace. Defaults to false.
returns [not-null] this

Exceptions:

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.