more macro to simplify the class declaration

put the default value constructor in the C++ files

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@76 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-04-06 17:16:54 +00:00
parent 7b4779fe5f
commit 2f079f185e
6 changed files with 61 additions and 33 deletions

View File

@ -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);

View File

@ -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) \

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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