Flutter Engine
The Flutter Engine
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:
flutter::MessageCodec< EncodableValue >

Public Member Functions

 ~StandardMessageCodec ()
 
 StandardMessageCodec (StandardMessageCodec const &)=delete
 
StandardMessageCodecoperator= (StandardMessageCodec const &)=delete
 
- Public Member Functions inherited from flutter::MessageCodec< EncodableValue >
 MessageCodec ()=default
 
 MessageCodec (MessageCodec< EncodableValue > const &)=delete
 
virtual ~MessageCodec ()=default
 
MessageCodecoperator= (MessageCodec< EncodableValue > const &)=delete
 
std::unique_ptr< EncodableValueDecodeMessage (const uint8_t *binary_message, const size_t message_size) const
 
std::unique_ptr< EncodableValueDecodeMessage (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 StandardMessageCodecGetInstance (const StandardCodecSerializer *serializer=nullptr)
 

Protected Member Functions

std::unique_ptr< EncodableValueDecodeMessageInternal (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
 
virtual std::unique_ptr< EncodableValueDecodeMessageInternal (const uint8_t *binary_message, const size_t message_size) const=0
 
virtual std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal (const EncodableValue &message) const=0
 

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

Member Function Documentation

◆ DecodeMessageInternal()

std::unique_ptr< EncodableValue > flutter::StandardMessageCodec::DecodeMessageInternal ( const uint8_t *  binary_message,
const size_t  message_size 
) const
overrideprotectedvirtual

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}
EncodableValue ReadValue(ByteStreamReader *stream) const

◆ EncodeMessageInternal()

std::unique_ptr< std::vector< uint8_t > > flutter::StandardMessageCodec::EncodeMessageInternal ( const EncodableValue message) const
overrideprotectedvirtual

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}
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
Win32Message message

◆ GetInstance()

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

Definition at line 293 of file standard_codec.cc.

294 {
295 if (!serializer) {
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}
static const StandardCodecSerializer & GetInstance()
StandardMessageCodec(StandardMessageCodec const &)=delete
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

◆ operator=()

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

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