| 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_FL_JSON_MESSAGE_CODEC_H_
6 #define FLUTTER_SHELL_PLATFORM_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 GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST;
36
37 G_MODULE_EXPORT
38 G_DECLARE_FINAL_TYPE(FlJsonMessageCodec,
39 fl_json_message_codec,
40 FL,
41 JSON_CODEC,
42 FlMessageCodec)
43
44 /**
45 * FlJsonMessageCodec:
46 *
47 * #FlJsonMessageCodec is an #FlMessageCodec that implements the encodes
48 * #FlValue to/from JSON. This codec encodes and decodes #FlValue of type
49 * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT,
50 * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST,
51 * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST,
52 * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP.
53 *
54 * #FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter
55 * services library.
56 */
57
58 /**
59 * fl_json_message_codec_new:
60 *
61 * Creates an #FlJsonMessageCodec.
62 *
63 * Returns: a new #FlJsonMessageCodec.
64 */
65 FlJsonMessageCodec* fl_json_message_codec_new();
66
67 /**
68 * fl_json_message_codec_encode:
69 * @codec: an #FlJsonMessageCodec.
70 * @value: value to encode.
71 * @error: (allow-none): #GError location to store the error occurring, or
72 * %NULL.
73 *
74 * Encodes a value to a JSON string.
75 *
76 * Returns: a JSON representation of this value or %NULL on error.
77 */
78 gchar* fl_json_message_codec_encode(FlJsonMessageCodec* codec,
79 FlValue* value,
80 GError** error);
81
82 /**
83 * fl_json_message_codec_decode:
84 * @codec: an #FlJsonMessageCodec.
85 * @text: UTF-8 text in JSON format.
86 * @error: (allow-none): #GError location to store the error occurring, or
87 * %NULL.
88 *
89 * Decodes a value from a JSON string.
90 *
91 * Returns: an #FlValue or %NULL on error.
92 */
93 FlValue* fl_json_message_codec_decode(FlJsonMessageCodec* codec,
94 const gchar* text,
95 GError** error);
96
97 G_END_DECLS
98
99 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_
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_OBJECT_KEY_TYPE
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
Definition: fl_json_message_codec.h:32
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
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_encode
gchar * fl_json_message_codec_encode(FlJsonMessageCodec *codec, FlValue *value, GError **error)
Definition: fl_json_message_codec.cc:311
fl_message_codec.h
FL
FL
Definition: fl_binary_messenger.cc:27
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
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_json_message_codec_error_quark
GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
Definition: fl_json_message_codec.h:31
FlJsonMessageCodecError
FlJsonMessageCodecError
Definition: fl_json_message_codec.h:29
value
uint8_t value
Definition: fl_standard_message_codec.cc:41