blob: cf32aad6bf3ddf0b72b3c281b6ec0d9e3473bc18 [file] [log] [blame]
Mark Slee7e9eea42007-09-10 21:00:23 +00001#import "TProtocolUtil.h"
2
3@implementation TProtocolUtil
4
5+ (void) skipType: (int) type onProtocol: (id <TProtocol>) protocol
6{
7 switch (type) {
8 case TType_BOOL:
9 [protocol readBool];
10 break;
11 case TType_BYTE:
12 [protocol readByte];
13 break;
14 case TType_I16:
15 [protocol readI16];
16 break;
17 case TType_I32:
18 [protocol readI32];
19 break;
20 case TType_I64:
21 [protocol readI64];
22 break;
23 case TType_DOUBLE:
24 [protocol readDouble];
25 break;
26 case TType_STRING:
27 [protocol readString];
28 break;
29 case TType_STRUCT:
Mark Slee33a7d892007-09-14 19:44:30 +000030 [protocol readStructBeginReturningName: NULL];
Mark Slee7e9eea42007-09-10 21:00:23 +000031 while (true) {
32 int fieldType;
Mark Slee33a7d892007-09-14 19:44:30 +000033 [protocol readFieldBeginReturningName: nil type: &fieldType fieldID: nil];
Mark Slee7e9eea42007-09-10 21:00:23 +000034 if (fieldType == TType_STOP) {
35 break;
36 }
37 [TProtocolUtil skipType: fieldType onProtocol: protocol];
38 [protocol readFieldEnd];
39 }
40 [protocol readStructEnd];
41 break;
42 case TType_MAP:
43 {
44 int keyType;
45 int valueType;
46 int size;
Mark Slee33a7d892007-09-14 19:44:30 +000047 [protocol readMapBeginReturningKeyType: &keyType valueType: &valueType size: &size];
Mark Slee7e9eea42007-09-10 21:00:23 +000048 int i;
49 for (i = 0; i < size; i++) {
50 [TProtocolUtil skipType: keyType onProtocol: protocol];
51 [TProtocolUtil skipType: valueType onProtocol: protocol];
52 }
53 [protocol readMapEnd];
54 }
55 break;
56 case TType_SET:
57 {
58 int elemType;
59 int size;
Mark Slee33a7d892007-09-14 19:44:30 +000060 [protocol readSetBeginReturningElementType: &elemType size: &size];
Mark Slee7e9eea42007-09-10 21:00:23 +000061 int i;
62 for (i = 0; i < size; i++) {
63 [TProtocolUtil skipType: elemType onProtocol: protocol];
64 }
65 [protocol readSetEnd];
66 }
67 break;
68 case TType_LIST:
69 {
70 int elemType;
71 int size;
Mark Slee33a7d892007-09-14 19:44:30 +000072 [protocol readListBeginReturningElementType: &elemType size: &size];
Mark Slee7e9eea42007-09-10 21:00:23 +000073 int i;
74 for (i = 0; i < size; i++) {
75 [TProtocolUtil skipType: elemType onProtocol: protocol];
76 }
77 [protocol readListEnd];
78 }
79 break;
80 default:
81 return;
82 }
83}
84
85@end