Added: #1440 Extended parser for AppData entries

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 6f1125b97a
commit 492a1701cb

@ -142,6 +142,40 @@ void CAppData::disown()
CStorageContainer::disown();
}
const uint8 *CAppData::read(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 &size) const
{
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; }
TKey key(classId, superClassId, subId);
TMap::const_iterator it = m_Entries.find(key);
if (it == m_Entries.end()) return NULL;
size = it->second->value()->Value.size();
return &it->second->value()->Value[0];
}
uint8 *CAppData::lock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 capacity)
{
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; }
TKey key(classId, superClassId, subId);
}
void CAppData::unlock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 size)
{
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
TKey key(classId, superClassId, subId);
}
void CAppData::fill(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint8 *buffer, uint32 size)
{
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
TKey key(classId, superClassId, subId);
}
void CAppData::erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId)
{
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
TKey key(classId, superClassId, subId);
}
IStorageObject *CAppData::createChunkById(uint16 id, bool container)
{
switch (id)
@ -199,7 +233,7 @@ void CAppDataEntryKey::toString(std::ostream &ostream, const std::string &pad)
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CAppDataEntry::CAppDataEntry()
CAppDataEntry::CAppDataEntry() : m_Key(NULL), m_Value(NULL)
{
}
@ -215,28 +249,77 @@ std::string CAppDataEntry::getClassName()
}
void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad)
{
if (m_Key && m_Value)
{
ostream << "(" << getClassName() << ") [" << Chunks.size() << "] PARSED { ";
std::string padpad = pad + "\t";
ostream << "\n" << pad << "Key: ";
m_Key->toString(ostream, padpad);
ostream << "\n" << pad << "Value: ";
m_Value->toString(ostream, padpad);
ostream << "} ";
}
else
{
CStorageContainer::toString(ostream, pad);
}
}
void CAppDataEntry::parse(uint16 version, TParseLevel level)
{
CStorageContainer::parse(version, level);
if (level & PARSE_BUILTIN)
{
// CStorageContainer::parse(version, level);
// if (!ChunksOwnsPointers) { nlwarning("Already parsed"); return; }
if (Chunks.size() != 2) { nlwarning("Bad container size"); disown(); return; }
TStorageObjectContainer::iterator it = Chunks.begin();
if (it->first != NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID); disown(); return; }
m_Key = static_cast<CAppDataEntryKey *>(it->second);
++it;
if (it->first != NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID) { nlwarning("Bad id %x, expected %x", (uint32)it->first, NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID); disown(); return; }
m_Value = static_cast<CStorageRaw *>(it->second);
// ChunksOwnsPointers = false;
}
}
void CAppDataEntry::clean()
{
CStorageContainer::clean();
// CStorageContainer::clean();
// if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
// Nothing to do here!
}
void CAppDataEntry::build(uint16 version)
{
CStorageContainer::build(version);
// if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
// Nothing to do here!
// CStorageContainer::build(version);
}
void CAppDataEntry::disown()
{
CStorageContainer::disown();
// CStorageContainer::disown();
m_Key = NULL;
m_Value = NULL;
}
void CAppDataEntry::init()
{
nlassert(Chunks.size() == 0);
m_Key = new CAppDataEntryKey();
Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID, m_Key));
m_Value = new CStorageRaw();
Chunks.push_back(TStorageObjectWithId(NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID, m_Value));
}
CStorageRaw *CAppDataEntry::value()
{
return m_Value;
}
IStorageObject *CAppDataEntry::createChunkById(uint16 id, bool container)

@ -65,6 +65,7 @@ private:
bool operator>(const TKey &right) const;
bool operator==(const TKey &right) const;
};
typedef std::map<TKey, CAppDataEntry *> TMap;
public:
CAppData();
@ -94,7 +95,7 @@ protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
private:
std::map<TKey, CAppDataEntry *> m_Entries;
TMap m_Entries;
}; /* class CAppData */
@ -143,9 +144,19 @@ public:
virtual void build(uint16 version);
virtual void disown();
// public
// Initializes a new entry
void init();
// Returns the blob
CStorageRaw *value();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
private:
CAppDataEntryKey *m_Key;
CStorageRaw *m_Value;
}; /* class CAppDataEntry */
} /* namespace MAX */

@ -58,7 +58,7 @@ struct EStorageParse : public EStorage
enum TParseLevel
{
PARSE_INTERNAL = 0x00000001, // Directly parse basic class formats
// PARSE_BUILTIN = 0x00000002; // Parse all builtin classes - reserved
PARSE_BUILTIN = 0x00000002, // Parse all builtin classes
// PARSE_NELDATA = 0x00000004, // Parse all structures related to nel specific data (nel material, node properties, etcetera)
// PARSE_NEL3D = 0x00000008, // Parse classes to initialize their nel3d equivalent classes
};

@ -150,7 +150,9 @@ int main(int argc, char **argv)
g_object_unref(input);
//classDirectory3.toString(std::cout);
//std::cout << "\n";
scene.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); // parse the structure to readable data
scene.parse(PIPELINE::MAX::VersionUnknown, (PIPELINE::MAX::TParseLevel)(
PIPELINE::MAX::PARSE_INTERNAL
| PIPELINE::MAX::PARSE_BUILTIN)); // parse the structure to readable data
scene.clean(); // cleanup unused file structure
scene.toString(std::cout);
std::cout << "\n";

Loading…
Cancel
Save