Added: #1440 Parser for AppData

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

@ -32,7 +32,14 @@ const CClassId CClassId::Null(0);
void CClassId::serial(NLMISC::IStream &s)
{
s.serial(Uid);
// s.serial(Uid);
// Backwards.
uint32 va = a();
uint32 vb = b();
s.serial(va);
s.serial(vb);
setA(va);
setB(vb);
}
std::string CClassId::toString() const

@ -14,8 +14,8 @@ ENDIF (NOT GLIB2_FOUND)
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${LIBGSF_INCLUDE_DIR})
FILE(GLOB SRCS *.cpp)
FILE(GLOB HDRS *.h)
FILE(GLOB SRCS *.cpp builtin/*.cpp)
FILE(GLOB HDRS *.h builtin/*.h)
NL_TARGET_LIB(pipeline_max
${SRCS}

@ -0,0 +1,263 @@
/**
* \file app_data.cpp
* \brief CAppData
* \date 2012-08-21 11:47GMT
* \author Jan Boon (Kaetemi)
* CAppData
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include "app_data.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
// Project includes
using namespace std;
// using namespace NLMISC;
namespace PIPELINE {
namespace MAX {
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#define NLMAXFILE_APP_DATA_HEADER_CHUNK_ID 0x0100
#define NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID 0x0110
#define NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID 0x0120
#define NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID 0x0130
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CAppData::TKey::TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId) : ClassId(classId), SuperClassId(superClassId), SubId(subId)
{
}
bool CAppData::TKey::operator<(const CAppData::TKey &right) const
{
if (ClassId < right.ClassId)
return true;
if (ClassId > right.ClassId)
return false;
if (SuperClassId < right.SuperClassId)
return true;
if (SuperClassId > right.SuperClassId)
return false;
if (SubId < right.SubId)
return true;
if (SubId > right.SubId)
return false;
return false;
}
bool CAppData::TKey::operator>(const CAppData::TKey &right) const
{
if (ClassId > right.ClassId)
return true;
if (ClassId < right.ClassId)
return false;
if (SuperClassId > right.SuperClassId)
return true;
if (SuperClassId < right.SuperClassId)
return false;
if (SubId > right.SubId)
return true;
if (SubId < right.SubId)
return false;
return false;
}
bool CAppData::TKey::operator==(const CAppData::TKey &right) const
{
return ClassId == right.ClassId && SuperClassId == right.SuperClassId && SubId == right.SubId;
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CAppData::CAppData()
{
}
CAppData::~CAppData()
{
}
std::string CAppData::getClassName()
{
return "AppData";
}
void CAppData::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
void CAppData::parse(uint16 version, TParseLevel level)
{
CStorageContainer::parse(version, level);
}
void CAppData::clean()
{
CStorageContainer::clean();
}
void CAppData::build(uint16 version)
{
CStorageContainer::build(version);
}
void CAppData::disown()
{
CStorageContainer::disown();
}
IStorageObject *CAppData::createChunkById(uint16 id, bool container)
{
switch (id)
{
case NLMAXFILE_APP_DATA_HEADER_CHUNK_ID:
nlassert(!container);
return new CStorageValue<uint32>();
break;
case NLMAXFILE_APP_DATA_ENTRY_CHUNK_ID:
nlassert(container);
return new CAppDataEntry();
break;
}
return CStorageContainer::createChunkById(id, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CAppDataEntryKey::CAppDataEntryKey()
{
}
CAppDataEntryKey::~CAppDataEntryKey()
{
}
std::string CAppDataEntryKey::getClassName()
{
return "AppDataEntryKey";
}
void CAppDataEntryKey::serial(NLMISC::IStream &stream)
{
stream.serial(ClassId);
stream.serial(SuperClassId);
stream.serial(SubId);
stream.serial(Size);
}
void CAppDataEntryKey::toString(std::ostream &ostream, const std::string &pad)
{
ostream << "(" << getClassName() << ") { ";
ostream << "\n" << pad << "ClassId: " << NLMISC::toString(ClassId);
ostream << "\n" << pad << "SuperClassId: " << SuperClassId;
ostream << "\n" << pad << "SubId: " << SubId;
ostream << "\n" << pad << "Size: " << Size;
ostream << " } ";
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CAppDataEntry::CAppDataEntry()
{
}
CAppDataEntry::~CAppDataEntry()
{
}
std::string CAppDataEntry::getClassName()
{
return "AppDataEntry";
}
void CAppDataEntry::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
void CAppDataEntry::parse(uint16 version, TParseLevel level)
{
CStorageContainer::parse(version, level);
}
void CAppDataEntry::clean()
{
CStorageContainer::clean();
}
void CAppDataEntry::build(uint16 version)
{
CStorageContainer::build(version);
}
void CAppDataEntry::disown()
{
CStorageContainer::disown();
}
IStorageObject *CAppDataEntry::createChunkById(uint16 id, bool container)
{
switch (id)
{
case NLMAXFILE_APP_DATA_ENTRY_KEY_CHUNK_ID:
nlassert(!container);
return new CAppDataEntryKey();
case NLMAXFILE_APP_DATA_ENTRY_VALUE_CHUNK_ID:
nlassert(!container);
return new CStorageRaw();
}
return CStorageContainer::createChunkById(id, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */

@ -0,0 +1,156 @@
/**
* \file app_data.h
* \brief CAppData
* \date 2012-08-21 11:47GMT
* \author Jan Boon (Kaetemi)
* CAppData
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_APP_DATA_H
#define PIPELINE_APP_DATA_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/misc/class_id.h>
// Project includes
#include "../typedefs.h"
#include "../storage_object.h"
#include "../storage_value.h"
namespace PIPELINE {
namespace MAX {
#define NLMAXFILE_APP_DATA_CHUNK_ID 0x2150
class CAppDataEntry;
/**
* \brief CAppData
* \date 2012-08-21 11:47GMT
* \author Jan Boon (Kaetemi)
* This implements the AppData chunk in the storage
*/
class CAppData : public CStorageContainer
{
private:
struct TKey
{
TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId);
NLMISC::CClassId ClassId;
TSClassId SuperClassId;
uint32 SubId;
bool operator<(const TKey &right) const;
bool operator>(const TKey &right) const;
bool operator==(const TKey &right) const;
};
public:
CAppData();
virtual ~CAppData();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
// public
/// Gets a pointer to an appdata chunk buffer. Returns NULL if it does not exist. Size is returned in the size parameter.
const uint8 *read(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 &size) const;
/// Locks a pointer to an appdata chunk buffer for writing to with specified capacity.
uint8 *lock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 capacity);
/// Unlocks a pointer to an appdata chunk buffer, setting the final written size.
void unlock(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 size);
/// Fills an appdata chunk buffer with specified data, which will be copied.
void fill(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint8 *buffer, uint32 size);
/// Erases an appdata chunk.
void erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId);
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
private:
std::map<TKey, CAppDataEntry *> m_Entries;
}; /* class CAppData */
/**
* \brief CAppDataEntryKey
* \date 2012-08-18 18:01GMT
* \author Jan Boon (Kaetemi)
* CAppDataEntryKey
*/
class CAppDataEntryKey : public IStorageObject
{
public:
CAppDataEntryKey();
virtual ~CAppDataEntryKey();
// public data
NLMISC::CClassId ClassId;
TSClassId SuperClassId;
uint32 SubId;
uint32 Size;
// inherited
virtual std::string getClassName();
virtual void serial(NLMISC::IStream &stream);
virtual void toString(std::ostream &ostream, const std::string &pad = "");
}; /* class CAppDataEntryKey */
/**
* \brief CAppDataEntry
* \date 2012-08-21 11:47GMT
* \author Jan Boon (Kaetemi)
* This implements an entry in the AppData chunk in the storage
*/
class CAppDataEntry : public CStorageContainer
{
public:
CAppDataEntry();
virtual ~CAppDataEntry();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
virtual void parse(uint16 version, TParseLevel level);
virtual void clean();
virtual void build(uint16 version);
virtual void disown();
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
}; /* class CAppDataEntry */
} /* namespace MAX */
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_APP_DATA_H */
/* end of file */

@ -84,7 +84,7 @@ void CScene::clean()
void CScene::build(uint16 version)
{
nlassert(Chunks.size() == 1);
CStorageContainer::build(version);
CStorageContainer::build(this->version());
}
void CScene::disown()
@ -160,7 +160,7 @@ void CSceneClassContainer::disown()
IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container)
{
nldebug("Scene class id %x (%i)", (uint32)id, (uint32)id);
// nldebug("Scene class id %x (%i)", (uint32)id, (uint32)id);
const CClassEntry *classEntry = m_ClassDirectory3->get(id);
CSceneClass *sceneClass = m_SceneClassRegistry->create(classEntry->classId());
if (sceneClass)

@ -35,6 +35,9 @@
// Project includes
// Temporary project includes
#include "builtin/app_data.h"
using namespace std;
// using namespace NLMISC;
@ -87,6 +90,12 @@ void CSceneClass::disown()
IStorageObject *CSceneClass::createChunkById(uint16 id, bool container)
{
// Temporary
switch (id)
{
case NLMAXFILE_APP_DATA_CHUNK_ID:
return new CAppData();
}
return CStorageContainer::createChunkById(id, container);
}

@ -35,6 +35,7 @@
#include <nel/misc/class_id.h>
// Project includes
#include "typedefs.h"
#include "storage_object.h"
#include "storage_value.h"
#include "dll_plugin_desc.h"
@ -42,9 +43,6 @@
namespace PIPELINE {
namespace MAX {
// Don't really care about superclass IDs right now, but we have to.
typedef uint32 TSClassId;
class ISceneClassDesc;
/**

@ -63,17 +63,6 @@ enum TParseLevel
// PARSE_NEL3D = 0x00000008, // Parse classes to initialize their nel3d equivalent classes
};
// NOTE: This is the wrong location. Make a definitions header.
const uint16 VersionUnknown = 0x0000;
const uint16 Version3 = 0x2004;
const uint16 Version4 = 0x2006;
const uint16 Version5 = 0x2008;
const uint16 Version6 = 0x2009;
const uint16 Version9 = 0x200E;
const uint16 Version2008 = 0x200F;
const uint16 Version2010 = 0x2012;
// END OF NOTE
// IStorageObject : exposes serial(CStorageStream &stream) and dump(const std::string &pad)
class IStorageObject : public NLMISC::IStreamable
{

@ -0,0 +1,49 @@
/**
* \file typedefs.cpp
* \brief CTypeDefs
* \date 2012-08-21 12:14GMT
* \author Jan Boon (Kaetemi)
* CTypeDefs
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include "typedefs.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
// Project includes
using namespace std;
// using namespace NLMISC;
namespace PIPELINE {
namespace MAX {
void blahblahblah_typedefs() { }
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */

@ -0,0 +1,61 @@
/**
* \file typedefs.h
* \brief CTypeDefs
* \date 2012-08-21 12:14GMT
* \author Jan Boon (Kaetemi)
* CTypeDefs
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* RYZOM CORE PIPELINE is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_TYPEDEFS_H
#define PIPELINE_TYPEDEFS_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
namespace PIPELINE {
namespace MAX {
// Don't really care about superclass IDs right now, but we have to.
typedef uint32 TSClassId;
// Application versions
const uint16 VersionUnknown = 0x0000;
const uint16 Version3 = 0x2004;
const uint16 Version4 = 0x2006;
const uint16 Version5 = 0x2008;
const uint16 Version6 = 0x2009;
const uint16 Version7 = 0x200A;
const uint16 Version8 = 0x200B;
const uint16 Version9 = 0x200E;
const uint16 Version2008 = 0x200F;
const uint16 Version2010 = 0x2012;
} /* namespace MAX */
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_TYPEDEFS_H */
/* end of file */

@ -36,7 +36,7 @@ static const char *streamname = "Scene";
// int __stdcall WinMain(void *, void *, void *, int)
int main(int argc, char **argv)
{
printf("Pipeline Max Dump (Temporary Tool)\n");
//printf("Pipeline Max Dump (Temporary Tool)\n");
char const *me = (argv[0] ? argv[0] : "pipeline_max_dump");
g_set_prgname(me);
@ -77,7 +77,7 @@ int main(int argc, char **argv)
}
display_name = g_filename_display_name(filename);
g_print("%s\n", display_name);
//g_print("%s\n", display_name);
g_free(display_name);
// g_print("%s\n", streamname);
std::cout << "\n";
@ -141,6 +141,7 @@ int main(int argc, char **argv)
PIPELINE::MAX::CScene scene(&sceneClassRegistry, &dllDirectory, &classDirectory3);
//PIPELINE::MAX::CStorageContainer scene;
input = gsf_infile_child_by_name(infile, "Scene");
{
PIPELINE::MAX::CStorageStream instream(input);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save