Allow extending the C++ standard codec (#20317)
Standard*Codec allows for extensions to support arbitrary types; this had not previously been implemented for the C++ version. Overview of changes: - EncodableValue's std::variant type now allows for a new CustomEncodableValue, which is a thin wrapper around std::any, to store arbitrary extension types. - ByteBufferStream* has been split into an interface class and the buffer-based implementation, with the former now part of the public API surface to be used in standard codec extensions. - They also gained utility methods for some common data types to simplify writing extensions. - StandardCodecSerializer is now part of the public API surface, and is subclassable. - StandardCodecSerializer's ReadValue has been split into ReadValue and ReadValueOfType to match the structure used when subclassing on the Dart side, for easier porting of custom extensions across languages. - Standard*Codec now optionally accepts a non-default serializer in GetInstance, providing a shared instance using that serializer. Fixes https://github.com/flutter/flutter/issues/31174
Showing
想要评论请 注册 或 登录