diff --git a/ebml/EbmlCrc32.h b/ebml/EbmlCrc32.h index 5b22302..9e3a3dc 100644 --- a/ebml/EbmlCrc32.h +++ b/ebml/EbmlCrc32.h @@ -54,9 +54,8 @@ const uint32 CRC32_NEGL = 0xffffffffL; # define CRC32_SHIFTED(c) (c >> 8) #endif -class EBML_DLL_API EbmlCrc32 : public EbmlBinary { +DECLARE_EBML_BINARY(EbmlCrc32) public: - EbmlCrc32(); EbmlCrc32(const EbmlCrc32 & ElementToClone); bool ValidateSize() const {return (GetSize() == 4);} filepos_t RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false); diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index d1ecc2f..5d229e1 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -97,6 +97,30 @@ extern const EbmlSemanticContext Context_EbmlGlobal; const EbmlId Id_##x (id, idl); \ const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ + x::x() {} + +#define DEFINE_xxx_CLASS_CUS(x,id,idl,parent,name,global) \ + const EbmlId Id_##x (id, idl); \ + const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ + const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); + +#define DEFINE_xxx_UINTEGER_DEF(x,id,idl,parent,name,global,defval) \ + const EbmlId Id_##x (id, idl); \ + const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ + const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ + x::x() :EbmlUInteger(defval) {} + +#define DEFINE_xxx_STRING_DEF(x,id,idl,parent,name,global,defval) \ + const EbmlId Id_##x (id, idl); \ + const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ + const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ + x::x() :EbmlString(defval) {} + +#define DEFINE_xxx_FLOAT_DEF(x,id,idl,parent,name,global,defval) \ + const EbmlId Id_##x (id, idl); \ + const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, &Context_##parent, global, &EBML_INFO(x)); \ + const EbmlCallbacks x::ClassInfos(x::Create, Id_##x, name, Context_##x); \ + x::x() :EbmlFloat(defval) {} #define DEFINE_xxx_CLASS_GLOBAL(x,id,idl,name,global) \ const EbmlId Id_##x (id, idl); \ @@ -107,13 +131,27 @@ extern const EbmlSemanticContext Context_EbmlGlobal; const EbmlSemanticContext Context_##x = EbmlSemanticContext(0, NULL, NULL, global, &EBML_INFO(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_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_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_ORPHAN(x,id,idl,name) DEFINE_xxx_CLASS_ORPHAN(x,id,idl,name,*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_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_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_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 DECLARE_EBML_MASTER(x) class EBML_DLL_API x : public EbmlMaster { \ + public: \ + x(); +#define DECLARE_EBML_UINTEGER(x) class EBML_DLL_API x : public EbmlUInteger { \ + public: \ + x(); +#define DECLARE_EBML_STRING(x) class EBML_DLL_API x : public EbmlString { \ + public: \ + x(); +#define DECLARE_EBML_BINARY(x) class EBML_DLL_API x : public EbmlBinary { \ + public: \ + x(); #if defined(EBML_STRICT_API) #define EBML_CONCRETE_CLASS(Type) \ diff --git a/ebml/EbmlHead.h b/ebml/EbmlHead.h index 9e6af48..cbe9186 100644 --- a/ebml/EbmlHead.h +++ b/ebml/EbmlHead.h @@ -41,9 +41,8 @@ START_LIBEBML_NAMESPACE -class EBML_DLL_API EbmlHead : public EbmlMaster { +DECLARE_EBML_MASTER(EbmlHead) public: - EbmlHead(); EbmlHead(const EbmlHead & ElementToClone) : EbmlMaster(ElementToClone) {} EBML_CONCRETE_CLASS(EbmlHead) diff --git a/ebml/EbmlSubHead.h b/ebml/EbmlSubHead.h index 0615b42..f842f2c 100644 --- a/ebml/EbmlSubHead.h +++ b/ebml/EbmlSubHead.h @@ -43,57 +43,50 @@ START_LIBEBML_NAMESPACE -class EBML_DLL_API EVersion : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EVersion) public: - EVersion() :EbmlUInteger(1) {} EVersion(const EVersion & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EVersion) }; -class EBML_DLL_API EReadVersion : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EReadVersion) public: - EReadVersion() :EbmlUInteger(1) {} EReadVersion(const EReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EReadVersion) }; -class EBML_DLL_API EMaxIdLength : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EMaxIdLength) public: - EMaxIdLength() :EbmlUInteger(4) {} EMaxIdLength(const EMaxIdLength & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EMaxIdLength) }; -class EBML_DLL_API EMaxSizeLength : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EMaxSizeLength) public: - EMaxSizeLength() :EbmlUInteger(8) {} EMaxSizeLength(const EMaxSizeLength & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EMaxSizeLength) }; -class EBML_DLL_API EDocType : public EbmlString { +DECLARE_EBML_STRING(EDocType) public: - EDocType() {} EDocType(const EDocType & ElementToClone) : EbmlString(ElementToClone) {} EBML_CONCRETE_CLASS(EDocType) }; -class EBML_DLL_API EDocTypeVersion : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EDocTypeVersion) public: - EDocTypeVersion() {} EDocTypeVersion(const EDocTypeVersion & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EDocTypeVersion) }; -class EBML_DLL_API EDocTypeReadVersion : public EbmlUInteger { +DECLARE_EBML_UINTEGER(EDocTypeReadVersion) public: - EDocTypeReadVersion() {} EDocTypeReadVersion(const EDocTypeReadVersion & ElementToClone) : EbmlUInteger(ElementToClone) {} EBML_CONCRETE_CLASS(EDocTypeReadVersion) diff --git a/ebml/EbmlVoid.h b/ebml/EbmlVoid.h index 0d59f03..4c2745a 100644 --- a/ebml/EbmlVoid.h +++ b/ebml/EbmlVoid.h @@ -41,9 +41,8 @@ START_LIBEBML_NAMESPACE -class EBML_DLL_API EbmlVoid : public EbmlBinary { +DECLARE_EBML_BINARY(EbmlVoid) public: - EbmlVoid(); EbmlVoid(const EbmlVoid & ElementToClone) :EbmlBinary(ElementToClone){} bool ValidateSize() const {return true;} // any void element is accepted diff --git a/src/EbmlSubHead.cpp b/src/EbmlSubHead.cpp index 48adb69..f642434 100644 --- a/src/EbmlSubHead.cpp +++ b/src/EbmlSubHead.cpp @@ -38,12 +38,12 @@ START_LIBEBML_NAMESPACE -DEFINE_EBML_CLASS(EVersion, 0x4286, 2, EbmlHead, "EBMLVersion"); -DEFINE_EBML_CLASS(EReadVersion, 0x42F7, 2, EbmlHead, "EBMLReadVersion"); -DEFINE_EBML_CLASS(EMaxIdLength, 0x42F2, 2, EbmlHead, "EBMLMaxIdLength"); -DEFINE_EBML_CLASS(EMaxSizeLength, 0x42F3, 2, EbmlHead, "EBMLMaxSizeLength"); -DEFINE_EBML_CLASS(EDocType, 0x4282, 2, EbmlHead, "EBMLDocType"); -DEFINE_EBML_CLASS(EDocTypeVersion, 0x4287, 2, EbmlHead, "EBMLDocTypeVersion"); -DEFINE_EBML_CLASS(EDocTypeReadVersion, 0x4285, 2, EbmlHead, "EBMLDocTypeReadVersion"); +DEFINE_EBML_UINTEGER_DEF(EVersion, 0x4286, 2, EbmlHead, "EBMLVersion", 1); +DEFINE_EBML_UINTEGER_DEF(EReadVersion, 0x42F7, 2, EbmlHead, "EBMLReadVersion", 1); +DEFINE_EBML_UINTEGER_DEF(EMaxIdLength, 0x42F2, 2, EbmlHead, "EBMLMaxIdLength", 4); +DEFINE_EBML_UINTEGER_DEF(EMaxSizeLength, 0x42F3, 2, EbmlHead, "EBMLMaxSizeLength", 8); +DEFINE_EBML_STRING_DEF (EDocType, 0x4282, 2, EbmlHead, "EBMLDocType", "matroska"); +DEFINE_EBML_UINTEGER_DEF(EDocTypeVersion, 0x4287, 2, EbmlHead, "EBMLDocTypeVersion", 1); +DEFINE_EBML_UINTEGER_DEF(EDocTypeReadVersion, 0x4285, 2, EbmlHead, "EBMLDocTypeReadVersion", 1); END_LIBEBML_NAMESPACE