blob: 917de2da37abeae3bc249ba3a27ddebbd34a53a5 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v10.1.2), do not edit directly.
// See also:
#include <flutter/basic_message_channel.h>
#include <flutter/binary_messenger.h>
#include <flutter/encodable_value.h>
#include <flutter/standard_message_codec.h>
#include <map>
#include <optional>
#include <string>
namespace pigeon_example {
// Generated class from Pigeon.
class FlutterError {
explicit FlutterError(const std::string& code) : code_(code) {}
explicit FlutterError(const std::string& code, const std::string& message)
: code_(code), message_(message) {}
explicit FlutterError(const std::string& code, const std::string& message,
const flutter::EncodableValue& details)
: code_(code), message_(message), details_(details) {}
const std::string& code() const { return code_; }
const std::string& message() const { return message_; }
const flutter::EncodableValue& details() const { return details_; }
std::string code_;
std::string message_;
flutter::EncodableValue details_;
template <class T>
class ErrorOr {
ErrorOr(const T& rhs) : v_(rhs) {}
ErrorOr(const T&& rhs) : v_(std::move(rhs)) {}
ErrorOr(const FlutterError& rhs) : v_(rhs) {}
ErrorOr(const FlutterError&& rhs) : v_(std::move(rhs)) {}
bool has_error() const { return std::holds_alternative<FlutterError>(v_); }
const T& value() const { return std::get<T>(v_); };
const FlutterError& error() const { return std::get<FlutterError>(v_); };
friend class ExampleHostApi;
friend class MessageFlutterApi;
ErrorOr() = default;
T TakeValue() && { return std::get<T>(std::move(v_)); }
std::variant<T, FlutterError> v_;
enum class Code { one = 0, two = 1 };
// Generated class from Pigeon that represents data sent in messages.
class MessageData {
// Constructs an object setting all non-nullable fields.
explicit MessageData(const Code& code, const flutter::EncodableMap& data);
// Constructs an object setting all fields.
explicit MessageData(const std::string* name, const std::string* description,
const Code& code, const flutter::EncodableMap& data);
const std::string* name() const;
void set_name(const std::string_view* value_arg);
void set_name(std::string_view value_arg);
const std::string* description() const;
void set_description(const std::string_view* value_arg);
void set_description(std::string_view value_arg);
const Code& code() const;
void set_code(const Code& value_arg);
const flutter::EncodableMap& data() const;
void set_data(const flutter::EncodableMap& value_arg);
static MessageData FromEncodableList(const flutter::EncodableList& list);
flutter::EncodableList ToEncodableList() const;
friend class ExampleHostApi;
friend class ExampleHostApiCodecSerializer;
friend class MessageFlutterApi;
friend class MessageFlutterApiCodecSerializer;
std::optional<std::string> name_;
std::optional<std::string> description_;
Code code_;
flutter::EncodableMap data_;
class ExampleHostApiCodecSerializer : public flutter::StandardCodecSerializer {
inline static ExampleHostApiCodecSerializer& GetInstance() {
static ExampleHostApiCodecSerializer sInstance;
return sInstance;
void WriteValue(const flutter::EncodableValue& value,
flutter::ByteStreamWriter* stream) const override;
flutter::EncodableValue ReadValueOfType(
uint8_t type, flutter::ByteStreamReader* stream) const override;
// Generated interface from Pigeon that represents a handler of messages from
// Flutter.
class ExampleHostApi {
ExampleHostApi(const ExampleHostApi&) = delete;
ExampleHostApi& operator=(const ExampleHostApi&) = delete;
virtual ~ExampleHostApi() {}
virtual ErrorOr<std::string> GetHostLanguage() = 0;
virtual ErrorOr<int64_t> Add(int64_t a, int64_t b) = 0;
virtual void SendMessage(const MessageData& message,
std::function<void(ErrorOr<bool> reply)> result) = 0;
// The codec used by ExampleHostApi.
static const flutter::StandardMessageCodec& GetCodec();
// Sets up an instance of `ExampleHostApi` to handle messages through the
// `binary_messenger`.
static void SetUp(flutter::BinaryMessenger* binary_messenger,
ExampleHostApi* api);
static flutter::EncodableValue WrapError(std::string_view error_message);
static flutter::EncodableValue WrapError(const FlutterError& error);
ExampleHostApi() = default;
// Generated class from Pigeon that represents Flutter messages that can be
// called from C++.
class MessageFlutterApi {
MessageFlutterApi(flutter::BinaryMessenger* binary_messenger);
static const flutter::StandardMessageCodec& GetCodec();
void FlutterMethod(const std::string* a_string,
std::function<void(const std::string&)>&& on_success,
std::function<void(const FlutterError&)>&& on_error);
flutter::BinaryMessenger* binary_messenger_;
} // namespace pigeon_example