#include <standard_method_codec.h>
Definition at line 18 of file standard_method_codec.h.
◆ ~StandardMethodCodec()
flutter::StandardMethodCodec::~StandardMethodCodec |
( |
| ) |
|
|
default |
◆ StandardMethodCodec()
◆ DecodeAndProcessResponseEnvelopeInternal()
bool flutter::StandardMethodCodec::DecodeAndProcessResponseEnvelopeInternal |
( |
const uint8_t * |
response, |
|
|
size_t |
response_size, |
|
|
MethodResult< EncodableValue > * |
result |
|
) |
| const |
|
overrideprotectedvirtual |
Implements flutter::MethodCodec< EncodableValue >.
Definition at line 432 of file standard_codec.cc.
435 {
436 ByteBufferStreamReader
stream(response, response_size);
439 case 0: {
441 if (
value.IsNull()) {
443 } else {
445 }
446 return true;
447 }
448 case 1: {
451 EncodableValue details = serializer_->
ReadValue(&stream);
452 const std::string& message_string =
454 if (details.IsNull()) {
455 result->Error(std::get<std::string>(code), message_string);
456 } else {
457 result->Error(std::get<std::string>(code), message_string, details);
458 }
459 return true;
460 }
461 default:
462 return false;
463 }
464}
EncodableValue ReadValue(ByteStreamReader *stream) const
FlutterSemanticsFlag flag
◆ DecodeMethodCallInternal()
std::unique_ptr< MethodCall< EncodableValue > > flutter::StandardMethodCodec::DecodeMethodCallInternal |
( |
const uint8_t * |
message, |
|
|
size_t |
message_size |
|
) |
| const |
|
overrideprotectedvirtual |
Implements flutter::MethodCodec< EncodableValue >.
Definition at line 366 of file standard_codec.cc.
367 {
369 EncodableValue method_name_value = serializer_->
ReadValue(&stream);
370 const auto* method_name = std::get_if<std::string>(&method_name_value);
371 if (!method_name) {
372 std::cerr << "Invalid method call; method name is not a string."
373 << std::endl;
374 return nullptr;
375 }
376 auto arguments =
377 std::make_unique<EncodableValue>(serializer_->
ReadValue(&stream));
378 return std::make_unique<MethodCall<EncodableValue>>(*method_name,
379 std::move(arguments));
380}
◆ EncodeErrorEnvelopeInternal()
std::unique_ptr< std::vector< uint8_t > > flutter::StandardMethodCodec::EncodeErrorEnvelopeInternal |
( |
const std::string & |
error_code, |
|
|
const std::string & |
error_message, |
|
|
const EncodableValue * |
error_details |
|
) |
| const |
|
overrideprotectedvirtual |
Implements flutter::MethodCodec< EncodableValue >.
Definition at line 411 of file standard_codec.cc.
414 {
415 auto encoded = std::make_unique<std::vector<uint8_t>>();
416 ByteBufferStreamWriter
stream(encoded.get());
418 serializer_->
WriteValue(EncodableValue(error_code), &stream);
419 if (error_message.empty()) {
420 serializer_->
WriteValue(EncodableValue(), &stream);
421 } else {
422 serializer_->
WriteValue(EncodableValue(error_message), &stream);
423 }
424 if (error_details) {
425 serializer_->
WriteValue(*error_details, &stream);
426 } else {
427 serializer_->
WriteValue(EncodableValue(), &stream);
428 }
429 return encoded;
430}
virtual void WriteValue(const EncodableValue &value, ByteStreamWriter *stream) const
◆ EncodeMethodCallInternal()
std::unique_ptr< std::vector< uint8_t > > flutter::StandardMethodCodec::EncodeMethodCallInternal |
( |
const MethodCall< EncodableValue > & |
method_call | ) |
const |
|
overrideprotectedvirtual |
Implements flutter::MethodCodec< EncodableValue >.
Definition at line 383 of file standard_codec.cc.
384 {
385 auto encoded = std::make_unique<std::vector<uint8_t>>();
386 ByteBufferStreamWriter
stream(encoded.get());
390 } else {
391 serializer_->
WriteValue(EncodableValue(), &stream);
392 }
393 return encoded;
394}
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
◆ EncodeSuccessEnvelopeInternal()
std::unique_ptr< std::vector< uint8_t > > flutter::StandardMethodCodec::EncodeSuccessEnvelopeInternal |
( |
const EncodableValue * |
result | ) |
const |
|
overrideprotectedvirtual |
◆ GetInstance()
Definition at line 340 of file standard_codec.cc.
341 {
342 if (!serializer) {
344 }
345 static auto* sInstances = new std::map<const StandardCodecSerializer*,
346 std::unique_ptr<StandardMethodCodec>>;
347 auto it = sInstances->find(serializer);
348 if (it == sInstances->end()) {
349
350
351 auto emplace_result = sInstances->emplace(
352 serializer, std::unique_ptr<StandardMethodCodec>(
354 it = emplace_result.first;
355 }
356 return *(it->second);
357}
static const StandardCodecSerializer & GetInstance()
StandardMethodCodec(StandardMethodCodec const &)=delete
◆ operator=()
The documentation for this class was generated from the following files: