Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
flutter::StandardCodecSerializer Class Reference

#include <standard_codec_serializer.h>

Inheritance diagram for flutter::StandardCodecSerializer:
flutter::PointExtensionSerializer flutter::SomeDataExtensionSerializer

Public Member Functions

virtual ~StandardCodecSerializer ()
 
 StandardCodecSerializer (StandardCodecSerializer const &)=delete
 
StandardCodecSerializeroperator= (StandardCodecSerializer const &)=delete
 
EncodableValue ReadValue (ByteStreamReader *stream) const
 
virtual void WriteValue (const EncodableValue &value, ByteStreamWriter *stream) const
 

Static Public Member Functions

static const StandardCodecSerializerGetInstance ()
 

Protected Member Functions

 StandardCodecSerializer ()
 
virtual EncodableValue ReadValueOfType (uint8_t type, ByteStreamReader *stream) const
 
size_t ReadSize (ByteStreamReader *stream) const
 
void WriteSize (size_t size, ByteStreamWriter *stream) const
 

Detailed Description

Definition at line 18 of file standard_codec_serializer.h.

Constructor & Destructor Documentation

◆ ~StandardCodecSerializer()

flutter::StandardCodecSerializer::~StandardCodecSerializer ( )
virtualdefault

◆ StandardCodecSerializer() [1/2]

flutter::StandardCodecSerializer::StandardCodecSerializer ( StandardCodecSerializer const &  )
delete

◆ StandardCodecSerializer() [2/2]

flutter::StandardCodecSerializer::StandardCodecSerializer ( )
protecteddefault

Member Function Documentation

◆ GetInstance()

const StandardCodecSerializer & flutter::StandardCodecSerializer::GetInstance ( )
static

Definition at line 87 of file standard_codec.cc.

87 {
88 static StandardCodecSerializer sInstance;
89 return sInstance;
90};

◆ operator=()

StandardCodecSerializer & flutter::StandardCodecSerializer::operator= ( StandardCodecSerializer const &  )
delete

◆ ReadSize()

size_t flutter::StandardCodecSerializer::ReadSize ( ByteStreamReader stream) const
protected

Definition at line 229 of file standard_codec.cc.

229 {
230 uint8_t byte = stream->ReadByte();
231 if (byte < 254) {
232 return byte;
233 } else if (byte == 254) {
234 uint16_t value = 0;
235 stream->ReadBytes(reinterpret_cast<uint8_t*>(&value), 2);
236 return value;
237 } else {
238 uint32_t value = 0;
239 stream->ReadBytes(reinterpret_cast<uint8_t*>(&value), 4);
240 return value;
241 }
242}
uint8_t value

◆ ReadValue()

EncodableValue flutter::StandardCodecSerializer::ReadValue ( ByteStreamReader stream) const

Definition at line 92 of file standard_codec.cc.

93 {
94 uint8_t type = stream->ReadByte();
96}
GLenum type
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const

◆ ReadValueOfType()

EncodableValue flutter::StandardCodecSerializer::ReadValueOfType ( uint8_t  type,
ByteStreamReader stream 
) const
protectedvirtual

Reimplemented in flutter::PointExtensionSerializer, and flutter::SomeDataExtensionSerializer.

Definition at line 168 of file standard_codec.cc.

170 {
171 switch (static_cast<EncodedType>(type)) {
173 return EncodableValue();
174 case EncodedType::kTrue:
175 return EncodableValue(true);
176 case EncodedType::kFalse:
177 return EncodableValue(false);
179 return EncodableValue(stream->ReadInt32());
181 return EncodableValue(stream->ReadInt64());
182 case EncodedType::kFloat64:
183 stream->ReadAlignment(8);
184 return EncodableValue(stream->ReadDouble());
185 case EncodedType::kLargeInt:
186 case EncodedType::kString: {
187 size_t size = ReadSize(stream);
188 std::string string_value;
189 string_value.resize(size);
190 stream->ReadBytes(reinterpret_cast<uint8_t*>(&string_value[0]), size);
191 return EncodableValue(string_value);
192 }
193 case EncodedType::kUInt8List:
194 return ReadVector<uint8_t>(stream);
195 case EncodedType::kInt32List:
196 return ReadVector<int32_t>(stream);
197 case EncodedType::kInt64List:
198 return ReadVector<int64_t>(stream);
199 case EncodedType::kFloat64List:
200 return ReadVector<double>(stream);
201 case EncodedType::kList: {
202 size_t length = ReadSize(stream);
203 EncodableList list_value;
204 list_value.reserve(length);
205 for (size_t i = 0; i < length; ++i) {
206 list_value.push_back(ReadValue(stream));
207 }
208 return EncodableValue(list_value);
209 }
210 case EncodedType::kMap: {
211 size_t length = ReadSize(stream);
212 EncodableMap map_value;
213 for (size_t i = 0; i < length; ++i) {
214 EncodableValue key = ReadValue(stream);
215 EncodableValue value = ReadValue(stream);
216 map_value.emplace(std::move(key), std::move(value));
217 }
218 return EncodableValue(map_value);
219 }
220 case EncodedType::kFloat32List: {
221 return ReadVector<float>(stream);
222 }
223 }
224 std::cerr << "Unknown type in StandardCodecSerializer::ReadValueOfType: "
225 << static_cast<int>(type) << std::endl;
226 return EncodableValue();
227}
EncodableValue ReadValue(ByteStreamReader *stream) const
size_t ReadSize(ByteStreamReader *stream) const
size_t length
static constexpr const char * kList
std::vector< EncodableValue > EncodableList
std::map< EncodableValue, EncodableValue > EncodableMap
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
@ kNull
Definition: paint.cc:59

◆ WriteSize()

void flutter::StandardCodecSerializer::WriteSize ( size_t  size,
ByteStreamWriter stream 
) const
protected

Definition at line 244 of file standard_codec.cc.

245 {
246 if (size < 254) {
247 stream->WriteByte(static_cast<uint8_t>(size));
248 } else if (size <= 0xffff) {
249 stream->WriteByte(254);
250 uint16_t value = static_cast<uint16_t>(size);
251 stream->WriteBytes(reinterpret_cast<uint8_t*>(&value), 2);
252 } else {
253 stream->WriteByte(255);
254 uint32_t value = static_cast<uint32_t>(size);
255 stream->WriteBytes(reinterpret_cast<uint8_t*>(&value), 4);
256 }
257}

◆ WriteValue()

void flutter::StandardCodecSerializer::WriteValue ( const EncodableValue value,
ByteStreamWriter stream 
) const
virtual

Reimplemented in flutter::PointExtensionSerializer, and flutter::SomeDataExtensionSerializer.

Definition at line 98 of file standard_codec.cc.

99 {
100 stream->WriteByte(static_cast<uint8_t>(EncodedTypeForValue(value)));
101 // TODO(cbracken): Consider replacing this with std::visit.
102 switch (value.index()) {
103 case 0:
104 case 1:
105 // Null and bool are encoded directly in the type.
106 break;
107 case 2:
108 stream->WriteInt32(std::get<int32_t>(value));
109 break;
110 case 3:
111 stream->WriteInt64(std::get<int64_t>(value));
112 break;
113 case 4:
114 stream->WriteAlignment(8);
115 stream->WriteDouble(std::get<double>(value));
116 break;
117 case 5: {
118 const auto& string_value = std::get<std::string>(value);
119 size_t size = string_value.size();
121 if (size > 0) {
122 stream->WriteBytes(
123 reinterpret_cast<const uint8_t*>(string_value.data()), size);
124 }
125 break;
126 }
127 case 6:
128 WriteVector(std::get<std::vector<uint8_t>>(value), stream);
129 break;
130 case 7:
131 WriteVector(std::get<std::vector<int32_t>>(value), stream);
132 break;
133 case 8:
134 WriteVector(std::get<std::vector<int64_t>>(value), stream);
135 break;
136 case 9:
137 WriteVector(std::get<std::vector<double>>(value), stream);
138 break;
139 case 10: {
140 const auto& list = std::get<EncodableList>(value);
141 WriteSize(list.size(), stream);
142 for (const auto& item : list) {
143 WriteValue(item, stream);
144 }
145 break;
146 }
147 case 11: {
148 const auto& map = std::get<EncodableMap>(value);
149 WriteSize(map.size(), stream);
150 for (const auto& pair : map) {
151 WriteValue(pair.first, stream);
152 WriteValue(pair.second, stream);
153 }
154 break;
155 }
156 case 12:
157 std::cerr
158 << "Unhandled custom type in StandardCodecSerializer::WriteValue. "
159 << "Custom types require codec extensions." << std::endl;
160 break;
161 case 13: {
162 WriteVector(std::get<std::vector<float>>(value), stream);
163 break;
164 }
165 }
166}
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
void WriteSize(size_t size, ByteStreamWriter *stream) const
const myers::Point & get(const myers::Segment &)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

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