blob: 67f0ce69269121cd91072786a6bacfc5f90abc9c [file] [log] [blame]
David Reiss7f42bcf2008-01-11 20:59:12 +00001//
2// TProtocolUtil.cs
3//
4// Begin: Aug 19, 2007
5// Authors:
6// 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;
16
17namespace Thrift.Protocol
18{
19 public static class TProtocolUtil
20 {
21 public static void Skip(TProtocol prot, TType type)
22 {
23 switch (type)
24 {
25 case TType.Bool:
26 prot.ReadBool();
27 break;
28 case TType.Byte:
29 prot.ReadByte();
30 break;
31 case TType.I16:
32 prot.ReadI16();
33 break;
34 case TType.I32:
35 prot.ReadI32();
36 break;
37 case TType.I64:
38 prot.ReadI64();
39 break;
40 case TType.Double:
41 prot.ReadDouble();
42 break;
43 case TType.String:
44 prot.ReadString();
45 break;
46 case TType.Struct:
47 prot.ReadStructBegin();
48 while (true)
49 {
50 TField field = prot.ReadFieldBegin();
51 if (field.Type == TType.Stop)
52 {
53 break;
54 }
55 Skip(prot, field.Type);
56 prot.ReadFieldEnd();
57 }
58 prot.ReadStructEnd();
59 break;
60 case TType.Map:
61 TMap map = prot.ReadMapBegin();
62 for (int i = 0; i < map.Count; i++)
63 {
64 Skip(prot, map.KeyType);
65 Skip(prot, map.ValueType);
66 }
67 prot.ReadMapEnd();
68 break;
69 case TType.Set:
70 TSet set = prot.ReadSetBegin();
71 for (int i = 0; i < set.Count; i++)
72 {
73 Skip(prot, set.ElementType);
74 }
75 prot.ReadSetEnd();
76 break;
77 case TType.List:
78 TList list = prot.ReadListBegin();
79 for (int i = 0; i < list.Count; i++)
80 {
81 Skip(prot, list.ElementType);
82 }
83 prot.ReadListEnd();
84 break;
85 }
86 }
87 }
88}