public static DateTime ReadTime(Reader reader) { var result = ValueReader.ReadTime(reader.Stream); reader.AddReference(result); return(result); }
public static Guid ReadGuid(Reader reader) { var result = ValueReader.ReadGuid(reader.Stream); reader.AddReference(result); return(result); }
public static string ReadString(Reader reader) { var result = ValueReader.ReadString(reader.Stream); reader.AddReference(result); return(result); }
public static char[] ReadChars(Reader reader) { var result = ValueReader.ReadChars(reader.Stream); reader.AddReference(result); return(result); }
public static byte[] ReadBytes(Reader reader) { var result = ValueReader.ReadBytes(reader.Stream); reader.AddReference(result); return(result); }
public static T[] ReadArray <T>(Reader reader) { Stream stream = reader.Stream; int count = ValueReader.ReadCount(stream); T[] a = new T[count]; reader.AddReference(a); var deserializer = Deserializer <T> .Instance; for (int i = 0; i < count; ++i) { a[i] = deserializer.Deserialize(reader); } stream.ReadByte(); return(a); }
private static void ReadUTF8CharRaw(Stream stream, Stream ostream) { int tag = stream.ReadByte(); switch (tag >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: { // 0xxx xxxx ostream.WriteByte((byte)tag); break; } case 12: case 13: { // 110x xxxx 10xx xxxx ostream.WriteByte((byte)tag); ostream.WriteByte((byte)stream.ReadByte()); break; } case 14: { // 1110 xxxx 10xx xxxx 10xx xxxx ostream.WriteByte((byte)tag); ostream.WriteByte((byte)stream.ReadByte()); ostream.WriteByte((byte)stream.ReadByte()); break; } default: throw ValueReader.BadEncoding(tag); } }
private static void ReadStringRaw(Stream stream, Stream ostream) { int count = 0; int tag = '0'; do { count *= 10; count += tag - '0'; tag = stream.ReadByte(); ostream.WriteByte((byte)tag); } while (tag != TagQuote); for (int i = 0; i < count; ++i) { tag = stream.ReadByte(); switch (tag >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: { // 0xxx xxxx ostream.WriteByte((byte)tag); break; } case 12: case 13: { // 110x xxxx 10xx xxxx ostream.WriteByte((byte)tag); ostream.WriteByte((byte)stream.ReadByte()); break; } case 14: { // 1110 xxxx 10xx xxxx 10xx xxxx ostream.WriteByte((byte)tag); ostream.WriteByte((byte)stream.ReadByte()); ostream.WriteByte((byte)stream.ReadByte()); break; } case 15: { // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx if ((tag & 0xf) <= 4) { ostream.WriteByte((byte)tag); ostream.WriteByte((byte)stream.ReadByte()); ostream.WriteByte((byte)stream.ReadByte()); ostream.WriteByte((byte)stream.ReadByte()); ++i; break; } goto default; // no break here!! here need throw exception. } default: throw ValueReader.BadEncoding(tag); } } ostream.WriteByte((byte)stream.ReadByte()); }