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

#include <json_message_codec.h>

Inheritance diagram for flutter::JsonMessageCodec:
flutter::MessageCodec< rapidjson::Document >

Public Member Functions

 ~JsonMessageCodec ()=default
 
 JsonMessageCodec (JsonMessageCodec const &)=delete
 
JsonMessageCodecoperator= (JsonMessageCodec const &)=delete
 
- Public Member Functions inherited from flutter::MessageCodec< rapidjson::Document >
 MessageCodec ()=default
 
 MessageCodec (MessageCodec< rapidjson::Document > const &)=delete
 
virtual ~MessageCodec ()=default
 
MessageCodecoperator= (MessageCodec< rapidjson::Document > const &)=delete
 
std::unique_ptr< rapidjson::Document > DecodeMessage (const uint8_t *binary_message, const size_t message_size) const
 
std::unique_ptr< rapidjson::Document > DecodeMessage (const std::vector< uint8_t > &binary_message) const
 
std::unique_ptr< std::vector< uint8_t > > EncodeMessage (const rapidjson::Document &message) const
 

Static Public Member Functions

static const JsonMessageCodecGetInstance ()
 

Protected Member Functions

 JsonMessageCodec ()=default
 
std::unique_ptr< rapidjson::Document > DecodeMessageInternal (const uint8_t *binary_message, const size_t message_size) const override
 
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal (const rapidjson::Document &message) const override
 
virtual std::unique_ptr< rapidjson::Document > DecodeMessageInternal (const uint8_t *binary_message, const size_t message_size) const=0
 
virtual std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal (const rapidjson::Document &message) const=0
 

Detailed Description

Definition at line 16 of file json_message_codec.h.

Constructor & Destructor Documentation

◆ ~JsonMessageCodec()

flutter::JsonMessageCodec::~JsonMessageCodec ( )
default

◆ JsonMessageCodec() [1/2]

flutter::JsonMessageCodec::JsonMessageCodec ( JsonMessageCodec const &  )
delete

◆ JsonMessageCodec() [2/2]

flutter::JsonMessageCodec::JsonMessageCodec ( )
protecteddefault

Member Function Documentation

◆ DecodeMessageInternal()

std::unique_ptr< rapidjson::Document > flutter::JsonMessageCodec::DecodeMessageInternal ( const uint8_t *  binary_message,
const size_t  message_size 
) const
overrideprotectedvirtual

Implements flutter::MessageCodec< rapidjson::Document >.

Definition at line 35 of file json_message_codec.cc.

37 {
38 auto raw_message = reinterpret_cast<const char*>(binary_message);
39 auto json_message = std::make_unique<rapidjson::Document>();
40 rapidjson::ParseResult result =
41 json_message->Parse(raw_message, message_size);
42 if (result.IsError()) {
43 std::cerr << "Unable to parse JSON message:" << std::endl
44 << rapidjson::GetParseError_En(result.Code()) << std::endl;
45 return nullptr;
46 }
47 return json_message;
48}
GAsyncResult * result

◆ EncodeMessageInternal()

std::unique_ptr< std::vector< uint8_t > > flutter::JsonMessageCodec::EncodeMessageInternal ( const rapidjson::Document &  message) const
overrideprotectedvirtual

Implements flutter::MessageCodec< rapidjson::Document >.

Definition at line 22 of file json_message_codec.cc.

23 {
24 rapidjson::StringBuffer buffer;
25 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
26 // clang-tidy has trouble reasoning about some of the complicated array and
27 // pointer-arithmetic code in rapidjson.
28 // NOLINTNEXTLINE(clang-analyzer-core.*)
29 message.Accept(writer);
30 const char* buffer_start = buffer.GetString();
31 return std::make_unique<std::vector<uint8_t>>(
32 buffer_start, buffer_start + buffer.GetSize());
33}
Win32Message message
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ GetInstance()

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

Definition at line 17 of file json_message_codec.cc.

17 {
18 static JsonMessageCodec sInstance;
19 return sInstance;
20}

◆ operator=()

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

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