C# Класс Fanx.Serial.ObjDecoder

ObjDecoder parses an object tree from an input stream.
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
ObjDecoder ( InStream @in, Map options ) : System.Collections

Construct for input stream.

decode ( string s ) : object
readObj ( ) : object

Read an object from the stream.

Приватные методы

Метод Описание
complexAdd ( Type t, object obj, Method addMethod, object val, int line ) : void
complexSet ( object obj, Field field, object val, int line ) : void
consume ( ) : void

Consume the current token.

consume ( int type, string expected ) : void

Check that the current token matches the specified type, and then consume it.

consumeId ( string expected ) : string

Consume the current token as a identifier.

consumeStr ( string expected ) : string

Consume the current token as a string literal.

endOfStmt ( int lastLine ) : void

Statements can be terminated with a semicolon, end of line or } end of block.

err ( string msg ) : System.Exception

Create exception based on tokenizers current line.

err ( string msg, int line ) : System.Exception

Create error reporting exception.

err ( string msg, int line, System ex ) : System.Exception
isEndOfStmt ( int lastLine ) : bool

Is current token part of the next statement?

readCollection ( Field curField, Type t ) : object

collection := list | map

readComplex ( int line, Type t, bool root ) : object

complex := type [fields] fields := "{" field (eos field)* "}" field := name "=" obj

readComplexAdd ( Type t, int line, List toAdd ) : void
readComplexFields ( Type t, Map toSet, List toAdd ) : void
readComplexSet ( Type t, int line, string name, Map toSet ) : void
readHeader ( ) : void

header := [using]*

readList ( Type of, object first ) : object

list := "[" obj ("," obj)* "]"

readMap ( MapType mapType, object firstKey ) : object

map := "[" mapPair ("," mapPair)* "]" mapPair := obj ":" + obj

readObj ( Field curField, Type peekType, bool root ) : object

obj := literal | simple | complex

readSimple ( int line, Type t ) : object

simple := type "(" str ")"

readSimpleType ( ) : Type

qname := [podName "::"] typeName

readType ( ) : Type

type := listSig | mapSig1 | mapSig2 | qname listSig := type "[]" mapSig1 := type ":" type mapSig2 := "[" type ":" type "]" Note: the mapSig2 with brackets is handled by the method succinctly named readMapTypeOrCollection().

readType ( bool lbracket ) : Type
readTypeOrSlotLiteral ( int line, Type t ) : object

typeLiteral := type "#" slotLiteral := type "#" id

readUsing ( ) : Using

using := usingPod | usingType | usingAs usingPod := "using" podName usingType := "using" podName::typeName usingAs := "using" podName::typeName "as" name

toListOfType ( Type t, Field curField, bool infer ) : Type

Figure out the type of the list: 1) if t was explicit then use it 2) if we have field typed as a list, then use its definition 3) if inferred is false, then drop back to list of Obj 4) If inferred is true then return null and we'll infer the common type

toMapType ( Type t, Field curField, bool infer ) : MapType

Figure out the map type: 1) if t was explicit then use it (check that it was a map type) 2) if we have field typed as a map , then use its definition 3) if inferred is false, then drop back to Obj:Obj 4) If inferred is true then return null and we'll infer the common key/val types

verify ( int type, string expected ) : void

Check that the current token matches the specified type, but do not consume it.

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

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

Construct for input stream.
public ObjDecoder ( InStream @in, Map options ) : System.Collections
@in Fan.Sys.InStream
options Fan.Sys.Map
Результат System.Collections

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

public static decode ( string s ) : object
s string
Результат object

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

Read an object from the stream.
public readObj ( ) : object
Результат object