| David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 1 | // | 
|  | 2 | //  TProtocolUtil.cs | 
|  | 3 | // | 
|  | 4 | //  Begin:  Aug 19, 2007 | 
| David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 5 | //  Authors: | 
| David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 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 |  | 
|  | 13 | using System; | 
|  | 14 | using System.Collections.Generic; | 
|  | 15 | using System.Text; | 
|  | 16 |  | 
|  | 17 | namespace 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: | 
| David Reiss | cba5727 | 2008-02-06 22:09:44 +0000 | [diff] [blame] | 44 | // Don't try to decode the string, just skip it. | 
|  | 45 | prot.ReadBinary(); | 
| David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 46 | break; | 
|  | 47 | case TType.Struct: | 
|  | 48 | prot.ReadStructBegin(); | 
|  | 49 | while (true) | 
|  | 50 | { | 
|  | 51 | TField field = prot.ReadFieldBegin(); | 
|  | 52 | if (field.Type == TType.Stop) | 
|  | 53 | { | 
|  | 54 | break; | 
|  | 55 | } | 
|  | 56 | Skip(prot, field.Type); | 
|  | 57 | prot.ReadFieldEnd(); | 
|  | 58 | } | 
|  | 59 | prot.ReadStructEnd(); | 
|  | 60 | break; | 
|  | 61 | case TType.Map: | 
|  | 62 | TMap map = prot.ReadMapBegin(); | 
|  | 63 | for (int i = 0; i < map.Count; i++) | 
|  | 64 | { | 
|  | 65 | Skip(prot, map.KeyType); | 
|  | 66 | Skip(prot, map.ValueType); | 
|  | 67 | } | 
|  | 68 | prot.ReadMapEnd(); | 
|  | 69 | break; | 
|  | 70 | case TType.Set: | 
|  | 71 | TSet set = prot.ReadSetBegin(); | 
|  | 72 | for (int i = 0; i < set.Count; i++) | 
|  | 73 | { | 
|  | 74 | Skip(prot, set.ElementType); | 
|  | 75 | } | 
|  | 76 | prot.ReadSetEnd(); | 
|  | 77 | break; | 
|  | 78 | case TType.List: | 
|  | 79 | TList list = prot.ReadListBegin(); | 
|  | 80 | for (int i = 0; i < list.Count; i++) | 
|  | 81 | { | 
|  | 82 | Skip(prot, list.ElementType); | 
|  | 83 | } | 
|  | 84 | prot.ReadListEnd(); | 
|  | 85 | break; | 
|  | 86 | } | 
|  | 87 | } | 
|  | 88 | } | 
|  | 89 | } |