Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2012-2022 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the license, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "as-enums.h"
/**
* SECTION:as-enums
* @short_description: Some enums used by various other modules
* @include: appstream.h
*/
/**
* as_format_kind_to_string:
* @kind: the #AsFormatKind.
*
* Converts the enumerated value to an text representation.
*
* Returns: string version of @kind
*
* Since: 0.10
**/
const gchar*
as_format_kind_to_string (AsFormatKind kind)
{
if (kind == AS_FORMAT_KIND_XML)
return "xml";
if (kind == AS_FORMAT_KIND_YAML)
return "yaml";
return "unknown";
}
/**
* as_format_kind_from_string:
* @kind_str: the string.
*
* Converts the text representation to an enumerated value.
*
* Returns: a #AsFormatKind or %AS_FORMAT_KIND_UNKNOWN for unknown
*
* Since: 0.10
**/
AsFormatKind
as_format_kind_from_string (const gchar *kind_str)
{
if (g_strcmp0 (kind_str, "xml") == 0)
return AS_FORMAT_KIND_XML;
if (g_strcmp0 (kind_str, "yaml") == 0)
return AS_FORMAT_KIND_YAML;
return AS_FORMAT_KIND_UNKNOWN;
}
/**
* as_url_kind_to_string:
* @url_kind: the %AsUrlKind.
*
* Converts the enumerated value to an text representation.
*
* Returns: string version of @url_kind
**/
const gchar*
as_url_kind_to_string (AsUrlKind url_kind)
{
if (url_kind == AS_URL_KIND_HOMEPAGE)
return "homepage";
if (url_kind == AS_URL_KIND_BUGTRACKER)
return "bugtracker";
if (url_kind == AS_URL_KIND_FAQ)
return "faq";
if (url_kind == AS_URL_KIND_HELP)
return "help";
if (url_kind == AS_URL_KIND_DONATION)
return "donation";
if (url_kind == AS_URL_KIND_TRANSLATE)
return "translate";
if (url_kind == AS_URL_KIND_CONTACT)
return "contact";
if (url_kind == AS_URL_KIND_VCS_BROWSER)
return "vcs-browser";
if (url_kind == AS_URL_KIND_CONTRIBUTE)
return "contribute";
return "unknown";
}
/**
* as_url_kind_from_string:
* @url_kind: the string.
*
* Converts the text representation to an enumerated value.
*
* Returns: a #AsUrlKind or %AS_URL_KIND_UNKNOWN for unknown
**/
AsUrlKind
as_url_kind_from_string (const gchar *url_kind)
{
if (g_strcmp0 (url_kind, "homepage") == 0)
return AS_URL_KIND_HOMEPAGE;
if (g_strcmp0 (url_kind, "bugtracker") == 0)
return AS_URL_KIND_BUGTRACKER;
if (g_strcmp0 (url_kind, "faq") == 0)
return AS_URL_KIND_FAQ;
if (g_strcmp0 (url_kind, "help") == 0)
return AS_URL_KIND_HELP;
if (g_strcmp0 (url_kind, "donation") == 0)
return AS_URL_KIND_DONATION;
if (g_strcmp0 (url_kind, "translate") == 0)
return AS_URL_KIND_TRANSLATE;
if (g_strcmp0 (url_kind, "contact") == 0)
return AS_URL_KIND_CONTACT;
if (g_strcmp0 (url_kind, "vcs-browser") == 0)
return AS_URL_KIND_VCS_BROWSER;
if (g_strcmp0 (url_kind, "contribute") == 0)
return AS_URL_KIND_CONTRIBUTE;
return AS_URL_KIND_UNKNOWN;
}
/**
* as_urgency_kind_to_string:
* @urgency_kind: the %AsUrgencyKind.
*
* Converts the enumerated value to an text representation.
*
* Returns: string version of @urgency_kind
*
* Since: 0.6.5
**/
const gchar*
as_urgency_kind_to_string (AsUrgencyKind urgency_kind)
{
if (urgency_kind == AS_URGENCY_KIND_LOW)
return "low";
if (urgency_kind == AS_URGENCY_KIND_MEDIUM)
return "medium";
if (urgency_kind == AS_URGENCY_KIND_HIGH)
return "high";
if (urgency_kind == AS_URGENCY_KIND_CRITICAL)
return "critical";
return "unknown";
}
/**
* as_urgency_kind_from_string:
* @urgency_kind: the string.
*
* Converts the text representation to an enumerated value.
*
* Returns: a %AsUrgencyKind or %AS_URGENCY_KIND_UNKNOWN for unknown
*
* Since: 0.6.5
**/
AsUrgencyKind
as_urgency_kind_from_string (const gchar *urgency_kind)
{
if (g_strcmp0 (urgency_kind, "low") == 0)
return AS_URGENCY_KIND_LOW;
if (g_strcmp0 (urgency_kind, "medium") == 0)
return AS_URGENCY_KIND_MEDIUM;
if (g_strcmp0 (urgency_kind, "high") == 0)
return AS_URGENCY_KIND_HIGH;
if (g_strcmp0 (urgency_kind, "critical") == 0)
return AS_URGENCY_KIND_CRITICAL;
return AS_URGENCY_KIND_UNKNOWN;
}