/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-processor-struct.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"

/**
 * fu_processor_feature_flags_to_string:
 * @val: value, e.g. %FU_PROCESSOR_FEATURE_FLAG_SHSTK
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 **/
gchar *
fu_processor_feature_flags_to_string(FuProcessorFeatureFlags val)
{
    const gchar *data[5] = {0};
    guint idx = 0;
    if (val == FU_PROCESSOR_FEATURE_FLAG_NONE)
        return g_strdup("none");
    if (val & FU_PROCESSOR_FEATURE_FLAG_SHSTK)
        data[idx++] = "shstk";
    if (val & FU_PROCESSOR_FEATURE_FLAG_IBT)
        data[idx++] = "ibt";
    if (val & FU_PROCESSOR_FEATURE_FLAG_TME)
        data[idx++] = "tme";
    if (val & FU_PROCESSOR_FEATURE_FLAG_SMAP)
        data[idx++] = "smap";
    return g_strjoinv(",", (gchar **)data);
}

/**
 * fu_processor_mitigation_flags_to_string:
 * @val: value, e.g. %FU_PROCESSOR_MITIGATION_FLAG_GDS
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 *
 **/
gchar *
fu_processor_mitigation_flags_to_string(FuProcessorMitigationFlags val)
{
    const gchar *data[3] = {0};
    guint idx = 0;
    if (val == FU_PROCESSOR_MITIGATION_FLAG_NONE)
        return g_strdup("none");
    if (val & FU_PROCESSOR_MITIGATION_FLAG_GDS)
        data[idx++] = "gds";
    if (val & FU_PROCESSOR_MITIGATION_FLAG_SINKCLOSE)
        data[idx++] = "sinkclose";
    return g_strjoinv(",", (gchar **)data);
}
/**
 * fu_processor_mitigation_flags_from_string:
 * @val: (nullable): a string, e.g. `gds`
 *
 * Converts a string to an enumerated value.
 *
 * Returns: enumerated value
 **/
FuProcessorMitigationFlags
fu_processor_mitigation_flags_from_string(const gchar *val)
{
    FuProcessorMitigationFlags value = 0;
    g_auto(GStrv) split = NULL;
    g_return_val_if_fail(val != NULL, 0);
    split = g_strsplit(val, ",", -1);
    for (guint i = 0; split[i] != NULL; i++) {
        if (g_strcmp0(split[i], "none") == 0) {
            value |= FU_PROCESSOR_MITIGATION_FLAG_NONE;
            continue;
        }
        if (g_strcmp0(split[i], "gds") == 0) {
            value |= FU_PROCESSOR_MITIGATION_FLAG_GDS;
            continue;
        }
        if (g_strcmp0(split[i], "sinkclose") == 0) {
            value |= FU_PROCESSOR_MITIGATION_FLAG_SINKCLOSE;
            continue;
        }
    }
    return value;
}

/**
 * fu_processor_kind_to_string:
 * @val: value, e.g. %FU_PROCESSOR_KIND_INTEL_PENTIUM
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_processor_kind_to_string(FuProcessorKind val)
{
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM)
        return "intel-pentium";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM_MMX)
        return "intel-pentium-mmx";
    if (val == FU_PROCESSOR_KIND_INTEL_QUARK_X1000)
        return "intel-quark-x1000";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM_PRO)
        return "intel-pentium-pro";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM2_KLAMATH)
        return "intel-pentium2-klamath";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM3_DESCHUTES)
        return "intel-pentium3-deschutes";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM3_TUALATIN)
        return "intel-pentium3-tualatin";
    if (val == FU_PROCESSOR_KIND_INTEL_PENTIUM3_DOTHAN)
        return "intel-pentium3-dothan";
    if (val == FU_PROCESSOR_KIND_INTEL_CORE_YONAH)
        return "intel-core-yonah";
    if (val == FU_PROCESSOR_KIND_INTEL_CORE2_MEROM)
        return "intel-core2-merom";
    if (val == FU_PROCESSOR_KIND_INTEL_CORE2_PENRYN)
        return "intel-core2-penryn";
    if (val == FU_PROCESSOR_KIND_INTEL_CORE2_DUNNINGTON)
        return "intel-core2-dunnington";
    if (val == FU_PROCESSOR_KIND_INTEL_NEHALEM)
        return "intel-nehalem";
    if (val == FU_PROCESSOR_KIND_INTEL_WESTMERE)
        return "intel-westmere";
    if (val == FU_PROCESSOR_KIND_INTEL_SANDYBRIDGE)
        return "intel-sandybridge";
    if (val == FU_PROCESSOR_KIND_INTEL_IVYBRIDGE)
        return "intel-ivybridge";
    if (val == FU_PROCESSOR_KIND_INTEL_HASWELL)
        return "intel-haswell";
    if (val == FU_PROCESSOR_KIND_INTEL_BROADWELL)
        return "intel-broadwell";
    if (val == FU_PROCESSOR_KIND_INTEL_SKYLAKE)
        return "intel-skylake";
    if (val == FU_PROCESSOR_KIND_INTEL_KABYLAKE)
        return "intel-kabylake";
    if (val == FU_PROCESSOR_KIND_INTEL_COMETLAKE)
        return "intel-cometlake";
    if (val == FU_PROCESSOR_KIND_INTEL_CANNONLAKE)
        return "intel-cannonlake";
    if (val == FU_PROCESSOR_KIND_INTEL_ICELAKE)
        return "intel-icelake";
    if (val == FU_PROCESSOR_KIND_INTEL_ROCKETLAKE)
        return "intel-rocketlake";
    if (val == FU_PROCESSOR_KIND_INTEL_TIGERLAKE)
        return "intel-tigerlake";
    if (val == FU_PROCESSOR_KIND_INTEL_SAPPHIRERAPIDS)
        return "intel-sapphirerapids";
    if (val == FU_PROCESSOR_KIND_INTEL_EMERALDRAPIDS)
        return "intel-emeraldrapids";
    if (val == FU_PROCESSOR_KIND_INTEL_GRANITERAPIDS)
        return "intel-graniterapids";
    if (val == FU_PROCESSOR_KIND_INTEL_DIAMONDRAPIDS)
        return "intel-diamondrapids";
    if (val == FU_PROCESSOR_KIND_INTEL_BARTLETTLAKE)
        return "intel-bartlettlake";
    if (val == FU_PROCESSOR_KIND_INTEL_LAKEFIELD)
        return "intel-lakefield";
    if (val == FU_PROCESSOR_KIND_INTEL_ALDERLAKE)
        return "intel-alderlake";
    if (val == FU_PROCESSOR_KIND_INTEL_RAPTORLAKE)
        return "intel-raptorlake";
    if (val == FU_PROCESSOR_KIND_INTEL_METEORLAKE)
        return "intel-meteorlake";
    if (val == FU_PROCESSOR_KIND_INTEL_ARROWLAKE)
        return "intel-arrowlake";
    if (val == FU_PROCESSOR_KIND_INTEL_LUNARLAKE)
        return "intel-lunarlake";
    if (val == FU_PROCESSOR_KIND_INTEL_PANTHERLAKE)
        return "intel-pantherlake";
    if (val == FU_PROCESSOR_KIND_INTEL_WILDCATLAKE)
        return "intel-wildcatlake";
    if (val == FU_PROCESSOR_KIND_INTEL_NOVALAKE)
        return "intel-novalake";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_BONNELL)
        return "intel-atom-bonnell";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_SALTWELL)
        return "intel-atom-saltwell";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_SILVERMONT)
        return "intel-atom-silvermont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_AIRMONT)
        return "intel-atom-airmont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_GOLDMONT)
        return "intel-atom-goldmont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_GOLDMONT_PLUS)
        return "intel-atom-goldmont-plus";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_TREMONT)
        return "intel-atom-tremont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_GRACEMONT)
        return "intel-atom-gracemont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_CRESTMONT)
        return "intel-atom-crestmont";
    if (val == FU_PROCESSOR_KIND_INTEL_ATOM_DARKMONT)
        return "intel-atom-darkmont";
    if (val == FU_PROCESSOR_KIND_INTEL_XEON_PHI)
        return "intel-xeon-phi";
    if (val == FU_PROCESSOR_KIND_INTEL_P4_WILLAMETTE)
        return "intel-p4-willamette";
    if (val == FU_PROCESSOR_KIND_INTEL_P4_PRESCOTT)
        return "intel-p4-prescott";
    if (val == FU_PROCESSOR_KIND_INTEL_P4_CEDARMILL)
        return "intel-p4-cedarmill";
    return NULL;
}
/**
 * fu_processor_kind_from_string:
 * @val: (nullable): a string, e.g. `intel-pentium`
 *
 * Converts a string to an enumerated value.
 *
 * Returns: enumerated value
 **/
FuProcessorKind
fu_processor_kind_from_string(const gchar *val)
{
    if (g_strcmp0(val, "intel-pentium") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM;
    if (g_strcmp0(val, "intel-pentium-mmx") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM_MMX;
    if (g_strcmp0(val, "intel-quark-x1000") == 0)
        return FU_PROCESSOR_KIND_INTEL_QUARK_X1000;
    if (g_strcmp0(val, "intel-pentium-pro") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM_PRO;
    if (g_strcmp0(val, "intel-pentium2-klamath") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM2_KLAMATH;
    if (g_strcmp0(val, "intel-pentium3-deschutes") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM3_DESCHUTES;
    if (g_strcmp0(val, "intel-pentium3-tualatin") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM3_TUALATIN;
    if (g_strcmp0(val, "intel-pentium3-dothan") == 0)
        return FU_PROCESSOR_KIND_INTEL_PENTIUM3_DOTHAN;
    if (g_strcmp0(val, "intel-core-yonah") == 0)
        return FU_PROCESSOR_KIND_INTEL_CORE_YONAH;
    if (g_strcmp0(val, "intel-core2-merom") == 0)
        return FU_PROCESSOR_KIND_INTEL_CORE2_MEROM;
    if (g_strcmp0(val, "intel-core2-penryn") == 0)
        return FU_PROCESSOR_KIND_INTEL_CORE2_PENRYN;
    if (g_strcmp0(val, "intel-core2-dunnington") == 0)
        return FU_PROCESSOR_KIND_INTEL_CORE2_DUNNINGTON;
    if (g_strcmp0(val, "intel-nehalem") == 0)
        return FU_PROCESSOR_KIND_INTEL_NEHALEM;
    if (g_strcmp0(val, "intel-westmere") == 0)
        return FU_PROCESSOR_KIND_INTEL_WESTMERE;
    if (g_strcmp0(val, "intel-sandybridge") == 0)
        return FU_PROCESSOR_KIND_INTEL_SANDYBRIDGE;
    if (g_strcmp0(val, "intel-ivybridge") == 0)
        return FU_PROCESSOR_KIND_INTEL_IVYBRIDGE;
    if (g_strcmp0(val, "intel-haswell") == 0)
        return FU_PROCESSOR_KIND_INTEL_HASWELL;
    if (g_strcmp0(val, "intel-broadwell") == 0)
        return FU_PROCESSOR_KIND_INTEL_BROADWELL;
    if (g_strcmp0(val, "intel-skylake") == 0)
        return FU_PROCESSOR_KIND_INTEL_SKYLAKE;
    if (g_strcmp0(val, "intel-kabylake") == 0)
        return FU_PROCESSOR_KIND_INTEL_KABYLAKE;
    if (g_strcmp0(val, "intel-cometlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_COMETLAKE;
    if (g_strcmp0(val, "intel-cannonlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_CANNONLAKE;
    if (g_strcmp0(val, "intel-icelake") == 0)
        return FU_PROCESSOR_KIND_INTEL_ICELAKE;
    if (g_strcmp0(val, "intel-rocketlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_ROCKETLAKE;
    if (g_strcmp0(val, "intel-tigerlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_TIGERLAKE;
    if (g_strcmp0(val, "intel-sapphirerapids") == 0)
        return FU_PROCESSOR_KIND_INTEL_SAPPHIRERAPIDS;
    if (g_strcmp0(val, "intel-emeraldrapids") == 0)
        return FU_PROCESSOR_KIND_INTEL_EMERALDRAPIDS;
    if (g_strcmp0(val, "intel-graniterapids") == 0)
        return FU_PROCESSOR_KIND_INTEL_GRANITERAPIDS;
    if (g_strcmp0(val, "intel-diamondrapids") == 0)
        return FU_PROCESSOR_KIND_INTEL_DIAMONDRAPIDS;
    if (g_strcmp0(val, "intel-bartlettlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_BARTLETTLAKE;
    if (g_strcmp0(val, "intel-lakefield") == 0)
        return FU_PROCESSOR_KIND_INTEL_LAKEFIELD;
    if (g_strcmp0(val, "intel-alderlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_ALDERLAKE;
    if (g_strcmp0(val, "intel-raptorlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_RAPTORLAKE;
    if (g_strcmp0(val, "intel-meteorlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_METEORLAKE;
    if (g_strcmp0(val, "intel-arrowlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_ARROWLAKE;
    if (g_strcmp0(val, "intel-lunarlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_LUNARLAKE;
    if (g_strcmp0(val, "intel-pantherlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_PANTHERLAKE;
    if (g_strcmp0(val, "intel-wildcatlake") == 0)
        return FU_PROCESSOR_KIND_INTEL_WILDCATLAKE;
    if (g_strcmp0(val, "intel-novalake") == 0)
        return FU_PROCESSOR_KIND_INTEL_NOVALAKE;
    if (g_strcmp0(val, "intel-atom-bonnell") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_BONNELL;
    if (g_strcmp0(val, "intel-atom-saltwell") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_SALTWELL;
    if (g_strcmp0(val, "intel-atom-silvermont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_SILVERMONT;
    if (g_strcmp0(val, "intel-atom-airmont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_AIRMONT;
    if (g_strcmp0(val, "intel-atom-goldmont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_GOLDMONT;
    if (g_strcmp0(val, "intel-atom-goldmont-plus") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_GOLDMONT_PLUS;
    if (g_strcmp0(val, "intel-atom-tremont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_TREMONT;
    if (g_strcmp0(val, "intel-atom-gracemont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_GRACEMONT;
    if (g_strcmp0(val, "intel-atom-crestmont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_CRESTMONT;
    if (g_strcmp0(val, "intel-atom-darkmont") == 0)
        return FU_PROCESSOR_KIND_INTEL_ATOM_DARKMONT;
    if (g_strcmp0(val, "intel-xeon-phi") == 0)
        return FU_PROCESSOR_KIND_INTEL_XEON_PHI;
    if (g_strcmp0(val, "intel-p4-willamette") == 0)
        return FU_PROCESSOR_KIND_INTEL_P4_WILLAMETTE;
    if (g_strcmp0(val, "intel-p4-prescott") == 0)
        return FU_PROCESSOR_KIND_INTEL_P4_PRESCOTT;
    if (g_strcmp0(val, "intel-p4-cedarmill") == 0)
        return FU_PROCESSOR_KIND_INTEL_P4_CEDARMILL;
    return FU_PROCESSOR_KIND_UNKNOWN;
}
