| Flutter macOS Embedder |

Enumerations | Functions
FlutterStandardCodecHelper.h File Reference
`#include <CoreFoundation/CoreFoundation.h>`
`#include <stdbool.h>`
`#include <stdint.h>`

Go to the source code of this file.

## Enumerations
enum | FlutterStandardField { FlutterStandardFieldNil , FlutterStandardFieldTrue , FlutterStandardFieldFalse , FlutterStandardFieldInt32 , FlutterStandardFieldInt64 , FlutterStandardFieldIntHex , FlutterStandardFieldFloat64 , FlutterStandardFieldString , FlutterStandardFieldUInt8Data , FlutterStandardFieldInt32Data , FlutterStandardFieldInt64Data , FlutterStandardFieldFloat64Data , FlutterStandardFieldList , FlutterStandardFieldMap , FlutterStandardFieldFloat32Data }
enum | FlutterStandardCodecObjcType { FlutterStandardCodecObjcTypeNil , FlutterStandardCodecObjcTypeNSNumber , FlutterStandardCodecObjcTypeNSString , FlutterStandardCodecObjcTypeFlutterStandardTypedData , FlutterStandardCodecObjcTypeNSData , FlutterStandardCodecObjcTypeNSArray , FlutterStandardCodecObjcTypeNSDictionary , FlutterStandardCodecObjcTypeUnknown }

## Functions
static bool | FlutterStandardFieldIsStandardType (uint8_t field)
Reader Helpers
void | FlutterStandardCodecHelperReadAlignment (unsigned long *location, uint8_t alignment)
void | FlutterStandardCodecHelperReadBytes (unsigned long *location, unsigned long length, void *destination, CFDataRef data)
uint8_t | FlutterStandardCodecHelperReadByte (unsigned long *location, CFDataRef data)
uint32_t | FlutterStandardCodecHelperReadSize (unsigned long *location, CFDataRef data)
CFStringRef | FlutterStandardCodecHelperReadUTF8 (unsigned long *location, CFDataRef data)
CFTypeRef | FlutterStandardCodecHelperReadValueOfType (unsigned long *location, CFDataRef data, uint8_t type, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)
Writer Helpers
void | FlutterStandardCodecHelperWriteByte (CFMutableDataRef data, uint8_t value)
void | FlutterStandardCodecHelperWriteBytes (CFMutableDataRef data, const void *bytes, unsigned long length)
void | FlutterStandardCodecHelperWriteSize (CFMutableDataRef data, uint32_t size)
void | FlutterStandardCodecHelperWriteAlignment (CFMutableDataRef data, uint8_t alignment)
void | FlutterStandardCodecHelperWriteUTF8 (CFMutableDataRef data, CFStringRef value)
void | FlutterStandardCodecHelperWriteData (CFMutableDataRef data, CFDataRef value)
bool | FlutterStandardCodecHelperWriteNumber (CFMutableDataRef data, CFNumberRef number)

## Enumeration Type Documentation

## ◆ FlutterStandardCodecObjcType

enum FlutterStandardCodecObjcType

Enumerator
FlutterStandardCodecObjcTypeNil |
FlutterStandardCodecObjcTypeNSNumber |
FlutterStandardCodecObjcTypeNSString |
FlutterStandardCodecObjcTypeFlutterStandardTypedData |
FlutterStandardCodecObjcTypeNSData |
FlutterStandardCodecObjcTypeNSArray |
FlutterStandardCodecObjcTypeNSDictionary |
FlutterStandardCodecObjcTypeUnknown |

Definition at line 44 of file FlutterStandardCodecHelper.h.

44 {
45 // NOLINTBEGIN(readability-identifier-naming)
46 FlutterStandardCodecObjcTypeNil,
47 FlutterStandardCodecObjcTypeNSNumber,
48 FlutterStandardCodecObjcTypeNSString,
49 FlutterStandardCodecObjcTypeFlutterStandardTypedData,
50 FlutterStandardCodecObjcTypeNSData,
51 FlutterStandardCodecObjcTypeNSArray,
52 FlutterStandardCodecObjcTypeNSDictionary,
53 FlutterStandardCodecObjcTypeUnknown,
54 // NOLINTEND(readability-identifier-naming)
55 } FlutterStandardCodecObjcType;
FlutterStandardCodecObjcType
FlutterStandardCodecObjcType
Definition: FlutterStandardCodecHelper.h:44
FlutterStandardCodecObjcTypeNSArray
@ FlutterStandardCodecObjcTypeNSArray
Definition: FlutterStandardCodecHelper.h:51
FlutterStandardCodecObjcTypeFlutterStandardTypedData
@ FlutterStandardCodecObjcTypeFlutterStandardTypedData
Definition: FlutterStandardCodecHelper.h:49
FlutterStandardCodecObjcTypeNSData
@ FlutterStandardCodecObjcTypeNSData
Definition: FlutterStandardCodecHelper.h:50
FlutterStandardCodecObjcTypeNSString
@ FlutterStandardCodecObjcTypeNSString
Definition: FlutterStandardCodecHelper.h:48
FlutterStandardCodecObjcTypeNil
@ FlutterStandardCodecObjcTypeNil
Definition: FlutterStandardCodecHelper.h:46
FlutterStandardCodecObjcTypeUnknown
@ FlutterStandardCodecObjcTypeUnknown
Definition: FlutterStandardCodecHelper.h:53
FlutterStandardCodecObjcTypeNSDictionary
@ FlutterStandardCodecObjcTypeNSDictionary
Definition: FlutterStandardCodecHelper.h:52
FlutterStandardCodecObjcTypeNSNumber
@ FlutterStandardCodecObjcTypeNSNumber
Definition: FlutterStandardCodecHelper.h:47

## ◆ FlutterStandardField

enum FlutterStandardField

Enumerator
FlutterStandardFieldNil |
FlutterStandardFieldTrue |
FlutterStandardFieldFalse |
FlutterStandardFieldInt32 |
FlutterStandardFieldInt64 |
FlutterStandardFieldIntHex |
FlutterStandardFieldFloat64 |
FlutterStandardFieldString |
FlutterStandardFieldUInt8Data |
FlutterStandardFieldInt32Data |
FlutterStandardFieldInt64Data |
FlutterStandardFieldFloat64Data |
FlutterStandardFieldList |
FlutterStandardFieldMap |
FlutterStandardFieldFloat32Data |

Definition at line 19 of file FlutterStandardCodecHelper.h.

19 {
20 // NOLINTBEGIN(readability-identifier-naming)
21 FlutterStandardFieldNil,
22 FlutterStandardFieldTrue,
23 FlutterStandardFieldFalse,
24 FlutterStandardFieldInt32,
25 FlutterStandardFieldInt64,
26 FlutterStandardFieldIntHex,
27 FlutterStandardFieldFloat64,
28 FlutterStandardFieldString,
29 FlutterStandardFieldUInt8Data,
30 FlutterStandardFieldInt32Data,
31 FlutterStandardFieldInt64Data,
32 FlutterStandardFieldFloat64Data,
33 FlutterStandardFieldList,
34 FlutterStandardFieldMap,
35 FlutterStandardFieldFloat32Data,
36 // NOLINTEND(readability-identifier-naming)
37 } FlutterStandardField;
FlutterStandardField
FlutterStandardField
Definition: FlutterStandardCodecHelper.h:19
FlutterStandardFieldUInt8Data
@ FlutterStandardFieldUInt8Data
Definition: FlutterStandardCodecHelper.h:29
FlutterStandardFieldFloat64
@ FlutterStandardFieldFloat64
Definition: FlutterStandardCodecHelper.h:27
FlutterStandardFieldFloat32Data
@ FlutterStandardFieldFloat32Data
Definition: FlutterStandardCodecHelper.h:35
FlutterStandardFieldIntHex
@ FlutterStandardFieldIntHex
Definition: FlutterStandardCodecHelper.h:26
FlutterStandardFieldMap
@ FlutterStandardFieldMap
Definition: FlutterStandardCodecHelper.h:34
FlutterStandardFieldInt64Data
@ FlutterStandardFieldInt64Data
Definition: FlutterStandardCodecHelper.h:31
FlutterStandardFieldList
@ FlutterStandardFieldList
Definition: FlutterStandardCodecHelper.h:33
FlutterStandardFieldInt32
@ FlutterStandardFieldInt32
Definition: FlutterStandardCodecHelper.h:24
FlutterStandardFieldNil
@ FlutterStandardFieldNil
Definition: FlutterStandardCodecHelper.h:21
FlutterStandardFieldTrue
@ FlutterStandardFieldTrue
Definition: FlutterStandardCodecHelper.h:22
FlutterStandardFieldString
@ FlutterStandardFieldString
Definition: FlutterStandardCodecHelper.h:28
FlutterStandardFieldFalse
@ FlutterStandardFieldFalse
Definition: FlutterStandardCodecHelper.h:23
FlutterStandardFieldInt32Data
@ FlutterStandardFieldInt32Data
Definition: FlutterStandardCodecHelper.h:30
FlutterStandardFieldInt64
@ FlutterStandardFieldInt64
Definition: FlutterStandardCodecHelper.h:25
FlutterStandardFieldFloat64Data
@ FlutterStandardFieldFloat64Data
Definition: FlutterStandardCodecHelper.h:32

## Function Documentation

## ◆ FlutterStandardCodecHelperReadAlignment()

void FlutterStandardCodecHelperReadAlignment | ( | unsigned long * | location,
|  | uint8_t | alignment
| ) |  |

Definition at line 18 of file FlutterStandardCodecHelper.cc.

19 {
20 uint8_t mod = *location % alignment;
21 if (mod) {
22 *location += (alignment - mod);
23 }
24 }

Referenced by FlutterStandardCodecHelperReadValueOfType(), and FlutterStandardReaderWriter::readerWithData:.

## ◆ FlutterStandardCodecHelperReadByte()

uint8_t FlutterStandardCodecHelperReadByte | ( | unsigned long * | location,
|  | CFDataRef | data
| ) |  |

Definition at line 42 of file FlutterStandardCodecHelper.cc.

43 {
44 uint8_t value;
45 FlutterStandardCodecHelperReadBytes(location, 1, &value, data);
46 return value;
47 }
FlutterStandardCodecHelperReadBytes
void FlutterStandardCodecHelperReadBytes(unsigned long *location, unsigned long length, void *destination, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:33

References FlutterStandardCodecHelperReadBytes().

Referenced by FlutterStandardCodecHelperReadSize().

## ◆ FlutterStandardCodecHelperReadBytes()

void FlutterStandardCodecHelperReadBytes | ( | unsigned long * | location,
|  | unsigned long | length,
|  | void * | destination,
|  | CFDataRef | data
| ) |  |

Definition at line 33 of file FlutterStandardCodecHelper.cc.

36 {
37 CFRange range = CFRangeMake(*location, length);
38 CFDataGetBytes(data, range, static_cast<UInt8*>(destination));
39 *location += length;
40 }

Referenced by FlutterStandardCodecHelperReadByte(), FlutterStandardCodecHelperReadSize(), and FlutterStandardCodecHelperReadValueOfType().

## ◆ FlutterStandardCodecHelperReadSize()

uint32_t FlutterStandardCodecHelperReadSize | ( | unsigned long * | location,
|  | CFDataRef | data
| ) |  |

Definition at line 49 of file FlutterStandardCodecHelper.cc.

50 {
51 uint8_t byte = FlutterStandardCodecHelperReadByte(location, data);
52 if (byte < 254) {
53 return static_cast<uint32_t>(byte);
54 } else if (byte == 254) {
55 UInt16 value;
56 FlutterStandardCodecHelperReadBytes(location, 2, &value, data);
57 return value;
58 } else {
59 UInt32 value;
60 FlutterStandardCodecHelperReadBytes(location, 4, &value, data);
61 return value;
62 }
63 }
FlutterStandardCodecHelperReadByte
uint8_t FlutterStandardCodecHelperReadByte(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:42

References FlutterStandardCodecHelperReadByte(), and FlutterStandardCodecHelperReadBytes().

Referenced by FlutterStandardCodecHelperReadUTF8(), FlutterStandardCodecHelperReadValueOfType(), and FlutterStandardReaderWriter::readerWithData:.

## ◆ FlutterStandardCodecHelperReadUTF8()

CFStringRef FlutterStandardCodecHelperReadUTF8 | ( | unsigned long * | location,
|  | CFDataRef | data
| ) |  |

Definition at line 75 of file FlutterStandardCodecHelper.cc.

76 {
77 uint32_t size = FlutterStandardCodecHelperReadSize(location, data);
78 CFDataRef bytes = ReadDataNoCopy(location, size, data);
79 CFStringRef result = CFStringCreateFromExternalRepresentation(
80 kCFAllocatorDefault, bytes, kCFStringEncodingUTF8);
81 return static_cast<CFStringRef>(CFAutorelease(result));
82 }
FlutterStandardCodecHelperReadSize
uint32_t FlutterStandardCodecHelperReadSize(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:49
ReadDataNoCopy
static CFDataRef ReadDataNoCopy(unsigned long *location, unsigned long length, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:65

References FlutterStandardCodecHelperReadSize(), and ReadDataNoCopy().

Referenced by FlutterStandardCodecHelperReadValueOfType().

## ◆ FlutterStandardCodecHelperReadValueOfType()

CFTypeRef FlutterStandardCodecHelperReadValueOfType | ( | unsigned long * | location,
|  | CFDataRef | data,
|  | uint8_t | type,
|  | CFTypeRef(*)(CFTypeRef) | ReadValue,
|  | CFTypeRef(*)(FlutterStandardField, CFTypeRef) | ReadTypedDataOfType,
|  | CFTypeRef | user_data
| ) |  |

Definition at line 103 of file FlutterStandardCodecHelper.cc.

109 {
110 FlutterStandardField field = static_cast<FlutterStandardField>(type);
111 switch (field) {
112 case FlutterStandardFieldNil:
113 return nil;
114 case FlutterStandardFieldTrue:
115 return kCFBooleanTrue;
116 case FlutterStandardFieldFalse:
117 return kCFBooleanFalse;
118 case FlutterStandardFieldInt32: {
119 int32_t value;
120 FlutterStandardCodecHelperReadBytes(location, 4, &value, data);
121 return CFAutorelease(
122 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
123 }
124 case FlutterStandardFieldInt64: {
125 int64_t value;
126 FlutterStandardCodecHelperReadBytes(location, 8, &value, data);
127 return CFAutorelease(
128 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
129 }
130 case FlutterStandardFieldFloat64: {
131 Float64 value;
132 FlutterStandardCodecHelperReadAlignment(location, 8);
133 FlutterStandardCodecHelperReadBytes(location, 8, &value, data);
134 return CFAutorelease(
135 CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
136 }
137 case FlutterStandardFieldIntHex:
138 case FlutterStandardFieldString:
139 return FlutterStandardCodecHelperReadUTF8(location, data);
140 case FlutterStandardFieldUInt8Data:
141 case FlutterStandardFieldInt32Data:
142 case FlutterStandardFieldInt64Data:
143 case FlutterStandardFieldFloat32Data:
144 case FlutterStandardFieldFloat64Data:
145 return ReadTypedDataOfType(field, user_data);
146 case FlutterStandardFieldList: {
147 UInt32 length = FlutterStandardCodecHelperReadSize(location, data);
148 CFMutableArrayRef array = CFArrayCreateMutable(
149 kCFAllocatorDefault, length, &kCFTypeArrayCallBacks);
150 for (UInt32 i = 0; i < length; i++) {
151 CFTypeRef value = FastReadValue(location, data, ReadValue,
152 ReadTypedDataOfType, user_data);
153 CFArrayAppendValue(array, (value == nil ? kCFNull : value));
154 }
155 return CFAutorelease(array);
156 }
157 case FlutterStandardFieldMap: {
158 UInt32 size = FlutterStandardCodecHelperReadSize(location, data);
159 CFMutableDictionaryRef dict = CFDictionaryCreateMutable(
160 kCFAllocatorDefault, size, &kCFTypeDictionaryKeyCallBacks,
161 &kCFTypeDictionaryValueCallBacks);
162 for (UInt32 i = 0; i < size; i++) {
163 CFTypeRef key = FastReadValue(location, data, ReadValue,
164 ReadTypedDataOfType, user_data);
165 CFTypeRef val = FastReadValue(location, data, ReadValue,
166 ReadTypedDataOfType, user_data);
167 CFDictionaryAddValue(dict, (key == nil ? kCFNull : key),
168 (val == nil ? kCFNull : val));
169 }
170 return CFAutorelease(dict);
171 }
172 default:
173 // Malformed message.
174 FML_DCHECK(false);
175 }
176 }
FlutterStandardCodecHelperReadUTF8
CFStringRef FlutterStandardCodecHelperReadUTF8(unsigned long *location, CFDataRef data)
Definition: FlutterStandardCodecHelper.cc:75
FlutterStandardCodecHelperReadAlignment
void FlutterStandardCodecHelperReadAlignment(unsigned long *location, uint8_t alignment)
Definition: FlutterStandardCodecHelper.cc:18
FastReadValue
static CFTypeRef FastReadValue(unsigned long *location, CFDataRef data, CFTypeRef(*ReadValue)(CFTypeRef), CFTypeRef(*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef), CFTypeRef user_data)
Definition: FlutterStandardCodecHelper.cc:87
user_data
void * user_data
Definition: texture_registrar_unittests.cc:27

References FastReadValue(), FlutterStandardCodecHelperReadAlignment(), FlutterStandardCodecHelperReadBytes(), FlutterStandardCodecHelperReadSize(), FlutterStandardCodecHelperReadUTF8(), FlutterStandardFieldFalse, FlutterStandardFieldFloat32Data, FlutterStandardFieldFloat64, FlutterStandardFieldFloat64Data, FlutterStandardFieldInt32, FlutterStandardFieldInt32Data, FlutterStandardFieldInt64, FlutterStandardFieldInt64Data, FlutterStandardFieldIntHex, FlutterStandardFieldList, FlutterStandardFieldMap, FlutterStandardFieldNil, FlutterStandardFieldString, FlutterStandardFieldTrue, FlutterStandardFieldUInt8Data, and user_data.

Referenced by FastReadValue().

## ◆ FlutterStandardCodecHelperWriteAlignment()

void FlutterStandardCodecHelperWriteAlignment | ( | CFMutableDataRef | data,
|  | uint8_t | alignment
| ) |  |

Definition at line 201 of file FlutterStandardCodecHelper.cc.

202 {
203 uint8_t mod = CFDataGetLength(data) % alignment;
204 if (mod) {
205 for (int i = 0; i < (alignment - mod); i++) {
206 FlutterStandardCodecHelperWriteByte(data, 0);
207 }
208 }
209 }
FlutterStandardCodecHelperWriteByte
void FlutterStandardCodecHelperWriteByte(CFMutableDataRef data, uint8_t value)
Definition: FlutterStandardCodecHelper.cc:178

References FlutterStandardCodecHelperWriteByte().

Referenced by FlutterStandardCodecHelperWriteNumber(), and FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardCodecHelperWriteByte()

void FlutterStandardCodecHelperWriteByte | ( | CFMutableDataRef | data,
|  | uint8_t | value
| ) |  |

Definition at line 178 of file FlutterStandardCodecHelper.cc.

178 {
179 CFDataAppendBytes(data, &value, 1);
180 }

Referenced by FlutterStandardCodecHelperWriteAlignment(), FlutterStandardCodecHelperWriteNumber(), FlutterStandardCodecHelperWriteSize(), and FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardCodecHelperWriteBytes()

void FlutterStandardCodecHelperWriteBytes | ( | CFMutableDataRef | data,
|  | const void * | bytes,
|  | unsigned long | length
| ) |  |

Definition at line 182 of file FlutterStandardCodecHelper.cc.

184 {
185 CFDataAppendBytes(data, static_cast<const UInt8*>(bytes), length);
186 }

Referenced by FlutterStandardCodecHelperWriteData(), FlutterStandardCodecHelperWriteNumber(), FlutterStandardCodecHelperWriteSize(), and FlutterStandardCodecHelperWriteUTF8().

## ◆ FlutterStandardCodecHelperWriteData()

void FlutterStandardCodecHelperWriteData | ( | CFMutableDataRef | data,
|  | CFDataRef | value
| ) |  |

Definition at line 232 of file FlutterStandardCodecHelper.cc.

233 {
234 const UInt8* bytes = CFDataGetBytePtr(value);
235 CFIndex length = CFDataGetLength(value);
236 FlutterStandardCodecHelperWriteBytes(data, bytes, length);
237 }
FlutterStandardCodecHelperWriteBytes
void FlutterStandardCodecHelperWriteBytes(CFMutableDataRef data, const void *bytes, unsigned long length)
Definition: FlutterStandardCodecHelper.cc:182

References FlutterStandardCodecHelperWriteBytes().

Referenced by FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardCodecHelperWriteNumber()

bool FlutterStandardCodecHelperWriteNumber | ( | CFMutableDataRef | data,
|  | CFNumberRef | number
| ) |  |

Definition at line 239 of file FlutterStandardCodecHelper.cc.

240 {
241 bool success = false;
242 if (CFGetTypeID(number) == CFBooleanGetTypeID()) {
243 bool b = CFBooleanGetValue(reinterpret_cast<CFBooleanRef>(number));
244 FlutterStandardCodecHelperWriteByte(
245 data, (b ? FlutterStandardFieldTrue : FlutterStandardFieldFalse));
246 success = true;
247 } else if (CFNumberIsFloatType(number)) {
248 Float64 f;
249 success = CFNumberGetValue(number, kCFNumberFloat64Type, &f);
250 if (success) {
251 FlutterStandardCodecHelperWriteByte(data, FlutterStandardFieldFloat64);
252 FlutterStandardCodecHelperWriteAlignment(data, 8);
253 FlutterStandardCodecHelperWriteBytes(data, &f, 8);
254 }
255 } else if (CFNumberGetByteSize(number) <= 4) {
256 SInt32 n;
257 success = CFNumberGetValue(number, kCFNumberSInt32Type, &n);
258 if (success) {
259 FlutterStandardCodecHelperWriteByte(data, FlutterStandardFieldInt32);
260 FlutterStandardCodecHelperWriteBytes(data, &n, 4);
261 }
262 } else if (CFNumberGetByteSize(number) <= 8) {
263 SInt64 n;
264 success = CFNumberGetValue(number, kCFNumberSInt64Type, &n);
265 if (success) {
266 FlutterStandardCodecHelperWriteByte(data, FlutterStandardFieldInt64);
267 FlutterStandardCodecHelperWriteBytes(data, &n, 8);
268 }
269 }
270 return success;
271 }
FlutterStandardCodecHelperWriteAlignment
void FlutterStandardCodecHelperWriteAlignment(CFMutableDataRef data, uint8_t alignment)
Definition: FlutterStandardCodecHelper.cc:201

References FlutterStandardCodecHelperWriteAlignment(), FlutterStandardCodecHelperWriteByte(), FlutterStandardCodecHelperWriteBytes(), FlutterStandardFieldFalse, FlutterStandardFieldFloat64, FlutterStandardFieldInt32, FlutterStandardFieldInt64, and FlutterStandardFieldTrue.

Referenced by FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardCodecHelperWriteSize()

void FlutterStandardCodecHelperWriteSize | ( | CFMutableDataRef | data,
|  | uint32_t | size
| ) |  |

Definition at line 188 of file FlutterStandardCodecHelper.cc.

188 {
189 if (size < 254) {
190 FlutterStandardCodecHelperWriteByte(data, size);
191 } else if (size <= 0xffff) {
192 FlutterStandardCodecHelperWriteByte(data, 254);
193 UInt16 value = static_cast<UInt16>(size);
194 FlutterStandardCodecHelperWriteBytes(data, &value, 2);
195 } else {
196 FlutterStandardCodecHelperWriteByte(data, 255);
197 FlutterStandardCodecHelperWriteBytes(data, &size, 4);
198 }
199 }

References FlutterStandardCodecHelperWriteByte(), and FlutterStandardCodecHelperWriteBytes().

Referenced by FlutterStandardCodecHelperWriteUTF8(), and FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardCodecHelperWriteUTF8()

void FlutterStandardCodecHelperWriteUTF8 | ( | CFMutableDataRef | data,
|  | CFStringRef | value
| ) |  |

Definition at line 211 of file FlutterStandardCodecHelper.cc.

212 {
213 const char* utf8 = CFStringGetCStringPtr(value, kCFStringEncodingUTF8);
214 if (utf8) {
215 size_t length = strlen(utf8);
216 FlutterStandardCodecHelperWriteSize(data, length);
217 FlutterStandardCodecHelperWriteBytes(data, utf8, length);
218 } else {
219 CFIndex length = CFStringGetLength(value);
220 CFIndex used_length = 0;
221 // UTF16 length times 3 will fit all UTF8.
222 CFIndex buffer_length = length * 3;
223 std::vector<UInt8> buffer;
224 buffer.resize(buffer_length);
225 CFStringGetBytes(value, CFRangeMake(0, length), kCFStringEncodingUTF8, 0,
226 false, buffer.data(), buffer_length, &used_length);
227 FlutterStandardCodecHelperWriteSize(data, used_length);
228 FlutterStandardCodecHelperWriteBytes(data, buffer.data(), used_length);
229 }
230 }
FlutterStandardCodecHelperWriteSize
void FlutterStandardCodecHelperWriteSize(CFMutableDataRef data, uint32_t size)
Definition: FlutterStandardCodecHelper.cc:188

References FlutterStandardCodecHelperWriteBytes(), and FlutterStandardCodecHelperWriteSize().

Referenced by FlutterStandardWriter::writeValue:.

## ◆ FlutterStandardFieldIsStandardType()

static bool FlutterStandardFieldIsStandardType | ( | uint8_t | field | ) |
| inline static

Definition at line 39 of file FlutterStandardCodecHelper.h.

39 {
40 return field <= FlutterStandardFieldFloat32Data &&
41 field >= FlutterStandardFieldNil;
42 }

References FlutterStandardFieldFloat32Data, and FlutterStandardFieldNil.

Referenced by FastReadValue().