Fix member initialization order

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@46 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Moritz Bunkus 2010-03-23 11:53:34 +00:00
parent 3171db6ec6
commit b8187152d2

View File

@ -1,375 +1,375 @@
/**************************************************************************** /****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/ ** libebml : parse EBML files, see http://embl.sourceforge.net/
** **
** <file/class description> ** <file/class description>
** **
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. ** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
** **
** This library is free software; you can redistribute it and/or ** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public ** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either ** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version. ** version 2.1 of the License, or (at your option) any later version.
** **
** This library is distributed in the hope that it will be useful, ** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details. ** Lesser General Public License for more details.
** **
** You should have received a copy of the GNU Lesser General Public ** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software ** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
** **
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information. ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
** **
** Contact license@matroska.org if any conditions of this licensing are ** Contact license@matroska.org if any conditions of this licensing are
** not clear to you. ** not clear to you.
** **
**********************************************************************/ **********************************************************************/
/*! /*!
\file \file
\version \$Id: EbmlElement.h 1232 2005-10-15 15:56:52Z robux4 $ \version \$Id: EbmlElement.h 1232 2005-10-15 15:56:52Z robux4 $
\author Steve Lhomme <robux4 @ users.sf.net> \author Steve Lhomme <robux4 @ users.sf.net>
*/ */
#ifndef LIBEBML_ELEMENT_H #ifndef LIBEBML_ELEMENT_H
#define LIBEBML_ELEMENT_H #define LIBEBML_ELEMENT_H
#include "EbmlTypes.h" #include "EbmlTypes.h"
#include "EbmlId.h" #include "EbmlId.h"
#include "IOCallback.h" #include "IOCallback.h"
START_LIBEBML_NAMESPACE START_LIBEBML_NAMESPACE
/*! /*!
\brief The size of the EBML-coded length \brief The size of the EBML-coded length
*/ */
int EBML_DLL_API CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeIsFinite = true); int EBML_DLL_API CodedSizeLength(uint64 Length, unsigned int SizeLength, bool bSizeIsFinite = true);
/*! /*!
\brief The coded value of the EBML-coded length \brief The coded value of the EBML-coded length
\note The size of OutBuffer must be 8 octets at least \note The size of OutBuffer must be 8 octets at least
*/ */
int EBML_DLL_API CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer); int EBML_DLL_API CodedValueLength(uint64 Length, int CodedSize, binary * OutBuffer);
/*! /*!
\brief Read an EBML-coded value from a buffer \brief Read an EBML-coded value from a buffer
\return the value read \return the value read
*/ */
uint64 EBML_DLL_API ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown); uint64 EBML_DLL_API ReadCodedSizeValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
/*! /*!
\brief The size of the EBML-coded signed length \brief The size of the EBML-coded signed length
*/ */
int EBML_DLL_API CodedSizeLengthSigned(int64 Length, unsigned int SizeLength); int EBML_DLL_API CodedSizeLengthSigned(int64 Length, unsigned int SizeLength);
/*! /*!
\brief The coded value of the EBML-coded signed length \brief The coded value of the EBML-coded signed length
\note the size of OutBuffer must be 8 octets at least \note the size of OutBuffer must be 8 octets at least
*/ */
int EBML_DLL_API CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer); int EBML_DLL_API CodedValueLengthSigned(int64 Length, int CodedSize, binary * OutBuffer);
/*! /*!
\brief Read a signed EBML-coded value from a buffer \brief Read a signed EBML-coded value from a buffer
\return the value read \return the value read
*/ */
int64 EBML_DLL_API ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown); int64 EBML_DLL_API ReadCodedSizeSignedValue(const binary * InBuffer, uint32 & BufferSize, uint64 & SizeUnknown);
class EbmlStream; class EbmlStream;
class EbmlSemanticContext; class EbmlSemanticContext;
class EbmlElement; class EbmlElement;
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
#define EBML_CONCRETE_CLASS(Type) \ #define EBML_CONCRETE_CLASS(Type) \
public: \ public: \
virtual const EbmlSemanticContext &Context() const {return ClassInfos.GetContext();} \ virtual const EbmlSemanticContext &Context() const {return ClassInfos.GetContext();} \
virtual const char *DebugName() const {return ClassInfos.GetName();} \ virtual const char *DebugName() const {return ClassInfos.GetName();} \
virtual operator const EbmlId &() const {return ClassInfos.ClassId();} \ virtual operator const EbmlId &() const {return ClassInfos.ClassId();} \
virtual EbmlElement & CreateElement() const {return Create();} \ virtual EbmlElement & CreateElement() const {return Create();} \
virtual EbmlElement * Clone() const { return new Type(*this); } \ virtual EbmlElement * Clone() const { return new Type(*this); } \
static EbmlElement & Create() {return *(new Type);} \ static EbmlElement & Create() {return *(new Type);} \
static const EbmlCallbacks & ClassInfo() {return ClassInfos;} \ static const EbmlCallbacks & ClassInfo() {return ClassInfos;} \
static const EbmlId & ClassId() {return ClassInfos.ClassId();} \ static const EbmlId & ClassId() {return ClassInfos.ClassId();} \
private: \ private: \
static const EbmlCallbacks ClassInfos; \ static const EbmlCallbacks ClassInfos; \
#define EBML_INFO(ref) ref::ClassInfo() #define EBML_INFO(ref) ref::ClassInfo()
#define EBML_ID(ref) ref::ClassId() #define EBML_ID(ref) ref::ClassId()
#define EBML_CONTEXT(e) (e)->Context() #define EBML_CONTEXT(e) (e)->Context()
#define EBML_NAME(e) (e)->DebugName() #define EBML_NAME(e) (e)->DebugName()
#define EBML_INFO_ID(cb) (cb).ClassId() #define EBML_INFO_ID(cb) (cb).ClassId()
#define EBML_INFO_NAME(cb) (cb).GetName() #define EBML_INFO_NAME(cb) (cb).GetName()
#define EBML_INFO_CREATE(cb) (cb).NewElement() #define EBML_INFO_CREATE(cb) (cb).NewElement()
#define EBML_INFO_CONTEXT(cb) (cb).GetContext() #define EBML_INFO_CONTEXT(cb) (cb).GetContext()
#define EBML_SEM_UNIQUE(s) (s).IsUnique() #define EBML_SEM_UNIQUE(s) (s).IsUnique()
#define EBML_SEM_INFO(s) (const EbmlCallbacks &)(s) #define EBML_SEM_INFO(s) (const EbmlCallbacks &)(s)
#define EBML_SEM_ID(s) ((const EbmlCallbacks &)(s)).ClassId() #define EBML_SEM_ID(s) ((const EbmlCallbacks &)(s)).ClassId()
#define EBML_SEM_CONTEXT(s) ((const EbmlCallbacks &)(s)).GetContext() #define EBML_SEM_CONTEXT(s) ((const EbmlCallbacks &)(s)).GetContext()
#define EBML_SEM_CREATE(s) (s).Create() #define EBML_SEM_CREATE(s) (s).Create()
#define EBML_CTX_SIZE(c) (c).GetSize() #define EBML_CTX_SIZE(c) (c).GetSize()
#define EBML_CTX_MASTER(c) (c).GetMaster() #define EBML_CTX_MASTER(c) (c).GetMaster()
#define EBML_CTX_PARENT(c) (c).Parent() #define EBML_CTX_PARENT(c) (c).Parent()
#else #else
#define EBML_CONCRETE_CLASS(Type) \ #define EBML_CONCRETE_CLASS(Type) \
public: \ public: \
virtual const EbmlCallbacks & Generic() const {return ClassInfos;} \ virtual const EbmlCallbacks & Generic() const {return ClassInfos;} \
virtual operator const EbmlId &() const {return ClassInfos.GlobalId;} \ virtual operator const EbmlId &() const {return ClassInfos.GlobalId;} \
virtual EbmlElement & CreateElement() const {return Create();} \ virtual EbmlElement & CreateElement() const {return Create();} \
virtual EbmlElement * Clone() const { return new Type(*this); } \ virtual EbmlElement * Clone() const { return new Type(*this); } \
static EbmlElement & Create() {return *(new Type);} \ static EbmlElement & Create() {return *(new Type);} \
static const EbmlCallbacks ClassInfos; \ static const EbmlCallbacks ClassInfos; \
#define EBML_INFO(ref) ref::ClassInfos #define EBML_INFO(ref) ref::ClassInfos
#define EBML_ID(ref) ref::ClassInfos.GlobalId #define EBML_ID(ref) ref::ClassInfos.GlobalId
#define EBML_CONTEXT(e) (e)->Generic().Context #define EBML_CONTEXT(e) (e)->Generic().Context
#define EBML_NAME(e) (e)->Generic().DebugName #define EBML_NAME(e) (e)->Generic().DebugName
#define EBML_INFO_ID(cb) (cb).GlobalId #define EBML_INFO_ID(cb) (cb).GlobalId
#define EBML_INFO_NAME(cb) (cb).DebugName #define EBML_INFO_NAME(cb) (cb).DebugName
#define EBML_INFO_CREATE(cb) (cb).Create() #define EBML_INFO_CREATE(cb) (cb).Create()
#define EBML_INFO_CONTEXT(cb) (cb).Context #define EBML_INFO_CONTEXT(cb) (cb).Context
#define EBML_SEM_UNIQUE(s) (s).Unique #define EBML_SEM_UNIQUE(s) (s).Unique
#define EBML_SEM_INFO(s) (s).GetCallbacks #define EBML_SEM_INFO(s) (s).GetCallbacks
#define EBML_SEM_ID(s) (s).GetCallbacks.GlobalId #define EBML_SEM_ID(s) (s).GetCallbacks.GlobalId
#define EBML_SEM_CONTEXT(s) (s).GetCallbacks.Context #define EBML_SEM_CONTEXT(s) (s).GetCallbacks.Context
#define EBML_SEM_CREATE(s) (s).Create() #define EBML_SEM_CREATE(s) (s).Create()
#define EBML_CTX_SIZE(c) (c).Size #define EBML_CTX_SIZE(c) (c).Size
#define EBML_CTX_MASTER(c) (c).MasterElt #define EBML_CTX_MASTER(c) (c).MasterElt
#define EBML_CTX_PARENT(c) (c).UpTable #define EBML_CTX_PARENT(c) (c).UpTable
#endif #endif
// functions for generic handling of data (should be static to all classes) // functions for generic handling of data (should be static to all classes)
/*! /*!
\todo Handle default value \todo Handle default value
*/ */
class EBML_DLL_API EbmlCallbacks { class EBML_DLL_API EbmlCallbacks {
public: public:
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext); EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext);
inline const EbmlId & ClassId() const { return GlobalId; } inline const EbmlId & ClassId() const { return GlobalId; }
inline const EbmlSemanticContext & GetContext() const { return Context; } inline const EbmlSemanticContext & GetContext() const { return Context; }
inline const char * GetName() const { return DebugName; } inline const char * GetName() const { return DebugName; }
inline EbmlElement & NewElement() const { return Create(); } inline EbmlElement & NewElement() const { return Create(); }
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
private: private:
#endif #endif
EbmlElement & (*Create)(); EbmlElement & (*Create)();
const EbmlId & GlobalId; const EbmlId & GlobalId;
const char * DebugName; const char * DebugName;
const EbmlSemanticContext & Context; const EbmlSemanticContext & Context;
}; };
/*! /*!
\brief contains the semantic informations for a given level and all sublevels \brief contains the semantic informations for a given level and all sublevels
\todo move the ID in the element class \todo move the ID in the element class
*/ */
class EBML_DLL_API EbmlSemantic { class EBML_DLL_API EbmlSemantic {
public: public:
EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks) EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
:Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {} :Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {}
inline bool IsMandatory() const { return Mandatory; } inline bool IsMandatory() const { return Mandatory; }
inline bool IsUnique() const { return Unique; } inline bool IsUnique() const { return Unique; }
inline EbmlElement & Create() const { return EBML_INFO_CREATE(GetCallbacks); } inline EbmlElement & Create() const { return EBML_INFO_CREATE(GetCallbacks); }
inline operator const EbmlCallbacks &() { return GetCallbacks; } inline operator const EbmlCallbacks &() { return GetCallbacks; }
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
private: private:
#endif #endif
bool Mandatory; ///< wether the element is mandatory in the context or not bool Mandatory; ///< wether the element is mandatory in the context or not
bool Unique; bool Unique;
const EbmlCallbacks & GetCallbacks; const EbmlCallbacks & GetCallbacks;
}; };
typedef const class EbmlSemanticContext & (*_GetSemanticContext)(); typedef const class EbmlSemanticContext & (*_GetSemanticContext)();
/*! /*!
Context of the element Context of the element
\todo allow more than one parent ? \todo allow more than one parent ?
*/ */
class EBML_DLL_API EbmlSemanticContext { class EBML_DLL_API EbmlSemanticContext {
public: public:
EbmlSemanticContext(size_t aSize, EbmlSemanticContext(size_t aSize,
const EbmlSemantic *aMyTable, const EbmlSemantic *aMyTable,
const EbmlSemanticContext *aUpTable, const EbmlSemanticContext *aUpTable,
const _GetSemanticContext aGetGlobalContext, const _GetSemanticContext aGetGlobalContext,
const EbmlCallbacks *aMasterElt) const EbmlCallbacks *aMasterElt)
:Size(aSize), MyTable(aMyTable), UpTable(aUpTable), : MyTable(aMyTable), GetGlobalContext(aGetGlobalContext), Size(aSize),
GetGlobalContext(aGetGlobalContext), MasterElt(aMasterElt) {} UpTable(aUpTable), MasterElt(aMasterElt) {}
bool operator!=(const EbmlSemanticContext & aElt) const { bool operator!=(const EbmlSemanticContext & aElt) const {
return ((Size != aElt.Size) || (MyTable != aElt.MyTable) || return ((Size != aElt.Size) || (MyTable != aElt.MyTable) ||
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) | (UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
(MasterElt != aElt.MasterElt)); (MasterElt != aElt.MasterElt));
} }
inline size_t GetSize() const { return Size; } inline size_t GetSize() const { return Size; }
inline const EbmlCallbacks* GetMaster() const { return MasterElt; } inline const EbmlCallbacks* GetMaster() const { return MasterElt; }
inline const EbmlSemanticContext* Parent() const { return UpTable; } inline const EbmlSemanticContext* Parent() const { return UpTable; }
const EbmlSemantic *MyTable; ///< First element in the table const EbmlSemantic *MyTable; ///< First element in the table
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
private: private:
#endif #endif
size_t Size; ///< number of elements in the table size_t Size; ///< number of elements in the table
const EbmlSemanticContext *UpTable; ///< Parent element const EbmlSemanticContext *UpTable; ///< Parent element
/// \todo replace with the global context directly /// \todo replace with the global context directly
const EbmlCallbacks *MasterElt; const EbmlCallbacks *MasterElt;
}; };
/*! /*!
\class EbmlElement \class EbmlElement
\brief Hold basic informations about an EBML element (ID + length) \brief Hold basic informations about an EBML element (ID + length)
*/ */
class EBML_DLL_API EbmlElement { class EBML_DLL_API EbmlElement {
public: public:
EbmlElement(uint64 aDefaultSize, bool bValueSet = false); EbmlElement(uint64 aDefaultSize, bool bValueSet = false);
virtual ~EbmlElement(); virtual ~EbmlElement();
/// Set the minimum length that will be used to write the element size (-1 = optimal) /// Set the minimum length that will be used to write the element size (-1 = optimal)
void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;} void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;}
int GetSizeLength() const {return SizeLength;} int GetSizeLength() const {return SizeLength;}
static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1); static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize); static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
/*! /*!
\brief find the next element with the same ID \brief find the next element with the same ID
*/ */
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize); EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize);
EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false); EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false);
/*! /*!
\brief Give a copy of the element, all data inside the element is copied \brief Give a copy of the element, all data inside the element is copied
\return NULL if there is not enough memory \return NULL if there is not enough memory
*/ */
virtual EbmlElement * Clone() const = 0; virtual EbmlElement * Clone() const = 0;
virtual operator const EbmlId &() const = 0; virtual operator const EbmlId &() const = 0;
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
virtual const char *DebugName() const = 0; virtual const char *DebugName() const = 0;
virtual const EbmlSemanticContext &Context() const = 0; virtual const EbmlSemanticContext &Context() const = 0;
#else #else
/// return the generic callback to monitor a derived class /// return the generic callback to monitor a derived class
virtual const EbmlCallbacks & Generic() const = 0; virtual const EbmlCallbacks & Generic() const = 0;
#endif #endif
virtual EbmlElement & CreateElement() const = 0; virtual EbmlElement & CreateElement() const = 0;
// by default only allow to set element as finite (override when needed) // by default only allow to set element as finite (override when needed)
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;} virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;}
virtual bool ValidateSize() const = 0; virtual bool ValidateSize() const = 0;
uint64 GetElementPosition() const { uint64 GetElementPosition() const {
return ElementPosition; return ElementPosition;
} }
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing
filepos_t Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false); filepos_t Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
virtual filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored virtual filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
virtual filepos_t GetSize() const {return Size;} /// return the size of the data stored in the element, on reading virtual filepos_t GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0; virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA); virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA);
bool IsLocked() const {return bLocked;} bool IsLocked() const {return bLocked;}
void Lock(bool bLock = true) { bLocked = bLock;} void Lock(bool bLock = true) { bLocked = bLock;}
/*! /*!
\brief default comparison for elements that can't be compared \brief default comparison for elements that can't be compared
*/ */
virtual bool operator<(const EbmlElement & EltB) const { virtual bool operator<(const EbmlElement & EltB) const {
return true; return true;
} }
static bool CompareElements(const EbmlElement *A, const EbmlElement *B); static bool CompareElements(const EbmlElement *A, const EbmlElement *B);
virtual bool IsDummy() const {return false;} virtual bool IsDummy() const {return false;}
virtual bool IsMaster() const {return false;} virtual bool IsMaster() const {return false;}
uint8 HeadSize() const { uint8 HeadSize() const {
return EBML_ID_LENGTH(EbmlId(*this)) + 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
/*! /*!
\brief Force the size of an element \brief Force the size of an element
\warning only possible if the size is "undefined" \warning only possible if the size is "undefined"
*/ */
bool ForceSize(uint64 NewSize); bool ForceSize(uint64 NewSize);
filepos_t OverwriteHead(IOCallback & output, bool bKeepPosition = false); filepos_t OverwriteHead(IOCallback & output, bool bKeepPosition = false);
/*! /*!
\brief void the content of the element (replace by EbmlVoid) \brief void the content of the element (replace by EbmlVoid)
*/ */
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false); uint32 VoidMe(IOCallback & output, bool bKeepIntact = false);
bool DefaultISset() const {return DefaultIsSet;} bool DefaultISset() const {return DefaultIsSet;}
virtual bool IsDefaultValue() const = 0; virtual bool IsDefaultValue() const = 0;
bool IsFiniteSize() const {return bSizeIsFinite;} bool IsFiniteSize() const {return bSizeIsFinite;}
/*! /*!
\brief set the default size of an element \brief set the default size of an element
*/ */
virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;} virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
bool ValueIsSet() const {return bValueIsSet;} bool ValueIsSet() const {return bValueIsSet;}
inline uint64 GetEndPosition() const { inline uint64 GetEndPosition() const {
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size; return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
} }
protected: protected:
/*! /*!
\brief find any element in the stream \brief find any element in the stream
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed \return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed
*/ */
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1); static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1);
filepos_t RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false); filepos_t RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false);
filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition); filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition);
/*! /*!
\brief prepare the data before writing them (in case it's not already done by default) \brief prepare the data before writing them (in case it's not already done by default)
*/ */
virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0; virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0;
/*! /*!
\brief special constructor for cloning \brief special constructor for cloning
*/ */
EbmlElement(const EbmlElement & ElementToClone); EbmlElement(const EbmlElement & ElementToClone);
inline uint64 GetDefaultSize() const {return DefaultSize;} inline uint64 GetDefaultSize() const {return DefaultSize;}
inline void SetSize_(uint64 aSize) {Size = aSize;} inline void SetSize_(uint64 aSize) {Size = aSize;}
inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;} inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;}
inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;} inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;}
inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;} inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;}
inline uint64 GetSizePosition() const {return SizePosition;} inline uint64 GetSizePosition() const {return SizePosition;}
#if defined(EBML_STRICT_API) #if defined(EBML_STRICT_API)
private: private:
#endif #endif
uint64 Size; ///< the size of the data to write uint64 Size; ///< the size of the data to write
uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal) uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
int SizeLength; /// the minimum size on which the size will be written (0 = optimal) int SizeLength; /// the minimum size on which the size will be written (0 = optimal)
bool bSizeIsFinite; bool bSizeIsFinite;
uint64 ElementPosition; uint64 ElementPosition;
uint64 SizePosition; uint64 SizePosition;
bool bValueIsSet; bool bValueIsSet;
bool DefaultIsSet; bool DefaultIsSet;
bool bLocked; bool bLocked;
}; };
END_LIBEBML_NAMESPACE END_LIBEBML_NAMESPACE
#endif // LIBEBML_ELEMENT_H #endif // LIBEBML_ELEMENT_H