Flutter macOS Embedder
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
FlutterStandardReader Class Reference

#import <FlutterCodecs.h>

Inheritance diagram for FlutterStandardReader:
ExtendedReader

Instance Methods

(instancetype) - initWithData:
 
(BOOL) - hasMore
 
(UInt8) - readByte
 
(void) - readBytes:length:
 
(NSData *) - readData:
 
(UInt32) - readSize
 
(void) - readAlignment:
 
(NSString *) - readUTF8
 
(nullable id) - readValue
 
(nullable id) - readValueOfType:
 

Detailed Description

A reader of the Flutter standard binary encoding.

See FlutterStandardMessageCodec for details on the encoding.

The encoding is extensible via subclasses overriding readValueOfType.

Definition at line 132 of file FlutterCodecs.h.

Method Documentation

◆ hasMore

- (BOOL) hasMore

Returns YES when the reader hasn't reached the end of its data.

Definition at line 356 of file FlutterStandardCodec.mm.

367  {
368  return _range.location < _data.length;
369 }
NSRange _range

◆ initWithData:

- (instancetype) initWithData: (NSData*)  data

Create a new FlutterStandardReader who reads from data.

Definition at line 356 of file FlutterStandardCodec.mm.

359  :(NSData*)data {
360  self = [super init];
361  NSAssert(self, @"Super init cannot be nil");
362  _data = [data copy];
363  _range = NSMakeRange(0, 0);
364  return self;
365 }

◆ readAlignment:

- (void) readAlignment: (UInt8)  alignment

Advances the read position until it is aligned with alignment.

Definition at line 356 of file FlutterStandardCodec.mm.

396  :(UInt8)alignment {
397  FlutterStandardCodecHelperReadAlignment(&_range.location, alignment);
398 }
void FlutterStandardCodecHelperReadAlignment(unsigned long *location, uint8_t alignment)

◆ readByte

- (UInt8) readByte

Reads a byte value and increments the position.

Definition at line 356 of file FlutterStandardCodec.mm.

376  {
377  return FlutterStandardCodecHelperReadByte(&_range.location, (__bridge CFDataRef)_data);
378 }
uint8_t FlutterStandardCodecHelperReadByte(unsigned long *location, CFDataRef data)

◆ readBytes:length:

- (void) readBytes: (void*)  destination
length: (NSUInteger)  length 

Reads a sequence of byte values of length and increments the position.

Definition at line 356 of file FlutterStandardCodec.mm.

371  :(void*)destination length:(NSUInteger)length {
372  FlutterStandardCodecHelperReadBytes(&_range.location, length, destination,
373  (__bridge CFDataRef)_data);
374 }
void FlutterStandardCodecHelperReadBytes(unsigned long *location, unsigned long length, void *destination, CFDataRef data)

◆ readData:

- (NSData *) readData: (NSUInteger)  length

Reads a sequence of byte values of length and increments the position.

Definition at line 356 of file FlutterStandardCodec.mm.

384  :(NSUInteger)length {
385  _range.length = length;
386  NSData* data = [_data subdataWithRange:_range];
387  _range.location += _range.length;
388  return data;
389 }

◆ readSize

- (UInt32) readSize

Reads a 32-bit unsigned integer representing a collection size and increments the position.

Definition at line 356 of file FlutterStandardCodec.mm.

380  {
381  return FlutterStandardCodecHelperReadSize(&_range.location, (__bridge CFDataRef)_data);
382 }
uint32_t FlutterStandardCodecHelperReadSize(unsigned long *location, CFDataRef data)

◆ readUTF8

- (NSString *) readUTF8

Read a null terminated string encoded with UTF-8/

Definition at line 356 of file FlutterStandardCodec.mm.

391  {
392  return (__bridge NSString*)FlutterStandardCodecHelperReadUTF8(&_range.location,
393  (__bridge CFDataRef)_data);
394 }
CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long *location, CFDataRef data)

◆ readValue

- (nullable id) readValue

Reads a byte for FlutterStandardField the decodes a value matching that type.

See also: -[FlutterStandardWriter writeValue]

Definition at line 356 of file FlutterStandardCodec.mm.

400  {
401  return (__bridge id)ReadValue((__bridge CFTypeRef)self);
402 }

◆ readValueOfType:

- (nullable id) readValueOfType: (UInt8)  type

Decodes a value matching the type specified.

See also:

Reimplemented in ExtendedReader.

Definition at line 411 of file FlutterStandardCodec.mm.

429  :(UInt8)type {
430  return (__bridge id)FlutterStandardCodecHelperReadValueOfType(
431  &_range.location, (__bridge CFDataRef)_data, type, ReadValue, ReadTypedDataOfType,
432  (__bridge CFTypeRef)self);
433 }
CFTypeRef FlutterStandardCodecHelperReadValueOfType(unsigned long *location, CFDataRef data, uint8_t type, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)

The documentation for this class was generated from the following files: