Tag: add methods RemoveAll(), RemoveType()
This commit is contained in:
parent
c6ef0e8887
commit
20ebacf489
@ -223,3 +223,23 @@ Tag::AddItem(TagType type, const char *value)
|
|||||||
{
|
{
|
||||||
AddItem(type, value, strlen(value));
|
AddItem(type, value, strlen(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Tag::RemoveType(TagType type)
|
||||||
|
{
|
||||||
|
auto dest = items, src = items, end = items + num_items;
|
||||||
|
|
||||||
|
tag_pool_lock.lock();
|
||||||
|
while (src != end) {
|
||||||
|
TagItem *item = *src++;
|
||||||
|
if (item->type == type)
|
||||||
|
/* remove it */
|
||||||
|
tag_pool_put_item(item);
|
||||||
|
else
|
||||||
|
/* keep it */
|
||||||
|
*dest++ = item;
|
||||||
|
}
|
||||||
|
tag_pool_lock.unlock();
|
||||||
|
|
||||||
|
num_items = dest - items;
|
||||||
|
}
|
||||||
|
@ -121,6 +121,18 @@ struct Tag {
|
|||||||
*/
|
*/
|
||||||
void AddItem(TagType type, const char *value);
|
void AddItem(TagType type, const char *value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all tag items.
|
||||||
|
*/
|
||||||
|
void RemoveAll() {
|
||||||
|
num_items = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all tag items of the specified type.
|
||||||
|
*/
|
||||||
|
void RemoveType(TagType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges the data from two tags. If both tags share data for the
|
* Merges the data from two tags. If both tags share data for the
|
||||||
* same TagType, only data from "add" is used.
|
* same TagType, only data from "add" is used.
|
||||||
|
Loading…
Reference in New Issue
Block a user