Flutter Engine
fl_test.cc File Reference
#include "flutter/shell/platform/linux/testing/fl_test.h"

Go to the source code of this file.

Functions

static uint8_t hex_digit_to_int (char value)
 
static uint8_t parse_hex8 (const gchar *hex_string)
 
GBytes * hex_string_to_bytes (const gchar *hex_string)
 
gchar * bytes_to_hex_string (GBytes *bytes)
 

Function Documentation

◆ bytes_to_hex_string()

gchar* bytes_to_hex_string ( GBytes *  bytes)

Definition at line 33 of file fl_test.cc.

Referenced by encode_error_envelope(), encode_message(), encode_method_call(), and encode_success_envelope().

33  {
34  GString* hex_string = g_string_new("");
35  size_t data_length;
36  const uint8_t* data =
37  static_cast<const uint8_t*>(g_bytes_get_data(bytes, &data_length));
38  for (size_t i = 0; i < data_length; i++)
39  g_string_append_printf(hex_string, "%02x", data[i]);
40  return g_string_free(hex_string, FALSE);
41 }

◆ hex_digit_to_int()

static uint8_t hex_digit_to_int ( char  value)
static

Definition at line 7 of file fl_test.cc.

Referenced by parse_hex8().

7  {
8  if (value >= '0' && value <= '9')
9  return value - '0';
10  else if (value >= 'a' && value <= 'f')
11  return value - 'a' + 10;
12  else if (value >= 'F' && value <= 'F')
13  return value - 'A' + 10;
14  else
15  return 0;
16 }
uint8_t value

◆ hex_string_to_bytes()

GBytes* hex_string_to_bytes ( const gchar *  hex_string)

Definition at line 24 of file fl_test.cc.

References parse_hex8(), and value.

Referenced by decode_error_method_call(), decode_error_response(), decode_error_value(), decode_message(), decode_method_call(), decode_response_with_error(), and decode_response_with_success().

24  {
25  GByteArray* buffer = g_byte_array_new();
26  for (int i = 0; hex_string[i] != '\0' && hex_string[i + 1] != '\0'; i += 2) {
27  uint8_t value = parse_hex8(hex_string + i);
28  g_byte_array_append(buffer, &value, 1);
29  }
30  return g_byte_array_free_to_bytes(buffer);
31 }
uint8_t value
static uint8_t parse_hex8(const gchar *hex_string)
Definition: fl_test.cc:18

◆ parse_hex8()

static uint8_t parse_hex8 ( const gchar *  hex_string)
static

Definition at line 18 of file fl_test.cc.

References hex_digit_to_int().

Referenced by hex_string_to_bytes().

18  {
19  if (hex_string[0] == '\0')
20  return 0x00;
21  return hex_digit_to_int(hex_string[0]) << 4 | hex_digit_to_int(hex_string[1]);
22 }
static uint8_t hex_digit_to_int(char value)
Definition: fl_test.cc:7