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