summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/thrift/lib/swift/Sources/TWrappedProtocol.swift
blob: 8e8577bb5f21a6187d131d34af4b524dd8cfca74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import Foundation // For (NS)Data


/// Generic protocol, implementes TProtocol and wraps a concrete protocol.
/// Useful for generically subclassing protocols to override specific methods 
/// (i.e. TMultiplexedProtocol)
open class TWrappedProtocol<Protocol: TProtocol> : TProtocol {
  var concreteProtocol: Protocol
  
  public var transport: TTransport {
    get {
      return concreteProtocol.transport
    }
    set {
      concreteProtocol.transport = newValue
    }
  }

  public required init(on transport: TTransport) {
    self.concreteProtocol = Protocol(on: transport)
  }
  
  // Read methods
  
  public func readMessageBegin() throws -> (String, TMessageType, Int32) {
    return try concreteProtocol.readMessageBegin()
  }
  
  public func readMessageEnd() throws {
    try concreteProtocol.readMessageEnd()
  }
  
  public func readStructBegin() throws -> String {
    return try concreteProtocol.readStructBegin()
  }
  
  public func readStructEnd() throws {
    try concreteProtocol.readStructEnd()
  }
  
  public func readFieldBegin() throws -> (String, TType, Int32) {
    return try concreteProtocol.readFieldBegin()
  }
  
  public func readFieldEnd() throws {
    try concreteProtocol.readFieldEnd()
  }
  
  public func readMapBegin() throws -> (TType, TType, Int32) {
    return try concreteProtocol.readMapBegin()
  }
  
  public func readMapEnd() throws {
    try concreteProtocol.readMapEnd()
  }
  
  public func readSetBegin() throws -> (TType, Int32) {
    return try concreteProtocol.readSetBegin()
  }
  
  public func readSetEnd() throws {
    try concreteProtocol.readSetEnd()
  }
  
  public func readListBegin() throws -> (TType, Int32) {
    return try concreteProtocol.readListBegin()
  }
  
  public func readListEnd() throws {
    try concreteProtocol.readListEnd()
  }
  
  public func read() throws -> String {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Bool {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> UInt8 {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Int16 {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Int32 {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Int64 {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Double {
    return try concreteProtocol.read()
  }
  
  public func read() throws -> Data {
    return try concreteProtocol.read()
  }
  
  // Write methods
  
  public func writeMessageBegin(name: String, type messageType: TMessageType, sequenceID: Int32) throws {
    return try concreteProtocol.writeMessageBegin(name: name, type: messageType, sequenceID: sequenceID)
  }
  
  public func writeMessageEnd() throws {
    try concreteProtocol.writeMessageEnd()
  }
  
  public func writeStructBegin(name: String) throws {
    try concreteProtocol.writeStructBegin(name: name)
  }
  
  public func writeStructEnd() throws {
    try concreteProtocol.writeStructEnd()
  }
  
  public func writeFieldBegin(name: String, type fieldType: TType, fieldID: Int32) throws {
    try concreteProtocol.writeFieldBegin(name: name, type: fieldType, fieldID: fieldID)
  }
  
  public func writeFieldStop() throws {
    try concreteProtocol.writeFieldStop()
  }
  
  public func writeFieldEnd() throws {
    try concreteProtocol.writeFieldEnd()
  }
  
  public func writeMapBegin(keyType: TType, valueType: TType, size: Int32) throws {
    try concreteProtocol.writeMapBegin(keyType: keyType, valueType: valueType, size: size)
  }
  
  public func writeMapEnd() throws {
    try concreteProtocol.writeMapEnd()
  }
  
  public func writeSetBegin(elementType: TType, size: Int32) throws {
    try concreteProtocol.writeSetBegin(elementType: elementType, size: size)
  }
  
  public func writeSetEnd() throws {
    try concreteProtocol.writeSetEnd()
  }
  
  public func writeListBegin(elementType: TType, size: Int32) throws {
    try concreteProtocol.writeListBegin(elementType: elementType, size: size)
  }
  
  public func writeListEnd() throws {
    try concreteProtocol.writeListEnd()
  }
  public func write(_ value: String) throws {
    try concreteProtocol.write(value)
  }
  
  public func write(_ value: Bool) throws {
    try concreteProtocol.write(value)
  }
  
  public func write(_ value: UInt8) throws {
    try concreteProtocol.write(value)
  }

  public func write(_ value: Int16) throws {
    try concreteProtocol.write(value)
  }
  
  public func write(_ value: Int32) throws {
    try concreteProtocol.write(value)
  }
  
  public func write(_ value: Int64) throws {
    try concreteProtocol.write(value)
  }
  
  public func write(_ value: Double) throws {
    try concreteProtocol.write(value)
  }

  public func write(_ data: Data) throws {
    try concreteProtocol.write(data)
  }
}