Flutter macOS Embedder
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 367 of file FlutterStandardCodec.mm.

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

References _range.

◆ initWithData:

- (instancetype) initWithData: (NSData*)  data

Create a new FlutterStandardReader who reads from data.

Definition at line 359 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 }

References _range.

◆ readAlignment:

- (void) readAlignment: (UInt8)  alignment

Advances the read position until it is aligned with alignment.

Definition at line 396 of file FlutterStandardCodec.mm.

396  :(UInt8)alignment {
397  FlutterStandardCodecHelperReadAlignment(&_range.location, alignment);
398 }

References _range, and FlutterStandardCodecHelperReadAlignment().

◆ readByte

- (UInt8) readByte

Reads a byte value and increments the position.

Definition at line 376 of file FlutterStandardCodec.mm.

376  {
377  return FlutterStandardCodecHelperReadByte(&_range.location, (__bridge CFDataRef)_data);
378 }

References _range, and FlutterStandardCodecHelperReadByte().

◆ readBytes:length:

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

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

Definition at line 371 of file FlutterStandardCodec.mm.

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

References _range, and FlutterStandardCodecHelperReadBytes().

Referenced by ExtendedReader::readValueOfType:.

◆ readData:

- (NSData *) readData: (NSUInteger)  length

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

Definition at line 384 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 }

References _range.

◆ readSize

- (UInt32) readSize

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

Definition at line 380 of file FlutterStandardCodec.mm.

380  {
381  return FlutterStandardCodecHelperReadSize(&_range.location, (__bridge CFDataRef)_data);
382 }

References _range, and FlutterStandardCodecHelperReadSize().

◆ readUTF8

- (NSString *) readUTF8

Read a null terminated string encoded with UTF-8/

Definition at line 391 of file FlutterStandardCodec.mm.

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

References _range, and FlutterStandardCodecHelperReadUTF8().

◆ readValue

- (nullable id) readValue

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

See also: -[FlutterStandardWriter writeValue]

Definition at line 400 of file FlutterStandardCodec.mm.

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

Referenced by ExtendedReader::readValueOfType:.

◆ readValueOfType:

- (nullable id) readValueOfType: (UInt8)  type

Decodes a value matching the type specified.

See also:

Reimplemented in ExtendedReader.

Definition at line 429 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 }

References _range, and FlutterStandardCodecHelperReadValueOfType().

Referenced by ExtendedReader::readValueOfType:.


The documentation for this class was generated from the following files:
FlutterStandardCodecHelperReadUTF8
CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:75
FlutterStandardCodecHelperReadSize
uint32_t FlutterStandardCodecHelperReadSize(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:49
_range
NSRange _range
Definition: FlutterStandardCodec.mm:354
FlutterStandardCodecHelperReadByte
uint8_t FlutterStandardCodecHelperReadByte(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:42
FlutterStandardCodecHelperReadValueOfType
CFTypeRef FlutterStandardCodecHelperReadValueOfType(unsigned long *location, CFDataRef data, uint8_t type, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)
Definition: FlutterStandardCodecHelper.cc:103
FlutterStandardCodecHelperReadBytes
void FlutterStandardCodecHelperReadBytes(unsigned long *location, unsigned long length, void *destination, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:33
FlutterStandardCodecHelperReadAlignment
void FlutterStandardCodecHelperReadAlignment(unsigned long *location, uint8_t alignment)
Definition: FlutterStandardCodecHelper.cc:18