diff options
author | Richard Hughes <richard@hughsie.com> | 2014-03-26 09:57:15 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-03-26 10:29:30 +0000 |
commit | 3abaa8d97a63ba8d9a161e5eb5d7b0678045b978 (patch) | |
tree | 1367b91b6645c5981d89653f385796f5044e9837 /libappstream-glib/as-tag.c | |
parent | 506209b6b97c7940f02cd2c2fd1be33a767340aa (diff) | |
download | appstream-glib-3abaa8d97a63ba8d9a161e5eb5d7b0678045b978.tar.gz |
Add as_tag_from_string_full()
Diffstat (limited to 'libappstream-glib/as-tag.c')
-rw-r--r-- | libappstream-glib/as-tag.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c index 6c463ef..7d87386 100644 --- a/libappstream-glib/as-tag.c +++ b/libappstream-glib/as-tag.c @@ -54,6 +54,23 @@ AsTag as_tag_from_string (const gchar *tag) { + return as_tag_from_string_full (tag, AS_TAG_FLAG_NONE); +} + +/** + * as_tag_from_string_full: + * @tag: the string. + * + * Converts the text representation to an enumerated value also converting + * legacy key names. + * + * Returns: a %AsTag, or %AS_TAG_UNKNOWN if not known. + * + * Since: 0.1.2 + **/ +AsTag +as_tag_from_string_full (const gchar *tag, AsTagFlags flags) +{ #ifdef HAVE_GPERF const struct tag_data *ky; #else @@ -76,16 +93,18 @@ as_tag_from_string (const gchar *tag) #endif /* deprecated names */ - if (g_strcmp0 (tag, "appcategories") == 0) - etag = AS_TAG_CATEGORIES; - if (g_strcmp0 (tag, "appcategory") == 0) - etag = AS_TAG_CATEGORY; - if (g_strcmp0 (tag, "licence") == 0) - etag = AS_TAG_PROJECT_LICENSE; - if (g_strcmp0 (tag, "applications") == 0) - etag = AS_TAG_APPLICATIONS; - if (g_strcmp0 (tag, "application") == 0) - etag = AS_TAG_APPLICATION; + if (etag == AS_TAG_UNKNOWN && (flags & AS_TAG_FLAG_USE_FALLBACKS)) { + if (g_strcmp0 (tag, "appcategories") == 0) + return AS_TAG_CATEGORIES; + if (g_strcmp0 (tag, "appcategory") == 0) + return AS_TAG_CATEGORY; + if (g_strcmp0 (tag, "licence") == 0) + return AS_TAG_PROJECT_LICENSE; + if (g_strcmp0 (tag, "applications") == 0) + return AS_TAG_APPLICATIONS; + if (g_strcmp0 (tag, "application") == 0) + return AS_TAG_APPLICATION; + } return etag; } |