| 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 319 of file standard_codec.cc.

321 {
322 if (!binary_message) {
323 return std::make_unique<EncodableValue>();
324 }
325 ByteBufferStreamReader stream(binary_message, message_size);
326 return std::make_unique<EncodableValue>(serializer_->ReadValue(&stream));
327 }
flutter::StandardCodecSerializer::ReadValue
EncodableValue ReadValue(ByteStreamReader *stream) const
Definition: standard_codec.cc:92

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 330 of file standard_codec.cc.

331 {
332 auto encoded = std::make_unique<std::vector<uint8_t>>();
333 ByteBufferStreamWriter stream(encoded.get());
334 serializer_->WriteValue(message, &stream);
335 return encoded;
336 }
flutter::StandardCodecSerializer::WriteValue
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
Definition: standard_codec.cc:98

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 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
305 auto emplace_result = sInstances->emplace(
306 serializer, std::unique_ptr<StandardMessageCodec>(
307 new StandardMessageCodec(serializer)));
308 it = emplace_result.first;
309 }
310 return *(it->second);
311 }
flutter::StandardCodecSerializer::GetInstance
static const StandardCodecSerializer & GetInstance()
Definition: standard_codec.cc:87
flutter::StandardMessageCodec::StandardMessageCodec
StandardMessageCodec(StandardMessageCodec const &)=delete

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