tag: added tag_get_value()
This commit is contained in:
12
src/tag.c
12
src/tag.c
@ -365,16 +365,22 @@ tag_merge(const struct tag *base, const struct tag *add)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tag_has_type(const struct tag *tag, enum tag_type type)
|
const char *
|
||||||
|
tag_get_value(const struct tag *tag, enum tag_type type)
|
||||||
{
|
{
|
||||||
assert(tag != NULL);
|
assert(tag != NULL);
|
||||||
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
||||||
|
|
||||||
for (unsigned i = 0; i < tag->numOfItems; i++)
|
for (unsigned i = 0; i < tag->numOfItems; i++)
|
||||||
if (tag->items[i]->type == type)
|
if (tag->items[i]->type == type)
|
||||||
return true;
|
return tag->items[i]->value;
|
||||||
|
|
||||||
return false;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tag_has_type(const struct tag *tag, enum tag_type type)
|
||||||
|
{
|
||||||
|
return tag_get_value(tag, type) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tag_equal(const struct tag *tag1, const struct tag *tag2)
|
int tag_equal(const struct tag *tag1, const struct tag *tag2)
|
||||||
|
@ -109,6 +109,13 @@ tag_is_empty(const struct tag *tag)
|
|||||||
return tag->numOfItems == 0;
|
return tag->numOfItems == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first value of the specified tag type, or NULL if none
|
||||||
|
* is present in this tag object.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
tag_get_value(const struct tag *tag, enum tag_type type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the tag contains one or more items with
|
* Checks whether the tag contains one or more items with
|
||||||
* the specified type.
|
* the specified type.
|
||||||
|
Reference in New Issue
Block a user