David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 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 | |
Andrew McGeachie | 6db89f2 | 2009-07-21 14:45:12 +0000 | [diff] [blame] | 20 | #import <Foundation/Foundation.h> |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 21 | |
| 22 | #import "TTransport.h" |
| 23 | |
| 24 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 25 | NS_ASSUME_NONNULL_BEGIN |
| 26 | |
| 27 | |
| 28 | typedef NS_ENUM (int, TMessageType) { |
| 29 | TMessageTypeCALL = 1, |
| 30 | TMessageTypeREPLY = 2, |
| 31 | TMessageTypeEXCEPTION = 3, |
| 32 | TMessageTypeONEWAY = 4 |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 35 | typedef 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 Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | |
| 52 | @protocol TProtocol <NSObject> |
| 53 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 54 | -(id <TTransport>) transport; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 55 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 56 | -(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 Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 61 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 62 | -(BOOL) readStructBeginReturningName:(NSString *__nullable __autoreleasing *__nullable)name |
| 63 | error:(NSError *__autoreleasing *)error; |
| 64 | -(BOOL) readStructEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 65 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 66 | -(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 Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 71 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 72 | -(BOOL) readString:(NSString *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 73 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 74 | -(BOOL) readBool:(BOOL *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 75 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 76 | -(BOOL) readByte:(UInt8 *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 77 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 78 | -(BOOL) readI16:(SInt16 *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 79 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 80 | -(BOOL) readI32:(SInt32 *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 81 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 82 | -(BOOL) readI64:(SInt64 *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 83 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 84 | -(BOOL) readDouble:(double *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 85 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 86 | -(BOOL) readBinary:(NSData *__nonnull __autoreleasing *__nonnull)value error:(NSError **)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 87 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 88 | -(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 Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 93 | |
| 94 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 95 | -(BOOL) readSetBeginReturningElementType:(nullable SInt32 *)elementType |
| 96 | size:(SInt32 *)size |
| 97 | error:(NSError *__autoreleasing *)error; |
| 98 | -(BOOL) readSetEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 99 | |
| 100 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 101 | -(BOOL) readListBeginReturningElementType:(nullable SInt32 *)elementType |
| 102 | size:(SInt32 *)size |
| 103 | error:(NSError *__autoreleasing *)error; |
| 104 | -(BOOL) readListEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 105 | |
| 106 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 107 | -(BOOL) writeMessageBeginWithName:(NSString *)name |
| 108 | type:(SInt32)messageType |
| 109 | sequenceID:(SInt32)sequenceID |
| 110 | error:(NSError *__autoreleasing *)error; |
| 111 | -(BOOL) writeMessageEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 112 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 113 | -(BOOL) writeStructBeginWithName:(NSString *)name error:(NSError **)error; |
| 114 | -(BOOL) writeStructEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 115 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 116 | -(BOOL) writeFieldBeginWithName:(NSString *)name |
| 117 | type:(SInt32)fieldType |
| 118 | fieldID:(SInt32)fieldID |
| 119 | error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 120 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 121 | -(BOOL) writeI32:(SInt32)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 122 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 123 | -(BOOL) writeI64:(SInt64)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 124 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 125 | -(BOOL) writeI16:(short)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 126 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 127 | -(BOOL) writeByte:(UInt8)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 128 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 129 | -(BOOL) writeString:(NSString *)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 130 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 131 | -(BOOL) writeDouble:(double)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 132 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 133 | -(BOOL) writeBool:(BOOL)value error:(NSError *__autoreleasing *)error; |
Mark Slee | 33a7d89 | 2007-09-14 19:44:30 +0000 | [diff] [blame] | 134 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 135 | -(BOOL) writeBinary:(NSData *)data error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 136 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 137 | -(BOOL) writeFieldStop:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 138 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 139 | -(BOOL) writeFieldEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 140 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 141 | -(BOOL) writeMapBeginWithKeyType:(SInt32)keyType |
| 142 | valueType:(SInt32)valueType |
| 143 | size:(SInt32)size |
| 144 | error:(NSError *__autoreleasing *)error; |
| 145 | -(BOOL) writeMapEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 146 | |
| 147 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 148 | -(BOOL) writeSetBeginWithElementType:(SInt32)elementType |
| 149 | size:(SInt32)size |
| 150 | error:(NSError *__autoreleasing *)error; |
| 151 | -(BOOL) writeSetEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 152 | |
| 153 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 154 | -(BOOL) writeListBeginWithElementType:(SInt32)elementType |
| 155 | size:(SInt32)size |
| 156 | error:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 157 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 158 | -(BOOL) writeListEnd:(NSError *__autoreleasing *)error; |
Mark Slee | 7e9eea4 | 2007-09-10 21:00:23 +0000 | [diff] [blame] | 159 | |
| 160 | |
| 161 | @end |
| 162 | |
Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 163 | |
| 164 | NS_ASSUME_NONNULL_END |