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