Commit 970b10d0 authored by Max Kellermann's avatar Max Kellermann

tag/TagTable: add lookup TagType -> name

parent 61b938d6
...@@ -51,3 +51,13 @@ tag_table_lookup_i(const struct tag_table *table, const char *name) ...@@ -51,3 +51,13 @@ tag_table_lookup_i(const struct tag_table *table, const char *name)
return TAG_NUM_OF_ITEM_TYPES; return TAG_NUM_OF_ITEM_TYPES;
} }
const char *
tag_table_lookup(const tag_table *table, TagType type)
{
for (; table->name != nullptr; ++table)
if (table->type == type)
return table->name;
return nullptr;
}
...@@ -47,4 +47,13 @@ gcc_pure ...@@ -47,4 +47,13 @@ gcc_pure
TagType TagType
tag_table_lookup_i(const tag_table *table, const char *name); tag_table_lookup_i(const tag_table *table, const char *name);
/**
* Looks up a #TagType in a tag translation table and returns its
* string representation. Returns nullptr if the specified type was
* not found in the table.
*/
gcc_pure
const char *
tag_table_lookup(const tag_table *table, TagType type);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment