mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-12 13:14:38 +00:00
function for removing mandatory elements set to their default value
This commit is contained in:
parent
f17d44b00b
commit
9336c70c9c
@ -647,6 +647,34 @@ remove_ietf_language_elements(libebml::EbmlMaster &master) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
remove_mandatory_elements_set_to_their_default(libebml::EbmlMaster &master) {
|
||||
auto idx = 0u;
|
||||
|
||||
while (idx < master.ListSize()) {
|
||||
auto child = master[idx];
|
||||
|
||||
if (dynamic_cast<libebml::EbmlMaster *>(child)) {
|
||||
remove_mandatory_elements_set_to_their_default(*static_cast<libebml::EbmlMaster *>(child));
|
||||
++idx;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!child->IsDefaultValue()) {
|
||||
++idx;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto semantic = find_ebml_semantic(KaxSegment::ClassInfos, libebml::EbmlId(*child));
|
||||
|
||||
if (!semantic || !semantic->IsMandatory())
|
||||
++idx;
|
||||
else {
|
||||
delete child;
|
||||
master.Remove(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
must_be_present_in_master_by_id(EbmlId const &id) {
|
||||
|
@ -410,6 +410,7 @@ void remove_voids_from_master(libebml::EbmlElement *element);
|
||||
void move_children(libebml::EbmlMaster &source, libebml::EbmlMaster &destination);
|
||||
bool remove_master_from_parent_if_empty_or_only_defaults(libebml::EbmlMaster *parent, libebml::EbmlMaster *child, std::unordered_map<libebml::EbmlMaster *, bool> &handled);
|
||||
void remove_ietf_language_elements(libebml::EbmlMaster &master);
|
||||
void remove_mandatory_elements_set_to_their_default(libebml::EbmlMaster &master);
|
||||
|
||||
const libebml::EbmlCallbacks *find_ebml_callbacks(const libebml::EbmlCallbacks &base, const libebml::EbmlId &id);
|
||||
const libebml::EbmlCallbacks *find_ebml_callbacks(const libebml::EbmlCallbacks &base, const char *debug_name);
|
||||
|
Loading…
Reference in New Issue
Block a user