add some macros to access the EBML ID/Context and use them
git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@14 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
@@ -144,6 +144,11 @@ class EBML_DLL_API EbmlSemanticContext {
|
|||||||
const EbmlCallbacks *MasterElt;
|
const EbmlCallbacks *MasterElt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EBML_INFO(ref) ref::ClassInfos
|
||||||
|
#define EBML_ID(ref) ref::ClassInfos.GlobalId
|
||||||
|
#define EBML_CONTEXT(e) e->Generic().Context
|
||||||
|
#define EBML_NAME(e) e->Generic().DebugName
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class EbmlElement
|
\class EbmlElement
|
||||||
\brief Hold basic informations about an EBML element (ID + length)
|
\brief Hold basic informations about an EBML element (ID + length)
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class EBML_DLL_API EbmlMaster : public EbmlElement {
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type & GetChild(EbmlMaster & Master)
|
Type & GetChild(EbmlMaster & Master)
|
||||||
{
|
{
|
||||||
return *(static_cast<Type *>(Master.FindFirstElt(Type::ClassInfos, true)));
|
return *(static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), true)));
|
||||||
}
|
}
|
||||||
// call with
|
// call with
|
||||||
// MyDocType = GetChild<EDocType>(TestHead);
|
// MyDocType = GetChild<EDocType>(TestHead);
|
||||||
@@ -191,7 +191,7 @@ Type & GetChild(EbmlMaster & Master)
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type * FindChild(EbmlMaster & Master)
|
Type * FindChild(EbmlMaster & Master)
|
||||||
{
|
{
|
||||||
return static_cast<Type *>(Master.FindFirstElt(Type::ClassInfos, false));
|
return static_cast<Type *>(Master.FindFirstElt(EBML_INFO(Type), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
@@ -203,7 +203,7 @@ Type & GetNextChild(EbmlMaster & Master, const Type & PastElt)
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
Type & AddNewChild(EbmlMaster & Master)
|
Type & AddNewChild(EbmlMaster & Master)
|
||||||
{
|
{
|
||||||
return *(static_cast<Type *>(Master.AddNewElt(Type::ClassInfos)));
|
return *(static_cast<Type *>(Master.AddNewElt(EBML_INFO(Type))));
|
||||||
}
|
}
|
||||||
|
|
||||||
END_LIBEBML_NAMESPACE
|
END_LIBEBML_NAMESPACE
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ START_LIBEBML_NAMESPACE
|
|||||||
|
|
||||||
const EbmlSemantic EbmlGlobal_ContextList[2] =
|
const EbmlSemantic EbmlGlobal_ContextList[2] =
|
||||||
{
|
{
|
||||||
EbmlSemantic(false, false, EbmlCrc32::ClassInfos), ///< EbmlCrc32
|
EbmlSemantic(false, false, EBML_INFO(EbmlCrc32)), ///< EbmlCrc32
|
||||||
EbmlSemantic(false, false, EbmlVoid::ClassInfos), ///< EbmlVoid
|
EbmlSemantic(false, false, EBML_INFO(EbmlVoid)), ///< EbmlVoid
|
||||||
};
|
};
|
||||||
|
|
||||||
const EbmlSemanticContext EbmlVoid_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, NULL);
|
const EbmlSemanticContext EbmlVoid_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, NULL);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
START_LIBEBML_NAMESPACE
|
START_LIBEBML_NAMESPACE
|
||||||
|
|
||||||
const EbmlId EbmlDummy::DummyRawId(0xFF, 1);
|
const EbmlId EbmlDummy::DummyRawId(0xFF, 1);
|
||||||
const EbmlSemanticContext EbmlDummy_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, &EbmlDummy::ClassInfos);
|
const EbmlSemanticContext EbmlDummy_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlDummy));
|
||||||
const EbmlCallbacks EbmlDummy::ClassInfos(NULL, DummyRawId, "DummyElement", EbmlDummy_Context);
|
const EbmlCallbacks EbmlDummy::ClassInfos(NULL, DummyRawId, "DummyElement", EbmlDummy_Context);
|
||||||
|
|
||||||
END_LIBEBML_NAMESPACE
|
END_LIBEBML_NAMESPACE
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ START_LIBEBML_NAMESPACE
|
|||||||
|
|
||||||
const EbmlSemantic EbmlHead_ContextList[] =
|
const EbmlSemantic EbmlHead_ContextList[] =
|
||||||
{
|
{
|
||||||
EbmlSemantic(true, true, EVersion::ClassInfos), ///< EBMLVersion
|
EbmlSemantic(true, true, EBML_INFO(EVersion)), ///< EBMLVersion
|
||||||
EbmlSemantic(true, true, EReadVersion::ClassInfos), ///< EBMLReadVersion
|
EbmlSemantic(true, true, EBML_INFO(EReadVersion)), ///< EBMLReadVersion
|
||||||
EbmlSemantic(true, true, EMaxIdLength::ClassInfos), ///< EBMLMaxIdLength
|
EbmlSemantic(true, true, EBML_INFO(EMaxIdLength)), ///< EBMLMaxIdLength
|
||||||
EbmlSemantic(true, true, EMaxSizeLength::ClassInfos), ///< EBMLMaxSizeLength
|
EbmlSemantic(true, true, EBML_INFO(EMaxSizeLength)), ///< EBMLMaxSizeLength
|
||||||
EbmlSemantic(true, true, EDocType::ClassInfos), ///< DocType
|
EbmlSemantic(true, true, EBML_INFO(EDocType)), ///< DocType
|
||||||
EbmlSemantic(true, true, EDocTypeVersion::ClassInfos), ///< DocTypeVersion
|
EbmlSemantic(true, true, EBML_INFO(EDocTypeVersion)), ///< DocTypeVersion
|
||||||
EbmlSemantic(true, true, EDocTypeReadVersion::ClassInfos), ///< DocTypeReadVersion
|
EbmlSemantic(true, true, EBML_INFO(EDocTypeReadVersion)), ///< DocTypeReadVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
const EbmlSemanticContext EbmlHead_Context = EbmlSemanticContext(countof(EbmlHead_ContextList), EbmlHead_ContextList, NULL, *GetEbmlGlobal_Context, &EbmlHead::ClassInfos);
|
const EbmlSemanticContext EbmlHead_Context = EbmlSemanticContext(countof(EbmlHead_ContextList), EbmlHead_ContextList, NULL, *GetEbmlGlobal_Context, &EBML_INFO(EbmlHead));
|
||||||
|
|
||||||
EbmlId EbmlHead_TheId(0x1A45DFA3, 4);
|
EbmlId EbmlHead_TheId(0x1A45DFA3, 4);
|
||||||
const EbmlCallbacks EbmlHead::ClassInfos(EbmlHead::Create, EbmlHead_TheId, "EBMLHead\0ratamapaga", EbmlHead_Context);
|
const EbmlCallbacks EbmlHead::ClassInfos(EbmlHead::Create, EbmlHead_TheId, "EBMLHead\0ratamapaga", EbmlHead_Context);
|
||||||
|
|||||||
@@ -227,9 +227,9 @@ std::vector<std::string> EbmlMaster::FindAllMissingElements()
|
|||||||
if (!childElement->ValueIsSet()) {
|
if (!childElement->ValueIsSet()) {
|
||||||
std::string missingValue;
|
std::string missingValue;
|
||||||
missingValue = "The Child Element \"";
|
missingValue = "The Child Element \"";
|
||||||
missingValue.append(childElement->Generic().DebugName);
|
missingValue.append(EBML_NAME(childElement));
|
||||||
missingValue.append("\" of EbmlMaster \"");
|
missingValue.append("\" of EbmlMaster \"");
|
||||||
missingValue.append(this->Generic().DebugName);
|
missingValue.append(EBML_NAME(this));
|
||||||
missingValue.append("\", does not have a value set.");
|
missingValue.append("\", does not have a value set.");
|
||||||
missingElements.push_back(missingValue);
|
missingElements.push_back(missingValue);
|
||||||
}
|
}
|
||||||
@@ -424,10 +424,10 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo
|
|||||||
// more logical to do it afterward
|
// more logical to do it afterward
|
||||||
ElementList.push_back(ElementLevelA);
|
ElementList.push_back(ElementLevelA);
|
||||||
|
|
||||||
ElementLevelA->Read(inDataStream, ElementLevelA->Generic().Context, UpperEltFound, FoundElt, AllowDummyElt, ReadFully);
|
ElementLevelA->Read(inDataStream, EBML_CONTEXT(ElementLevelA), UpperEltFound, FoundElt, AllowDummyElt, ReadFully);
|
||||||
|
|
||||||
// just in case
|
// just in case
|
||||||
ElementLevelA->SkipData(inDataStream, ElementLevelA->Generic().Context);
|
ElementLevelA->SkipData(inDataStream, EBML_CONTEXT(ElementLevelA));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UpperEltFound > 0) {
|
if (UpperEltFound > 0) {
|
||||||
@@ -456,7 +456,7 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo
|
|||||||
}
|
}
|
||||||
processCrc:
|
processCrc:
|
||||||
for (Index=0; Index<ElementList.size(); Index++) {
|
for (Index=0; Index<ElementList.size(); Index++) {
|
||||||
if ((EbmlId)(*ElementList[Index]) == EbmlCrc32::ClassInfos.GlobalId) {
|
if ((EbmlId)(*ElementList[Index]) == EBML_ID(EbmlCrc32)) {
|
||||||
bChecksumUsed = true;
|
bChecksumUsed = true;
|
||||||
// remove the element
|
// remove the element
|
||||||
Checksum = *(static_cast<EbmlCrc32*>(ElementList[Index]));
|
Checksum = *(static_cast<EbmlCrc32*>(ElementList[Index]));
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ const EbmlCallbacks EDocType::ClassInfos(EDocType::Create, EDocTyp
|
|||||||
const EbmlCallbacks EDocTypeVersion::ClassInfos(EDocTypeVersion::Create, EDocTypeVersion_TheId, "EBMLDocTypeVersion", EDocTypeVersion_Context);
|
const EbmlCallbacks EDocTypeVersion::ClassInfos(EDocTypeVersion::Create, EDocTypeVersion_TheId, "EBMLDocTypeVersion", EDocTypeVersion_Context);
|
||||||
const EbmlCallbacks EDocTypeReadVersion::ClassInfos(EDocTypeReadVersion::Create, EDocTypeReadVersion_TheId, "EBMLDocTypeReadVersion", EDocTypeReadVersion_Context);
|
const EbmlCallbacks EDocTypeReadVersion::ClassInfos(EDocTypeReadVersion::Create, EDocTypeReadVersion_TheId, "EBMLDocTypeReadVersion", EDocTypeReadVersion_Context);
|
||||||
|
|
||||||
const EbmlSemanticContext EVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EVersion::ClassInfos);
|
const EbmlSemanticContext EVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EVersion));
|
||||||
const EbmlSemanticContext EReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EReadVersion::ClassInfos);
|
const EbmlSemanticContext EReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EReadVersion));
|
||||||
const EbmlSemanticContext EMaxIdLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EMaxIdLength::ClassInfos);
|
const EbmlSemanticContext EMaxIdLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EMaxIdLength));
|
||||||
const EbmlSemanticContext EMaxSizeLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EMaxSizeLength::ClassInfos);
|
const EbmlSemanticContext EMaxSizeLength_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EMaxSizeLength));
|
||||||
const EbmlSemanticContext EDocType_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocType::ClassInfos);
|
const EbmlSemanticContext EDocType_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EDocType));
|
||||||
const EbmlSemanticContext EDocTypeVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocTypeVersion::ClassInfos);
|
const EbmlSemanticContext EDocTypeVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EDocTypeVersion));
|
||||||
const EbmlSemanticContext EDocTypeReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EDocTypeReadVersion::ClassInfos);
|
const EbmlSemanticContext EDocTypeReadVersion_Context = EbmlSemanticContext(0, NULL, &EbmlHead_Context, *GetEbmlGlobal_Context, &EBML_INFO(EDocTypeReadVersion));
|
||||||
|
|
||||||
END_LIBEBML_NAMESPACE
|
END_LIBEBML_NAMESPACE
|
||||||
|
|||||||
Reference in New Issue
Block a user