| Flutter Windows Embedder |

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:

## Public Member Functions
| ~JsonMessageCodec ()=default
| JsonMessageCodec (JsonMessageCodec const &)=delete
JsonMessageCodec & | operator= (JsonMessageCodec const &)=delete
Public Member Functions inherited from flutter::MessageCodec< rapidjson::Document >
| MessageCodec ()=default
| MessageCodec (MessageCodec< rapidjson::Document > const &)=delete
virtual | ~MessageCodec ()=default
MessageCodec & | operator= (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 JsonMessageCodec & | GetInstance ()

## 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

## 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 | ( |  | ) |
| protected default

## Member Function Documentation

## ◆ DecodeMessageInternal()

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

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 }

## ◆ EncodeMessageInternal()

std::unique_ptr< std::vector< uint8_t > > flutter::JsonMessageCodec::EncodeMessageInternal | ( | const rapidjson::Document & | message | ) | const
| override protected virtual

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 }

References message.

## ◆ 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 }

Referenced by flutter::JsonMethodCodec::DecodeAndProcessResponseEnvelopeInternal(), flutter::JsonMethodCodec::DecodeMethodCallInternal(), flutter::JsonMethodCodec::EncodeErrorEnvelopeInternal(), flutter::JsonMethodCodec::EncodeMethodCallInternal(), flutter::JsonMethodCodec::EncodeSuccessEnvelopeInternal(), flutter::KeyboardKeyChannelHandler::KeyboardHook(), and flutter::testing::TEST().

## ◆ operator=()

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

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

- shell/platform/common/json_message_codec.h
- shell/platform/common/json_message_codec.cc

flutter::JsonMessageCodec::JsonMessageCodec
JsonMessageCodec()=default
message
Win32Message message
Definition: keyboard_unittests.cc:137