Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Class Methods | List of all members
FlutterStandardReader Class Reference

#include <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:
 

Class Methods

(static CFTypeRef) + ReadValue [implementation]
 
(static CFTypeRef) + ReadTypedDataOfType [implementation]
 

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}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ 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 {
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)
size_t length

◆ 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)

◆ ReadTypedDataOfType

+ (static CFTypeRef) ReadTypedDataOfType (FlutterStandardField field
(CFTypeRef)  user_data 
implementation

Definition at line 411 of file FlutterStandardCodec.mm.

411 {
413 unsigned long* location = &reader->_range.location;
414 CFDataRef data = (__bridge CFDataRef)reader->_data;
415 FlutterStandardDataType type = FlutterStandardDataTypeForField(field);
416
417 UInt64 elementCount = FlutterStandardCodecHelperReadSize(location, data);
418 UInt64 elementSize = elementSizeForFlutterStandardDataType(type);
419 FlutterStandardCodecHelperReadAlignment(location, elementSize);
420 UInt64 length = elementCount * elementSize;
421 NSRange range = NSMakeRange(*location, length);
422 // Note: subdataWithRange performs better than CFDataCreate and
423 // CFDataCreateBytesNoCopy crashes.
424 NSData* bytes = [(__bridge NSData*)data subdataWithRange:range];
425 *location += length;
426 return (__bridge CFTypeRef)[FlutterStandardTypedData typedDataWithData:bytes type:type];
427}
instancetype typedDataWithData:type:(NSData *data, [type] FlutterStandardDataType type)
FlutterStandardDataType FlutterStandardDataTypeForField(FlutterStandardField field)
UInt8 elementSizeForFlutterStandardDataType(FlutterStandardDataType type)

◆ 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}
static CFTypeRef ReadValue(CFTypeRef user_data)

◆ ReadValue

+ (static CFTypeRef) ReadValue (CFTypeRef)  user_data
implementation

Definition at line 404 of file FlutterStandardCodec.mm.

404 {
406 uint8_t type = FlutterStandardCodecHelperReadByte(&reader->_range.location,
407 (__bridge CFDataRef)reader->_data);
408 return (__bridge CFTypeRef)[reader readValueOfType:type];
409}
nullable id readValueOfType:(UInt8 type)

◆ 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 {
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)
static CFTypeRef ReadTypedDataOfType(FlutterStandardField field, CFTypeRef user_data)

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