| Flutter macOS Embedder |

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
flutter::StandardMessageCodec Class Reference

`#include <standard_message_codec.h>`

Inheritance diagram for flutter::StandardMessageCodec:

## Public Member Functions
| ~StandardMessageCodec ()
| StandardMessageCodec (StandardMessageCodec const &)=delete
StandardMessageCodec & | operator= (StandardMessageCodec const &)=delete
Public Member Functions inherited from flutter::MessageCodec< EncodableValue >
| MessageCodec ()=default
| MessageCodec (MessageCodec< EncodableValue > const &)=delete
virtual | ~MessageCodec ()=default
MessageCodec & | operator= (MessageCodec< EncodableValue > const &)=delete
std::unique_ptr< EncodableValue > | DecodeMessage (const uint8_t *binary_message, const size_t message_size) const
std::unique_ptr< EncodableValue > | DecodeMessage (const std::vector< uint8_t > &binary_message) const
std::unique_ptr< std::vector< uint8_t > > | EncodeMessage (const EncodableValue &message) const

## Static Public Member Functions
static const StandardMessageCodec & | GetInstance (const StandardCodecSerializer *serializer=nullptr)

## Protected Member Functions
std::unique_ptr< EncodableValue > | DecodeMessageInternal (const uint8_t *binary_message, const size_t message_size) const override
std::unique_ptr< std::vector< uint8_t > > | EncodeMessageInternal (const EncodableValue &message) const override

## Detailed Description

Definition at line 18 of file standard_message_codec.h.

## Constructor & Destructor Documentation

## ◆ ~StandardMessageCodec()

flutter::StandardMessageCodec::~StandardMessageCodec | ( |  | ) |
| default

## ◆ StandardMessageCodec()

flutter::StandardMessageCodec::StandardMessageCodec | ( | StandardMessageCodec const & |  | ) |
| delete

Referenced by GetInstance().

## Member Function Documentation

## ◆ DecodeMessageInternal()

std::unique_ptr< EncodableValue > flutter::StandardMessageCodec::DecodeMessageInternal | ( | const uint8_t * | binary_message,
|  | const size_t | message_size
| ) |  | const
| override protected virtual

Implements flutter::MessageCodec< EncodableValue >.

Definition at line 318 of file standard_codec.cc.

320 {
321 if (!binary_message) {
322 return std::make_unique<EncodableValue>();
323 }
324 ByteBufferStreamReader stream(binary_message, message_size);
325 return std::make_unique<EncodableValue>(serializer_->ReadValue(&stream));
326 }

References flutter::StandardCodecSerializer::ReadValue().

## ◆ EncodeMessageInternal()

std::unique_ptr< std::vector< uint8_t > > flutter::StandardMessageCodec::EncodeMessageInternal | ( | const EncodableValue & | message | ) | const
| override protected virtual

Implements flutter::MessageCodec< EncodableValue >.

Definition at line 329 of file standard_codec.cc.

330 {
331 auto encoded = std::make_unique<std::vector<uint8_t>>();
332 ByteBufferStreamWriter stream(encoded.get());
333 serializer_->WriteValue(message, &stream);
334 return encoded;
335 }

References flutter::StandardCodecSerializer::WriteValue().

## ◆ GetInstance()

const StandardMessageCodec & flutter::StandardMessageCodec::GetInstance | ( | const StandardCodecSerializer * | serializer = `nullptr` | ) |
| static

Definition at line 293 of file standard_codec.cc.

294 {
295 if (!serializer) {
296 serializer = &StandardCodecSerializer::GetInstance();
297 }
298 static auto* sInstances = new std::map<const StandardCodecSerializer*,
299 std::unique_ptr<StandardMessageCodec>>;
300 auto it = sInstances->find(serializer);
301 if (it == sInstances->end()) {
302 // Uses new due to private constructor (to prevent API clients from
303 // accidentally passing temporary codec instances to channels).
304 auto emplace_result = sInstances->emplace(
305 serializer, std::unique_ptr<StandardMessageCodec>(
306 new StandardMessageCodec(serializer)));
307 it = emplace_result.first;
308 }
309 return *(it->second);
310 }

References flutter::StandardCodecSerializer::GetInstance(), and StandardMessageCodec().

Referenced by flutter::CheckEncodeDecode(), flutter::CheckEncodeDecodeWithEncodePrefix(), and flutter::TEST().

## ◆ operator=()

StandardMessageCodec& flutter::StandardMessageCodec::operator= | ( | StandardMessageCodec const & |  | ) |
| delete

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

- shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h
- shell/platform/common/client_wrapper/standard_codec.cc

flutter::StandardCodecSerializer::ReadValue
EncodableValue ReadValue(ByteStreamReader *stream) const
Definition: standard_codec.cc:92
flutter::StandardCodecSerializer::WriteValue
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
Definition: standard_codec.cc:98
flutter::StandardCodecSerializer::GetInstance
static const StandardCodecSerializer & GetInstance()
Definition: standard_codec.cc:87
flutter::StandardMessageCodec::StandardMessageCodec
StandardMessageCodec(StandardMessageCodec const &)=delete