Added: #1440 Parser for Config, ConfigScript

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 7fa54f1164
commit 546334a261

@ -99,7 +99,7 @@ CClassDataEntry::~CClassDataEntry()
std::string CClassDataEntry::getClassName()
{
return "ClassData";
return "ClassDataEntry";
}
void CClassDataEntry::toString(std::ostream &ostream, const std::string &pad)

@ -0,0 +1,326 @@
/**
* \file config.cpp
* \brief CConfig
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfig
*/
/*
* 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 "config.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/misc/vector.h>
// Project includes
using namespace std;
// using namespace NLMISC;
namespace PIPELINE {
namespace MAX {
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfig::CConfig()
{
}
CConfig::~CConfig()
{
}
std::string CConfig::getClassName()
{
return "Config";
}
void CConfig::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CConfig::createChunkById(uint16 id, bool container)
{
if (container)
{
switch (id)
{
case 0x2180: // CConfigScript
return new CConfigScript();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CConfig::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfigScript::CConfigScript()
{
}
CConfigScript::~CConfigScript()
{
}
std::string CConfigScript::getClassName()
{
return "ConfigScript";
}
void CConfigScript::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CConfigScript::createChunkById(uint16 id, bool container)
{
if (container)
{
switch (id)
{
case 0x0040: // ConfigScriptEntry
return new CConfigScriptEntry();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CConfigScript::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfigScriptEntry::CConfigScriptEntry()
{
}
CConfigScriptEntry::~CConfigScriptEntry()
{
}
std::string CConfigScriptEntry::getClassName()
{
return "ConfigScriptEntry";
}
void CConfigScriptEntry::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CConfigScriptEntry::createChunkById(uint16 id, bool container)
{
if (container)
{
switch (id)
{
case 0x0007: // ConfigScriptMetaContainer
return new CConfigScriptMetaContainer();
}
}
else
{
switch (id)
{
case 0x0050: // ConfigScriptHeader
return new CConfigScriptHeader();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CConfigScriptEntry::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfigScriptHeader::CConfigScriptHeader()
{
}
CConfigScriptHeader::~CConfigScriptHeader()
{
}
std::string CConfigScriptHeader::getClassName()
{
return "ConfigScriptHeader";
}
void CConfigScriptHeader::serial(NLMISC::IStream &stream)
{
stream.serial(SuperClassID);
stream.serial(ClassID);
}
void CConfigScriptHeader::toString(std::ostream &ostream, const std::string &pad)
{
ostream << "(" << getClassName() << ") { ";
ostream << "\n" << pad << "SuperClassID: " << SuperClassID;
ostream << "\n" << pad << "ClassID: " << NLMISC::toString(ClassID);
ostream << " } ";
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfigScriptMetaContainer::CConfigScriptMetaContainer()
{
}
CConfigScriptMetaContainer::~CConfigScriptMetaContainer()
{
}
std::string CConfigScriptMetaContainer::getClassName()
{
return "ConfigScriptMetaContainer";
}
void CConfigScriptMetaContainer::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CConfigScriptMetaContainer::createChunkById(uint16 id, bool container)
{
if (container)
{
switch (id)
{
case 0x0007: // ConfigScriptMetaContainer
return new CConfigScriptMetaContainer();
}
}
else
{
switch (id)
{
case 0x0001: // type: boolean (stored in four bytes, yes)
return new CStorageValue<uint32>();
case 0x0002: // ???
nlerror("0x0002 found, please implement");
break;
case 0x0003: // type: integer (not sure if signed)
return new CStorageValue<sint32>();
case 0x0004: // type: float
return new CStorageValue<float>();
case 0x0005: // type: string (same format as the meta string)
case 0x0006: // ConfigScriptMetaString
return new CConfigScriptMetaString();
case 0x0008: // type: color (stored as 3 float vector)
return new CStorageValue<NLMISC::CVector>;
case 0x0060: // ConfigScriptMetaContainerHeader (contains the number of entries, amusingly)
return new CStorageValue<uint32>();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CConfigScriptMetaContainer::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CConfigScriptMetaString::CConfigScriptMetaString()
{
}
CConfigScriptMetaString::~CConfigScriptMetaString()
{
}
std::string CConfigScriptMetaString::getClassName()
{
return "ConfigScriptMetaString";
}
void CConfigScriptMetaString::serial(NLMISC::IStream &stream)
{
if (stream.isReading())
{
uint32 size;
stream.serial(size);
Value.resize(size - 1);
}
else
{
uint32 size = Value.size() + 1;
stream.serial(size);
}
stream.serialBuffer(static_cast<uint8 *>(static_cast<void *>(&Value[0])), Value.size());
uint8 endByte = 0;
stream.serial(endByte);
nlassert(endByte == 0);
}
void CConfigScriptMetaString::toString(std::ostream &ostream, const std::string &pad)
{
ostream << "(" << getClassName() << ") { " << Value << " } ";
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */

@ -0,0 +1,183 @@
/**
* \file config.h
* \brief CConfig
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfig
*/
/*
* 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_CONFIG_H
#define PIPELINE_CONFIG_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/misc/class_id.h>
// Project includes
#include "storage_object.h"
#include "storage_value.h"
namespace PIPELINE {
namespace MAX {
/**
* \brief CConfig
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfig
*/
class CConfig : public CStorageContainer
{
public:
CConfig();
virtual ~CConfig();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
virtual void serialized(TStorageObjectContainer::iterator soit, bool container);
}; /* class CConfig */
/**
* \brief CConfigScript
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfig
*/
class CConfigScript : public CStorageContainer
{
public:
CConfigScript();
virtual ~CConfigScript();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
virtual void serialized(TStorageObjectContainer::iterator soit, bool container);
}; /* class CConfigScript */
/**
* \brief CConfigScriptEntry
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfig
*/
class CConfigScriptEntry : public CStorageContainer
{
public:
CConfigScriptEntry();
virtual ~CConfigScriptEntry();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
virtual void serialized(TStorageObjectContainer::iterator soit, bool container);
}; /* class CConfigScriptEntry */
/**
* \brief CConfigScriptHeader
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfigScriptHeader
*/
class CConfigScriptHeader : public IStorageObject
{
public:
CConfigScriptHeader();
virtual ~CConfigScriptHeader();
// public data
uint32 SuperClassID;
NLMISC::CClassId ClassID;
// inherited
virtual std::string getClassName();
virtual void serial(NLMISC::IStream &stream);
virtual void toString(std::ostream &ostream, const std::string &pad = "");
}; /* class CConfigScriptHeader */
/**
* \brief CConfigScriptMetaContainer
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfigScriptMetaContainer
* This is totally hilarious.
*/
class CConfigScriptMetaContainer : public CStorageContainer
{
public:
CConfigScriptMetaContainer();
virtual ~CConfigScriptMetaContainer();
// inherited
virtual std::string getClassName();
virtual void toString(std::ostream &ostream, const std::string &pad = "");
protected:
virtual IStorageObject *createChunkById(uint16 id, bool container);
virtual void serialized(TStorageObjectContainer::iterator soit, bool container);
}; /* class CConfigScriptMetaContainer */
/**
* \brief CConfigScriptMetaString
* \date 2012-08-18 19:25GMT
* \author Jan Boon (Kaetemi)
* CConfigScriptMetaString
*/
class CConfigScriptMetaString : public IStorageObject
{
public:
CConfigScriptMetaString();
virtual ~CConfigScriptMetaString();
// public data
std::string Value;
// inherited
virtual std::string getClassName();
virtual void serial(NLMISC::IStream &stream);
virtual void toString(std::ostream &ostream, const std::string &pad = "");
}; /* class CConfigScriptMetaString */
} /* namespace MAX */
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_CONFIG_H */
/* end of file */

@ -235,7 +235,7 @@ void CStorageRaw::toString(std::ostream &ostream, const std::string &pad)
}
}
ostream << " ";
if (!isString)
if (!isString || Value.size() <= 4)
{
ostream << "\n" << pad << "Hex: ";
for (TType::size_type i = 0; i < Value.size(); ++i)

File diff suppressed because it is too large Load Diff

@ -745,3 +745,46 @@ max 2010
Config
nel script material id:
0x64c75fec, 0x222b9eb9
ec 5f c7 64 b9 9e 2b 22
0x2180: (StorageContainer) {
0x0040: (StorageContainer) {
0x0050: (StorageRaw) {
Size: 12
String: ....._.d..+"
Hex: 00 0c 00 00 ec 5f c7 64 b9 9e 2b 22 }
0x0007: (StorageContainer) {
0x0060: (StorageRaw) {
Size: 4
String: ....
Hex: 09 00 00 00 }
0x0007: (StorageContainer) {
0x0060: (StorageRaw) {
Size: 4
String: ....
Hex: 0e 00 00 00 }
0x0006: (StorageRaw) {
Size: 9
String: ....nlbp.
Hex: 05 00 00 00 6e 6c 62 70 00 }
0x0003: (StorageRaw) {
Size: 4
String: .... }
0x0003: (StorageRaw) {
Size: 4
String: ....
Hex: 01 00 00 00 }
0x0007: (StorageContainer) {
0x0060: (StorageRaw) {
Size: 4
String: ....
Hex: 02 00 00 00 }

@ -21,12 +21,13 @@
#include "../max/dll_directory.h"
#include "../max/class_directory_3.h"
#include "../max/class_data.h"
#include "../max/config.h"
//static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max";
static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max";
//static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max";
static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max";
static const char *streamname = "ClassData";
static const char *streamname = "Config";
// int __stdcall WinMain(void *, void *, void *, int)
int main(int argc, char **argv)
@ -78,7 +79,7 @@ int main(int argc, char **argv)
//gsf_input_dump(input, 1); // just a regular hex dump of this input stream
PIPELINE::MAX::CStorageStream instream(input);
//dumpContainer(instream, "");
PIPELINE::MAX::CClassData ctr;
PIPELINE::MAX::CConfig ctr;
ctr.serial(instream);
ctr.toString(std::cout);
std::cout << "\n";

Loading…
Cancel
Save