Flutter Engine
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 "fl_message_codec.h"
13 
14 G_BEGIN_DECLS
15 
16 /**
17  * FlJsonMessageCodecError:
18  * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8: Message is not valid UTF-8.
19  * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON: Message is not valid JSON.
20  * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE: Invalid object key
21  * type.
22  *
23  * Errors for #FlJsonMessageCodec objects to set on failures.
24  */
25 #define FL_JSON_MESSAGE_CODEC_ERROR fl_json_message_codec_error_quark()
26 
27 typedef enum {
32 
33 GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST;
34 
35 G_DECLARE_FINAL_TYPE(FlJsonMessageCodec,
36  fl_json_message_codec,
37  FL,
38  JSON_CODEC,
39  FlMessageCodec)
40 
41 /**
42  * FlJsonMessageCodec:
43  *
44  * #FlJsonMessageCodec is an #FlMessageCodec that implements the encodes
45  * #FlValue to/from JSON. This codec encodes and decodes #FlValue of type
46  * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT,
47  * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST,
48  * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST,
49  * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP.
50  *
51  * #FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter
52  * services library.
53  */
54 
55 /**
56  * fl_json_message_codec_new:
57  *
58  * Creates an #FlJsonMessageCodec.
59  *
60  * Returns: a new #FlJsonMessageCodec.
61  */
62 FlJsonMessageCodec* fl_json_message_codec_new();
63 
64 /**
65  * fl_json_message_codec_encode:
66  * @codec: an #FlJsonMessageCodec.
67  * @value: value to encode.
68  * @error: (allow-none): #GError location to store the error occurring, or
69  * %NULL.
70  *
71  * Encodes a value to a JSON string.
72  *
73  * Returns: a JSON representation of this value or %NULL on error.
74  */
75 gchar* fl_json_message_codec_encode(FlJsonMessageCodec* codec,
76  FlValue* value,
77  GError** error);
78 
79 /**
80  * fl_json_message_codec_decode:
81  * @codec: an #FlJsonMessageCodec.
82  * @text: UTF-8 text in JSON format.
83  * @error: (allow-none): #GError location to store the error occurring, or
84  * %NULL.
85  *
86  * Decodes a value from a JSON string.
87  *
88  * Returns: an #FlValue or %NULL on error.
89  */
90 FlValue* fl_json_message_codec_decode(FlJsonMessageCodec* codec,
91  const gchar* text,
92  GError** error);
93 
94 G_END_DECLS
95 
96 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
FlMethodResponse GError ** error
GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
uint8_t value
FlJsonMessageCodecError
G_BEGIN_DECLS FL
G_DECLARE_FINAL_TYPE(FlJsonMessageCodec, fl_json_message_codec, FL, JSON_CODEC, FlMessageCodec) FlJsonMessageCodec *fl_json_message_codec_new()
FlValue * fl_json_message_codec_decode(FlJsonMessageCodec *codec, const gchar *text, GError **error)
gchar * fl_json_message_codec_encode(FlJsonMessageCodec *codec, FlValue *value, GError **error)