Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
standard_codec_serializer.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_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_
7
8#include "byte_streams.h"
9#include "encodable_value.h"
10
11namespace flutter {
12
13// Encapsulates the logic for encoding/decoding EncodableValues to/from the
14// standard codec binary representation.
15//
16// This can be subclassed to extend the standard codec with support for new
17// types.
19 public:
21
22 // Returns the shared serializer instance.
24
25 // Prevent copying.
28
29 // Reads and returns the next value from |stream|.
31
32 // Writes the encoding of |value| to |stream|, including the initial type
33 // discrimination byte.
34 //
35 // Can be overridden by a subclass to extend the codec.
36 virtual void WriteValue(const EncodableValue& value,
37 ByteStreamWriter* stream) const;
38
39 protected:
40 // Codecs require long-lived serializers, so clients should always use
41 // GetInstance().
43
44 // Reads and returns the next value from |stream|, whose discrimination byte
45 // was |type|.
46 //
47 // The discrimination byte will already have been read from the stream when
48 // this is called.
49 //
50 // Can be overridden by a subclass to extend the codec.
51 virtual EncodableValue ReadValueOfType(uint8_t type,
52 ByteStreamReader* stream) const;
53
54 // Reads the variable-length size from the current position in |stream|.
55 size_t ReadSize(ByteStreamReader* stream) const;
56
57 // Writes the variable-length size encoding to |stream|.
58 void WriteSize(size_t size, ByteStreamWriter* stream) const;
59
60 private:
61 // Reads a fixed-type list whose values are of type T from the current
62 // position in |stream|, and returns it as the corresponding EncodableValue.
63 // |T| must correspond to one of the supported list value types of
64 // EncodableValue.
65 template <typename T>
66 EncodableValue ReadVector(ByteStreamReader* stream) const;
67
68 // Writes |vector| to |stream| as a fixed-type list. |T| must correspond to
69 // one of the supported list value types of EncodableValue.
70 template <typename T>
71 void WriteVector(const std::vector<T> vector, ByteStreamWriter* stream) const;
72};
73
74} // namespace flutter
75
76#endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
void WriteSize(size_t size, ByteStreamWriter *stream) const
StandardCodecSerializer & operator=(StandardCodecSerializer const &)=delete
StandardCodecSerializer(StandardCodecSerializer const &)=delete
static const StandardCodecSerializer & GetInstance()
EncodableValue ReadValue(ByteStreamReader *stream) const
virtual EncodableValue ReadValueOfType(uint8_t type, ByteStreamReader *stream) const
size_t ReadSize(ByteStreamReader *stream) const
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259