| Flutter Linux Embedder |

fl_json_message_codec.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_JSON_MESSAGE_CODEC_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_JSON_MESSAGE_CODEC_H_
7
8 #if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9 #error "Only <flutter_linux/flutter_linux.h> can be included directly."
10 #endif
11
12 #include <gmodule.h>
13
14 #include "fl_message_codec.h"
15
16 G_BEGIN_DECLS
17
18 /**
19 * FlJsonMessageCodecError:
20 * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8: Message is not valid UTF-8.
21 * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON: Message is not valid JSON.
22 * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE: Invalid object key
23 * type.
24 *
25 * Errors for #FlJsonMessageCodec objects to set on failures.
26 */
27 #define FL_JSON_MESSAGE_CODEC_ERROR fl_json_message_codec_error_quark()
28
29 typedef enum {
30 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8,
31 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON,
32 FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE,
33 } FlJsonMessageCodecError;
34
35 G_MODULE_EXPORT
36 GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST;
37
38 G_MODULE_EXPORT
39 G_DECLARE_FINAL_TYPE(FlJsonMessageCodec,
40 fl_json_message_codec,
41 FL,
42 JSON_CODEC,
43 FlMessageCodec)
44
45 /**
46 * FlJsonMessageCodec:
47 *
48 * #FlJsonMessageCodec is an #FlMessageCodec that implements the encodes
49 * #FlValue to/from JSON. This codec encodes and decodes #FlValue of type
50 * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT,
51 * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST,
52 * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST,
53 * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP.
54 *
55 * #FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter
56 * services library.
57 */
58
59 /**
60 * fl_json_message_codec_new:
61 *
62 * Creates an #FlJsonMessageCodec.
63 *
64 * Returns: a new #FlJsonMessageCodec.
65 */
66 FlJsonMessageCodec* fl_json_message_codec_new();
67
68 /**
69 * fl_json_message_codec_encode:
70 * @codec: an #FlJsonMessageCodec.
71 * @value: value to encode.
72 * @error: (allow-none): #GError location to store the error occurring, or
73 * %NULL.
74 *
75 * Encodes a value to a JSON string.
76 *
77 * Returns: a JSON representation of this value or %NULL on error.
78 */
79 gchar* fl_json_message_codec_encode(FlJsonMessageCodec* codec,
80 FlValue* value,
81 GError** error);
82
83 /**
84 * fl_json_message_codec_decode:
85 * @codec: an #FlJsonMessageCodec.
86 * @text: UTF-8 text in JSON format.
87 * @error: (allow-none): #GError location to store the error occurring, or
88 * %NULL.
89 *
90 * Decodes a value from a JSON string.
91 *
92 * Returns: an #FlValue or %NULL on error.
93 */
94 FlValue* fl_json_message_codec_decode(FlJsonMessageCodec* codec,
95 const gchar* text,
96 GError** error);
97
98 G_END_DECLS
99
100 #endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_JSON_MESSAGE_CODEC_H_
FL
FL
Definition: fl_binary_messenger.cc:27
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
FlJsonMessageCodecError
FlJsonMessageCodecError
Definition: fl_json_message_codec.h:29
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
Definition: fl_json_message_codec.h:32
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8
Definition: fl_json_message_codec.h:30
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
Definition: fl_json_message_codec.h:31
G_DECLARE_FINAL_TYPE
G_MODULE_EXPORT G_DECLARE_FINAL_TYPE(FlJsonMessageCodec, fl_json_message_codec, FL, JSON_CODEC, FlMessageCodec) FlJsonMessageCodec *fl_json_message_codec_new()
fl_json_message_codec_error_quark
G_MODULE_EXPORT GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST
fl_json_message_codec_encode
gchar * fl_json_message_codec_encode(FlJsonMessageCodec *codec, FlValue *value, GError **error)
Definition: fl_json_message_codec.cc:311
fl_json_message_codec_decode
FlValue * fl_json_message_codec_decode(FlJsonMessageCodec *codec, const gchar *text, GError **error)
Definition: fl_json_message_codec.cc:326
fl_message_codec.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42