blob: 2702ad8046a05bc237f6073f1142334420a252a7 [file] [log] [blame]
David Reiss7f42bcf2008-01-11 20:59:12 +00001//
2// TProtocol.cs
3//
4// Begin: Aug 19, 2007
David Reiss0c90f6f2008-02-06 22:18:40 +00005// Authors:
David Reiss7f42bcf2008-01-11 20:59:12 +00006// Todd Berman <tberman@imeem.com>
7//
8// Distributed under the Thrift Software License
9//
10// See accompanying file LICENSE or visit the Thrift site at:
11// http://developers.facebook.com/thrift/using
12
13using System;
14using System.Collections.Generic;
15using System.Text;
16using Thrift.Transport;
17
18namespace Thrift.Protocol
19{
20 public abstract class TProtocol
21 {
22 protected TTransport trans;
23
24 protected TProtocol(TTransport trans)
25 {
26 this.trans = trans;
27 }
28
29 public TTransport Transport
30 {
31 get { return trans; }
32 }
33
34 public abstract void WriteMessageBegin(TMessage message);
35 public abstract void WriteMessageEnd();
36 public abstract void WriteStructBegin(TStruct struc);
37 public abstract void WriteStructEnd();
38 public abstract void WriteFieldBegin(TField field);
39 public abstract void WriteFieldEnd();
40 public abstract void WriteFieldStop();
41 public abstract void WriteMapBegin(TMap map);
42 public abstract void WriteMapEnd();
43 public abstract void WriteListBegin(TList list);
44 public abstract void WriteListEnd();
45 public abstract void WriteSetBegin(TSet set);
46 public abstract void WriteSetEnd();
47 public abstract void WriteBool(bool b);
48 public abstract void WriteByte(byte b);
49 public abstract void WriteI16(short i16);
50 public abstract void WriteI32(int i32);
51 public abstract void WriteI64(long i64);
52 public abstract void WriteDouble(double d);
David Reisscba57272008-02-06 22:09:44 +000053 public void WriteString(string s) {
54 WriteBinary(Encoding.UTF8.GetBytes(s));
55 }
56 public abstract void WriteBinary(byte[] b);
David Reiss7f42bcf2008-01-11 20:59:12 +000057
58 public abstract TMessage ReadMessageBegin();
59 public abstract void ReadMessageEnd();
60 public abstract TStruct ReadStructBegin();
61 public abstract void ReadStructEnd();
62 public abstract TField ReadFieldBegin();
63 public abstract void ReadFieldEnd();
64 public abstract TMap ReadMapBegin();
65 public abstract void ReadMapEnd();
66 public abstract TList ReadListBegin();
67 public abstract void ReadListEnd();
68 public abstract TSet ReadSetBegin();
69 public abstract void ReadSetEnd();
70 public abstract bool ReadBool();
71 public abstract byte ReadByte();
72 public abstract short ReadI16();
73 public abstract int ReadI32();
74 public abstract long ReadI64();
75 public abstract double ReadDouble();
David Reisscba57272008-02-06 22:09:44 +000076 public string ReadString() {
77 return Encoding.UTF8.GetString(ReadBinary());
78 }
79 public abstract byte[] ReadBinary();
David Reiss7f42bcf2008-01-11 20:59:12 +000080 }
81}