add macros to access the EbmlId internal variables

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@15 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme
2010-03-15 16:08:31 +00:00
parent cd378f23ff
commit de3185abde
4 changed files with 10 additions and 8 deletions

View File

@@ -217,7 +217,7 @@ class EBML_DLL_API EbmlElement {
virtual bool IsMaster() const {return false;} virtual bool IsMaster() const {return false;}
uint8 HeadSize() const { uint8 HeadSize() const {
return EbmlId(*this).Length + CodedSizeLength(Size, SizeLength, bSizeIsFinite); return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
} /// return the size of the head, on reading/writing } /// return the size of the head, on reading/writing
/*! /*!

View File

@@ -40,6 +40,8 @@
START_LIBEBML_NAMESPACE START_LIBEBML_NAMESPACE
#define EBML_ID_VALUE(id) id.Value
#define EBML_ID_LENGTH(id) id.Length
/*! /*!
\class EbmlId \class EbmlId
*/ */

View File

@@ -79,7 +79,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
} }
uint64 GetDataStart() const { uint64 GetDataStart() const {
return GetElementPosition() + EbmlId(*this).Length + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()); return GetElementPosition() + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize());
} }
/*! /*!

View File

@@ -415,8 +415,8 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
Result->SetSizeInfinite(); Result->SetSizeInfinite();
} }
Result->SizePosition = DataStream.getFilePointer() - SizeIdx + PossibleID.Length; Result->SizePosition = DataStream.getFilePointer() - SizeIdx + EBML_ID_LENGTH(PossibleID);
Result->ElementPosition = Result->SizePosition - PossibleID.Length; Result->ElementPosition = Result->SizePosition - EBML_ID_LENGTH(PossibleID);
// place the file at the beggining of the data // place the file at the beggining of the data
DataStream.setFilePointer(Result->SizePosition + _SizeLength); DataStream.setFilePointer(Result->SizePosition + _SizeLength);
return Result; return Result;
@@ -579,7 +579,7 @@ uint32 EbmlElement::Render(IOCallback & output, bool bKeepIntact, bool bKeepPosi
*/ */
uint32 EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact, bool bKeepPosition) uint32 EbmlElement::RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact, bool bKeepPosition)
{ {
if (EbmlId(*this).Length <= 0 || EbmlId(*this).Length > 4) if (EBML_ID_LENGTH(EbmlId(*this)) <= 0 || EBML_ID_LENGTH(EbmlId(*this)) > 4)
return 0; return 0;
UpdateSize(bKeepIntact, bForceRender); UpdateSize(bKeepIntact, bForceRender);
@@ -592,7 +592,7 @@ uint32 EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
binary FinalHead[4+8]; // Class D + 64 bits coded size binary FinalHead[4+8]; // Class D + 64 bits coded size
unsigned int FinalHeadSize; unsigned int FinalHeadSize;
FinalHeadSize = EbmlId(*this).Length; FinalHeadSize = EBML_ID_LENGTH(EbmlId(*this));
EbmlId(*this).Fill(FinalHead); EbmlId(*this).Fill(FinalHead);
int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite); int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite);
@@ -602,7 +602,7 @@ uint32 EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
output.writeFully(FinalHead, FinalHeadSize); output.writeFully(FinalHead, FinalHeadSize);
if (!bKeepPosition) { if (!bKeepPosition) {
ElementPosition = output.getFilePointer() - FinalHeadSize; ElementPosition = output.getFilePointer() - FinalHeadSize;
SizePosition = ElementPosition + EbmlId(*this).Length; SizePosition = ElementPosition + EBML_ID_LENGTH(EbmlId(*this));
} }
return FinalHeadSize; return FinalHeadSize;
@@ -612,7 +612,7 @@ uint64 EbmlElement::ElementSize(bool bKeepIntact) const
{ {
if (!bKeepIntact && IsDefaultValue()) if (!bKeepIntact && IsDefaultValue())
return 0; // won't be saved return 0; // won't be saved
return Size + EbmlId(*this).Length + CodedSizeLength(Size, SizeLength, bSizeIsFinite); return Size + EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
} }
bool EbmlElement::CompareElements(const EbmlElement *A, const EbmlElement *B) bool EbmlElement::CompareElements(const EbmlElement *A, const EbmlElement *B)