Commit 8bb2da06 authored by Max Kellermann's avatar Max Kellermann

tag: added function tag_has_type()

tag_has_type() checks whether the tag contains one or more items with the specified type.
parent b9d456a0
......@@ -319,6 +319,18 @@ struct tag *tag_dup(const struct tag *tag)
return ret;
}
bool tag_has_type(const struct tag *tag, enum tag_type type)
{
assert(tag != NULL);
assert(type < TAG_NUM_OF_ITEM_TYPES);
for (unsigned i = 0; i < tag->numOfItems; i++)
if (tag->items[i]->type == type)
return true;
return false;
}
int tag_equal(const struct tag *tag1, const struct tag *tag2)
{
int i;
......
......@@ -23,6 +23,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
enum tag_type {
......@@ -88,6 +89,12 @@ static inline void tag_add_item(struct tag *tag, enum tag_type itemType,
struct tag *tag_dup(const struct tag *tag);
/**
* Checks whether the tag contains one or more items with
* the specified type.
*/
bool tag_has_type(const struct tag *tag, enum tag_type type);
int tag_equal(const struct tag *tag1, const struct tag *tag2);
#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