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,
  FL_VALUE_TYPE_FLOAT32_LIST
}
 

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_float32_list (const float *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 float * fl_value_get_float32_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 40 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. : An ordered list of 32bit floating point numbers.

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 
FL_VALUE_TYPE_FLOAT32_LIST 

Definition at line 59 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 552 of file fl_value.cc.

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

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

552  {
553  g_return_if_fail(self != nullptr);
554  g_return_if_fail(self->type == FL_VALUE_TYPE_LIST);
555  g_return_if_fail(value != nullptr);
556 
558 }
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:560
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:363

◆ 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 560 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().

560  {
561  g_return_if_fail(self != nullptr);
562  g_return_if_fail(self->type == FL_VALUE_TYPE_LIST);
563  g_return_if_fail(value != nullptr);
564 
565  FlValueList* v = reinterpret_cast<FlValueList*>(self);
566  g_ptr_array_add(v->values, value);
567 }
GPtrArray * values
Definition: fl_value.cc:68
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 433 of file fl_value.cc.

References fl_value_equal(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_float32_list(), 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_FLOAT32_LIST, 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, key, 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().

433  {
434  g_return_val_if_fail(a != nullptr, false);
435  g_return_val_if_fail(b != nullptr, false);
436 
437  if (a->type != b->type) {
438  return false;
439  }
440 
441  switch (a->type) {
442  case FL_VALUE_TYPE_NULL:
443  return true;
444  case FL_VALUE_TYPE_BOOL:
445  return fl_value_get_bool(a) == fl_value_get_bool(b);
446  case FL_VALUE_TYPE_INT:
447  return fl_value_get_int(a) == fl_value_get_int(b);
448  case FL_VALUE_TYPE_FLOAT:
449  return fl_value_get_float(a) == fl_value_get_float(b);
450  case FL_VALUE_TYPE_STRING: {
451  FlValueString* a_ = reinterpret_cast<FlValueString*>(a);
452  FlValueString* b_ = reinterpret_cast<FlValueString*>(b);
453  return g_strcmp0(a_->value, b_->value) == 0;
454  }
457  return false;
458  }
459  const uint8_t* values_a = fl_value_get_uint8_list(a);
460  const uint8_t* values_b = fl_value_get_uint8_list(b);
461  for (size_t i = 0; i < fl_value_get_length(a); i++) {
462  if (values_a[i] != values_b[i]) {
463  return false;
464  }
465  }
466  return true;
467  }
470  return false;
471  }
472  const int32_t* values_a = fl_value_get_int32_list(a);
473  const int32_t* values_b = fl_value_get_int32_list(b);
474  for (size_t i = 0; i < fl_value_get_length(a); i++) {
475  if (values_a[i] != values_b[i]) {
476  return false;
477  }
478  }
479  return true;
480  }
483  return false;
484  }
485  const int64_t* values_a = fl_value_get_int64_list(a);
486  const int64_t* values_b = fl_value_get_int64_list(b);
487  for (size_t i = 0; i < fl_value_get_length(a); i++) {
488  if (values_a[i] != values_b[i]) {
489  return false;
490  }
491  }
492  return true;
493  }
496  return false;
497  }
498  const float* values_a = fl_value_get_float32_list(a);
499  const float* values_b = fl_value_get_float32_list(b);
500  for (size_t i = 0; i < fl_value_get_length(a); i++) {
501  if (values_a[i] != values_b[i]) {
502  return false;
503  }
504  }
505  return true;
506  }
509  return false;
510  }
511  const double* values_a = fl_value_get_float_list(a);
512  const double* values_b = fl_value_get_float_list(b);
513  for (size_t i = 0; i < fl_value_get_length(a); i++) {
514  if (values_a[i] != values_b[i]) {
515  return false;
516  }
517  }
518  return true;
519  }
520  case FL_VALUE_TYPE_LIST: {
522  return false;
523  }
524  for (size_t i = 0; i < fl_value_get_length(a); i++) {
526  fl_value_get_list_value(b, i))) {
527  return false;
528  }
529  }
530  return true;
531  }
532  case FL_VALUE_TYPE_MAP: {
534  return false;
535  }
536  for (size_t i = 0; i < fl_value_get_length(a); i++) {
538  FlValue* value_b = fl_value_lookup(b, key);
539  if (value_b == nullptr) {
540  return false;
541  }
542  FlValue* value_a = fl_value_get_map_value(a, i);
543  if (!fl_value_equal(value_a, value_b)) {
544  return false;
545  }
546  }
547  return true;
548  }
549  }
550 }
G_MODULE_EXPORT const float * fl_value_get_float32_list(FlValue *self)
Definition: fl_value.cc:670
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
Definition: fl_value.cc:677
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:628
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
Definition: fl_value.cc:663
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition: fl_value.cc:649
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:433
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:635
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:735
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:751
G_MODULE_EXPORT FlValue * fl_value_lookup(FlValue *self, FlValue *key)
Definition: fl_value.cc:759
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition: fl_value.cc:743
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition: fl_value.cc:656
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:684
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:621

◆ 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 621 of file fl_value.cc.

References FALSE, FL_VALUE_TYPE_BOOL, and FlValueBool::value.

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

621  {
622  g_return_val_if_fail(self != nullptr, FALSE);
623  g_return_val_if_fail(self->type == FL_VALUE_TYPE_BOOL, FALSE);
624  FlValueBool* v = reinterpret_cast<FlValueBool*>(self);
625  return v->value;
626 }
bool value
Definition: fl_value.cc:18
return FALSE

◆ 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 635 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().

635  {
636  g_return_val_if_fail(self != nullptr, 0.0);
637  g_return_val_if_fail(self->type == FL_VALUE_TYPE_FLOAT, 0.0);
638  FlValueDouble* v = reinterpret_cast<FlValueDouble*>(self);
639  return v->value;
640 }
double value
Definition: fl_value.cc:28

◆ fl_value_get_float32_list()

const float* fl_value_get_float32_list ( FlValue value)

fl_value_get_float32_list: : an FlValue of type FL_VALUE_TYPE_FLOAT32_LIST.

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

Returns: an array of floating point numbers.

Definition at line 670 of file fl_value.cc.

References FL_VALUE_TYPE_FLOAT32_LIST, and FlValueFloat32List::values.

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

670  {
671  g_return_val_if_fail(self != nullptr, nullptr);
672  g_return_val_if_fail(self->type == FL_VALUE_TYPE_FLOAT32_LIST, nullptr);
673  FlValueFloat32List* v = reinterpret_cast<FlValueFloat32List*>(self);
674  return v->values;
675 }

◆ 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_value_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 677 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().

677  {
678  g_return_val_if_fail(self != nullptr, nullptr);
679  g_return_val_if_fail(self->type == FL_VALUE_TYPE_FLOAT_LIST, nullptr);
680  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
681  return v->values;
682 }
double * values
Definition: fl_value.cc:62

◆ 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 628 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().

628  {
629  g_return_val_if_fail(self != nullptr, 0);
630  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT, 0);
631  FlValueInt* v = reinterpret_cast<FlValueInt*>(self);
632  return v->value;
633 }
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_value_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 656 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().

656  {
657  g_return_val_if_fail(self != nullptr, nullptr);
658  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT32_LIST, nullptr);
659  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
660  return v->values;
661 }
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_value_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 663 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().

663  {
664  g_return_val_if_fail(self != nullptr, nullptr);
665  g_return_val_if_fail(self->type == FL_VALUE_TYPE_INT64_LIST, nullptr);
666  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
667  return v->values;
668 }
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_FLOAT32_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 684 of file fl_value.cc.

References FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT32_LIST, 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, FlValueFloat32List::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(), G_DEFINE_TYPE(), set_client(), set_editable_size_and_transform(), TEST(), value_to_string(), and _FlutterTaskRunner::~_FlutterTaskRunner().

684  {
685  g_return_val_if_fail(self != nullptr, 0);
686  g_return_val_if_fail(self->type == FL_VALUE_TYPE_UINT8_LIST ||
687  self->type == FL_VALUE_TYPE_INT32_LIST ||
688  self->type == FL_VALUE_TYPE_INT64_LIST ||
689  self->type == FL_VALUE_TYPE_FLOAT32_LIST ||
690  self->type == FL_VALUE_TYPE_FLOAT_LIST ||
691  self->type == FL_VALUE_TYPE_LIST ||
692  self->type == FL_VALUE_TYPE_MAP,
693  0);
694 
695  switch (self->type) {
697  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
698  return v->values_length;
699  }
701  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
702  return v->values_length;
703  }
705  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
706  return v->values_length;
707  }
709  FlValueFloat32List* v = reinterpret_cast<FlValueFloat32List*>(self);
710  return v->values_length;
711  }
713  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
714  return v->values_length;
715  }
716  case FL_VALUE_TYPE_LIST: {
717  FlValueList* v = reinterpret_cast<FlValueList*>(self);
718  return v->values->len;
719  }
720  case FL_VALUE_TYPE_MAP: {
721  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
722  return v->keys->len;
723  }
724  case FL_VALUE_TYPE_NULL:
725  case FL_VALUE_TYPE_BOOL:
726  case FL_VALUE_TYPE_INT:
727  case FL_VALUE_TYPE_FLOAT:
729  return 0;
730  }
731 
732  return 0;
733 }
size_t values_length
Definition: fl_value.cc:51
size_t values_length
Definition: fl_value.cc:57
GPtrArray * keys
Definition: fl_value.cc:73
GPtrArray * values
Definition: fl_value.cc:68
size_t values_length
Definition: fl_value.cc:45
size_t values_length
Definition: fl_value.cc:63
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 735 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(), G_DEFINE_TYPE(), set_client(), set_editable_size_and_transform(), TEST(), value_to_string(), and _FlutterTaskRunner::~_FlutterTaskRunner().

735  {
736  g_return_val_if_fail(self != nullptr, nullptr);
737  g_return_val_if_fail(self->type == FL_VALUE_TYPE_LIST, nullptr);
738 
739  FlValueList* v = reinterpret_cast<FlValueList*>(self);
740  return static_cast<FlValue*>(g_ptr_array_index(v->values, index));
741 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
GPtrArray * values
Definition: fl_value.cc:68

◆ 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 743 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().

743  {
744  g_return_val_if_fail(self != nullptr, nullptr);
745  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
746 
747  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
748  return static_cast<FlValue*>(g_ptr_array_index(v->keys, index));
749 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
GPtrArray * keys
Definition: fl_value.cc:73

◆ 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 751 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().

751  {
752  g_return_val_if_fail(self != nullptr, nullptr);
753  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
754 
755  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
756  return static_cast<FlValue*>(g_ptr_array_index(v->values, index));
757 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
GPtrArray * values
Definition: fl_value.cc:74

◆ 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_value_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 649 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().

649  {
650  g_return_val_if_fail(self != nullptr, nullptr);
651  g_return_val_if_fail(self->type == FL_VALUE_TYPE_UINT8_LIST, nullptr);
652  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
653  return v->values;
654 }
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 optimized 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 759 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().

759  {
760  g_return_val_if_fail(self != nullptr, nullptr);
761  g_return_val_if_fail(self->type == FL_VALUE_TYPE_MAP, nullptr);
762 
763  ssize_t index = fl_value_lookup_index(self, key);
764  if (index < 0) {
765  return nullptr;
766  }
767  return fl_value_get_map_value(self, index);
768 }
static ssize_t fl_value_lookup_index(FlValue *self, FlValue *key)
Definition: fl_value.cc:92
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:751

◆ 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 optimized 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 770 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(), handle_response(), set_client(), set_editable_size_and_transform(), set_editing_state(), set_marked_text_rect(), and TEST().

771  {
772  g_return_val_if_fail(self != nullptr, nullptr);
773  FlValue* string_key = fl_value_new_string(key);
774  FlValue* value = fl_value_lookup(self, string_key);
775  // Explicit unref used because the g_autoptr is triggering a false positive
776  // with clang-tidy.
777  fl_value_unref(string_key);
778  return value;
779 }
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:369
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:265
G_MODULE_EXPORT FlValue * fl_value_lookup(FlValue *self, FlValue *key)
Definition: fl_value.cc:759

◆ 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 244 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(), echo_response_cb(), encode_bool(), fl_standard_message_codec_read_value(), TEST(), update_editing_state(), update_settings(), and _FlutterTaskRunner::~_FlutterTaskRunner().

244  {
245  FlValueBool* self = reinterpret_cast<FlValueBool*>(
247  self->value = value ? true : false;
248  return reinterpret_cast<FlValue*>(self);
249 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
bool value
Definition: fl_value.cc:18
uint8_t value
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 258 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(), FlValueHandler::Uint64(), and update_settings().

258  {
259  FlValueDouble* self = reinterpret_cast<FlValueDouble*>(
261  self->value = value;
262  return reinterpret_cast<FlValue*>(self);
263 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
uint8_t value
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77
double value
Definition: fl_value.cc:28

◆ fl_value_new_float32_list()

FlValue* fl_value_new_float32_list ( const float *  value,
size_t  value_length 
)

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

Creates an ordered list containing 32 bit floating point numbers. The equivalent Dart type is a Float32List.

Returns: a new FlValue.

Definition at line 318 of file fl_value.cc.

References fl_value_new(), FL_VALUE_TYPE_FLOAT32_LIST, and FlValueFloat32List::values_length.

Referenced by read_float32_list_value(), and TEST().

319  {
320  FlValueFloat32List* self = reinterpret_cast<FlValueFloat32List*>(
322  self->values_length = data_length;
323  self->values = static_cast<float*>(g_malloc(sizeof(float) * data_length));
324  memcpy(self->values, data, sizeof(float) * data_length);
325  return reinterpret_cast<FlValue*>(self);
326 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
size_t values_length
Definition: fl_value.cc:57
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 328 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().

329  {
330  FlValueFloatList* self = reinterpret_cast<FlValueFloatList*>(
332  self->values_length = data_length;
333  self->values = static_cast<double*>(g_malloc(sizeof(double) * data_length));
334  memcpy(self->values, data, sizeof(double) * data_length);
335  return reinterpret_cast<FlValue*>(self);
336 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77
size_t values_length
Definition: fl_value.cc:63

◆ 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 251 of file fl_value.cc.

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

Referenced by encode_int(), fl_key_channel_responder_handle_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().

251  {
252  FlValueInt* self = reinterpret_cast<FlValueInt*>(
254  self->value = value;
255  return reinterpret_cast<FlValue*>(self);
256 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
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:77

◆ 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 298 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().

299  {
300  FlValueInt32List* self = reinterpret_cast<FlValueInt32List*>(
302  self->values_length = data_length;
303  self->values = static_cast<int32_t*>(g_malloc(sizeof(int32_t) * data_length));
304  memcpy(self->values, data, sizeof(int32_t) * data_length);
305  return reinterpret_cast<FlValue*>(self);
306 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77
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 308 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().

309  {
310  FlValueInt64List* self = reinterpret_cast<FlValueInt64List*>(
312  self->values_length = data_length;
313  self->values = static_cast<int64_t*>(g_malloc(sizeof(int64_t) * data_length));
314  memcpy(self->values, data, sizeof(int64_t) * data_length);
315  return reinterpret_cast<FlValue*>(self);
316 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
size_t values_length
Definition: fl_value.cc:51
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 338 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().

338  {
339  FlValueList* self = reinterpret_cast<FlValueList*>(
341  self->values = g_ptr_array_new_with_free_func(fl_value_destroy);
342  return reinterpret_cast<FlValue*>(self);
343 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
GPtrArray * values
Definition: fl_value.cc:68
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:85
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 345 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().

346  {
347  g_return_val_if_fail(str_array != nullptr, nullptr);
348  g_autoptr(FlValue) value = fl_value_new_list();
349  for (int i = 0; str_array[i] != nullptr; i++) {
351  }
352  return fl_value_ref(value);
353 }
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:338
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:560
uint8_t value
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:265
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:363

◆ 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 355 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(), echo_response_cb(), fl_json_method_codec_encode_method_call(), fl_key_channel_responder_handle_event(), read_map_value(), FlValueHandler::StartObject(), TEST(), update_editing_state(), update_settings(), and _FlutterTaskRunner::~_FlutterTaskRunner().

355  {
356  FlValueMap* self = reinterpret_cast<FlValueMap*>(
358  self->keys = g_ptr_array_new_with_free_func(fl_value_destroy);
359  self->values = g_ptr_array_new_with_free_func(fl_value_destroy);
360  return reinterpret_cast<FlValue*>(self);
361 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
GPtrArray * keys
Definition: fl_value.cc:73
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:85
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 240 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().

240  {
241  return fl_value_new(FL_VALUE_TYPE_NULL, sizeof(FlValue));
242 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 265 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_channel_responder_handle_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(), reassign_method_cb(), TEST(), update_editing_state(), and update_settings().

265  {
266  FlValueString* self = reinterpret_cast<FlValueString*>(
268  self->value = g_strdup(value);
269  return reinterpret_cast<FlValue*>(self);
270 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
uint8_t value
gchar * value
Definition: fl_value.cc:33
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 272 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().

273  {
274  FlValueString* self = reinterpret_cast<FlValueString*>(
276  self->value =
277  value_length == 0 ? g_strdup("") : g_strndup(value, value_length);
278  return reinterpret_cast<FlValue*>(self);
279 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
uint8_t value
gchar * value
Definition: fl_value.cc:33
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77

◆ 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 281 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().

282  {
283  FlValueUint8List* self = reinterpret_cast<FlValueUint8List*>(
285  self->values_length = data_length;
286  self->values = static_cast<uint8_t*>(g_malloc(sizeof(uint8_t) * data_length));
287  memcpy(self->values, data, sizeof(uint8_t) * data_length);
288  return reinterpret_cast<FlValue*>(self);
289 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:40
static FlValue * fl_value_new(FlValueType type, size_t size)
Definition: fl_value.cc:77
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 291 of file fl_value.cc.

References fl_value_new_uint8_list(), and length.

291  {
292  gsize length;
293  const uint8_t* d =
294  static_cast<const uint8_t*>(g_bytes_get_data(data, &length));
295  return fl_value_new_uint8_list(d, length);
296 }
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:281
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 569 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().

569  {
570  g_return_if_fail(self != nullptr);
571  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
572  g_return_if_fail(key != nullptr);
573  g_return_if_fail(value != nullptr);
574 
576 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:578
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:363

◆ 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 599 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().

601  {
602  g_return_if_fail(self != nullptr);
603  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
604  g_return_if_fail(key != nullptr);
605  g_return_if_fail(value != nullptr);
606 
608 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:578
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:265
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:363

◆ 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 610 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(), echo_response_cb(), fl_key_channel_responder_handle_event(), TEST(), update_editing_state(), update_settings(), and _FlutterTaskRunner::~_FlutterTaskRunner().

612  {
613  g_return_if_fail(self != nullptr);
614  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
615  g_return_if_fail(key != nullptr);
616  g_return_if_fail(value != nullptr);
617 
619 }
uint8_t value
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:578
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:265

◆ 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 578 of file fl_value.cc.

References fl_value_destroy(), fl_value_lookup_index(), FL_VALUE_TYPE_MAP, key, 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().

580  {
581  g_return_if_fail(self != nullptr);
582  g_return_if_fail(self->type == FL_VALUE_TYPE_MAP);
583  g_return_if_fail(key != nullptr);
584  g_return_if_fail(value != nullptr);
585 
586  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
587  ssize_t index = fl_value_lookup_index(self, key);
588  if (index < 0) {
589  g_ptr_array_add(v->keys, key);
590  g_ptr_array_add(v->values, value);
591  } else {
592  fl_value_destroy(v->keys->pdata[index]);
593  v->keys->pdata[index] = key;
594  fl_value_destroy(v->values->pdata[index]);
595  v->values->pdata[index] = value;
596  }
597 }
static ssize_t fl_value_lookup_index(FlValue *self, FlValue *key)
Definition: fl_value.cc:92
GPtrArray * keys
Definition: fl_value.cc:73
static void fl_value_destroy(gpointer value)
Definition: fl_value.cc:85
uint8_t value
GPtrArray * values
Definition: fl_value.cc:74

◆ 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 781 of file fl_value.cc.

References buffer, FALSE, and value_to_string().

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

781  {
782  GString* buffer = g_string_new("");
783  value_to_string(value, buffer);
784  return g_string_free(buffer, FALSE);
785 }
uint8_t value
static const uint8_t buffer[]
return FALSE
static void value_to_string(FlValue *value, GString *buffer)
Definition: fl_value.cc:129

◆ 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 369 of file fl_value.cc.

References FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_FLOAT32_LIST, 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, FlValueFloat32List::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().

369  {
370  g_return_if_fail(self != nullptr);
371  g_return_if_fail(self->ref_count > 0);
372  self->ref_count--;
373  if (self->ref_count != 0) {
374  return;
375  }
376 
377  switch (self->type) {
378  case FL_VALUE_TYPE_STRING: {
379  FlValueString* v = reinterpret_cast<FlValueString*>(self);
380  g_free(v->value);
381  break;
382  }
384  FlValueUint8List* v = reinterpret_cast<FlValueUint8List*>(self);
385  g_free(v->values);
386  break;
387  }
389  FlValueInt32List* v = reinterpret_cast<FlValueInt32List*>(self);
390  g_free(v->values);
391  break;
392  }
394  FlValueInt64List* v = reinterpret_cast<FlValueInt64List*>(self);
395  g_free(v->values);
396  break;
397  }
399  FlValueFloat32List* v = reinterpret_cast<FlValueFloat32List*>(self);
400  g_free(v->values);
401  break;
402  }
404  FlValueFloatList* v = reinterpret_cast<FlValueFloatList*>(self);
405  g_free(v->values);
406  break;
407  }
408  case FL_VALUE_TYPE_LIST: {
409  FlValueList* v = reinterpret_cast<FlValueList*>(self);
410  g_ptr_array_unref(v->values);
411  break;
412  }
413  case FL_VALUE_TYPE_MAP: {
414  FlValueMap* v = reinterpret_cast<FlValueMap*>(self);
415  g_ptr_array_unref(v->keys);
416  g_ptr_array_unref(v->values);
417  break;
418  }
419  case FL_VALUE_TYPE_NULL:
420  case FL_VALUE_TYPE_BOOL:
421  case FL_VALUE_TYPE_INT:
422  case FL_VALUE_TYPE_FLOAT:
423  break;
424  }
425  g_free(self);
426 }
double * values
Definition: fl_value.cc:62
GPtrArray * keys
Definition: fl_value.cc:73
int64_t * values
Definition: fl_value.cc:50
GPtrArray * values
Definition: fl_value.cc:68
uint8_t * values
Definition: fl_value.cc:38
gchar * value
Definition: fl_value.cc:33
GPtrArray * values
Definition: fl_value.cc:74
int32_t * values
Definition: fl_value.cc:44