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