Flutter Engine
fl_value.h File Reference
#include <glib.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef typedefG_BEGIN_DECLS struct _FlValue FlValue
 

Enumerations

enum  FlValueType {
  FL_VALUE_TYPE_NULL,
  FL_VALUE_TYPE_BOOL,
  FL_VALUE_TYPE_INT,
  FL_VALUE_TYPE_FLOAT,
  FL_VALUE_TYPE_STRING,
  FL_VALUE_TYPE_UINT8_LIST,
  FL_VALUE_TYPE_INT32_LIST,
  FL_VALUE_TYPE_INT64_LIST,
  FL_VALUE_TYPE_FLOAT_LIST,
  FL_VALUE_TYPE_LIST,
  FL_VALUE_TYPE_MAP
}
 

Functions

FlValuefl_value_new_null ()
 
FlValuefl_value_new_bool (bool value)
 
FlValuefl_value_new_int (int64_t value)
 
FlValuefl_value_new_float (double value)
 
FlValuefl_value_new_string (const gchar *value)
 
FlValuefl_value_new_string_sized (const gchar *value, size_t value_length)
 
FlValuefl_value_new_uint8_list (const uint8_t *value, size_t value_length)
 
FlValuefl_value_new_uint8_list_from_bytes (GBytes *value)
 
FlValuefl_value_new_int32_list (const int32_t *value, size_t value_length)
 
FlValuefl_value_new_int64_list (const int64_t *value, size_t value_length)
 
FlValuefl_value_new_float_list (const double *value, size_t value_length)
 
FlValuefl_value_new_list ()
 
FlValuefl_value_new_list_from_strv (const gchar *const *value)
 
FlValuefl_value_new_map ()
 
FlValuefl_value_ref (FlValue *value)
 
void fl_value_unref (FlValue *value)
 
FlValueType fl_value_get_type (FlValue *value)
 
bool fl_value_equal (FlValue *a, FlValue *b)
 
void fl_value_append (FlValue *value, FlValue *child)
 
void fl_value_append_take (FlValue *value, FlValue *child)
 
void fl_value_set (FlValue *value, FlValue *key, FlValue *child_value)
 
void fl_value_set_take (FlValue *value, FlValue *key, FlValue *child_value)
 
void fl_value_set_string (FlValue *value, const gchar *key, FlValue *child_value)
 
void fl_value_set_string_take (FlValue *value, const gchar *key, FlValue *child_value)
 
bool fl_value_get_bool (FlValue *value)
 
int64_t fl_value_get_int (FlValue *value)
 
double fl_value_get_float (FlValue *value)
 
const gchar * fl_value_get_string (FlValue *value)
 
size_t fl_value_get_length (FlValue *value)
 
const uint8_t * fl_value_get_uint8_list (FlValue *value)
 
const int32_t * fl_value_get_int32_list (FlValue *value)
 
const int64_t * fl_value_get_int64_list (FlValue *value)
 
const double * fl_value_get_float_list (FlValue *value)
 
FlValuefl_value_get_list_value (FlValue *value, size_t index)
 
FlValuefl_value_get_map_key (FlValue *value, size_t index)
 
FlValuefl_value_get_map_value (FlValue *value, size_t index)
 
FlValuefl_value_lookup (FlValue *value, FlValue *key)
 
FlValuefl_value_lookup_string (FlValue *value, const gchar *key)
 
gchar * fl_value_to_string (FlValue *value)
 

Typedef Documentation

◆ FlValue

typedef typedefG_BEGIN_DECLS struct _FlValue FlValue

FlValue:

FlValue is an object that contains the data types used in the platform channel used by Flutter.

In Dart the values are represented as follows:

See #FlMessageCodec to encode and decode these values.

Definition at line 39 of file fl_value.h.

Enumeration Type Documentation

◆ FlValueType

FlValueType: : The null value. : A boolean. : A 64 bit signed integer. : A 64 bit floating point number. : UTF-8 text. : An ordered list of unsigned 8 bit integers. : An ordered list of 32 bit integers. : An ordered list of 64 bit integers. : An ordered list of floating point numbers. : An ordered list of FlValue objects. : A map of FlValue objects keyed by FlValue object.

Types of FlValue.

Enumerator
FL_VALUE_TYPE_NULL 
FL_VALUE_TYPE_BOOL 
FL_VALUE_TYPE_INT 
FL_VALUE_TYPE_FLOAT 
FL_VALUE_TYPE_STRING 
FL_VALUE_TYPE_UINT8_LIST 
FL_VALUE_TYPE_INT32_LIST 
FL_VALUE_TYPE_INT64_LIST 
FL_VALUE_TYPE_FLOAT_LIST 
FL_VALUE_TYPE_LIST 
FL_VALUE_TYPE_MAP 

Definition at line 57 of file fl_value.h.

Function Documentation

◆ fl_value_append()

void fl_value_append ( FlValue value,
FlValue child 
)

fl_value_append: : an FlValue of type FL_VALUE_TYPE_LIST. : an FlValue.

Adds to the end of . Calling this with an FlValue that is not of type FL_VALUE_TYPE_LIST is a programming error.

Definition at line 506 of file fl_value.cc.

References fl_value_append_take(), fl_value_ref(), and FL_VALUE_TYPE_LIST.

Referenced by FlValueHandler::add(), listen_channel(), read_list_value(), TEST(), and update_editing_state().

506  {
507  g_return_if_fail(self != nullptr);
508  g_return_if_fail(self->type == FL_VALUE_TYPE_LIST);
509  g_return_if_fail(value != nullptr);
510 
512 }
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:514
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ fl_value_append_take()

void fl_value_append_take ( FlValue value,
FlValue child 
)

fl_value_append_take: : an FlValue of type FL_VALUE_TYPE_LIST. : (transfer full): an FlValue.

Adds to the end of . Ownership of is taken by . Calling this with an FlValue that is not of type FL_VALUE_TYPE_LIST is a programming error.

Definition at line 514 of file fl_value.cc.

References FL_VALUE_TYPE_LIST, and FlValueList::values.

Referenced by cancel_channel(), fl_json_method_codec_encode_error_envelope(), fl_json_method_codec_encode_success_envelope(), fl_value_append(), fl_value_new_list_from_strv(), listen_channel(), perform_action(), TEST(), and update_editing_state().

514  {
515  g_return_if_fail(self != nullptr);
516  g_return_if_fail(self->type == FL_VALUE_TYPE_LIST);
517  g_return_if_fail(value != nullptr);
518 
519  FlValueList* v = reinterpret_cast<FlValueList*>(self);
520  g_ptr_array_add(v->values, value);
521 }
GPtrArray * values
Definition: fl_value.cc:62
uint8_t value

◆ fl_value_equal()

bool fl_value_equal ( FlValue a,
FlValue b 
)

fl_value_equal: : an FlValue. : an FlValue.

Compares two FlValue to see if they are equivalent. Two values are considered equivalent if they are of the same type and their data is the same including any child values. For values of type FL_VALUE_TYPE_MAP the order of the values does not matter.

Returns: TRUE if both values are equivalent.

Definition at line 400 of file fl_value.cc.

References fl_value_equal(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_float_list(), fl_value_get_int(), fl_value_get_int32_list(), fl_value_get_int64_list(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_get_uint8_list(), fl_value_lookup(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, and FlValueString::value.

Referenced by args_cancel_cb(), args_listen_cb(), decode_response_with_error(), decode_response_with_success(), fl_value_equal(), fl_value_lookup_index(), and TEST().

400  {
401  g_return_val_if_fail(a != nullptr, false);
402  g_return_val_if_fail(b != nullptr, false);
403 
404  if (a->type != b->type) {
405  return false;
406  }
407 
408  switch (a->type) {
409  case FL_VALUE_TYPE_NULL:
410  return true;
411  case FL_VALUE_TYPE_BOOL:
412  return fl_value_get_bool(a) == fl_value_get_bool(b);
413  case FL_VALUE_TYPE_INT:
414  return fl_value_get_int(a) == fl_value_get_int(b);
415  case FL_VALUE_TYPE_FLOAT:
416  return fl_value_get_float(a) == fl_value_get_float(b);
417  case FL_VALUE_TYPE_STRING: {
418  FlValueString* a_ = reinterpret_cast<FlValueString*>(a);
419  FlValueString* b_ = reinterpret_cast<FlValueString*>(b);
420  return g_strcmp0(a_->value, b_->value) == 0;
421  }
424  return false;
425  }
426  const uint8_t* values_a = fl_value_get_uint8_list(a);
427  const uint8_t* values_b = fl_value_get_uint8_list(b);
428  for (size_t i = 0; i < fl_value_get_length(a); i++) {
429  if (values_a[i] != values_b[i]) {
430  return false;
431  }
432  }
433  return true;
434  }
437  return false;
438  }
439  const int32_t* values_a = fl_value_get_int32_list(a);
440  const int32_t* values_b = fl_value_get_int32_list(b);
441  for (size_t i = 0; i < fl_value_get_length(a); i++) {
442  if (values_a[i] != values_b[i]) {
443  return false;
444  }
445  }
446  return true;
447  }
450  return false;
451  }
452  const int64_t* values_a = fl_value_get_int64_list(a);
453  const int64_t* values_b = fl_value_get_int64_list(b);
454  for (size_t i = 0; i < fl_value_get_length(a); i++) {
455  if (values_a[i] != values_b[i]) {
456  return false;
457  }
458  }
459  return true;
460  }
463  return false;
464  }
465  const double* values_a = fl_value_get_float_list(a);
466  const double* values_b = fl_value_get_float_list(b);
467  for (size_t i = 0; i < fl_value_get_length(a); i++) {
468  if (values_a[i] != values_b[i]) {
469  return false;
470  }
471  }
472  return true;
473  }
474  case FL_VALUE_TYPE_LIST: {
476  return false;
477  }
478  for (size_t i = 0; i < fl_value_get_length(a); i++) {
480  fl_value_get_list_value(b, i))) {
481  return false;
482  }
483  }
484  return true;
485  }
486  case FL_VALUE_TYPE_MAP: {
488  return false;
489  }
490  for (size_t i = 0; i < fl_value_get_length(a); i++) {
491  FlValue* key = fl_value_get_map_key(a, i);
492  FlValue* value_b = fl_value_lookup(b, key);
493  if (value_b == nullptr) {
494  return false;
495  }
496  FlValue* value_a = fl_value_get_map_value(a, i);
497  if (!fl_value_equal(value_a, value_b)) {
498  return false;
499  }
500  }
501  return true;
502  }
503  }
504 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
Definition: fl_value.cc:624
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:582
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
Definition: fl_value.cc:617
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:603
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:400
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:589
gchar * value
Definition: fl_value.cc:33
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition: fl_value.cc:677
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:693
G_MODULE_EXPORT FlValue * fl_value_lookup(FlValue *self, FlValue *key)
Definition: fl_value.cc:701
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition: fl_value.cc:685
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:610
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:631
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:575

◆ fl_value_get_bool()

bool fl_value_get_bool ( FlValue value)

fl_value_get_bool: : an FlValue of type FL_VALUE_TYPE_BOOL.

Gets the boolean value of . Calling this with an FlValue that is not of type FL_VALUE_TYPE_BOOL is a programming error.

Returns: a boolean value.

Definition at line 575 of file fl_value.cc.

References FL_VALUE_TYPE_BOOL, and FlValueBool::value.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), TEST(), and value_to_string().

575  {
576  g_return_val_if_fail(self != nullptr, FALSE);
577  g_return_val_if_fail(self->type == FL_VALUE_TYPE_BOOL, FALSE);
578  FlValueBool* v = reinterpret_cast<FlValueBool*>(self);
579  return v->value;
580 }
bool value
Definition: fl_value.cc:18

◆ fl_value_get_float()

double fl_value_get_float ( FlValue value)

fl_value_get_float: : an FlValue of type FL_VALUE_TYPE_FLOAT.

Gets the floating point number of . Calling this with an FlValue that is not of type FL_VALUE_TYPE_FLOAT is a programming error.

Returns: a floating point number.

Definition at line 589 of file fl_value.cc.

References FL_VALUE_TYPE_FLOAT, and FlValueDouble::value.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), set_editable_size_and_transform(), set_marked_text_rect(), TEST(), and value_to_string().

589  {
590  g_return_val_if_fail(self != nullptr, 0.0);
591  g_return_val_if_fail(self->type == FL_VALUE_TYPE_FLOAT, 0.0);
592  FlValueDouble* v = reinterpret_cast<FlValueDouble*>(self);
593  return v->value;
594 }
double value
Definition: fl_value.cc:28

◆ fl_value_get_float_list()

const double* fl_value_get_float_list ( FlValue value)

fl_value_get_float_list: : an FlValue of type FL_VALUE_TYPE_FLOAT_LIST.

Gets the array of floating point numbers contains. The data contains fl_get_length() elements. Calling this with an FlValue that is not of type FL_VALUE_TYPE_FLOAT_LIST is a programming error.

Returns: an array of floating point numbers.

Definition at line 624 of file fl_value.cc.

References FL_VALUE_TYPE_FLOAT_LIST, and FlValueFloatList::values.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), TEST(), and value_to_string().

624  {
625  g_return_val_if_fail(self != nullptr, nullptr);
626  g_return_val_if_fail(self->type == FL_VALUE_TYPE_FLOAT_LIST, nullptr);
627  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
628  return v->values;
629 }
double * values
Definition: fl_value.cc:56

◆ fl_value_get_int()

int64_t fl_value_get_int ( FlValue value)

fl_value_get_int: : an FlValue of type FL_VALUE_TYPE_INT.

Gets the integer number of . Calling this with an FlValue that is not of type FL_VALUE_TYPE_INT is a programming error.

Returns: an integer number.

Definition at line 582 of file fl_value.cc.

References FL_VALUE_TYPE_INT, and FlValueInt::value.

Referenced by fl_standard_message_codec_write_value(), fl_test_codec_encode_error_envelope(), fl_test_codec_encode_message(), fl_test_codec_encode_method_call(), fl_test_codec_encode_success_envelope(), fl_value_equal(), G_DEFINE_TYPE(), send_events_events_cb(), set_client(), set_editing_state(), TEST(), and value_to_string().

582  {
583  g_return_val_if_fail(self != nullptr, 0);
584  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT, 0);
585  FlValueInt* v = reinterpret_cast<FlValueInt*>(self);
586  return v->value;
587 }
int64_t value
Definition: fl_value.cc:23

◆ fl_value_get_int32_list()

const int32_t* fl_value_get_int32_list ( FlValue value)

fl_value_get_int32_list: : an FlValue of type FL_VALUE_TYPE_INT32_LIST.

Gets the array of 32 bit integers contains. The data contains fl_get_length() elements. Calling this with an FlValue that is not of type FL_VALUE_TYPE_INT32_LIST is a programming error.

Returns: an array of 32 bit integers.

Definition at line 610 of file fl_value.cc.

References FL_VALUE_TYPE_INT32_LIST, and FlValueInt32List::values.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), TEST(), and value_to_string().

610  {
611  g_return_val_if_fail(self != nullptr, nullptr);
612  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT32_LIST, nullptr);
613  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
614  return v->values;
615 }
int32_t * values
Definition: fl_value.cc:44

◆ fl_value_get_int64_list()

const int64_t* fl_value_get_int64_list ( FlValue value)

fl_value_get_int64_list: : an FlValue of type FL_VALUE_TYPE_INT64_LIST.

Gets the array of 64 bit integers contains. The data contains fl_get_length() elements. Calling this with an FlValue that is not of type FL_VALUE_TYPE_INT64_LIST is a programming error.

Returns: an array of 64 bit integers.

Definition at line 617 of file fl_value.cc.

References FL_VALUE_TYPE_INT64_LIST, and FlValueInt64List::values.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), TEST(), and value_to_string().

617  {
618  g_return_val_if_fail(self != nullptr, nullptr);
619  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT64_LIST, nullptr);
620  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
621  return v->values;
622 }
int64_t * values
Definition: fl_value.cc:50

◆ fl_value_get_length()

size_t fl_value_get_length ( FlValue value)

fl_value_get_length: : an FlValue of type FL_VALUE_TYPE_UINT8_LIST, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_LIST or FL_VALUE_TYPE_MAP.

Gets the number of elements contains. This is only valid for list and map types. Calling this with other types is a programming error.

Returns: the number of elements inside .

Definition at line 631 of file fl_value.cc.

References FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, FlValueMap::keys, FlValueList::values, FlValueUint8List::values_length, FlValueInt32List::values_length, FlValueInt64List::values_length, and FlValueFloatList::values_length.

Referenced by fl_binary_codec_encode_message(), fl_json_method_codec_decode_response(), fl_standard_message_codec_write_value(), fl_value_equal(), fl_value_lookup_index(), FlutterEngineSendPlatformMessage(), G_DEFINE_TYPE(), set_client(), set_editable_size_and_transform(), TEST(), and value_to_string().

631  {
632  g_return_val_if_fail(self != nullptr, 0);
633  g_return_val_if_fail(self->type == FL_VALUE_TYPE_UINT8_LIST ||
634  self->type == FL_VALUE_TYPE_INT32_LIST ||
635  self->type == FL_VALUE_TYPE_INT64_LIST ||
636  self->type == FL_VALUE_TYPE_FLOAT_LIST ||
637  self->type == FL_VALUE_TYPE_LIST ||
638  self->type == FL_VALUE_TYPE_MAP,
639  0);
640 
641  switch (self->type) {
643  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
644  return v->values_length;
645  }
647  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
648  return v->values_length;
649  }
651  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
652  return v->values_length;
653  }
655  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
656  return v->values_length;
657  }
658  case FL_VALUE_TYPE_LIST: {
659  FlValueList* v = reinterpret_cast<FlValueList*>(self);
660  return v->values->len;
661  }
662  case FL_VALUE_TYPE_MAP: {
663  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
664  return v->keys->len;
665  }
666  case FL_VALUE_TYPE_NULL:
667  case FL_VALUE_TYPE_BOOL:
668  case FL_VALUE_TYPE_INT:
669  case FL_VALUE_TYPE_FLOAT:
671  return 0;
672  }
673 
674  return 0;
675 }
size_t values_length
Definition: fl_value.cc:51
GPtrArray * keys
Definition: fl_value.cc:67
GPtrArray * values
Definition: fl_value.cc:62
size_t values_length
Definition: fl_value.cc:45
size_t values_length
Definition: fl_value.cc:57
size_t values_length
Definition: fl_value.cc:39

◆ fl_value_get_list_value()

FlValue* fl_value_get_list_value ( FlValue value,
size_t  index 
)

fl_value_get_list_value: : an FlValue of type FL_VALUE_TYPE_LIST. : an index in the list.

Gets a child element of the list. It is a programming error to request an index that is outside the size of the list as returned from fl_value_get_length(). Calling this with an FlValue that is not of type FL_VALUE_TYPE_LIST is a programming error.

Returns: an FlValue.

Definition at line 677 of file fl_value.cc.

References FL_VALUE_TYPE_LIST, and FlValueList::values.

Referenced by fl_json_method_codec_decode_response(), fl_standard_message_codec_write_value(), fl_value_equal(), FlutterEngineSendPlatformMessage(), G_DEFINE_TYPE(), set_client(), set_editable_size_and_transform(), TEST(), and value_to_string().

677  {
678  g_return_val_if_fail(self != nullptr, nullptr);
679  g_return_val_if_fail(self->type == FL_VALUE_TYPE_LIST, nullptr);
680 
681  FlValueList* v = reinterpret_cast<FlValueList*>(self);
682  return static_cast<FlValue*>(g_ptr_array_index(v->values, index));
683 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
GPtrArray * values
Definition: fl_value.cc:62

◆ fl_value_get_map_key()

FlValue* fl_value_get_map_key ( FlValue value,
size_t  index 
)

fl_value_get_map_key: : an FlValue of type FL_VALUE_TYPE_MAP. : an index in the map.

Gets a key from the map. It is a programming error to request an index that is outside the size of the list as returned from fl_value_get_length(). Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Returns: an FlValue.

Definition at line 685 of file fl_value.cc.

References FL_VALUE_TYPE_MAP, and FlValueMap::keys.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), fl_value_lookup_index(), G_DEFINE_TYPE(), TEST(), and value_to_string().

685  {
686  g_return_val_if_fail(self != nullptr, nullptr);
687  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
688 
689  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
690  return static_cast<FlValue*>(g_ptr_array_index(v->keys, index));
691 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
GPtrArray * keys
Definition: fl_value.cc:67

◆ fl_value_get_map_value()

FlValue* fl_value_get_map_value ( FlValue value,
size_t  index 
)

fl_value_get_map_value: : an FlValue of type FL_VALUE_TYPE_MAP. : an index in the map.

Gets a value from the map. It is a programming error to request an index that is outside the size of the list as returned from fl_value_get_length(). Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Returns: an FlValue.

Definition at line 693 of file fl_value.cc.

References FL_VALUE_TYPE_MAP, and FlValueMap::values.

Referenced by fl_standard_message_codec_write_value(), fl_value_equal(), fl_value_lookup(), G_DEFINE_TYPE(), TEST(), and value_to_string().

693  {
694  g_return_val_if_fail(self != nullptr, nullptr);
695  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
696 
697  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
698  return static_cast<FlValue*>(g_ptr_array_index(v->values, index));
699 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
GPtrArray * values
Definition: fl_value.cc:68

◆ fl_value_get_string()

◆ fl_value_get_type()

◆ fl_value_get_uint8_list()

const uint8_t* fl_value_get_uint8_list ( FlValue value)

fl_value_get_uint8_list: : an FlValue of type FL_VALUE_TYPE_UINT8_LIST.

Gets the array of unisigned 8 bit integers contains. The data contains fl_get_length() elements. Calling this with an FlValue that is not of type FL_VALUE_TYPE_UINT8_LIST is a programming error.

Returns: an array of unsigned 8 bit integers.

Definition at line 603 of file fl_value.cc.

References FL_VALUE_TYPE_UINT8_LIST, and FlValueUint8List::values.

Referenced by fl_binary_codec_encode_message(), fl_standard_message_codec_write_value(), fl_value_equal(), G_DEFINE_TYPE(), TEST(), and value_to_string().

603  {
604  g_return_val_if_fail(self != nullptr, nullptr);
605  g_return_val_if_fail(self->type == FL_VALUE_TYPE_UINT8_LIST, nullptr);
606  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
607  return v->values;
608 }
uint8_t * values
Definition: fl_value.cc:38

◆ fl_value_lookup()

FlValue* fl_value_lookup ( FlValue value,
FlValue key 
)

fl_value_lookup: : an FlValue of type FL_VALUE_TYPE_MAP. : a key value.

Gets the map entry that matches . Keys are checked using fl_value_equal(). Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Map lookups are not optimised for performance - if you have a large map or need frequent access you should copy the data into another structure, e.g. #GHashTable.

Returns: (allow-none): the value with this key or NULL if not one present.

Definition at line 701 of file fl_value.cc.

References fl_value_get_map_value(), fl_value_lookup_index(), and FL_VALUE_TYPE_MAP.

Referenced by fl_value_equal(), fl_value_lookup_string(), and TEST().

701  {
702  g_return_val_if_fail(self != nullptr, nullptr);
703  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
704 
705  ssize_t index = fl_value_lookup_index(self, key);
706  if (index < 0) {
707  return nullptr;
708  }
709  return fl_value_get_map_value(self, index);
710 }
static ssize_t fl_value_lookup_index(FlValue *self, FlValue *key)
Definition: fl_value.cc:86
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:693

◆ fl_value_lookup_string()

FlValue* fl_value_lookup_string ( FlValue value,
const gchar *  key 
)

fl_value_lookup_string: : an FlValue of type FL_VALUE_TYPE_MAP. : a key value.

Gets the map entry that matches . Keys are checked using fl_value_equal(). Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Map lookups are not optimised for performance - if you have a large map or need frequent access you should copy the data into another structure, e.g. #GHashTable.

Returns: (allow-none): the value with this key or NULL if not one present.

Definition at line 712 of file fl_value.cc.

References fl_value_lookup(), fl_value_new_string(), fl_value_unref(), and value.

Referenced by activate_system_cursor(), clipboard_set_data(), fl_json_method_codec_decode_method_call(), set_client(), set_editable_size_and_transform(), set_editing_state(), set_marked_text_rect(), and TEST().

713  {
714  g_return_val_if_fail(self != nullptr, nullptr);
715  FlValue* string_key = fl_value_new_string(key);
716  FlValue* value = fl_value_lookup(self, string_key);
717  // Explicit unref used because the g_autoptr is triggering a false positive
718  // with clang-tidy.
719  fl_value_unref(string_key);
720  return value;
721 }
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:341
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:247
G_MODULE_EXPORT FlValue * fl_value_lookup(FlValue *self, FlValue *key)
Definition: fl_value.cc:701

◆ fl_value_new_bool()

FlValue* fl_value_new_bool ( bool  value)

fl_value_new_bool: : the value.

Creates an FlValue that contains a boolean value. The equivalent Dart type is a bool.

Returns: a new FlValue.

Definition at line 226 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_BOOL, and FlValueBool::value.

Referenced by FlValueHandler::Bool(), clipboard_text_has_strings_cb(), encode_bool(), fl_standard_message_codec_read_value(), TEST(), and update_editing_state().

226  {
227  FlValueBool* self = reinterpret_cast<FlValueBool*>(
229  self->value = value ? true : false;
230  return reinterpret_cast<FlValue*>(self);
231 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
bool value
Definition: fl_value.cc:18
uint8_t value
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_float()

FlValue* fl_value_new_float ( double  value)

fl_value_new_float: : the value.

Creates an FlValue that contains a floating point number. The equivalent Dart type is a num.

Returns: a new FlValue.

Definition at line 240 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_FLOAT, FlValueDouble::value, and value.

Referenced by FlValueHandler::Double(), encode_float(), read_float64_value(), TEST(), and FlValueHandler::Uint64().

240  {
241  FlValueDouble* self = reinterpret_cast<FlValueDouble*>(
243  self->value = value;
244  return reinterpret_cast<FlValue*>(self);
245 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
uint8_t value
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71
double value
Definition: fl_value.cc:28

◆ fl_value_new_float_list()

FlValue* fl_value_new_float_list ( const double *  value,
size_t  value_length 
)

fl_value_new_float_list: : an array of floating point numbers. : number of elements in .

Creates an ordered list containing floating point numbers. The equivalent Dart type is a Float64List.

Returns: a new FlValue.

Definition at line 300 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_FLOAT_LIST, and FlValueFloatList::values_length.

Referenced by read_float64_list_value(), and TEST().

301  {
302  FlValueFloatList* self = reinterpret_cast<FlValueFloatList*>(
304  self->values_length = data_length;
305  self->values = static_cast<double*>(g_malloc(sizeof(double) * data_length));
306  memcpy(self->values, data, sizeof(double) * data_length);
307  return reinterpret_cast<FlValue*>(self);
308 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71
size_t values_length
Definition: fl_value.cc:57

◆ fl_value_new_int()

FlValue* fl_value_new_int ( int64_t  value)

fl_value_new_int: : the value.

Creates an FlValue that contains an integer number. The equivalent Dart type is a num.

Returns: a new FlValue.

Definition at line 233 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_INT, FlValueInt::value, and value.

Referenced by encode_int(), fl_key_event_plugin_send_key_event(), fl_test_codec_decode_message(), fl_test_codec_decode_response(), FlValueHandler::Int(), FlValueHandler::Int64(), method_call_error_error_cb(), method_call_success_error_cb(), perform_action(), read_int32_value(), read_int64_value(), send_events_listen_cb(), TEST(), FlValueHandler::Uint(), FlValueHandler::Uint64(), and update_editing_state().

233  {
234  FlValueInt* self = reinterpret_cast<FlValueInt*>(
236  self->value = value;
237  return reinterpret_cast<FlValue*>(self);
238 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
uint8_t value
int64_t value
Definition: fl_value.cc:23
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_int32_list()

FlValue* fl_value_new_int32_list ( const int32_t *  value,
size_t  value_length 
)

fl_value_new_int32_list: : an array of signed 32 bit integers. : number of elements in .

Creates an ordered list containing 32 bit integers. The equivalent Dart type is a Int32List.

Returns: a new FlValue.

Definition at line 280 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_INT32_LIST, and FlValueInt32List::values_length.

Referenced by read_int32_list_value(), and TEST().

281  {
282  FlValueInt32List* self = reinterpret_cast<FlValueInt32List*>(
284  self->values_length = data_length;
285  self->values = static_cast<int32_t*>(g_malloc(sizeof(int32_t) * data_length));
286  memcpy(self->values, data, sizeof(int32_t) * data_length);
287  return reinterpret_cast<FlValue*>(self);
288 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71
size_t values_length
Definition: fl_value.cc:45

◆ fl_value_new_int64_list()

FlValue* fl_value_new_int64_list ( const int64_t *  value,
size_t  value_length 
)

fl_value_new_int64_list: : an array of signed 64 bit integers. : number of elements in .

Creates an ordered list containing 64 bit integers. The equivalent Dart type is a Int64List.

Returns: a new FlValue.

Definition at line 290 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_INT64_LIST, and FlValueInt64List::values_length.

Referenced by read_int64_list_value(), and TEST().

291  {
292  FlValueInt64List* self = reinterpret_cast<FlValueInt64List*>(
294  self->values_length = data_length;
295  self->values = static_cast<int64_t*>(g_malloc(sizeof(int64_t) * data_length));
296  memcpy(self->values, data, sizeof(int64_t) * data_length);
297  return reinterpret_cast<FlValue*>(self);
298 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
size_t values_length
Definition: fl_value.cc:51
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_list()

FlValue* fl_value_new_list ( )

fl_value_new_list:

Creates an ordered list. Children can be added to the list using fl_value_append(). The children are accessed using fl_value_get_length() and fl_value_get_list_value(). The equivalent Dart type is a List<dynamic>.

The following example shows a simple list of values:

|[ g_autoptr(FlValue) value = fl_value_new_list (); fl_value_append_take (value, fl_value_new_string ("one"); fl_value_append_take (value, fl_value_new_int (2); fl_value_append_take (value, fl_value_new_double (3.0); ]|

This value can be decoded using:

|[ g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_LIST); for (size_t i = 0; i < fl_value_get_length (value); i++) { FlValue *child = fl_value_get_list_value (value, i); process_value (child); } ]|

Returns: a new FlValue.

Definition at line 310 of file fl_value.cc.

References fl_value_destroy(), fl_value_new(), FL_VALUE_TYPE_LIST, and FlValueList::values.

Referenced by cancel_channel(), fl_json_method_codec_encode_error_envelope(), fl_json_method_codec_encode_success_envelope(), fl_value_new_list_from_strv(), listen_channel(), perform_action(), read_list_value(), FlValueHandler::StartArray(), TEST(), and update_editing_state().

310  {
311  FlValueList* self = reinterpret_cast<FlValueList*>(
313  self->values = g_ptr_array_new_with_free_func(fl_value_destroy);
314  return reinterpret_cast<FlValue*>(self);
315 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
GPtrArray * values
Definition: fl_value.cc:62
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:79
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_list_from_strv()

FlValue* fl_value_new_list_from_strv ( const gchar *const *  value)

fl_value_new_list_from_strv: : a NULL-terminated array of strings.

Creates an ordered list containing #FlString values.

Returns: a new FlValue.

Definition at line 317 of file fl_value.cc.

References fl_value_append_take(), fl_value_new_list(), fl_value_new_string(), fl_value_ref(), and value.

Referenced by TEST().

318  {
319  g_return_val_if_fail(str_array != nullptr, nullptr);
320  g_autoptr(FlValue) value = fl_value_new_list();
321  for (int i = 0; str_array[i] != nullptr; i++) {
323  }
324  return fl_value_ref(value);
325 }
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:310
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:514
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:247
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ fl_value_new_map()

FlValue* fl_value_new_map ( )

fl_value_new_map:

Creates an ordered associative array. Children can be added to the map using fl_value_set(), fl_value_set_take(), fl_value_set_string(), fl_value_set_string_take(). The children are accessed using fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_lookup() and fl_value_lookup_string(). The equivalent Dart type is a Map<dynamic>.

The following example shows how to create a map of values keyed by strings:

|[ g_autoptr(FlValue) value = fl_value_new_map (); fl_value_set_string_take (value, "name", fl_value_new_string ("Gandalf")); fl_value_set_string_take (value, "occupation", fl_value_new_string ("Wizard")); fl_value_set_string_take (value, "age", fl_value_new_int (2019)); ]|

This value can be decoded using: |[ g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_MAP); FlValue *name = fl_value_lookup_string (value, "name"); g_assert (fl_value_get_type (name) == FL_VALUE_TYPE_STRING); FlValue *age = fl_value_lookup_string (value, "age"); g_assert (fl_value_get_type (age) == FL_VALUE_TYPE_INT); g_message ("Next customer is %s (%d years old)", fl_value_get_string (name), fl_value_get_int (age)); ]|

Returns: a new FlValue.

Definition at line 327 of file fl_value.cc.

References fl_value_destroy(), fl_value_new(), FL_VALUE_TYPE_MAP, and FlValueMap::keys.

Referenced by clipboard_text_cb(), clipboard_text_has_strings_cb(), fl_json_method_codec_encode_method_call(), fl_key_event_plugin_send_key_event(), read_map_value(), FlValueHandler::StartObject(), TEST(), and update_editing_state().

327  {
328  FlValueMap* self = reinterpret_cast<FlValueMap*>(
330  self->keys = g_ptr_array_new_with_free_func(fl_value_destroy);
331  self->values = g_ptr_array_new_with_free_func(fl_value_destroy);
332  return reinterpret_cast<FlValue*>(self);
333 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
GPtrArray * keys
Definition: fl_value.cc:67
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:79
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_null()

FlValue* fl_value_new_null ( )

fl_value_new_null:

Creates an FlValue that contains a null value. The equivalent Dart type is null.

Returns: a new FlValue.

Definition at line 222 of file fl_value.cc.

References fl_value_new(), and FL_VALUE_TYPE_NULL.

Referenced by cancel_channel(), fl_json_method_codec_encode_error_envelope(), fl_json_method_codec_encode_method_call(), fl_json_method_codec_encode_success_envelope(), fl_message_codec_encode_message(), fl_standard_message_codec_read_value(), fl_test_codec_decode_method_call(), listen_channel(), FlValueHandler::Null(), and TEST().

222  {
223  return fl_value_new(FL_VALUE_TYPE_NULL, sizeof(FlValue));
224 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_string()

FlValue* fl_value_new_string ( const gchar *  value)

fl_value_new_string: : a NULL-terminated UTF-8 string.

Creates an FlValue that contains UTF-8 text. The equivalent Dart type is a String.

Returns: a new FlValue.

Definition at line 247 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_STRING, and FlValueString::value.

Referenced by args_cancel_cb(), args_listen_cb(), cancel_channel(), clipboard_text_cb(), encode_string(), fl_json_method_codec_encode_error_envelope(), fl_json_method_codec_encode_method_call(), fl_key_event_plugin_send_key_event(), fl_standard_method_codec_encode_error_envelope(), fl_standard_method_codec_encode_method_call(), fl_test_codec_decode_response(), fl_value_lookup_string(), fl_value_new_list_from_strv(), fl_value_set_string(), fl_value_set_string_take(), listen_channel(), message_cb(), method_call_error_cb(), method_call_success_cb(), perform_action(), TEST(), and update_editing_state().

247  {
248  FlValueString* self = reinterpret_cast<FlValueString*>(
250  self->value = g_strdup(value);
251  return reinterpret_cast<FlValue*>(self);
252 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
uint8_t value
gchar * value
Definition: fl_value.cc:33
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_string_sized()

FlValue* fl_value_new_string_sized ( const gchar *  value,
size_t  value_length 
)

fl_value_new_string_sized: : a buffer containing UTF-8 text. It does not require a nul terminator. : the number of bytes to use from .

Creates an FlValue that contains UTF-8 text. The equivalent Dart type is a String.

Returns: a new FlValue.

Definition at line 254 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_STRING, and FlValueString::value.

Referenced by fl_string_codec_decode_message(), FlValueHandler::Key(), read_string_value(), FlValueHandler::String(), and TEST().

255  {
256  FlValueString* self = reinterpret_cast<FlValueString*>(
258  self->value =
259  value_length == 0 ? g_strdup("") : g_strndup(value, value_length);
260  return reinterpret_cast<FlValue*>(self);
261 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
uint8_t value
gchar * value
Definition: fl_value.cc:33
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71

◆ fl_value_new_uint8_list()

FlValue* fl_value_new_uint8_list ( const uint8_t *  value,
size_t  value_length 
)

fl_value_new_uint8_list: : an array of unsigned 8 bit integers. : number of elements in .

Creates an ordered list containing 8 bit unsigned integers. The data is copied. The equivalent Dart type is a Uint8List.

Returns: a new FlValue.

Definition at line 263 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_UINT8_LIST, and FlValueUint8List::values_length.

Referenced by fl_binary_codec_decode_message(), fl_value_new_uint8_list_from_bytes(), read_uint8_list_value(), and TEST().

264  {
265  FlValueUint8List* self = reinterpret_cast<FlValueUint8List*>(
267  self->values_length = data_length;
268  self->values = static_cast<uint8_t*>(g_malloc(sizeof(uint8_t) * data_length));
269  memcpy(self->values, data, sizeof(uint8_t) * data_length);
270  return reinterpret_cast<FlValue*>(self);
271 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:71
size_t values_length
Definition: fl_value.cc:39

◆ fl_value_new_uint8_list_from_bytes()

FlValue* fl_value_new_uint8_list_from_bytes ( GBytes *  value)

fl_value_new_uint8_list_from_bytes: : a #GBytes.

Creates an ordered list containing 8 bit unsigned integers. The data is copied. The equivalent Dart type is a Uint8List.

Returns: a new FlValue.

Definition at line 273 of file fl_value.cc.

References fl_value_new_uint8_list(), and length.

273  {
274  gsize length;
275  const uint8_t* d =
276  static_cast<const uint8_t*>(g_bytes_get_data(data, &length));
277  return fl_value_new_uint8_list(d, length);
278 }
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:263
size_t length

◆ fl_value_ref()

◆ fl_value_set()

void fl_value_set ( FlValue value,
FlValue key,
FlValue child_value 
)

fl_value_set: : an FlValue of type FL_VALUE_TYPE_MAP. : an FlValue. : an FlValue.

Sets in to . If an existing value was in the map with the same key it is replaced. Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Definition at line 523 of file fl_value.cc.

References fl_value_ref(), fl_value_set_take(), and FL_VALUE_TYPE_MAP.

Referenced by read_map_value(), and TEST().

523  {
524  g_return_if_fail(self != nullptr);
525  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
526  g_return_if_fail(key != nullptr);
527  g_return_if_fail(value != nullptr);
528 
530 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:532
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ fl_value_set_string()

void fl_value_set_string ( FlValue value,
const gchar *  key,
FlValue child_value 
)

fl_value_set_string: : an FlValue of type FL_VALUE_TYPE_MAP. : a UTF-8 text key. : an FlValue.

Sets a value in the map with a text key. If an existing value was in the map with the same key it is replaced. Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Definition at line 553 of file fl_value.cc.

References fl_value_new_string(), fl_value_ref(), fl_value_set_take(), and FL_VALUE_TYPE_MAP.

Referenced by TEST().

555  {
556  g_return_if_fail(self != nullptr);
557  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
558  g_return_if_fail(key != nullptr);
559  g_return_if_fail(value != nullptr);
560 
562 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:532
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:247
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ fl_value_set_string_take()

void fl_value_set_string_take ( FlValue value,
const gchar *  key,
FlValue child_value 
)

fl_value_set_string_take: : an FlValue of type FL_VALUE_TYPE_MAP. : a UTF-8 text key. : (transfer full): an FlValue.

Sets a value in the map with a text key, taking ownership of the value. If an existing value was in the map with the same key it is replaced. Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Definition at line 564 of file fl_value.cc.

References fl_value_new_string(), fl_value_set_take(), and FL_VALUE_TYPE_MAP.

Referenced by clipboard_text_cb(), clipboard_text_has_strings_cb(), fl_key_event_plugin_send_key_event(), TEST(), and update_editing_state().

566  {
567  g_return_if_fail(self != nullptr);
568  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
569  g_return_if_fail(key != nullptr);
570  g_return_if_fail(value != nullptr);
571 
573 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:532
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:247

◆ fl_value_set_take()

void fl_value_set_take ( FlValue value,
FlValue key,
FlValue child_value 
)

fl_value_set_take: : an FlValue of type FL_VALUE_TYPE_MAP. : (transfer full): an FlValue. : (transfer full): an FlValue.

Sets in to . Ownership of both and is taken by . If an existing value was in the map with the same key it is replaced. Calling this with an FlValue that is not of type FL_VALUE_TYPE_MAP is a programming error.

Definition at line 532 of file fl_value.cc.

References fl_value_destroy(), fl_value_lookup_index(), FL_VALUE_TYPE_MAP, FlValueMap::keys, value, and FlValueMap::values.

Referenced by FlValueHandler::add(), fl_json_method_codec_encode_method_call(), fl_value_set(), fl_value_set_string(), fl_value_set_string_take(), and TEST().

534  {
535  g_return_if_fail(self != nullptr);
536  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
537  g_return_if_fail(key != nullptr);
538  g_return_if_fail(value != nullptr);
539 
540  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
541  ssize_t index = fl_value_lookup_index(self, key);
542  if (index < 0) {
543  g_ptr_array_add(v->keys, key);
544  g_ptr_array_add(v->values, value);
545  } else {
546  fl_value_destroy(v->keys->pdata[index]);
547  v->keys->pdata[index] = key;
548  fl_value_destroy(v->values->pdata[index]);
549  v->values->pdata[index] = value;
550  }
551 }
static ssize_t fl_value_lookup_index(FlValue *self, FlValue *key)
Definition: fl_value.cc:86
GPtrArray * keys
Definition: fl_value.cc:67
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:79
uint8_t value
GPtrArray * values
Definition: fl_value.cc:68

◆ fl_value_to_string()

gchar* fl_value_to_string ( FlValue value)

fl_value_to_string: : an FlValue.

Converts an FlValue to a text representation, suitable for logging purposes. The text is formatted to be the equivalent of Dart toString() methods.

Returns: UTF-8 text.

Definition at line 723 of file fl_value.cc.

References value_to_string().

Referenced by echo_response_cb(), fl_method_response_get_result(), and TEST().

723  {
724  GString* buffer = g_string_new("");
725  value_to_string(value, buffer);
726  return g_string_free(buffer, FALSE);
727 }
uint8_t value
static void value_to_string(FlValue *value, GString *buffer)
Definition: fl_value.cc:123

◆ fl_value_unref()

void fl_value_unref ( FlValue value)

fl_value_unref: : an FlValue.

Decreases the reference count of an FlValue. When the reference count hits zero is destroyed and no longer valid.

Definition at line 341 of file fl_value.cc.

References FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT_LIST, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_INT32_LIST, FL_VALUE_TYPE_INT64_LIST, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, FL_VALUE_TYPE_UINT8_LIST, FlValueMap::keys, FlValueString::value, FlValueUint8List::values, FlValueInt32List::values, FlValueInt64List::values, FlValueFloatList::values, FlValueList::values, and FlValueMap::values.

Referenced by fl_method_call_dispose(), fl_method_error_response_dispose(), fl_method_success_response_dispose(), fl_value_destroy(), fl_value_lookup_string(), FlValueHandler::FlValueHandler(), FlValueHandler::Key(), and FlValueHandler::~FlValueHandler().

341  {
342  g_return_if_fail(self != nullptr);
343  g_return_if_fail(self->ref_count > 0);
344  self->ref_count--;
345  if (self->ref_count != 0) {
346  return;
347  }
348 
349  switch (self->type) {
350  case FL_VALUE_TYPE_STRING: {
351  FlValueString* v = reinterpret_cast<FlValueString*>(self);
352  g_free(v->value);
353  break;
354  }
356  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
357  g_free(v->values);
358  break;
359  }
361  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
362  g_free(v->values);
363  break;
364  }
366  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
367  g_free(v->values);
368  break;
369  }
371  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
372  g_free(v->values);
373  break;
374  }
375  case FL_VALUE_TYPE_LIST: {
376  FlValueList* v = reinterpret_cast<FlValueList*>(self);
377  g_ptr_array_unref(v->values);
378  break;
379  }
380  case FL_VALUE_TYPE_MAP: {
381  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
382  g_ptr_array_unref(v->keys);
383  g_ptr_array_unref(v->values);
384  break;
385  }
386  case FL_VALUE_TYPE_NULL:
387  case FL_VALUE_TYPE_BOOL:
388  case FL_VALUE_TYPE_INT:
389  case FL_VALUE_TYPE_FLOAT:
390  break;
391  }
392  g_free(self);
393 }
double * values
Definition: fl_value.cc:56
GPtrArray * keys
Definition: fl_value.cc:67
int64_t * values
Definition: fl_value.cc:50
GPtrArray * values
Definition: fl_value.cc:62
uint8_t * values
Definition: fl_value.cc:38
gchar * value
Definition: fl_value.cc:33
GPtrArray * values
Definition: fl_value.cc:68
int32_t * values
Definition: fl_value.cc:44