/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ /** * @generated by Thrift */ #import #import "TProtocol.h" #import "TApplicationException.h" #import "TProtocolException.h" #import "TProtocolUtil.h" #import "TProcessor.h" #import "TObjective-C.h" #import "TBase.h" #import "TBaseStruct.h" #import "TBaseException.h" #import "module.h" @implementation exampleFoo - (instancetype) init { self = [super init]; return self; } - (id) initWithMyInteger: (int32_t) myInteger myString: (nullable NSString *) myString myBools: (nullable TBaseStructArray *) myBools myNumbers: (nonnull TBaseStructArray *) myNumbers { self = [super init]; __thrift_myInteger = myInteger; __thrift_myInteger_set = YES; __thrift_myString = myString; __thrift_myString_set = YES; __thrift_myBools = myBools; __thrift_myBools_set = YES; __thrift_myNumbers = myNumbers; __thrift_myNumbers_set = YES; return self; } - (id) initWithCoder: (NSCoder *) decoder { self = [super init]; if ([decoder containsValueForKey: @"myInteger"]) { __thrift_myInteger = [decoder decodeInt32ForKey: @"myInteger"]; __thrift_myInteger_set = YES; } if ([decoder containsValueForKey: @"myString"]) { __thrift_myString = [[decoder decodeObjectForKey: @"myString"] retain_stub]; __thrift_myString_set = YES; } if ([decoder containsValueForKey: @"myBools"]) { __thrift_myBools = [[decoder decodeObjectForKey: @"myBools"] retain_stub]; __thrift_myBools_set = YES; } if ([decoder containsValueForKey: @"myNumbers"]) { __thrift_myNumbers = [[decoder decodeObjectForKey: @"myNumbers"] retain_stub]; __thrift_myNumbers_set = YES; } return self; } - (void) encodeWithCoder: (NSCoder *) encoder { if (__thrift_myInteger_set) { [encoder encodeInt32: __thrift_myInteger forKey: @"myInteger"]; } if (__thrift_myString_set) { [encoder encodeObject: __thrift_myString forKey: @"myString"]; } if (__thrift_myBools_set) { [encoder encodeObject: __thrift_myBools forKey: @"myBools"]; } if (__thrift_myNumbers_set) { [encoder encodeObject: __thrift_myNumbers forKey: @"myNumbers"]; } } - (int32_t) myInteger { return __thrift_myInteger; } - (void) setMyInteger: (int32_t) myInteger { [self throwExceptionIfImmutable]; __thrift_myInteger = myInteger; __thrift_myInteger_set = YES; } - (BOOL) myIntegerIsSet { return __thrift_myInteger_set; } - (void) unsetMyInteger { __thrift_myInteger_set = NO; } - (NSString *) myString { return __thrift_myString; } - (void) setMyString: (NSString *) myString { [self throwExceptionIfImmutable]; __thrift_myString = myString; __thrift_myString_set = YES; } - (BOOL) myStringIsSet { return __thrift_myString_set; } - (void) unsetMyString { __thrift_myString = nil; __thrift_myString_set = NO; } - (TBaseStructArray *) myBools { return __thrift_myBools; } - (void) setMyBools: (TBaseStructArray *) myBools { [self throwExceptionIfImmutable]; __thrift_myBools = myBools; __thrift_myBools_set = YES; } - (BOOL) myBoolsIsSet { return __thrift_myBools_set; } - (void) unsetMyBools { __thrift_myBools = nil; __thrift_myBools_set = NO; } - (TBaseStructArray *) myNumbers { return __thrift_myNumbers; } - (void) setMyNumbers: (TBaseStructArray *) myNumbers { [self throwExceptionIfImmutable]; __thrift_myNumbers = myNumbers; __thrift_myNumbers_set = YES; } - (BOOL) myNumbersIsSet { return __thrift_myNumbers_set; } - (void) unsetMyNumbers { __thrift_myNumbers = nil; __thrift_myNumbers_set = NO; } - (void) read: (id ) inProtocol { NSString * fieldName; int fieldType; int fieldID; [inProtocol readStructBeginReturningName: NULL]; while (true) { [inProtocol readFieldBeginReturningName: &fieldName type: &fieldType fieldID: &fieldID]; if (fieldType == TType_STOP) { break; } switch (fieldID) { case 1: if (fieldType == TType_I32) { int32_t fieldValue = [inProtocol readI32]; [self setMyInteger: fieldValue]; } else { [TProtocolUtil skipType: fieldType onProtocol: inProtocol]; } break; case 2: if (fieldType == TType_STRING) { NSString * fieldValue = [inProtocol readString]; [self setMyString: fieldValue]; } else { [TProtocolUtil skipType: fieldType onProtocol: inProtocol]; } break; case 3: if (fieldType == TType_LIST) { int _size0; [inProtocol readListBeginReturningElementType: NULL size: &_size0]; NSMutableArray * fieldValue = [[NSMutableArray alloc] initWithCapacity: _size0]; int _i1; for (_i1 = 0; _i1 < _size0; ++_i1) { BOOL _elem2 = [inProtocol readBool]; [fieldValue addObject: [NSNumber numberWithBool: _elem2]]; } [inProtocol readListEnd]; [self setMyBools: fieldValue]; [fieldValue release_stub]; } else { [TProtocolUtil skipType: fieldType onProtocol: inProtocol]; } break; case 4: if (fieldType == TType_LIST) { int _size3; [inProtocol readListBeginReturningElementType: NULL size: &_size3]; NSMutableArray * fieldValue = [[NSMutableArray alloc] initWithCapacity: _size3]; int _i4; for (_i4 = 0; _i4 < _size3; ++_i4) { int32_t _elem5 = [inProtocol readI32]; [fieldValue addObject: [NSNumber numberWithLong: _elem5]]; } [inProtocol readListEnd]; [self setMyNumbers: fieldValue]; [fieldValue release_stub]; } else { [TProtocolUtil skipType: fieldType onProtocol: inProtocol]; } break; default: [TProtocolUtil skipType: fieldType onProtocol: inProtocol]; break; } [inProtocol readFieldEnd]; } [inProtocol readStructEnd]; } - (void) write: (id ) outProtocol { [outProtocol writeStructBeginWithName: @"Foo"]; if (__thrift_myInteger_set) { [outProtocol writeFieldBeginWithName: @"myInteger" type: TType_I32 fieldID: 1]; [outProtocol writeI32: __thrift_myInteger]; [outProtocol writeFieldEnd]; } if (__thrift_myString_set) { if (__thrift_myString != nil) { [outProtocol writeFieldBeginWithName: @"myString" type: TType_STRING fieldID: 2]; [outProtocol writeString: __thrift_myString]; [outProtocol writeFieldEnd]; } } if (__thrift_myBools_set) { if (__thrift_myBools != nil) { [outProtocol writeFieldBeginWithName: @"myBools" type: TType_LIST fieldID: 3]; { [outProtocol writeListBeginWithElementType: TType_BOOL size: (int)[__thrift_myBools count]]; int i7; for (i7 = 0; i7 < [__thrift_myBools count]; i7++) { [outProtocol writeBool: [[__thrift_myBools objectAtIndex: i7] boolValue]]; } [outProtocol writeListEnd]; } [outProtocol writeFieldEnd]; } } if (__thrift_myNumbers_set) { if (__thrift_myNumbers != nil) { [outProtocol writeFieldBeginWithName: @"myNumbers" type: TType_LIST fieldID: 4]; { [outProtocol writeListBeginWithElementType: TType_I32 size: (int)[__thrift_myNumbers count]]; int i9; for (i9 = 0; i9 < [__thrift_myNumbers count]; i9++) { [outProtocol writeI32: [[__thrift_myNumbers objectAtIndex: i9] longValue]]; } [outProtocol writeListEnd]; } [outProtocol writeFieldEnd]; } } [outProtocol writeFieldStop]; [outProtocol writeStructEnd]; } - (void) validate { // check for required fields if (!__thrift_myInteger_set) { @throw [TProtocolException exceptionWithName: @"TProtocolException" reason: @"Required field 'myInteger' is not set."]; } if (!__thrift_myNumbers_set) { @throw [TProtocolException exceptionWithName: @"TProtocolException" reason: @"Required field 'myNumbers' is not set."]; } } - (NSString *) description { return [[self toDict] description]; } - (NSDictionary *) toDict { NSMutableDictionary *ret = [NSMutableDictionary dictionary]; ret[@"__thrift_struct_name"] = @"Foo"; ret[@"myInteger"] = @(__thrift_myInteger); if (__thrift_myString) { ret[@"myString"] = __thrift_myString; } if (__thrift_myBools) { NSMutableArray* a = [NSMutableArray array]; for (id item in __thrift_myBools) { if ([item isKindOfClass:[TBaseStruct class]]) {[a addObject:[item toDict]];} else {[a addObject:item];} } ret[@"myBools"] = [a copy]; } if (__thrift_myNumbers) { NSMutableArray* a = [NSMutableArray array]; for (id item in __thrift_myNumbers) { if ([item isKindOfClass:[TBaseStruct class]]) {[a addObject:[item toDict]];} else {[a addObject:item];} } ret[@"myNumbers"] = [a copy]; } return [ret copy]; } - (BOOL) makeImmutable { const BOOL wasImmutable = [self isImmutable]; if (!wasImmutable) { if (__thrift_myBools) { for (id item in __thrift_myBools) { if ([item isKindOfClass:[TBaseStruct class]]) {[((TBaseStruct*)item) makeImmutable];} } __thrift_myBools = [__thrift_myBools copy]; } if (__thrift_myNumbers) { for (id item in __thrift_myNumbers) { if ([item isKindOfClass:[TBaseStruct class]]) {[((TBaseStruct*)item) makeImmutable];} } __thrift_myNumbers = [__thrift_myNumbers copy]; } [super makeImmutable]; } return YES; } - (id) mutableCopyWithZone:(NSZone *)zone { exampleFoo *newCopy = [[[self class] alloc] init];; newCopy->__thrift_myInteger = self->__thrift_myInteger; newCopy->__thrift_myInteger_set = self->__thrift_myInteger_set; if (__thrift_myString) { newCopy->__thrift_myString = self->__thrift_myString; } newCopy->__thrift_myString_set = self->__thrift_myString_set; if (__thrift_myBools) { newCopy->__thrift_myBools = [self->__thrift_myBools mutableCopyWithZone:zone]; } newCopy->__thrift_myBools_set = self->__thrift_myBools_set; if (__thrift_myNumbers) { newCopy->__thrift_myNumbers = [self->__thrift_myNumbers mutableCopyWithZone:zone]; } newCopy->__thrift_myNumbers_set = self->__thrift_myNumbers_set; return newCopy; } @end