Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
FlValueHandler Struct Reference

Public Member Functions

 FlValueHandler ()
 
 ~FlValueHandler ()
 
FlValueget_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
 
FlValuekey
 
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 }
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition fl_value.cc:400

◆ ~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) {
140 }
141 if (error != nullptr) {
142 g_error_free(error);
143 }
144 }

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 {
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 }
@ FL_MESSAGE_CODEC_ERROR_FAILED
#define FL_MESSAGE_CODEC_ERROR
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition fl_value.cc:394
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition fl_value.cc:466
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition fl_value.cc:592
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition fl_value.cc:618
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
@ FL_VALUE_TYPE_LIST
Definition fl_value.h:74
@ FL_VALUE_TYPE_MAP
Definition fl_value.h:75
void push(FlValue *value)

◆ 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)); }
static bool b
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition fl_value.cc:255
bool add(FlValue *value)

◆ 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)); }
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition fl_value.cc:269

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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)); }
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition fl_value.cc:262

◆ 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)); }

◆ 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) {
224 }
226 return true;
227 }
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition fl_value.cc:283
size_t length

◆ Null()

bool FlValueHandler::Null ( )
inline

Definition at line 187 of file fl_json_message_codec.cc.

187{ return add(fl_value_new_null()); }
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition fl_value.cc:251

◆ 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); }

◆ 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)); }

◆ 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 {
210 "RawNumber not supported");
211 return false;
212 }

◆ StartArray()

bool FlValueHandler::StartArray ( )
inline

Definition at line 234 of file fl_json_message_codec.cc.

234{ return add(fl_value_new_list()); }
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition fl_value.cc:349

◆ StartObject()

bool FlValueHandler::StartObject ( )
inline

Definition at line 219 of file fl_json_message_codec.cc.

219{ return add(fl_value_new_map()); }
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition fl_value.cc:366

◆ 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 {
216 return add(v);
217 }

◆ 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)); }

◆ 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 }

Member Data Documentation

◆ error

GError* FlValueHandler::error

Definition at line 127 of file fl_json_message_codec.cc.

◆ key

FlValue* FlValueHandler::key

Definition at line 126 of file fl_json_message_codec.cc.

◆ stack

GPtrArray* FlValueHandler::stack

Definition at line 125 of file fl_json_message_codec.cc.


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