| Flutter Linux Embedder |

Classes | Functions
fl_string_codec.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_string_codec.h"`
`#include <gmodule.h>`
`#include <cstring>`

Go to the source code of this file.

## Classes
struct | _FlStringCodec

## Functions
static GBytes * | fl_string_codec_encode_message (FlMessageCodec *codec, FlValue *value, GError **error)
static FlValue * | fl_string_codec_decode_message (FlMessageCodec *codec, GBytes *message, GError **error)
static void | fl_string_codec_class_init (FlStringCodecClass *klass)
static void | fl_string_codec_init (FlStringCodec *self)
G_MODULE_EXPORT FlStringCodec * | fl_string_codec_new ()

## Function Documentation

## ◆ fl_string_codec_class_init()

static void fl_string_codec_class_init | ( | FlStringCodecClass * | klass | ) |
| static

Definition at line 44 of file fl_string_codec.cc.

44 {
45 FL_MESSAGE_CODEC_CLASS(klass)->encode_message =
46 fl_string_codec_encode_message;
47 FL_MESSAGE_CODEC_CLASS(klass)->decode_message =
48 fl_string_codec_decode_message;
49 }

References fl_string_codec_decode_message(), and fl_string_codec_encode_message().

## ◆ fl_string_codec_decode_message()

static FlValue* fl_string_codec_decode_message | ( | FlMessageCodec * | codec,
|  | GBytes * | message,
|  | GError ** | error
| ) |  |
| static

Definition at line 35 of file fl_string_codec.cc.

37 {
38 gsize data_length;
39 const gchar* data =
40 static_cast<const gchar*>(g_bytes_get_data(message, &data_length));
41 return fl_value_new_string_sized(data, data_length);
42 }

References fl_value_new_string_sized().

Referenced by fl_string_codec_class_init().

## ◆ fl_string_codec_encode_message()

static GBytes* fl_string_codec_encode_message | ( | FlMessageCodec * | codec,
|  | FlValue * | value,
|  | GError ** | error
| ) |  |
| static

Definition at line 20 of file fl_string_codec.cc.

22 {
23 if (fl_value_get_type(value) != FL_VALUE_TYPE_STRING) {
24 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
25 FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE,
26 "Only string values supported");
27 return nullptr;
28 }
29
30 const gchar* text = fl_value_get_string(value);
31 return g_bytes_new(text, strlen(text));
32 }

References error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_STRING, and value.

Referenced by fl_string_codec_class_init().

## ◆ fl_string_codec_init()

static void fl_string_codec_init | ( | FlStringCodec * | self | ) |
| static

Definition at line 51 of file fl_string_codec.cc.

51 {}

## ◆ fl_string_codec_new()

G_MODULE_EXPORT FlStringCodec* fl_string_codec_new | ( |  | ) |

Definition at line 53 of file fl_string_codec.cc.

53 {
54 return static_cast<FlStringCodec*>(
55 g_object_new(fl_string_codec_get_type(), nullptr));
56 }

Referenced by decode_message(), encode_message(), encode_message_error(), FlValueStringMatcher::MatchAndExplain(), send_lifecycle_state(), and TEST().

fl_value_new_string_sized
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition: fl_value.cc:283
fl_value_get_string
const G_MODULE_EXPORT gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
fl_string_codec_encode_message
static GBytes * fl_string_codec_encode_message(FlMessageCodec *codec, FlValue *value, GError **error)
Definition: fl_string_codec.cc:20
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:69
fl_string_codec_decode_message
static FlValue * fl_string_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
Definition: fl_string_codec.cc:35
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
@ FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE
Definition: fl_message_codec.h:37
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
FL_MESSAGE_CODEC_ERROR
#define FL_MESSAGE_CODEC_ERROR
Definition: fl_message_codec.h:30