C# Класс 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);
Показать файл Открыть проект

Открытые методы

Метод Описание
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

Описание методов

Append() публичный Метод

append any text
public Append ( string sText ) : void
sText string
Результат void

BeginTable() публичный Метод

public BeginTable ( ) : void
Результат void

EndTable() публичный Метод

public EndTable ( ) : void
Результат void

GetEmptyMessage() публичный статический Метод

public static GetEmptyMessage ( ) : string
Результат string

GetNilMessage() публичный статический Метод

public static GetNilMessage ( ) : string
Результат string

NPLWriter() публичный Метод

public NPLWriter ( )

NPLWriter() публичный Метод

public NPLWriter ( StringBuilder buff_ )
buff_ StringBuilder

NPLWriter() публичный Метод

public NPLWriter ( int nReservedSize )
nReservedSize int

Reset() публичный Метод

public Reset ( ) : void
Результат void

Reset() публичный Метод

public Reset ( int nReservedSize ) : void
nReservedSize int
Результат void

ToString() публичный Метод

public ToString ( ) : string
Результат string

WriteName() публичный Метод

public WriteName ( string name ) : void
name string
Результат void

WriteName() публичный Метод

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.
Результат void

WriteNil() публичный Метод

public WriteNil ( ) : void
Результат void

WriteParamDelimiter() публичный Метод

public WriteParamDelimiter ( ) : void
Результат void

WriteValue() публичный Метод

public WriteValue ( double value ) : void
value double
Результат void

WriteValue() публичный Метод

public WriteValue ( string value ) : void
value string
Результат void

WriteValue() публичный Метод

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.
Результат void