Deleting all children of type T from an EbmlMaster

This commit is contained in:
Moritz Bunkus 2012-08-27 22:32:54 +02:00
parent 1509b4a549
commit a0563fb125

View File

@ -203,6 +203,24 @@ GetFirstOrNextChild(EbmlMaster *master,
return !previous_child ? GetChild<A>(*master) : GetNextChild<A>(*master, *previous_child);
}
template<typename T>
EbmlMaster *
DeleteChildren(EbmlMaster *master) {
for (auto idx = master->ListSize(); 0 < idx; --idx)
if (dynamic_cast<T *>((*master)[idx - 1])) {
delete (*master)[idx - 1];
master->Remove(idx - 1);
}
return master;
}
template<typename T>
EbmlMaster &
DeleteChildren(EbmlMaster &master) {
return *DeleteChildren<T>(&master);
}
template<typename T>
memory_cptr
find_and_clone_binary(EbmlElement &parent) {