Add enum <=> nick conversion functions

They are for planets, aspects and antiscia
This commit is contained in:
Gergely Polonkai 2014-09-09 21:42:46 +02:00
parent c38bba8707
commit 655c65de9d
2 changed files with 106 additions and 0 deletions

View File

@ -188,6 +188,102 @@ ag_house_system_nick_to_id(const gchar *nick)
return GSWE_HOUSE_SYSTEM_NONE; return GSWE_HOUSE_SYSTEM_NONE;
} }
const gchar *
ag_planet_id_to_nick(GswePlanet planet)
{
GEnumClass *planet_class;
GEnumValue *enum_value;
planet_class = g_type_class_ref(GSWE_TYPE_PLANET);
enum_value = g_enum_get_value(planet_class, planet);
if (enum_value) {
return enum_value->value_nick;
}
return NULL;
}
GswePlanet
ag_planet_nick_to_id(const gchar *nick)
{
GEnumClass *planet_class;
GEnumValue *enum_value;
planet_class = g_type_class_ref(GSWE_TYPE_PLANET);
enum_value = g_enum_get_value_by_nick(planet_class, nick);
if (enum_value) {
return enum_value->value;
}
return GSWE_PLANET_NONE;
}
const gchar *
ag_aspect_id_to_nick(GsweAspect aspect)
{
GEnumClass *aspect_class;
GEnumValue *enum_value;
aspect_class = g_type_class_ref(GSWE_TYPE_ASPECT);
enum_value = g_enum_get_value(aspect_class, aspect);
if (enum_value) {
return enum_value->value_nick;
}
return NULL;
}
GsweAspect
ag_aspect_nick_to_id(const gchar *nick)
{
GEnumClass *aspect_class;
GEnumValue *enum_value;
aspect_class = g_type_class_ref(GSWE_TYPE_ASPECT);
enum_value = g_enum_get_value_by_nick(aspect_class, nick);
if (enum_value) {
return enum_value->value;
}
return GSWE_ASPECT_NONE;
}
const gchar *
ag_antiscion_axis_id_to_nick(GsweAntiscionAxis antiscion_axis)
{
GEnumClass *antiscion_axis_class;
GEnumValue *enum_value;
antiscion_axis_class = g_type_class_ref(GSWE_TYPE_ANTISCION_AXIS);
enum_value = g_enum_get_value(antiscion_axis_class, antiscion_axis);
if (enum_value) {
return enum_value->value_nick;
}
return NULL;
}
GsweAntiscionAxis
ag_antiscion_axis_nick_to_id(const gchar *nick)
{
GEnumClass *antiscion_axis_class;
GEnumValue *enum_value;
antiscion_axis_class = g_type_class_ref(GSWE_TYPE_ANTISCION_AXIS);
enum_value = g_enum_get_value_by_nick(antiscion_axis_class, nick);
if (enum_value) {
return enum_value->value;
}
return GSWE_ANTISCION_AXIS_NONE;
}
/** /**
* ag_get_user_data_dir: * ag_get_user_data_dir:
* *

View File

@ -35,6 +35,16 @@ enum {
const gchar *ag_house_system_id_to_nick(GsweHouseSystem house_system); const gchar *ag_house_system_id_to_nick(GsweHouseSystem house_system);
GsweHouseSystem ag_house_system_nick_to_id(const gchar *nick); GsweHouseSystem ag_house_system_nick_to_id(const gchar *nick);
const gchar *ag_planet_id_to_nick(GswePlanet planet);
GswePlanet ag_planet_nick_to_id(const gchar *nick);
const gchar *ag_aspect_id_to_nick(GsweAspect aspect);
GsweAspect ag_aspect_nick_to_id(const gchar *nick);
const gchar *ag_antiscion_axis_id_to_nick(GsweAntiscionAxis antiscion_axis);
GsweAntiscionAxis ag_antiscion_axis_nick_to_id(const gchar *nick);
GFile *ag_get_user_data_dir(void); GFile *ag_get_user_data_dir(void);
#ifndef GDOUBLE_FROM_LE #ifndef GDOUBLE_FROM_LE