How to write a C Program to Array Deserialization in C Programming Language ?
Solution:
- - (NSArray *)deserializeArray:(avro_reader_t)reader
- withSelector:(SEL)deserializeFunc
- andParam:(id)param
- target:(id)target {
- int64_t size;
- avro_binary_encoding.read_long(reader, &size);
- NSMutableArray *array = [NSMutableArray arrayWithCapacity:size];
- if (size != 0 && [(target ? target : self) respondsToSelector:deserializeFunc]) {
- if (size < 0) {
- int64_t temp;
- size *= (-1);
- avro_binary_encoding.read_long(reader, &temp);
- }
- __unsafe_unretained id parameter = param;
- NSMethodSignature *signature = [(target ? target : self) methodSignatureForSelector:deserializeFunc];
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
- NSUInteger argsCount = [signature numberOfArguments];
- [invocation setSelector:deserializeFunc];
- [invocation setTarget:(target ? target : self)];
- [invocation setArgument:&reader atIndex:2];
- if (argsCount > 3 && parameter) {
- [invocation setArgument:¶meter atIndex:3];
- }
- __unsafe_unretained id object;
- int index;
- for (index = 0; index < size; index++) {
- [invocation invoke];
- [invocation getReturnValue:&object];
- [array addObject:object];
- }
- avro_binary_encoding.read_long(reader, &size);
- }
- return array;
- }