blob: 841059f5102565b853855f873a582c8b41cb2176 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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
Andrew McGeachie6db89f22009-07-21 14:45:12 +000020#import <Foundation/Foundation.h>
Mark Slee7e9eea42007-09-10 21:00:23 +000021
22#import "TTransport.h"
23
24
Jens Geyer56e5b9b2015-10-09 22:01:55 +020025NS_ASSUME_NONNULL_BEGIN
26
27
28typedef NS_ENUM (int, TMessageType) {
29 TMessageTypeCALL = 1,
30 TMessageTypeREPLY = 2,
31 TMessageTypeEXCEPTION = 3,
32 TMessageTypeONEWAY = 4
Mark Slee7e9eea42007-09-10 21:00:23 +000033};
34
Jens Geyer56e5b9b2015-10-09 22:01:55 +020035typedef NS_ENUM (int, TType) {
36 TTypeSTOP = 0,
37 TTypeVOID = 1,
38 TTypeBOOL = 2,
39 TTypeBYTE = 3,
40 TTypeDOUBLE = 4,
41 TTypeI16 = 6,
42 TTypeI32 = 8,
43 TTypeI64 = 10,
44 TTypeSTRING = 11,
45 TTypeSTRUCT = 12,
46 TTypeMAP = 13,
47 TTypeSET = 14,
48 TTypeLIST = 15
Mark Slee7e9eea42007-09-10 21:00:23 +000049};
50
51
52@protocol TProtocol <NSObject>
53
Jens Geyer56e5b9b2015-10-09 22:01:55 +020054-(id <TTransport>) transport;
Mark Slee7e9eea42007-09-10 21:00:23 +000055
Jens Geyer56e5b9b2015-10-09 22:01:55 +020056-(BOOL) readMessageBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
57 type:(nullable SInt32 *)type
58 sequenceID:(nullable SInt32 *)sequenceID
59 error:(NSError *__autoreleasing *)error;
60-(BOOL) readMessageEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000061
Jens Geyer56e5b9b2015-10-09 22:01:55 +020062-(BOOL) readStructBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
63 error:(NSError *__autoreleasing *)error;
64-(BOOL) readStructEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000065
Jens Geyer56e5b9b2015-10-09 22:01:55 +020066-(BOOL) readFieldBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name
67 type:(SInt32 *)fieldType
68 fieldID:(nullable SInt32 *)fieldID
69 error:(NSError *__autoreleasing *)error;
70-(BOOL) readFieldEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000071
Jens Geyer56e5b9b2015-10-09 22:01:55 +020072-(BOOL) readString:(NSString *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000073
Jens Geyer56e5b9b2015-10-09 22:01:55 +020074-(BOOL) readBool:(BOOL *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000075
Jens Geyer56e5b9b2015-10-09 22:01:55 +020076-(BOOL) readByte:(UInt8 *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000077
Jens Geyer56e5b9b2015-10-09 22:01:55 +020078-(BOOL) readI16:(SInt16 *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000079
Jens Geyer56e5b9b2015-10-09 22:01:55 +020080-(BOOL) readI32:(SInt32 *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000081
Jens Geyer56e5b9b2015-10-09 22:01:55 +020082-(BOOL) readI64:(SInt64 *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000083
Jens Geyer56e5b9b2015-10-09 22:01:55 +020084-(BOOL) readDouble:(double *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000085
Jens Geyer56e5b9b2015-10-09 22:01:55 +020086-(BOOL) readBinary:(NSData *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000087
Jens Geyer56e5b9b2015-10-09 22:01:55 +020088-(BOOL) readMapBeginReturningKeyType:(nullable SInt32 *)keyType
89 valueType:(nullable SInt32 *)valueType
90 size:(SInt32 *)size
91 error:(NSError *__autoreleasing *)error;
92-(BOOL) readMapEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000093
94
Jens Geyer56e5b9b2015-10-09 22:01:55 +020095-(BOOL) readSetBeginReturningElementType:(nullable SInt32 *)elementType
96 size:(SInt32 *)size
97 error:(NSError *__autoreleasing *)error;
98-(BOOL) readSetEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +000099
100
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200101-(BOOL) readListBeginReturningElementType:(nullable SInt32 *)elementType
102 size:(SInt32 *)size
103 error:(NSError *__autoreleasing *)error;
104-(BOOL) readListEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000105
106
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200107-(BOOL) writeMessageBeginWithName:(NSString *)name
108 type:(SInt32)messageType
109 sequenceID:(SInt32)sequenceID
110 error:(NSError *__autoreleasing *)error;
111-(BOOL) writeMessageEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000112
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200113-(BOOL) writeStructBeginWithName:(NSString *)name error:(NSError **)error;
114-(BOOL) writeStructEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000115
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200116-(BOOL) writeFieldBeginWithName:(NSString *)name
117 type:(SInt32)fieldType
118 fieldID:(SInt32)fieldID
119 error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000120
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200121-(BOOL) writeI32:(SInt32)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000122
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200123-(BOOL) writeI64:(SInt64)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000124
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200125-(BOOL) writeI16:(short)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000126
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200127-(BOOL) writeByte:(UInt8)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000128
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200129-(BOOL) writeString:(NSString *)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000130
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200131-(BOOL) writeDouble:(double)value error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000132
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200133-(BOOL) writeBool:(BOOL)value error:(NSError *__autoreleasing *)error;
Mark Slee33a7d892007-09-14 19:44:30 +0000134
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200135-(BOOL) writeBinary:(NSData *)data error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000136
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200137-(BOOL) writeFieldStop:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000138
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200139-(BOOL) writeFieldEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000140
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200141-(BOOL) writeMapBeginWithKeyType:(SInt32)keyType
142 valueType:(SInt32)valueType
143 size:(SInt32)size
144 error:(NSError *__autoreleasing *)error;
145-(BOOL) writeMapEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000146
147
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200148-(BOOL) writeSetBeginWithElementType:(SInt32)elementType
149 size:(SInt32)size
150 error:(NSError *__autoreleasing *)error;
151-(BOOL) writeSetEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000152
153
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200154-(BOOL) writeListBeginWithElementType:(SInt32)elementType
155 size:(SInt32)size
156 error:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000157
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200158-(BOOL) writeListEnd:(NSError *__autoreleasing *)error;
Mark Slee7e9eea42007-09-10 21:00:23 +0000159
160
161@end
162
Jens Geyer56e5b9b2015-10-09 22:01:55 +0200163
164NS_ASSUME_NONNULL_END