Added: #1440 Unparser for DllDirectory

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 33f548341a
commit 93365f8618

@ -75,6 +75,11 @@ void CClassData::build(uint16 version)
CStorageContainer::build(version);
}
void CClassData::disown()
{
CStorageContainer::disown();
}
IStorageObject *CClassData::createChunkById(uint16 id, bool container)
{
if (container)
@ -122,6 +127,11 @@ void CClassDataEntry::build(uint16 version)
CStorageContainer::build(version);
}
void CClassDataEntry::disown()
{
CStorageContainer::disown();
}
IStorageObject *CClassDataEntry::createChunkById(uint16 id, bool container)
{
if (!container)

@ -58,6 +58,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -81,6 +82,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);

@ -75,6 +75,11 @@ void CClassDirectory3::build(uint16 version)
CStorageContainer::build(version);
}
void CClassDirectory3::disown()
{
CStorageContainer::disown();
}
IStorageObject *CClassDirectory3::createChunkById(uint16 id, bool container)
{
if (container)
@ -122,6 +127,11 @@ void CClassEntry::build(uint16 version)
CStorageContainer::build(version);
}
void CClassEntry::disown()
{
CStorageContainer::disown();
}
IStorageObject *CClassEntry::createChunkById(uint16 id, bool container)
{
if (!container)

@ -58,6 +58,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -81,6 +82,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);

@ -76,6 +76,11 @@ void CConfig::build(uint16 version)
CStorageContainer::build(version);
}
void CConfig::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfig::createChunkById(uint16 id, bool container)
{
if (container)
@ -133,6 +138,11 @@ void CConfig20a0::build(uint16 version)
CStorageContainer::build(version);
}
void CConfig20a0::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfig20a0::createChunkById(uint16 id, bool container)
{
if (container)
@ -188,6 +198,11 @@ void CConfig20a0Entry::build(uint16 version)
CStorageContainer::build(version);
}
void CConfig20a0Entry::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfig20a0Entry::createChunkById(uint16 id, bool container)
{
if (container)
@ -270,6 +285,11 @@ void CConfigScript::build(uint16 version)
CStorageContainer::build(version);
}
void CConfigScript::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfigScript::createChunkById(uint16 id, bool container)
{
if (container)
@ -317,6 +337,11 @@ void CConfigScriptEntry::build(uint16 version)
CStorageContainer::build(version);
}
void CConfigScriptEntry::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfigScriptEntry::createChunkById(uint16 id, bool container)
{
if (container)
@ -405,6 +430,11 @@ void CConfigScriptMetaContainer::build(uint16 version)
CStorageContainer::build(version);
}
void CConfigScriptMetaContainer::disown()
{
CStorageContainer::disown();
}
IStorageObject *CConfigScriptMetaContainer::createChunkById(uint16 id, bool container)
{
if (container)

@ -58,6 +58,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -81,6 +82,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -104,6 +106,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -127,6 +130,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -150,6 +154,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -197,6 +202,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);

@ -72,7 +72,7 @@ void CDllDirectory::toString(std::ostream &ostream, const std::string &pad)
uint16 id = it->first;
switch (id)
{
case 0x2038:
case 0x2038: // DllEntry
{
uint subi = 0;
for (std::vector<CDllEntry *>::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit)
@ -109,7 +109,6 @@ void CDllDirectory::parse(uint16 version, TParseLevel level)
CStorageContainer::parse(version, level);
// Initialize
m_ParseVersion = version;
uint16 lastCached = 0xFFFF;
bool parsedDllEntry = false;
@ -144,13 +143,44 @@ void CDllDirectory::parse(uint16 version, TParseLevel level)
void CDllDirectory::build(uint16 version)
{
// TODO: Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries.
// Ensure parsed
nlassert(!ChunksOwnsPointers);
// Initialize
Chunks.clear();
// Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries.
for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it)
{
uint16 id = it->first;
switch (id)
{
case 0x2038: // DllEntry
for (std::vector<CDllEntry *>::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit)
Chunks.push_back(TStorageObjectWithId(id, (*subit)));
break;
default:
Chunks.push_back(*it);
break;
}
}
// Build the entries last
CStorageContainer::build(version);
// NOTE: Ownership remains with m_ChunkCache and m_Entries
}
void CDllDirectory::disown()
{
CStorageContainer::disown();
m_ChunkCache.clear();
m_Entries.clear();
// Ownership goes back to Chunks
ChunksOwnsPointers = true;
}
const CDllEntry *CDllDirectory::get(std::vector<CDllEntry *>::size_type idx) const
{
return m_Entries[idx];
@ -227,6 +257,14 @@ void CDllEntry::build(uint16 version)
// CStorageContainer::build(version);
}
void CDllEntry::disown()
{
// CStorageContainer::disown();
m_DllDescription = NULL;
m_DllFilename = NULL;
nlassert(ChunksOwnsPointers);
}
IStorageObject *CDllEntry::createChunkById(uint16 id, bool container)
{
if (!container)

@ -60,6 +60,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
// public
const CDllEntry *get(std::vector<CDllEntry *>::size_type idx) const;
@ -68,7 +69,6 @@ protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
private:
uint16 m_ParseVersion;
TStorageObjectContainer m_ChunkCache;
std::vector<CDllEntry *> m_Entries;
@ -91,6 +91,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
const ucstring &dllDescription() { return m_DllDescription->Value; }
const ucstring &dllFilename() { return m_DllFilename->Value; }

@ -76,6 +76,11 @@ void CScene::build(uint16 version)
CStorageContainer::build(version);
}
void CScene::disown()
{
CStorageContainer::disown();
}
IStorageObject *CScene::createChunkById(uint16 id, bool container)
{
if (container)
@ -120,6 +125,11 @@ void CSceneClassContainer::build(uint16 version)
CStorageContainer::build(version);
}
void CSceneClassContainer::disown()
{
CStorageContainer::disown();
}
IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container)
{
if (container)
@ -165,6 +175,11 @@ void CSceneClass::build(uint16 version)
CStorageContainer::build(version);
}
void CSceneClass::disown()
{
CStorageContainer::disown();
}
IStorageObject *CSceneClass::createChunkById(uint16 id, bool container)
{
return CStorageContainer::createChunkById(id, container);

@ -61,6 +61,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -84,6 +85,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
@ -109,6 +111,7 @@ public:
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void build(uint16 version);
virtual void disown();
// static const
static const ucchar *DisplayName;

@ -191,6 +191,17 @@ void CStorageContainer::build(uint16 version)
}
}
void CStorageContainer::disown()
{
for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it)
{
if (it->second->isContainer())
{
static_cast<CStorageContainer *>(it->second)->disown();
}
}
}
bool CStorageContainer::isContainer() const
{
return true;

@ -122,6 +122,8 @@ public:
virtual void parse(uint16 version, TParseLevel level);
// Build the storage structure needed to store the parsed data back
virtual void build(uint16 version);
// Give ownership of the chunks back to the Chunks, must build first
virtual void disown();
public: // should be protected but that doesn't compile, nice c++!
// inherited

@ -88,6 +88,10 @@ int main(int argc, char **argv)
dllDirectory.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL);
dllDirectory.toString(std::cout);
std::cout << "\n";
dllDirectory.build(PIPELINE::MAX::VersionUnknown);
dllDirectory.disown();
dllDirectory.toString(std::cout);
std::cout << "\n";
/*

Loading…
Cancel
Save