Added: #1440 Parser for DllDirectory

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 274ed370af
commit 8410019c50

@ -0,0 +1,132 @@
/**
* \file dll_directory.cpp
* \brief CDllDirectory
* \date 2012-08-18 09:01GMT
* \author Jan Boon (Kaetemi)
* CDllDirectory
*/
/*
* 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 "dll_directory.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
// Project includes
using namespace std;
// using namespace NLMISC;
namespace PIPELINE {
namespace MAX {
CDllDirectory::CDllDirectory()
{
}
CDllDirectory::~CDllDirectory()
{
}
std::string CDllDirectory::getClassName()
{
return "DllDirectory";
}
void CDllDirectory::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CDllDirectory::createChunkById(uint16 id, bool container)
{
if (container)
{
switch (id)
{
case 0x2038: // DllEntry
return new CDllEntry();
}
}
else
{
switch (id)
{
case 0x21C0: // FileVersion
return new CStorageValue<uint32>();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CDllDirectory::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
CDllEntry::CDllEntry()
{
}
CDllEntry::~CDllEntry()
{
}
std::string CDllEntry::getClassName()
{
return "DllEntry";
}
void CDllEntry::toString(std::ostream &ostream, const std::string &pad)
{
CStorageContainer::toString(ostream, pad);
}
IStorageObject *CDllEntry::createChunkById(uint16 id, bool container)
{
if (!container)
{
switch (id)
{
case 0x2039: // DllDescription
case 0x2037: // DllFilename
return new CStorageValue<ucstring>();
}
}
return CStorageContainer::createChunkById(id, container);
}
void CDllEntry::serialized(TStorageObjectContainer::iterator soit, bool container)
{
CStorageContainer::serialized(soit, container);
}
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */

@ -0,0 +1,92 @@
/**
* \file dll_directory.h
* \brief CDllDirectory
* \date 2012-08-18 09:01GMT
* \author Jan Boon (Kaetemi)
* CDllDirectory
*/
/*
* 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_DLL_DIRECTORY_H
#define PIPELINE_DLL_DIRECTORY_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
#include "storage_object.h"
#include "storage_value.h"
namespace PIPELINE {
namespace MAX {
/**
* \brief CDllDirectory
* \date 2012-08-18 09:01GMT
* \author Jan Boon (Kaetemi)
* CDllDirectory
*/
class CDllDirectory : public CStorageContainer
{
public:
CDllDirectory();
virtual ~CDllDirectory();
// 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 CDllDirectory */
/**
* \brief CDllEntry
* \date 2012-08-18 09:01GMT
* \author Jan Boon (Kaetemi)
* CDllDirectory
*/
class CDllEntry : public CStorageContainer
{
public:
CDllEntry();
virtual ~CDllEntry();
// 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 CDllDirectory */
} /* namespace MAX */
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_DLL_DIRECTORY_H */
/* end of file */

@ -39,9 +39,51 @@ using namespace std;
// using namespace NLMISC; // using namespace NLMISC;
namespace PIPELINE { namespace PIPELINE {
namespace MAX {
void dummy_storage_value_cpp() { } template <>
void CStorageValue<std::string>::serial(NLMISC::IStream &stream)
{
stream.serialBuffer(static_cast<uint8 *>(static_cast<void *>(&Value[0])), Value.size());
}
template <>
void CStorageValue<ucstring>::serial(NLMISC::IStream &stream)
{
stream.serialBuffer(static_cast<uint8 *>(static_cast<void *>(&Value[0])), Value.size() * 2);
}
template <>
void CStorageValue<ucstring>::toString(std::ostream &ostream, const std::string &pad)
{
ostream << "(" << getClassName() << ") { " << Value.toUtf8() << " } ";
}
template <>
void CStorageValue<std::string>::setSize(sint32 size)
{
Value.resize(size);
}
template <>
void CStorageValue<ucstring>::setSize(sint32 size)
{
Value.resize(size / 2);
}
template <>
bool CStorageValue<std::string>::getSize(sint32 &size) const
{
return Value.size();
}
template <>
bool CStorageValue<ucstring>::getSize(sint32 &size) const
{
return Value.size() * 2;
}
} /* namespace MAX */
} /* namespace PIPELINE */ } /* namespace PIPELINE */
/* end of file */ /* end of file */

@ -61,7 +61,7 @@ public: // should be protected but that doesn't compile, nice c++!
}; };
template <typename T> template <typename T>
std::string getClassName() std::string CStorageValue<T>::getClassName()
{ {
return "CStorageValue"; return "CStorageValue";
} }
@ -73,16 +73,10 @@ void CStorageValue<T>::serial(NLMISC::IStream &stream)
} }
template <> template <>
void CStorageValue<std::string>::serial(NLMISC::IStream &stream) void CStorageValue<std::string>::serial(NLMISC::IStream &stream);
{
stream.serialBuffer(static_cast<uint8 *>(static_cast<void *>(&Value[0])), Value.size());
}
template <> template <>
void CStorageValue<ucstring>::serial(NLMISC::IStream &stream) void CStorageValue<ucstring>::serial(NLMISC::IStream &stream);
{
stream.serialBuffer(static_cast<uint8 *>(static_cast<void *>(&Value[0])), Value.size() * 2);
}
template <typename T> template <typename T>
void CStorageValue<T>::toString(std::ostream &ostream, const std::string &pad) void CStorageValue<T>::toString(std::ostream &ostream, const std::string &pad)
@ -90,6 +84,9 @@ void CStorageValue<T>::toString(std::ostream &ostream, const std::string &pad)
ostream << "(" << getClassName() << ") { " << Value << " } "; ostream << "(" << getClassName() << ") { " << Value << " } ";
} }
template <>
void CStorageValue<ucstring>::toString(std::ostream &ostream, const std::string &pad);
template <typename T> template <typename T>
void CStorageValue<T>::setSize(sint32 size) void CStorageValue<T>::setSize(sint32 size)
{ {
@ -99,16 +96,10 @@ void CStorageValue<T>::setSize(sint32 size)
} }
template <> template <>
void CStorageValue<std::string>::setSize(sint32 size) void CStorageValue<std::string>::setSize(sint32 size);
{
Value.resize(size);
}
template <> template <>
void CStorageValue<ucstring>::setSize(sint32 size) void CStorageValue<ucstring>::setSize(sint32 size);
{
Value.resize(size / 2);
}
template <typename T> template <typename T>
bool CStorageValue<T>::getSize(sint32 &size) const bool CStorageValue<T>::getSize(sint32 &size) const
@ -118,16 +109,10 @@ bool CStorageValue<T>::getSize(sint32 &size) const
} }
template <> template <>
bool CStorageValue<std::string>::getSize(sint32 &size) const bool CStorageValue<std::string>::getSize(sint32 &size) const;
{
return Value.size();
}
template <> template <>
bool CStorageValue<ucstring>::getSize(sint32 &size) const bool CStorageValue<ucstring>::getSize(sint32 &size) const;
{
return Value.size() * 2;
}
} /* namespace MAX */ } /* namespace MAX */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

@ -18,6 +18,7 @@
#include "../max/storage_stream.h" #include "../max/storage_stream.h"
#include "../max/storage_object.h" #include "../max/storage_object.h"
#include "../max/dll_directory.h"
//static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max"; //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/source/minimax/GE_Acc_MikotoBaniere.max";
@ -34,6 +35,9 @@ inline uint8 cleanChar(uint8 c)
namespace PIPELINE { namespace PIPELINE {
namespace MAX { namespace MAX {
/* /*
struct CClass_ID : public NLMISC::IStreamable struct CClass_ID : public NLMISC::IStreamable
{ {
@ -307,7 +311,7 @@ int main(int argc, char **argv)
//gsf_input_dump(input, 1); // just a regular hex dump of this input stream //gsf_input_dump(input, 1); // just a regular hex dump of this input stream
PIPELINE::MAX::CStorageStream instream(input); PIPELINE::MAX::CStorageStream instream(input);
//dumpContainer(instream, ""); //dumpContainer(instream, "");
PIPELINE::MAX::CStorageContainer ctr; PIPELINE::MAX::CDllDirectory ctr;
ctr.serial(instream); ctr.serial(instream);
ctr.toString(std::cout); ctr.toString(std::cout);
std::cout << "\n"; std::cout << "\n";

Loading…
Cancel
Save