C# Class NPLMono.NPLWriter

a simple class for creating NPL script code, especially data table code. this class is reentrant (thread-safe). Please note that this class does not ensure that the code is a pure table. See Example: // to generate the string : msg={name=1,2,{"3"="4",},}; NPLWriter writer = new NPLWriter(); writer.WriteName("msg"); writer.BeginTable(); writer.WriteName("name"); writer.WriteValue(1); writer.WriteValue(2); writer.BeginTable(); writer.WriteName("3", true); writer.WriteValue("4"); writer.EndTable(); writer.EndTable(); writer.WriteParamDelimiter(); ParaGlobal.log(writer.ToString()); One can also provide their own string buffer to write to, like below. StringBuilder buff = new StringBuilder(); buff.EnsureCapacity(100); NPLWriter writer = new NPLWriter(buff);
Mostrar archivo Open project: LiXizhi/NPLRuntime

Public Methods

Method Description
Append ( string sText ) : void

append any text

BeginTable ( ) : void
EndTable ( ) : void
GetEmptyMessage ( ) : string

GetNilMessage ( ) : string

NPLWriter ( )
NPLWriter ( StringBuilder buff_ )
NPLWriter ( int nReservedSize )
Reset ( ) : void
Reset ( int nReservedSize ) : void
ToString ( ) : string
WriteName ( string name ) : void
WriteName ( string name, bool bUseBrackets ) : void

write a parameter name

WriteNil ( ) : void
WriteParamDelimiter ( ) : void
WriteValue ( double value ) : void
WriteValue ( string value ) : void
WriteValue ( string value, bool bInQuotation ) : void

rite a parameter value

Method Details

Append() public method

append any text
public Append ( string sText ) : void
sText string
return void

BeginTable() public method

public BeginTable ( ) : void
return void

EndTable() public method

public EndTable ( ) : void
return void

GetEmptyMessage() public static method

public static GetEmptyMessage ( ) : string
return string

GetNilMessage() public static method

public static GetNilMessage ( ) : string
return string

NPLWriter() public method

public NPLWriter ( )

NPLWriter() public method

public NPLWriter ( StringBuilder buff_ )
buff_ StringBuilder

NPLWriter() public method

public NPLWriter ( int nReservedSize )
nReservedSize int

Reset() public method

public Reset ( ) : void
return void

Reset() public method

public Reset ( int nReservedSize ) : void
nReservedSize int
return void

ToString() public method

public ToString ( ) : string
return string

WriteName() public method

public WriteName ( string name ) : void
name string
return void

WriteName() public method

write a parameter name
public WriteName ( string name, bool bUseBrackets ) : void
name string
bUseBrackets bool if false, one has to make sure that the name is a valid NPL name string, without special characters.
return void

WriteNil() public method

public WriteNil ( ) : void
return void

WriteParamDelimiter() public method

public WriteParamDelimiter ( ) : void
return void

WriteValue() public method

public WriteValue ( double value ) : void
value double
return void

WriteValue() public method

public WriteValue ( string value ) : void
value string
return void

WriteValue() public method

rite a parameter value
public WriteValue ( string value, bool bInQuotation ) : void
value string
bInQuotation bool if bInQuotation is true, it writes a parameter text value. Otherwise it will just append the value without encoding it with quotation marks.
return void