| Flutter Linux Embedder |

Public Member Functions | Public Attributes | List of all members
FlValueHandler Struct Reference

## Public Member Functions
| FlValueHandler ()
| ~FlValueHandler ()
FlValue * | get_head ()
void | push (FlValue *value)
void | pop ()
bool | add (FlValue *value)
bool | Null ()
bool | Bool (bool b)
bool | Int (int i)
bool | Uint (unsigned i)
bool | Int64 (int64_t i)
bool | Uint64 (uint64_t i)
bool | Double (double d)
bool | RawNumber (const char *str, rapidjson::SizeType length, bool copy)
bool | String (const char *str, rapidjson::SizeType length, bool copy)
bool | StartObject ()
bool | Key (const char *str, rapidjson::SizeType length, bool copy)
bool | EndObject (rapidjson::SizeType memberCount)
bool | StartArray ()
bool | EndArray (rapidjson::SizeType elementCount)

## Public Attributes
GPtrArray * | stack
FlValue * | key
GError * | error

## Detailed Description

Definition at line 124 of file fl_json_message_codec.cc.

## Constructor & Destructor Documentation

## ◆ FlValueHandler()

FlValueHandler::FlValueHandler | ( |  | ) |
| inline

Definition at line 129 of file fl_json_message_codec.cc.

129 {
130 stack = g_ptr_array_new_with_free_func(
131 reinterpret_cast<GDestroyNotify>(fl_value_unref));
132 key = nullptr;
133 error = nullptr;
134 }

References error, fl_value_unref(), key, and stack.

## ◆ ~FlValueHandler()

FlValueHandler::~FlValueHandler | ( |  | ) |
| inline

Definition at line 136 of file fl_json_message_codec.cc.

136 {
137 g_ptr_array_unref(stack);
138 if (key != nullptr) {
139 fl_value_unref(key);
140 }
141 if (error != nullptr) {
142 g_error_free(error);
143 }
144 }

References error, fl_value_unref(), key, and stack.

## Member Function Documentation

## ◆ add()

bool FlValueHandler::add | ( | FlValue * | value | ) |
| inline

Definition at line 161 of file fl_json_message_codec.cc.

161 {
162 g_autoptr(FlValue) owned_value = value;
163 FlValue* head = get_head();
164 if (head == nullptr) {
165 push(owned_value);
166 } else if (fl_value_get_type(head) == FL_VALUE_TYPE_LIST) {
167 fl_value_append(head, owned_value);
168 } else if (fl_value_get_type(head) == FL_VALUE_TYPE_MAP) {
169 fl_value_set_take(head, key, fl_value_ref(owned_value));
170 key = nullptr;
171 } else {
172 g_set_error(&error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED,
173 "Can't add value to non container");
174 return false;
175 }
176
177 if (fl_value_get_type(owned_value) == FL_VALUE_TYPE_LIST ||
178 fl_value_get_type(owned_value) == FL_VALUE_TYPE_MAP) {
179 push(value);
180 }
181
182 return true;
183 }

References error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED, fl_value_append(), fl_value_get_type(), fl_value_ref(), fl_value_set_take(), FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, get_head(), key, push(), and value.

Referenced by Bool(), Double(), Int(), Int64(), Null(), StartArray(), StartObject(), String(), Uint(), and Uint64().

## ◆ Bool()

bool FlValueHandler::Bool | ( | bool | b | ) |
| inline

Definition at line 189 of file fl_json_message_codec.cc.

189 { return add(fl_value_new_bool(b)); }

References add(), and fl_value_new_bool().

## ◆ Double()

bool FlValueHandler::Double | ( | double | d | ) |
| inline

Definition at line 206 of file fl_json_message_codec.cc.

206 { return add(fl_value_new_float(d)); }

References add(), and fl_value_new_float().

## ◆ EndArray()

bool FlValueHandler::EndArray | ( | rapidjson::SizeType | elementCount | ) |
| inline

Definition at line 236 of file fl_json_message_codec.cc.

236 {
237 pop();
238 return true;
239 }

References pop().

## ◆ EndObject()

bool FlValueHandler::EndObject | ( | rapidjson::SizeType | memberCount | ) |
| inline

Definition at line 229 of file fl_json_message_codec.cc.

229 {
230 pop();
231 return true;
232 }

References pop().

## ◆ get_head()

FlValue* FlValueHandler::get_head | ( |  | ) |
| inline

Definition at line 147 of file fl_json_message_codec.cc.

147 {
148 if (stack->len == 0) {
149 return nullptr;
150 }
151 return static_cast<FlValue*>(g_ptr_array_index(stack, stack->len - 1));
152 }

References stack.

Referenced by add(), and fl_json_message_codec_decode_message().

## ◆ Int()

bool FlValueHandler::Int | ( | int | i | ) |
| inline

Definition at line 191 of file fl_json_message_codec.cc.

191 { return add(fl_value_new_int(i)); }

References add(), and fl_value_new_int().

## ◆ Int64()

bool FlValueHandler::Int64 | ( | int64_t | i | ) |
| inline

Definition at line 195 of file fl_json_message_codec.cc.

195 { return add(fl_value_new_int(i)); }

References add(), and fl_value_new_int().

## ◆ Key()

bool FlValueHandler::Key | ( | const char * | str,
|  | rapidjson::SizeType | length,
|  | bool | copy
| ) |  |
| inline

Definition at line 221 of file fl_json_message_codec.cc.

221 {
222 if (key != nullptr) {
223 fl_value_unref(key);
224 }
225 key = fl_value_new_string_sized(str, length);
226 return true;
227 }

References fl_value_new_string_sized(), fl_value_unref(), key, and length.

## ◆ Null()

bool FlValueHandler::Null | ( |  | ) |
| inline

Definition at line 187 of file fl_json_message_codec.cc.

187 { return add(fl_value_new_null()); }

References add(), and fl_value_new_null().

## ◆ pop()

void FlValueHandler::pop | ( |  | ) |
| inline

Definition at line 158 of file fl_json_message_codec.cc.

158 { g_ptr_array_remove_index(stack, stack->len - 1); }

References stack.

Referenced by EndArray(), and EndObject().

## ◆ push()

void FlValueHandler::push | ( | FlValue * | value | ) |
| inline

Definition at line 155 of file fl_json_message_codec.cc.

155 { g_ptr_array_add(stack, fl_value_ref(value)); }

References fl_value_ref(), stack, and value.

Referenced by add().

## ◆ RawNumber()

bool FlValueHandler::RawNumber | ( | const char * | str,
|  | rapidjson::SizeType | length,
|  | bool | copy
| ) |  |
| inline

Definition at line 208 of file fl_json_message_codec.cc.

208 {
209 g_set_error(&error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED,
210 "RawNumber not supported");
211 return false;
212 }

References error, FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_FAILED.

## ◆ StartArray()

bool FlValueHandler::StartArray | ( |  | ) |
| inline

Definition at line 234 of file fl_json_message_codec.cc.

234 { return add(fl_value_new_list()); }

References add(), and fl_value_new_list().

## ◆ StartObject()

bool FlValueHandler::StartObject | ( |  | ) |
| inline

Definition at line 219 of file fl_json_message_codec.cc.

219 { return add(fl_value_new_map()); }

References add(), and fl_value_new_map().

## ◆ String()

bool FlValueHandler::String | ( | const char * | str,
|  | rapidjson::SizeType | length,
|  | bool | copy
| ) |  |
| inline

Definition at line 214 of file fl_json_message_codec.cc.

214 {
215 FlValue* v = fl_value_new_string_sized(str, length);
216 return add(v);
217 }

References add(), fl_value_new_string_sized(), and length.

## ◆ Uint()

bool FlValueHandler::Uint | ( | unsigned | i | ) |
| inline

Definition at line 193 of file fl_json_message_codec.cc.

193 { return add(fl_value_new_int(i)); }

References add(), and fl_value_new_int().

## ◆ Uint64()

bool FlValueHandler::Uint64 | ( | uint64_t | i | ) |
| inline

Definition at line 197 of file fl_json_message_codec.cc.

197 {
198 // For some reason (bug in rapidjson?) this is not returned in Int64.
199 if (i == G_MAXINT64) {
200 return add(fl_value_new_int(i));
201 } else {
202 return add(fl_value_new_float(i));
203 }
204 }

References add(), fl_value_new_float(), and fl_value_new_int().

## Member Data Documentation

## ◆ error

GError* FlValueHandler::error

Definition at line 127 of file fl_json_message_codec.cc.

Referenced by add(), fl_json_message_codec_decode_message(), FlValueHandler(), RawNumber(), and ~FlValueHandler().

## ◆ key

FlValue* FlValueHandler::key

Definition at line 126 of file fl_json_message_codec.cc.

Referenced by add(), FlValueHandler(), Key(), and ~FlValueHandler().

## ◆ stack

GPtrArray* FlValueHandler::stack

Definition at line 125 of file fl_json_message_codec.cc.

Referenced by FlValueHandler(), get_head(), pop(), push(), and ~FlValueHandler().

The documentation for this struct was generated from the following file:

- shell/platform/linux/fl_json_message_codec.cc

fl_value_new_string_sized
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition: fl_value.cc:283
FL_VALUE_TYPE_MAP
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:75
FlValueHandler::key
FlValue * key
Definition: fl_json_message_codec.cc:126
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
fl_value_set_take
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:618
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:74
FlValueHandler::get_head
FlValue * get_head()
Definition: fl_json_message_codec.cc:147
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:400
FlValueHandler::add
bool add(FlValue *value)
Definition: fl_json_message_codec.cc:161
fl_value_ref
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:394
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
FlValueHandler::pop
void pop()
Definition: fl_json_message_codec.cc:158
FL_MESSAGE_CODEC_ERROR_FAILED
@ FL_MESSAGE_CODEC_ERROR_FAILED
Definition: fl_message_codec.h:34
FlValueHandler::push
void push(FlValue *value)
Definition: fl_json_message_codec.cc:155
fl_value_append
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition: fl_value.cc:592
FlValueHandler::error
GError * error
Definition: fl_json_message_codec.cc:127
fl_value_new_float
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition: fl_value.cc:269
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
length
size_t length
Definition: fl_standard_message_codec_test.cc:1113
FlValueHandler::stack
GPtrArray * stack
Definition: fl_json_message_codec.cc:125
FL_MESSAGE_CODEC_ERROR
#define FL_MESSAGE_CODEC_ERROR
Definition: fl_message_codec.h:30