Flutter iOS Embedder
json_message_codec.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_COMMON_JSON_MESSAGE_CODEC_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_JSON_MESSAGE_CODEC_H_
7 
8 #include <rapidjson/document.h>
9 
11 
12 namespace flutter {
13 
14 // A message encoding/decoding mechanism for communications to/from the
15 // Flutter engine via JSON channels.
16 class JsonMessageCodec : public MessageCodec<rapidjson::Document> {
17  public:
18  // Returns the shared instance of the codec.
19  static const JsonMessageCodec& GetInstance();
20 
21  ~JsonMessageCodec() = default;
22 
23  // Prevent copying.
24  JsonMessageCodec(JsonMessageCodec const&) = delete;
26 
27  protected:
28  // Instances should be obtained via GetInstance.
29  JsonMessageCodec() = default;
30 
31  // |flutter::MessageCodec|
32  std::unique_ptr<rapidjson::Document> DecodeMessageInternal(
33  const uint8_t* binary_message,
34  const size_t message_size) const override;
35 
36  // |flutter::MessageCodec|
37  std::unique_ptr<std::vector<uint8_t>> EncodeMessageInternal(
38  const rapidjson::Document& message) const override;
39 };
40 
41 } // namespace flutter
42 
43 #endif // FLUTTER_SHELL_PLATFORM_COMMON_JSON_MESSAGE_CODEC_H_
flutter::MessageCodec
Definition: message_codec.h:17
flutter::JsonMessageCodec::GetInstance
static const JsonMessageCodec & GetInstance()
Definition: json_message_codec.cc:17
flutter::JsonMessageCodec::JsonMessageCodec
JsonMessageCodec()=default
flutter::JsonMessageCodec::~JsonMessageCodec
~JsonMessageCodec()=default
flutter::JsonMessageCodec::DecodeMessageInternal
std::unique_ptr< rapidjson::Document > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
Definition: json_message_codec.cc:35
flutter::JsonMessageCodec::operator=
JsonMessageCodec & operator=(JsonMessageCodec const &)=delete
message_codec.h
flutter
Definition: accessibility_bridge.h:28
flutter::JsonMessageCodec
Definition: json_message_codec.h:16
flutter::JsonMessageCodec::EncodeMessageInternal
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const rapidjson::Document &message) const override
Definition: json_message_codec.cc:22