Subversion Repositories SmartDukaan

Rev

Rev 30 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements. See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership. The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License. You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied. See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
 
20
#import "TProtocolUtil.h"
21
 
22
@implementation TProtocolUtil
23
 
24
+ (void) skipType: (int) type onProtocol: (id <TProtocol>) protocol
25
{
26
  switch (type) {
27
  case TType_BOOL:
28
    [protocol readBool];
29
    break;
30
  case TType_BYTE:
31
    [protocol readByte];
32
    break;
33
  case TType_I16:
34
    [protocol readI16];
35
    break;
36
  case TType_I32:
37
    [protocol readI32];
38
    break;
39
  case TType_I64:
40
    [protocol readI64];
41
    break;
42
  case TType_DOUBLE:
43
    [protocol readDouble];
44
    break;
45
  case TType_STRING:
46
    [protocol readString];
47
    break;
48
  case TType_STRUCT:
49
    [protocol readStructBeginReturningName: NULL];
50
    while (true) {
51
      int fieldType;
52
      [protocol readFieldBeginReturningName: nil type: &fieldType fieldID: nil];
53
      if (fieldType == TType_STOP) {
54
        break;
55
      }
56
      [TProtocolUtil skipType: fieldType onProtocol: protocol];
57
      [protocol readFieldEnd];
58
    }
59
    [protocol readStructEnd];
60
    break;
61
  case TType_MAP:
62
  {
63
    int keyType;
64
    int valueType;
65
    int size;
66
    [protocol readMapBeginReturningKeyType: &keyType valueType: &valueType size: &size];
67
    int i;
68
    for (i = 0; i < size; i++) {
69
      [TProtocolUtil skipType: keyType onProtocol: protocol];
70
      [TProtocolUtil skipType: valueType onProtocol: protocol];
71
    }
72
    [protocol readMapEnd];
73
  }
74
    break;
75
    case TType_SET:
76
    {
77
      int elemType;
78
      int size;
79
      [protocol readSetBeginReturningElementType: &elemType size: &size];
80
      int i;
81
      for (i = 0; i < size; i++) {
82
        [TProtocolUtil skipType: elemType onProtocol: protocol];
83
      }
84
      [protocol readSetEnd];
85
    }
86
      break;
87
    case TType_LIST:
88
    {
89
      int elemType;
90
      int size;
91
      [protocol readListBeginReturningElementType: &elemType size: &size];
92
      int i;
93
      for (i = 0; i < size; i++) {
94
        [TProtocolUtil skipType: elemType onProtocol: protocol];
95
      }
96
      [protocol readListEnd];
97
    }
98
      break;
99
    default:
100
      return;
101
  }
102
}
103
 
104
@end