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);
Afficher le fichier Open project: LiXizhi/NPLRuntime

Méthodes publiques

Méthode 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 méthode

append any text
public Append ( string sText ) : void
sText string
Résultat void

BeginTable() public méthode

public BeginTable ( ) : void
Résultat void

EndTable() public méthode

public EndTable ( ) : void
Résultat void

GetEmptyMessage() public static méthode

public static GetEmptyMessage ( ) : string
Résultat string

GetNilMessage() public static méthode

public static GetNilMessage ( ) : string
Résultat string

NPLWriter() public méthode

public NPLWriter ( )

NPLWriter() public méthode

public NPLWriter ( StringBuilder buff_ )
buff_ StringBuilder

NPLWriter() public méthode

public NPLWriter ( int nReservedSize )
nReservedSize int

Reset() public méthode

public Reset ( ) : void
Résultat void

Reset() public méthode

public Reset ( int nReservedSize ) : void
nReservedSize int
Résultat void

ToString() public méthode

public ToString ( ) : string
Résultat string

WriteName() public méthode

public WriteName ( string name ) : void
name string
Résultat void

WriteName() public méthode

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.
Résultat void

WriteNil() public méthode

public WriteNil ( ) : void
Résultat void

WriteParamDelimiter() public méthode

public WriteParamDelimiter ( ) : void
Résultat void

WriteValue() public méthode

public WriteValue ( double value ) : void
value double
Résultat void

WriteValue() public méthode

public WriteValue ( string value ) : void
value string
Résultat void

WriteValue() public méthode

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.
Résultat void