Flutter Engine
 
Loading...
Searching...
No Matches
fl_json_message_codec.h File Reference
#include <gmodule.h>
#include "fl_message_codec.h"

Go to the source code of this file.

Macros

#define FL_JSON_MESSAGE_CODEC_ERROR   fl_json_message_codec_error_quark()
 

Enumerations

enum  FlJsonMessageCodecError {
  FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8 ,
  FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON ,
  FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
}
 

Functions

G_MODULE_EXPORT GQuark fl_json_message_codec_error_quark (void) G_GNUC_CONST
 
G_MODULE_EXPORT G_DECLARE_FINAL_TYPE (FlJsonMessageCodec, fl_json_message_codec, FL, JSON_CODEC, FlMessageCodec) FlJsonMessageCodec *fl_json_message_codec_new()
 
gchar * fl_json_message_codec_encode (FlJsonMessageCodec *codec, FlValue *value, GError **error)
 
FlValuefl_json_message_codec_decode (FlJsonMessageCodec *codec, const gchar *text, GError **error)
 

Macro Definition Documentation

◆ FL_JSON_MESSAGE_CODEC_ERROR

#define FL_JSON_MESSAGE_CODEC_ERROR   fl_json_message_codec_error_quark()

FlJsonMessageCodecError: @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8: Message is not valid UTF-8. @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON: Message is not valid JSON. @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE: Invalid object key type.

Errors for #FlJsonMessageCodec objects to set on failures.

Definition at line 27 of file fl_json_message_codec.h.

Enumeration Type Documentation

◆ FlJsonMessageCodecError

Enumerator
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8 
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON 
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE 

Definition at line 29 of file fl_json_message_codec.h.

Function Documentation

◆ fl_json_message_codec_decode()

FlValue * fl_json_message_codec_decode ( FlJsonMessageCodec *  codec,
const gchar *  text,
GError **  error 
)

fl_json_message_codec_decode: @codec: an #FlJsonMessageCodec. @text: UTF-8 text in JSON format. @error: (allow-none): #GError location to store the error occurring, or NULL.

Decodes a value from a JSON string.

Returns: an FlValue or NULL on error.

Definition at line 326 of file fl_json_message_codec.cc.

328 {
329 g_return_val_if_fail(FL_IS_JSON_CODEC(codec), nullptr);
330
331 g_autoptr(GBytes) data = g_bytes_new_static(text, strlen(text));
333 FL_MESSAGE_CODEC(codec), data, error);
334 if (value == nullptr) {
335 return nullptr;
336 }
337
338 return fl_value_ref(value);
339}
int32_t value
g_autoptr(GMutexLocker) locker
static FlValue * fl_json_message_codec_decode_message(FlMessageCodec *codec, GBytes *message, GError **error)
const uint8_t uint32_t uint32_t GError ** error
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition fl_value.cc:394
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
std::u16string text
std::shared_ptr< const fml::Mapping > data

References data, error, fl_json_message_codec_decode_message(), fl_value_ref(), g_autoptr(), text, and value.

Referenced by decode_error_message(), decode_message(), and TEST().

◆ fl_json_message_codec_encode()

gchar * fl_json_message_codec_encode ( FlJsonMessageCodec *  codec,
FlValue value,
GError **  error 
)

fl_json_message_codec_encode: @codec: an #FlJsonMessageCodec. @value: value to encode. @error: (allow-none): #GError location to store the error occurring, or NULL.

Encodes a value to a JSON string.

Returns: a JSON representation of this value or NULL on error.

Definition at line 311 of file fl_json_message_codec.cc.

313 {
314 g_return_val_if_fail(FL_IS_JSON_CODEC(codec), nullptr);
315
316 rapidjson::StringBuffer buffer;
317 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
318
319 if (!write_value(writer, value, error)) {
320 return nullptr;
321 }
322
323 return g_strdup(buffer.GetString());
324}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98

References error, and value.

Referenced by encode_error_message(), encode_message(), and TEST().

◆ fl_json_message_codec_error_quark()

G_MODULE_EXPORT GQuark fl_json_message_codec_error_quark ( void  )

◆ G_DECLARE_FINAL_TYPE()

G_MODULE_EXPORT G_DECLARE_FINAL_TYPE ( FlJsonMessageCodec  ,
fl_json_message_codec  ,
FL  ,
JSON_CODEC  ,
FlMessageCodec   
)

FlJsonMessageCodec:

#FlJsonMessageCodec is an #FlMessageCodec that implements the encodes FlValue to/from JSON. This codec encodes and decodes FlValue of type FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_LIST, and FL_VALUE_TYPE_MAP.

#FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter services library. fl_json_message_codec_new:

Creates an #FlJsonMessageCodec.

Returns: a new #FlJsonMessageCodec.