[Matroska-devel] EbmlMaster...

Moritz Bunkus moritz at bunkus.org
Thu Jul 24 23:12:00 CEST 2003


Hi.

Here's a solution to my problem that strangely smells like HACK, but I
don't care at the moment:

template <typename Type>Type &GetEmptyChild(EbmlMaster &master) {
  EbmlElement *e;

  e = master.FindFirstElt(Type::ClassInfos, true);
  try {
    EbmlMaster *m = &dynamic_cast<EbmlMaster &>(*e);
    if (m != NULL)
      while (m->ListSize() > 0) {
        delete (*m)[0];
        m->Remove(0);
      }
  } catch (...) {
  }

  return *(static_cast<Type *>(e));
}

template <typename Type>Type &GetNextEmptyChild(EbmlMaster &master,
                                                const Type &past_elt) {
  EbmlElement *e;

  e = master.FindNextElt(past_elt, true);
  try {
    EbmlMaster *m = &dynamic_cast<EbmlMaster &>(*e);
    if (m != NULL)
      while (m->ListSize() > 0) {
        delete (*m)[0];
        m->Remove(0);
      }
  } catch (...) {
  }

  return *(static_cast<Type *>(e));
}

I will definitely not add that to EbmlMaster.h but only use it in my
source files.

-- 
 ==> Ciao, Mosu (Moritz Bunkus)



More information about the Matroska-devel mailing list