v1/v2: add support for reverse iterators
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@133 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
parent
ab093ddf20
commit
4eef9565c1
@ -44,6 +44,7 @@
|
|||||||
#include "EbmlCrc32.h"
|
#include "EbmlCrc32.h"
|
||||||
|
|
||||||
#define EBML_MASTER_ITERATOR std::vector<EbmlElement *>::const_iterator
|
#define EBML_MASTER_ITERATOR std::vector<EbmlElement *>::const_iterator
|
||||||
|
#define EBML_MASTER_RITERATOR std::vector<EbmlElement *>::const_reverse_iterator
|
||||||
|
|
||||||
START_LIBEBML_NAMESPACE
|
START_LIBEBML_NAMESPACE
|
||||||
|
|
||||||
@ -121,6 +122,8 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
|
|||||||
|
|
||||||
inline EBML_MASTER_ITERATOR begin() const {return ElementList.begin();}
|
inline EBML_MASTER_ITERATOR begin() const {return ElementList.begin();}
|
||||||
inline EBML_MASTER_ITERATOR end() const {return ElementList.end();}
|
inline EBML_MASTER_ITERATOR end() const {return ElementList.end();}
|
||||||
|
inline EBML_MASTER_RITERATOR rbegin() const {return ElementList.rbegin();}
|
||||||
|
inline EBML_MASTER_RITERATOR rend() const {return ElementList.rend();}
|
||||||
|
|
||||||
EbmlElement * operator[](unsigned int position) {return ElementList[position];}
|
EbmlElement * operator[](unsigned int position) {return ElementList[position];}
|
||||||
const EbmlElement * operator[](unsigned int position) const {return ElementList[position];}
|
const EbmlElement * operator[](unsigned int position) const {return ElementList[position];}
|
||||||
@ -141,6 +144,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
|
|||||||
*/
|
*/
|
||||||
void Remove(size_t Index);
|
void Remove(size_t Index);
|
||||||
void Remove(const EBML_MASTER_ITERATOR & Itr);
|
void Remove(const EBML_MASTER_ITERATOR & Itr);
|
||||||
|
void Remove(const EBML_MASTER_RITERATOR & Itr);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief remove all elements, even the mandatory ones
|
\brief remove all elements, even the mandatory ones
|
||||||
|
@ -455,14 +455,16 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
processCrc:
|
processCrc:
|
||||||
for (Index=0; Index<ElementList.size(); Index++) {
|
EBML_MASTER_ITERATOR Itr;
|
||||||
if ((EbmlId)(*ElementList[Index]) == EBML_ID(EbmlCrc32)) {
|
for (Itr = ElementList.begin(); Itr != ElementList.end();) {
|
||||||
|
if ((EbmlId)(*(*Itr)) == EBML_ID(EbmlCrc32)) {
|
||||||
bChecksumUsed = true;
|
bChecksumUsed = true;
|
||||||
// remove the element
|
// remove the element
|
||||||
Checksum = *(static_cast<EbmlCrc32*>(ElementList[Index]));
|
Checksum = *(static_cast<EbmlCrc32*>(*Itr));
|
||||||
delete ElementList[Index];
|
delete *Itr;
|
||||||
Remove(Index--);
|
Remove(Itr);
|
||||||
}
|
}
|
||||||
|
else ++Itr;
|
||||||
}
|
}
|
||||||
SetValueIsSet();
|
SetValueIsSet();
|
||||||
}
|
}
|
||||||
@ -473,7 +475,7 @@ void EbmlMaster::Remove(size_t Index)
|
|||||||
if (Index < ElementList.size()) {
|
if (Index < ElementList.size()) {
|
||||||
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
||||||
while (Index-- > 0) {
|
while (Index-- > 0) {
|
||||||
Itr++;
|
++Itr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementList.erase(Itr);
|
ElementList.erase(Itr);
|
||||||
@ -485,6 +487,11 @@ void EbmlMaster::Remove(const std::vector<EbmlElement *>::const_iterator & Itr)
|
|||||||
ElementList.erase(Itr);
|
ElementList.erase(Itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EbmlMaster::Remove(const std::vector<EbmlElement *>::const_reverse_iterator & Itr)
|
||||||
|
{
|
||||||
|
ElementList.erase(Itr.base());
|
||||||
|
}
|
||||||
|
|
||||||
bool EbmlMaster::VerifyChecksum() const
|
bool EbmlMaster::VerifyChecksum() const
|
||||||
{
|
{
|
||||||
if (!bChecksumUsed)
|
if (!bChecksumUsed)
|
||||||
|
Loading…
Reference in New Issue
Block a user