private Tdf ReadTdf() { Tdf tdf = null; var label = ReadLabel(); var type = (TdfBaseType)_stream.ReadByte(); switch (type) { case TdfBaseType.Integer: tdf = DecodeTdfInteger(label); break; case TdfBaseType.String: tdf = DecodeTdfString(label); break; case TdfBaseType.Binary: tdf = DecodeTdfBlob(label); break; case TdfBaseType.Struct: tdf = DecodeTdfStruct(label); break; case TdfBaseType.List: tdf = DecodeTdfList(label); break; case TdfBaseType.Map: tdf = DecodeTdfMap(label); break; case TdfBaseType.Union: tdf = DecodeTdfUnion(label); break; case TdfBaseType.Variable: tdf = DecodeTdfIntegerList(label); break; case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_TYPE: tdf = DecodeTdfVector2(label); break; case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID: tdf = DecodeTdfVector3(label); break; default: Log.Warn(string.Format("Unknown Tdf type: {0}", type)); break; } return(tdf); }
private void WriteTdf(Tdf tdf) { // write label WriteLabel(tdf.Label); // write type _stream.WriteByte((byte)tdf.Type); switch (tdf.Type) { case TdfBaseType.Integer: WriteTdfInteger((TdfInteger)tdf); break; case TdfBaseType.String: WriteString(((TdfString)tdf).Value); break; case TdfBaseType.Binary: WriteBlob(((TdfBlob)tdf).Data); break; case TdfBaseType.Struct: WriteStruct(((TdfStruct)tdf).Data); break; case TdfBaseType.List: WriteTdfList((TdfList)tdf); break; case TdfBaseType.Map: WriteTdfMap((TdfMap)tdf); break; case TdfBaseType.Union: WriteTdfUnion((TdfUnion)tdf); break; case TdfBaseType.Variable: WriteTdfIntegerList((TdfIntegerList)tdf); break; case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_TYPE: WriteTdfVector2((TdfVector2)tdf); break; case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID: WriteTdfVector3((TdfVector3)tdf); break; default: Log.Warn(string.Format("Unknown Tdf type: {0}", tdf.Type)); break; } }
public Dictionary <string, Tdf> Decode() { while (_stream.Position != _stream.Length) { Tdf tdf = ReadTdf(); if (tdf != null) { _result.Add(tdf.Label, tdf); } } return(_result); }