Flutter Engine
flutter::SomeDataExtensionSerializer Class Reference

#include <test_codec_extensions.h>

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

Public Member Functions

 SomeDataExtensionSerializer ()
 
virtual ~SomeDataExtensionSerializer ()
 
EncodableValue ReadValueOfType (uint8_t type, ByteStreamReader *stream) const override
 
void WriteValue (const EncodableValue &value, ByteStreamWriter *stream) const override
 
- Public Member Functions inherited from flutter::StandardCodecSerializer
virtual ~StandardCodecSerializer ()
 
 StandardCodecSerializer (StandardCodecSerializer const &)=delete
 
StandardCodecSerializeroperator= (StandardCodecSerializer const &)=delete
 
EncodableValue ReadValue (ByteStreamReader *stream) const
 

Static Public Member Functions

static const SomeDataExtensionSerializerGetInstance ()
 
- Static Public Member Functions inherited from flutter::StandardCodecSerializer
static const StandardCodecSerializerGetInstance ()
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::StandardCodecSerializer
 StandardCodecSerializer ()
 
size_t ReadSize (ByteStreamReader *stream) const
 
void WriteSize (size_t size, ByteStreamWriter *stream) const
 

Detailed Description

Definition at line 68 of file test_codec_extensions.h.

Constructor & Destructor Documentation

◆ SomeDataExtensionSerializer()

flutter::SomeDataExtensionSerializer::SomeDataExtensionSerializer ( )
default

◆ ~SomeDataExtensionSerializer()

flutter::SomeDataExtensionSerializer::~SomeDataExtensionSerializer ( )
virtualdefault

Member Function Documentation

◆ GetInstance()

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

Definition at line 46 of file test_codec_extensions.cc.

Referenced by flutter::TEST().

46  {
47  static SomeDataExtensionSerializer sInstance;
48  return sInstance;
49 }

◆ ReadValueOfType()

EncodableValue flutter::SomeDataExtensionSerializer::ReadValueOfType ( uint8_t  type,
ByteStreamReader stream 
) const
overridevirtual

Reimplemented from flutter::StandardCodecSerializer.

Definition at line 51 of file test_codec_extensions.cc.

References flutter::ByteStreamReader::ReadBytes(), flutter::StandardCodecSerializer::ReadSize(), flutter::StandardCodecSerializer::ReadValue(), flutter::StandardCodecSerializer::ReadValueOfType(), and fml::size().

53  {
54  if (type == kSomeDataType) {
55  size_t size = ReadSize(stream);
56  std::vector<uint8_t> data;
57  data.resize(size);
58  stream->ReadBytes(data.data(), size);
59  EncodableValue label = ReadValue(stream);
60  return CustomEncodableValue(SomeData(std::get<std::string>(label), data));
61  }
62  return StandardCodecSerializer::ReadValueOfType(type, stream);
63 }
size_t ReadSize(ByteStreamReader *stream) const
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
EncodableValue ReadValue(ByteStreamReader *stream) const
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const

◆ WriteValue()

void flutter::SomeDataExtensionSerializer::WriteValue ( const EncodableValue value,
ByteStreamWriter stream 
) const
overridevirtual

Reimplemented from flutter::StandardCodecSerializer.

Definition at line 65 of file test_codec_extensions.cc.

References flutter::SomeData::data(), flutter::SomeData::label(), value, flutter::ByteStreamWriter::WriteByte(), flutter::ByteStreamWriter::WriteBytes(), flutter::StandardCodecSerializer::WriteSize(), flutter::StandardCodecSerializer::WriteValue(), and flutter::PointExtensionSerializer::WriteValue().

66  {
67  auto custom_value = std::get_if<CustomEncodableValue>(&value);
68  if (!custom_value) {
70  return;
71  }
72  stream->WriteByte(kSomeDataType);
73  const SomeData& some_data = std::any_cast<SomeData>(*custom_value);
74  size_t data_size = some_data.data().size();
75  WriteSize(data_size, stream);
76  stream->WriteBytes(some_data.data().data(), data_size);
77  WriteValue(EncodableValue(some_data.label()), stream);
78 }
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const override
uint8_t value
void WriteSize(size_t size, ByteStreamWriter *stream) const

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