add new ghost params necessary for libebml2

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@107 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-04-13 14:07:28 +00:00
parent 0eac10d271
commit 8bff224319

View File

@ -1,477 +1,480 @@
/**************************************************************************** /****************************************************************************
** 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;
extern const EbmlSemanticContext Context_EbmlGlobal; extern const EbmlSemanticContext Context_EbmlGlobal;
#define DEFINE_xxx_CONTEXT(x,global) \ #define DEFINE_xxx_CONTEXT(x,global) \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, NULL, global, NULL); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, NULL, global, NULL); \
#define DEFINE_xxx_MASTER(x,id,idl,parent,name,global) \ #define DEFINE_xxx_MASTER(x,id,idl,parent,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlMaster(Context_##x) {} x::x() :EbmlMaster(Context_##x) {}
#define DEFINE_xxx_MASTER_CONS(x,id,idl,parent,name,global) \ #define DEFINE_xxx_MASTER_CONS(x,id,idl,parent,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x);
#define DEFINE_xxx_MASTER_ORPHAN(x,id,idl,name,global) \ #define DEFINE_xxx_MASTER_ORPHAN(x,id,idl,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, NULL, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(countof(ContextList_##x), ContextList_##x, NULL, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
#define DEFINE_xxx_CLASS(x,id,idl,parent,name,global) \ #define DEFINE_xxx_CLASS(x,id,idl,parent,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() {} x::x() {}
#define DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \ #define DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x);
#define DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,global,defval) \ #define DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,global,defval) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlUInteger(defval) {} x::x() :EbmlUInteger(defval) {}
#define DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,global,defval) \ #define DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,global,defval) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlString(defval) {} x::x() :EbmlString(defval) {}
#define DEFINE_xxx_FLOAT_DEF(x,id,idl,parent,name,global,defval) \ #define DEFINE_xxx_FLOAT_DEF(x,id,idl,parent,name,global,defval) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
x::x() :EbmlFloat(defval) {} x::x() :EbmlFloat(defval) {}
#define DEFINE_xxx_CLASS_GLOBAL(x,id,idl,name,global) \ #define DEFINE_xxx_CLASS_GLOBAL(x,id,idl,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_EbmlGlobal); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_EbmlGlobal); \
#define DEFINE_xxx_CLASS_ORPHAN(x,id,idl,name,global) \ #define DEFINE_xxx_CLASS_ORPHAN(x,id,idl,name,global) \
const EbmlId Id_##x (id, idl); \ const EbmlId Id_##x (id, idl); \
const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, NULL, global, &EBML_INFO(x)); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, NULL, global, &EBML_INFO(x)); \
const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \
#define DEFINE_EBML_CONTEXT(x) DEFINE_xxx_CONTEXT(x,*GetEbmlGlobal_Context) #define DEFINE_EBML_CONTEXT(x) DEFINE_xxx_CONTEXT(x,*GetEbmlGlobal_Context)
#define DEFINE_EBML_MASTER(x,id,idl,parent,name) DEFINE_xxx_MASTER(x,id,idl,parent,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_MASTER(x,id,idl,parent,name) DEFINE_xxx_MASTER(x,id,idl,parent,name,*GetEbmlGlobal_Context)
#define DEFINE_EBML_MASTER_ORPHAN(x,id,idl,name) DEFINE_xxx_MASTER_ORPHAN(x,id,idl,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_MASTER_ORPHAN(x,id,idl,name) DEFINE_xxx_MASTER_ORPHAN(x,id,idl,name,*GetEbmlGlobal_Context)
#define DEFINE_EBML_CLASS(x,id,idl,parent,name) DEFINE_xxx_CLASS(x,id,idl,parent,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_CLASS(x,id,idl,parent,name) DEFINE_xxx_CLASS(x,id,idl,parent,name,*GetEbmlGlobal_Context)
#define DEFINE_EBML_CLASS_GLOBAL(x,id,idl,name) DEFINE_xxx_CLASS_GLOBAL(x,id,idl,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_CLASS_GLOBAL(x,id,idl,name) DEFINE_xxx_CLASS_GLOBAL(x,id,idl,name,*GetEbmlGlobal_Context)
#define DEFINE_EBML_CLASS_ORPHAN(x,id,idl,name) DEFINE_xxx_CLASS_ORPHAN(x,id,idl,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_CLASS_ORPHAN(x,id,idl,name) DEFINE_xxx_CLASS_ORPHAN(x,id,idl,name,*GetEbmlGlobal_Context)
#define DEFINE_EBML_UINTEGER_DEF(x,id,idl,parent,name,val) DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,*GetEbmlGlobal_Context,val) #define DEFINE_EBML_UINTEGER_DEF(x,id,idl,parent,name,val) DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,*GetEbmlGlobal_Context,val)
#define DEFINE_EBML_STRING_DEF(x,id,idl,parent,name,val) DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,*GetEbmlGlobal_Context,val) #define DEFINE_EBML_STRING_DEF(x,id,idl,parent,name,val) DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,*GetEbmlGlobal_Context,val)
#define DEFINE_EBML_BINARY_CONS(x,id,idl,parent,name) DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,*GetEbmlGlobal_Context) #define DEFINE_EBML_BINARY_CONS(x,id,idl,parent,name) DEFINE_xxx_CLASS_CONS(x,id,idl,parent,name,*GetEbmlGlobal_Context)
#define DEFINE_SEMANTIC_CONTEXT(x) #define DEFINE_SEMANTIC_CONTEXT(x)
#define DEFINE_START_SEMANTIC(x) static const EbmlSemantic ContextList_##x[] = { #define DEFINE_START_SEMANTIC(x) static const EbmlSemantic ContextList_##x[] = {
#define DEFINE_END_SEMANTIC(x) }; #define DEFINE_END_SEMANTIC(x) };
#define DEFINE_SEMANTIC_ITEM(m,u,c) EbmlSemantic(m, u, EBML_INFO(c)), #define DEFINE_SEMANTIC_ITEM(m,u,c) EbmlSemantic(m, u, EBML_INFO(c)),
#define DECLARE_EBML_MASTER(x) class EBML_DLL_API x : public EbmlMaster { \ #define DECLARE_EBML_MASTER(x) class EBML_DLL_API x : public EbmlMaster { \
public: \ public: \
x(); x();
#define DECLARE_EBML_UINTEGER(x) class EBML_DLL_API x : public EbmlUInteger { \ #define DECLARE_EBML_UINTEGER(x) class EBML_DLL_API x : public EbmlUInteger { \
public: \ public: \
x(); x();
#define DECLARE_EBML_STRING(x) class EBML_DLL_API x : public EbmlString { \ #define DECLARE_EBML_STRING(x) class EBML_DLL_API x : public EbmlString { \
public: \ public: \
x(); x();
#define DECLARE_EBML_BINARY(x) class EBML_DLL_API x : public EbmlBinary { \ #define DECLARE_EBML_BINARY(x) class EBML_DLL_API x : public EbmlBinary { \
public: \ public: \
x(); x();
#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_CLASS_SEMCONTEXT(ref) Context_##ref #define EBML_CLASS_SEMCONTEXT(ref) Context_##ref
#define EBML_CLASS_CONTEXT(ref) ref::ClassInfo().GetContext() #define EBML_CLASS_CONTEXT(ref) ref::ClassInfo().GetContext()
#define EBML_CLASS_CALLBACK(ref) ref::ClassInfo() #define EBML_CLASS_CALLBACK(ref) ref::ClassInfo()
#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_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()
#define EBML_CTX_IDX(c,i) (c).GetSemantic(i) #define EBML_CTX_IDX(c,i) (c).GetSemantic(i)
#define EBML_CTX_IDX_INFO(c,i) (const EbmlCallbacks &)((c).GetSemantic(i)) #define EBML_CTX_IDX_INFO(c,i) (const EbmlCallbacks &)((c).GetSemantic(i))
#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_CLASS_SEMCONTEXT(ref) Context_##ref #define EBML_CLASS_SEMCONTEXT(ref) Context_##ref
#define EBML_CLASS_CONTEXT(ref) ref::ClassInfos.Context #define EBML_CLASS_CONTEXT(ref) ref::ClassInfos.Context
#define EBML_CLASS_CALLBACK(ref) ref::ClassInfos #define EBML_CLASS_CALLBACK(ref) ref::ClassInfos
#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_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
#define EBML_CTX_IDX(c,i) (c).MyTable[(i)] #define EBML_CTX_IDX(c,i) (c).MyTable[(i)]
#define EBML_CTX_IDX_INFO(c,i) (c).MyTable[(i)].GetCallbacks #define EBML_CTX_IDX_INFO(c,i) (c).MyTable[(i)].GetCallbacks
#endif #endif
#define EBML_DEF_CONS #define EBML_DEF_CONS
#define EBML_DEF_SEP #define EBML_DEF_SEP
#define EBML_DEF_PARAM #define EBML_DEF_PARAM
#define EBML_DEF_BINARY_INIT #define EBML_DEF_BINARY_INIT
#define EBML_DEF_BINARY_CTX(x) #define EBML_DEF_BINARY_CTX(x)
#define EBML_DEF_SINTEGER(x) #define EBML_DEF_SINTEGER(x)
#define EBML_DEF_BINARY(x) #define EBML_DEF_BINARY(x)
#define EBML_EXTRA_PARAM
// functions for generic handling of data (should be static to all classes) #define EBML_EXTRA_CALL
/*! #define EBML_EXTRA_DEF
\todo Handle default value
*/ // functions for generic handling of data (should be static to all classes)
class EBML_DLL_API EbmlCallbacks { /*!
public: \todo Handle default value
EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext); */
class EBML_DLL_API EbmlCallbacks {
inline const EbmlId & ClassId() const { return GlobalId; } public:
inline const EbmlSemanticContext & GetContext() const { return Context; } EbmlCallbacks(EbmlElement & (*Creator)(), const EbmlId & aGlobalId, const char * aDebugName, const EbmlSemanticContext & aContext);
inline const char * GetName() const { return DebugName; }
inline EbmlElement & NewElement() const { return Create(); } inline const EbmlId & ClassId() const { return GlobalId; }
inline const EbmlSemanticContext & GetContext() const { return Context; }
#if defined(EBML_STRICT_API) inline const char * GetName() const { return DebugName; }
private: inline EbmlElement & NewElement() const { return Create(); }
#endif
EbmlElement & (*Create)(); #if defined(EBML_STRICT_API)
const EbmlId & GlobalId; private:
const char * DebugName; #endif
const EbmlSemanticContext & Context; EbmlElement & (*Create)();
}; const EbmlId & GlobalId;
const char * DebugName;
/*! const EbmlSemanticContext & Context;
\brief contains the semantic informations for a given level and all sublevels };
\todo move the ID in the element class
*/ /*!
class EBML_DLL_API EbmlSemantic { \brief contains the semantic informations for a given level and all sublevels
public: \todo move the ID in the element class
EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks) */
:Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {} class EBML_DLL_API EbmlSemantic {
public:
inline bool IsMandatory() const { return Mandatory; } EbmlSemantic(bool aMandatory, bool aUnique, const EbmlCallbacks & aGetCallbacks)
inline bool IsUnique() const { return Unique; } :Mandatory(aMandatory), Unique(aUnique), GetCallbacks(aGetCallbacks) {}
inline EbmlElement & Create() const { return EBML_INFO_CREATE(GetCallbacks); }
inline operator const EbmlCallbacks &() const { return GetCallbacks; } inline bool IsMandatory() const { return Mandatory; }
inline bool IsUnique() const { return Unique; }
#if defined(EBML_STRICT_API) inline EbmlElement & Create() const { return EBML_INFO_CREATE(GetCallbacks); }
private: inline operator const EbmlCallbacks &() const { return GetCallbacks; }
#endif
bool Mandatory; ///< wether the element is mandatory in the context or not #if defined(EBML_STRICT_API)
bool Unique; private:
const EbmlCallbacks & GetCallbacks; #endif
}; bool Mandatory; ///< wether the element is mandatory in the context or not
bool Unique;
typedef const class EbmlSemanticContext & (*_GetSemanticContext)(); const EbmlCallbacks & GetCallbacks;
};
/*!
Context of the element typedef const class EbmlSemanticContext & (*_GetSemanticContext)();
\todo allow more than one parent ?
*/ /*!
class EBML_DLL_API EbmlSemanticContext { Context of the element
public: \todo allow more than one parent ?
EbmlSemanticContext(size_t aSize, */
const EbmlSemantic *aMyTable, class EBML_DLL_API EbmlSemanticContext {
const EbmlSemanticContext *aUpTable, public:
const _GetSemanticContext aGetGlobalContext, EbmlSemanticContext(size_t aSize,
const EbmlCallbacks *aMasterElt) const EbmlSemantic *aMyTable,
: GetGlobalContext(aGetGlobalContext), MyTable(aMyTable), Size(aSize), const EbmlSemanticContext *aUpTable,
UpTable(aUpTable), MasterElt(aMasterElt) {} const _GetSemanticContext aGetGlobalContext,
const EbmlCallbacks *aMasterElt)
bool operator!=(const EbmlSemanticContext & aElt) const { : GetGlobalContext(aGetGlobalContext), MyTable(aMyTable), Size(aSize),
return ((Size != aElt.Size) || (MyTable != aElt.MyTable) || UpTable(aUpTable), MasterElt(aMasterElt) {}
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
(MasterElt != aElt.MasterElt)); bool operator!=(const EbmlSemanticContext & aElt) const {
} return ((Size != aElt.Size) || (MyTable != aElt.MyTable) ||
(UpTable != aElt.UpTable) || (GetGlobalContext != aElt.GetGlobalContext) |
inline size_t GetSize() const { return Size; } (MasterElt != aElt.MasterElt));
inline const EbmlCallbacks* GetMaster() const { return MasterElt; } }
inline const EbmlSemanticContext* Parent() const { return UpTable; }
const EbmlSemantic & GetSemantic(size_t i) const; inline size_t GetSize() const { return Size; }
inline const EbmlCallbacks* GetMaster() const { return MasterElt; }
const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level inline const EbmlSemanticContext* Parent() const { return UpTable; }
const EbmlSemantic & GetSemantic(size_t i) const;
#if defined(EBML_STRICT_API)
private: const _GetSemanticContext GetGlobalContext; ///< global elements supported at this level
#endif
const EbmlSemantic *MyTable; ///< First element in the table #if defined(EBML_STRICT_API)
size_t Size; ///< number of elements in the table private:
const EbmlSemanticContext *UpTable; ///< Parent element #endif
/// \todo replace with the global context directly const EbmlSemantic *MyTable; ///< First element in the table
const EbmlCallbacks *MasterElt; size_t Size; ///< number of elements in the table
}; const EbmlSemanticContext *UpTable; ///< Parent element
/// \todo replace with the global context directly
/*! const EbmlCallbacks *MasterElt;
\class EbmlElement };
\brief Hold basic informations about an EBML element (ID + length)
*/ /*!
class EBML_DLL_API EbmlElement { \class EbmlElement
public: \brief Hold basic informations about an EBML element (ID + length)
EbmlElement(uint64 aDefaultSize, bool bValueSet = false); */
virtual ~EbmlElement(); class EBML_DLL_API EbmlElement {
public:
/// Set the minimum length that will be used to write the element size (-1 = optimal) EbmlElement(uint64 aDefaultSize, bool bValueSet = false);
void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;} virtual ~EbmlElement();
int GetSizeLength() const {return SizeLength;}
/// Set the minimum length that will be used to write the element size (-1 = optimal)
static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1); void SetSizeLength(int NewSizeLength) {SizeLength = NewSizeLength;}
static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize); int GetSizeLength() const {return SizeLength;}
/*! static EbmlElement * FindNextElement(IOCallback & DataStream, const EbmlSemanticContext & Context, int & UpperLevel, uint64 MaxDataSize, bool AllowDummyElt, unsigned int MaxLowerLevel = 1);
\brief find the next element with the same ID static EbmlElement * FindNextID(IOCallback & DataStream, const EbmlCallbacks & ClassInfos, const uint64 MaxDataSize);
*/
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize); /*!
\brief find the next element with the same ID
EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false); */
EbmlElement * FindNext(IOCallback & DataStream, const uint64 MaxDataSize);
/*!
\brief Give a copy of the element, all data inside the element is copied EbmlElement * SkipData(EbmlStream & DataStream, const EbmlSemanticContext & Context, EbmlElement * TestReadElt = NULL, bool AllowDummyElt = false);
\return NULL if there is not enough memory
*/ /*!
virtual EbmlElement * Clone() const = 0; \brief Give a copy of the element, all data inside the element is copied
\return NULL if there is not enough memory
virtual operator const EbmlId &() const = 0; */
#if defined(EBML_STRICT_API) virtual EbmlElement * Clone() const = 0;
virtual const char *DebugName() const = 0;
virtual const EbmlSemanticContext &Context() const = 0; virtual operator const EbmlId &() const = 0;
#else #if defined(EBML_STRICT_API)
/// return the generic callback to monitor a derived class virtual const char *DebugName() const = 0;
virtual const EbmlCallbacks & Generic() const = 0; virtual const EbmlSemanticContext &Context() const = 0;
#endif #else
virtual EbmlElement & CreateElement() const = 0; /// return the generic callback to monitor a derived class
virtual const EbmlCallbacks & Generic() const = 0;
// by default only allow to set element as finite (override when needed) #endif
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;} virtual EbmlElement & CreateElement() const = 0;
virtual bool ValidateSize() const = 0; // by default only allow to set element as finite (override when needed)
virtual bool SetSizeInfinite(bool bIsInfinite = true) {return !bIsInfinite;}
uint64 GetElementPosition() const {
return ElementPosition; virtual bool ValidateSize() const = 0;
}
uint64 GetElementPosition() const {
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing return ElementPosition;
}
filepos_t Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
uint64 ElementSize(bool bKeepIntact = false) const; /// return the size of the header+data, before writing
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 filepos_t Render(IOCallback & output, bool bKeepIntact = false, bool bKeepPosition = false, bool bForceRender = false);
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0; virtual filepos_t UpdateSize(bool bKeepIntact = false, bool bForceRender = false) = 0; /// update the Size of the Data stored
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA); virtual filepos_t GetSize() const {return Size;} /// return the size of the data stored in the element, on reading
bool IsLocked() const {return bLocked;} virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
void Lock(bool bLock = true) { bLocked = bLock;} 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;}
\brief default comparison for elements that can't be compared void Lock(bool bLock = true) { bLocked = bLock;}
*/
virtual bool IsSmallerThan(const EbmlElement *Cmp) const; /*!
static bool CompareElements(const EbmlElement *A, const EbmlElement *B); \brief default comparison for elements that can't be compared
*/
virtual bool IsDummy() const {return false;} virtual bool IsSmallerThan(const EbmlElement *Cmp) const;
virtual bool IsMaster() const {return false;} static bool CompareElements(const EbmlElement *A, const EbmlElement *B);
uint8 HeadSize() const { virtual bool IsDummy() const {return false;}
return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); virtual bool IsMaster() const {return false;}
} /// return the size of the head, on reading/writing
uint8 HeadSize() const {
/*! return EBML_ID_LENGTH(EbmlId(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
\brief Force the size of an element } /// return the size of the head, on reading/writing
\warning only possible if the size is "undefined"
*/ /*!
bool ForceSize(uint64 NewSize); \brief Force the size of an element
\warning only possible if the size is "undefined"
filepos_t OverwriteHead(IOCallback & output, bool bKeepPosition = false); */
bool ForceSize(uint64 NewSize);
/*!
\brief void the content of the element (replace by EbmlVoid) filepos_t OverwriteHead(IOCallback & output, bool bKeepPosition = false);
*/
uint32 VoidMe(IOCallback & output, bool bKeepIntact = false); /*!
\brief void the content of the element (replace by EbmlVoid)
bool DefaultISset() const {return DefaultIsSet;} */
virtual bool IsDefaultValue() const = 0; uint32 VoidMe(IOCallback & output, bool bKeepIntact = false);
bool IsFiniteSize() const {return bSizeIsFinite;}
bool DefaultISset() const {return DefaultIsSet;}
/*! virtual bool IsDefaultValue() const = 0;
\brief set the default size of an element bool IsFiniteSize() const {return bSizeIsFinite;}
*/
virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;} /*!
\brief set the default size of an element
bool ValueIsSet() const {return bValueIsSet;} */
virtual void SetDefaultSize(uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
inline uint64 GetEndPosition() const {
return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size; bool ValueIsSet() const {return bValueIsSet;}
}
inline uint64 GetEndPosition() const {
protected: return SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size;
/*! }
\brief find any element in the stream
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed protected:
*/ /*!
static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1); \brief find any element in the stream
\return a DummyRawElement if the element is unknown or NULL if the element dummy is not allowed
filepos_t RenderHead(IOCallback & output, bool bForceRender, bool bKeepIntact = false, bool bKeepPosition = false); */
filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition); 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);
\brief prepare the data before writing them (in case it's not already done by default) filepos_t MakeRenderHead(IOCallback & output, bool bKeepPosition);
*/
virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0; /*!
\brief prepare the data before writing them (in case it's not already done by default)
/*! */
\brief special constructor for cloning virtual filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false) = 0;
*/
EbmlElement(const EbmlElement & ElementToClone); /*!
\brief special constructor for cloning
inline uint64 GetDefaultSize() const {return DefaultSize;} */
inline void SetSize_(uint64 aSize) {Size = aSize;} EbmlElement(const EbmlElement & ElementToClone);
inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;}
inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;} inline uint64 GetDefaultSize() const {return DefaultSize;}
inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;} inline void SetSize_(uint64 aSize) {Size = aSize;}
inline uint64 GetSizePosition() const {return SizePosition;} inline void SetValueIsSet(bool Set = true) {bValueIsSet = Set;}
inline void SetDefaultIsSet(bool Set = true) {DefaultIsSet = Set;}
#if defined(EBML_STRICT_API) inline void SetSizeIsFinite(bool Set = true) {bSizeIsFinite = Set;}
private: inline uint64 GetSizePosition() const {return SizePosition;}
#endif
uint64 Size; ///< the size of the data to write #if defined(EBML_STRICT_API)
uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal) private:
int SizeLength; /// the minimum size on which the size will be written (0 = optimal) #endif
bool bSizeIsFinite; uint64 Size; ///< the size of the data to write
uint64 ElementPosition; uint64 DefaultSize; ///< Minimum data size to fill on rendering (0 = optimal)
uint64 SizePosition; int SizeLength; /// the minimum size on which the size will be written (0 = optimal)
bool bValueIsSet; bool bSizeIsFinite;
bool DefaultIsSet; uint64 ElementPosition;
bool bLocked; uint64 SizePosition;
}; bool bValueIsSet;
bool DefaultIsSet;
END_LIBEBML_NAMESPACE bool bLocked;
};
#endif // LIBEBML_ELEMENT_H
END_LIBEBML_NAMESPACE
#endif // LIBEBML_ELEMENT_H