/* auto-generated, do not modify */
#include "config.h"

#include "fu-dpaux-struct.h"
#include "fu-byte-array.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"
/* getters */
/**
 * fu_struct_dpaux_dpcd_get_ieee_oui: (skip):
 **/
guint32
fu_struct_dpaux_dpcd_get_ieee_oui(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_dpaux_dpcd_get_dev_id: (skip):
 **/
gchar *
fu_struct_dpaux_dpcd_get_dev_id(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    return fu_memstrsafe(st->data, st->len, 3, 6, NULL);
}
/**
 * fu_struct_dpaux_dpcd_get_hw_rev: (skip):
 **/
guint8
fu_struct_dpaux_dpcd_get_hw_rev(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->data[9];
}
/**
 * fu_struct_dpaux_dpcd_get_fw_ver: (skip):
 **/
guint32
fu_struct_dpaux_dpcd_get_fw_ver(const GByteArray *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->data + 10, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_dpaux_dpcd_to_string: (skip):
 **/
static gchar *
fu_struct_dpaux_dpcd_to_string(const GByteArray *st)
{
    g_autoptr(GString) str = g_string_new("DpauxDpcd:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
    {
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
        if (tmp != NULL)
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
    }
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
/**
 * fu_struct_dpaux_dpcd_parse: (skip):
 **/
GByteArray *
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(GByteArray) st = g_byte_array_new();
    g_autofree gchar *str = NULL;
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
        g_prefix_error(error, "invalid struct DpauxDpcd: ");
        return NULL;
    }
    g_byte_array_append(st, buf + offset, 13);
    str = fu_struct_dpaux_dpcd_to_string(st);
    g_debug("%s", str);
    return g_steal_pointer(&st);
}
