summaryrefslogtreecommitdiff
path: root/vendor/packaged/thrift/src/Protocol/TProtocolDecorator.php
blob: a85e0b8e54cf0b9c10c3aadc62f8e742eb5e2d28 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?php
/*
 * 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.
 *
 * @package thrift.protocol
 */

namespace Thrift\Protocol;

use Thrift\Exception\TException;

/**
 * <code>TProtocolDecorator</code> forwards all requests to an enclosed
 * <code>TProtocol</code> instance, providing a way to author concise
 * concrete decorator subclasses. While it has no abstract methods, it
 * is marked abstract as a reminder that by itself, it does not modify
 * the behaviour of the enclosed <code>TProtocol</code>.
 *
 * @package Thrift\Protocol
 */
abstract class TProtocolDecorator extends TProtocol
{
    /**
     * Instance of protocol, to which all operations will be forwarded.
     *
     * @var TProtocol
     */
    private $concreteProtocol_;

    /**
     * Constructor of <code>TProtocolDecorator</code> class.
     * Encloses the specified protocol.
     *
     * @param TProtocol $protocol All operations will be forward to this instance. Must be non-null.
     */
    protected function __construct(TProtocol $protocol)
    {
        parent::__construct($protocol->getTransport());
        $this->concreteProtocol_ = $protocol;
    }

    /**
     * Writes the message header.
     *
     * @param string $name  Function name
     * @param int    $type  message type TMessageType::CALL or TMessageType::REPLY
     * @param int    $seqid The sequence id of this message
     */
    public function writeMessageBegin($name, $type, $seqid)
    {
        return $this->concreteProtocol_->writeMessageBegin($name, $type, $seqid);
    }

    /**
     * Closes the message.
     */
    public function writeMessageEnd()
    {
        return $this->concreteProtocol_->writeMessageEnd();
    }

    /**
     * Writes a struct header.
     *
     * @param string $name Struct name
     *
     * @throws TException on write error
     * @return int        How many bytes written
     */
    public function writeStructBegin($name)
    {
        return $this->concreteProtocol_->writeStructBegin($name);
    }

    /**
     * Close a struct.
     *
     * @throws TException on write error
     * @return int        How many bytes written
     */
    public function writeStructEnd()
    {
        return $this->concreteProtocol_->writeStructEnd();
    }

    public function writeFieldBegin($fieldName, $fieldType, $fieldId)
    {
        return $this->concreteProtocol_->writeFieldBegin($fieldName, $fieldType, $fieldId);
    }

    public function writeFieldEnd()
    {
        return $this->concreteProtocol_->writeFieldEnd();
    }

    public function writeFieldStop()
    {
        return $this->concreteProtocol_->writeFieldStop();
    }

    public function writeMapBegin($keyType, $valType, $size)
    {
        return $this->concreteProtocol_->writeMapBegin($keyType, $valType, $size);
    }

    public function writeMapEnd()
    {
        return $this->concreteProtocol_->writeMapEnd();
    }

    public function writeListBegin($elemType, $size)
    {
        return $this->concreteProtocol_->writeListBegin($elemType, $size);
    }

    public function writeListEnd()
    {
        return $this->concreteProtocol_->writeListEnd();
    }

    public function writeSetBegin($elemType, $size)
    {
        return $this->concreteProtocol_->writeSetBegin($elemType, $size);
    }

    public function writeSetEnd()
    {
        return $this->concreteProtocol_->writeSetEnd();
    }

    public function writeBool($bool)
    {
        return $this->concreteProtocol_->writeBool($bool);
    }

    public function writeByte($byte)
    {
        return $this->concreteProtocol_->writeByte($byte);
    }

    public function writeI16($i16)
    {
        return $this->concreteProtocol_->writeI16($i16);
    }

    public function writeI32($i32)
    {
        return $this->concreteProtocol_->writeI32($i32);
    }

    public function writeI64($i64)
    {
        return $this->concreteProtocol_->writeI64($i64);
    }

    public function writeDouble($dub)
    {
        return $this->concreteProtocol_->writeDouble($dub);
    }

    public function writeString($str)
    {
        return $this->concreteProtocol_->writeString($str);
    }

    /**
     * Reads the message header
     *
     * @param string $name  Function name
     * @param int    $type  message type TMessageType::CALL or TMessageType::REPLY
     * @param int    $seqid The sequence id of this message
     */
    public function readMessageBegin(&$name, &$type, &$seqid)
    {
        return $this->concreteProtocol_->readMessageBegin($name, $type, $seqid);
    }

    /**
     * Read the close of message
     */
    public function readMessageEnd()
    {
        return $this->concreteProtocol_->readMessageEnd();
    }

    public function readStructBegin(&$name)
    {
        return $this->concreteProtocol_->readStructBegin($name);
    }

    public function readStructEnd()
    {
        return $this->concreteProtocol_->readStructEnd();
    }

    public function readFieldBegin(&$name, &$fieldType, &$fieldId)
    {
        return $this->concreteProtocol_->readFieldBegin($name, $fieldType, $fieldId);
    }

    public function readFieldEnd()
    {
        return $this->concreteProtocol_->readFieldEnd();
    }

    public function readMapBegin(&$keyType, &$valType, &$size)
    {
        $this->concreteProtocol_->readMapBegin($keyType, $valType, $size);
    }

    public function readMapEnd()
    {
        return $this->concreteProtocol_->readMapEnd();
    }

    public function readListBegin(&$elemType, &$size)
    {
        $this->concreteProtocol_->readListBegin($elemType, $size);
    }

    public function readListEnd()
    {
        return $this->concreteProtocol_->readListEnd();
    }

    public function readSetBegin(&$elemType, &$size)
    {
        return $this->concreteProtocol_->readSetBegin($elemType, $size);
    }

    public function readSetEnd()
    {
        return $this->concreteProtocol_->readSetEnd();
    }

    public function readBool(&$bool)
    {
        return $this->concreteProtocol_->readBool($bool);
    }

    public function readByte(&$byte)
    {
        return $this->concreteProtocol_->readByte($byte);
    }

    public function readI16(&$i16)
    {
        return $this->concreteProtocol_->readI16($i16);
    }

    public function readI32(&$i32)
    {
        return $this->concreteProtocol_->readI32($i32);
    }

    public function readI64(&$i64)
    {
        return $this->concreteProtocol_->readI64($i64);
    }

    public function readDouble(&$dub)
    {
        return $this->concreteProtocol_->readDouble($dub);
    }

    public function readString(&$str)
    {
        return $this->concreteProtocol_->readString($str);
    }
}