Renaming things in FileIO to match PWE's naming conventions

This commit is contained in:
parax0 2015-12-16 15:21:21 -07:00
parent 2db8d23516
commit 4eaf4d9440
85 changed files with 666 additions and 668 deletions

View File

@ -5,7 +5,7 @@ CColor::CColor()
{
}
CColor::CColor(CInputStream& rInput, bool Integral /*= false*/)
CColor::CColor(IInputStream& rInput, bool Integral /*= false*/)
{
if (Integral)
{
@ -47,7 +47,7 @@ void CColor::SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a /*= 255*/)
a = _a / 255.f;
}
void CColor::Write(COutputStream &rOutput, bool Integral /*= false*/)
void CColor::Write(IOutputStream &rOutput, bool Integral /*= false*/)
{
if (Integral)
{

View File

@ -1,8 +1,8 @@
#ifndef CCOLOR_H
#define CCOLOR_H
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
#include "types.h"
class CColor
@ -11,27 +11,27 @@ public:
float r, g, b, a;
CColor();
CColor(CInputStream& src, bool Integral = false);
CColor(IInputStream& rSrc, bool Integral = false);
CColor(float rgba);
CColor(float _r, float _g, float _b, float _a = 1.f);
void SetIntegral(u8 rgba);
void SetIntegral(u8 _r, u8 _g, u8 _b, u8 _a = 255);
void Write(COutputStream& Output, bool Integral = false);
void Write(IOutputStream& rOutput, bool Integral = false);
long ToLongRGBA() const;
long ToLongARGB() const;
bool operator==(const CColor& other) const;
bool operator!=(const CColor& other) const;
CColor operator+(const CColor& other) const;
void operator+=(const CColor& other);
CColor operator-(const CColor& other) const;
void operator-=(const CColor& other);
CColor operator*(const CColor& other) const;
void operator*=(const CColor& other);
bool operator==(const CColor& rkOther) const;
bool operator!=(const CColor& rkOther) const;
CColor operator+(const CColor& rkOther) const;
void operator+=(const CColor& rkOther);
CColor operator-(const CColor& rkOther) const;
void operator-=(const CColor& rkOther);
CColor operator*(const CColor& rkOther) const;
void operator*=(const CColor& rkOther);
CColor operator*(float other) const;
void operator*=(float other);
CColor operator/(const CColor& other) const;
void operator/=(const CColor& other);
CColor operator/(const CColor& rkOther) const;
void operator/=(const CColor& rkOther);
// Static
static CColor Integral(u8 rgba);

View File

@ -21,13 +21,13 @@ CFourCC::CFourCC(u32 src)
*this = src;
}
CFourCC::CFourCC(CInputStream& src)
CFourCC::CFourCC(IInputStream& src)
{
src.ReadBytes(&mFourCC[0], 4);
}
// ************ FUNCTIONALITY ************
void CFourCC::Write(COutputStream &Output)
void CFourCC::Write(IOutputStream &Output)
{
Output.WriteBytes(mFourCC, 4);
}

View File

@ -3,8 +3,8 @@
#include "types.h"
#include "TString.h"
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
class CFourCC
{
@ -15,10 +15,10 @@ public:
CFourCC(const char *src);
CFourCC(const TString& src);
CFourCC(u32 src);
CFourCC(CInputStream& src);
CFourCC(IInputStream& src);
// Functionality
void Write(COutputStream& Output);
void Write(IOutputStream& Output);
u32 ToLong() const;
TString ToString() const;
CFourCC ToUpper() const;

View File

@ -6,9 +6,9 @@
#include <sstream>
// this class probably isn't optimized! this may not be the best way to do things
using IOUtil::SystemEndianness;
using IOUtil::LittleEndian;
using IOUtil::BigEndian;
using IOUtil::kSystemEndianness;
using IOUtil::eLittleEndian;
using IOUtil::eBigEndian;
CUniqueID::CUniqueID()
{
@ -36,7 +36,7 @@ CUniqueID::CUniqueID(u64 ID)
}
// Reverse for Big Endian
if (SystemEndianness == BigEndian)
if (kSystemEndianness == eBigEndian)
Reverse();
}
@ -53,13 +53,13 @@ CUniqueID::CUniqueID(const char* ID)
*this = CUniqueID::FromString(ID);
}
CUniqueID::CUniqueID(CInputStream& Input, EUIDLength Length)
CUniqueID::CUniqueID(IInputStream& Input, EUIDLength Length)
{
memset(mID, 0, 16);
Input.ReadBytes(&mID[16 - Length], Length);
if (Length != e128Bit)
if (SystemEndianness == LittleEndian)
if (kSystemEndianness == eLittleEndian)
Reverse();
mLength = Length;
@ -67,7 +67,7 @@ CUniqueID::CUniqueID(CInputStream& Input, EUIDLength Length)
u32 CUniqueID::ToLong() const
{
if (SystemEndianness == LittleEndian)
if (kSystemEndianness == eLittleEndian)
return *((u32*) mID);
else
return *((u32*) &mID[12]);
@ -75,7 +75,7 @@ u32 CUniqueID::ToLong() const
u64 CUniqueID::ToLongLong() const
{
if (SystemEndianness == LittleEndian)
if (kSystemEndianness == eLittleEndian)
return *((u64*) mID);
else
return *((u64*) &mID[8]);
@ -240,7 +240,7 @@ CUniqueID CUniqueID::FromString(const TString& String)
u32 LongID = Name.ToInt32();
if (SystemEndianness == LittleEndian)
if (kSystemEndianness == eLittleEndian)
memcpy(ID.mID, &LongID, 4);
else
memcpy(&ID.mID[12], &LongID, 4);
@ -255,7 +255,7 @@ CUniqueID CUniqueID::FromString(const TString& String)
u64 LongID = Name.ToInt64();
if (SystemEndianness == LittleEndian)
if (kSystemEndianness == eLittleEndian)
memcpy(ID.mID, &LongID, 8);
else
memcpy(&ID.mID[8], &LongID, 8);

View File

@ -23,7 +23,7 @@ public:
CUniqueID(u64 ID);
CUniqueID(u64 Part1, u64 Part2);
CUniqueID(const char* ID);
CUniqueID(CInputStream& Input, EUIDLength Length);
CUniqueID(IInputStream& Input, EUIDLength Length);
u32 ToLong() const;
u64 ToLongLong() const;
TString ToString() const;

View File

@ -309,7 +309,7 @@ public:
u64 part1 = std::stoull(mInternalString.substr(0, 16), nullptr, base);
u64 part2 = std::stoull(mInternalString.substr(16, 16), nullptr, base);
if (IOUtil::SystemEndianness == IOUtil::LittleEndian)
if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian)
{
IOUtil::SwapBytes(part1);
IOUtil::SwapBytes(part2);

View File

@ -15,7 +15,7 @@ CAnimationParameters::CAnimationParameters()
mUnknown4 = 0;
}
CAnimationParameters::CAnimationParameters(CInputStream& SCLY, EGame game)
CAnimationParameters::CAnimationParameters(IInputStream& SCLY, EGame game)
{
mGame = game;
mpCharSet = nullptr;

View File

@ -19,7 +19,7 @@ class CAnimationParameters
public:
CAnimationParameters();
CAnimationParameters(CInputStream& SCLY, EGame game);
CAnimationParameters(IInputStream& SCLY, EGame game);
CModel* GetCurrentModel(s32 nodeIndex = -1);
// Getters

View File

@ -1,7 +1,7 @@
#ifndef CLIGHT_H
#define CLIGHT_H
#include <FileIO/CInputStream.h>
#include <FileIO/IInputStream.h>
#include <Common/CColor.h>
#include <Math/CVector3f.h>

View File

@ -12,7 +12,7 @@
#include <Common/CColor.h>
#include <Common/EnumUtil.h>
#include <Common/types.h>
#include <FileIO/CInputStream.h>
#include <FileIO/IInputStream.h>
class CMaterialSet;

View File

@ -4,7 +4,7 @@
#include "CMaterial.h"
#include "CTexture.h"
#include "EFormatVersion.h"
#include <FileIO/CInputStream.h>
#include <FileIO/IInputStream.h>
class CMaterialSet
{

View File

@ -13,7 +13,7 @@ CPakFile::CPakFile()
pak = nullptr;
}
CPakFile::CPakFile(CInputStream* pakfile)
CPakFile::CPakFile(IInputStream* pakfile)
{
pak = pakfile;
if (!pak->IsValid()) return;
@ -154,7 +154,7 @@ bool CPakFile::decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len)
while ((src < src_end) && (dst < dst_end)) {
short block_size;
memcpy(&block_size, src, 2);
if (IOUtil::SystemEndianness == IOUtil::LittleEndian) IOUtil::SwapBytes(block_size);
if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian) IOUtil::SwapBytes(block_size);
src += 2;
ret = lzo1x_decompress(src, block_size, dst, &decmp, LZO1X_MEM_DECOMPRESS);

View File

@ -13,13 +13,13 @@ private:
u32 version;
std::vector<SNamedResource> NamedResTable;
std::vector<SResInfo> ResInfoTable;
CInputStream* pak;
IInputStream* pak;
bool decompress(u8 *src, u32 src_len, u8 *dst, u32 dst_len);
public:
CPakFile();
CPakFile(CInputStream* pakfile);
CPakFile(IInputStream* pakfile);
~CPakFile();
std::vector<SNamedResource> getNamedResources();

View File

@ -62,7 +62,7 @@ void CResCache::SetFolder(TString path)
void CResCache::SetPak(const TString& path)
{
CFileInStream *pakfile = new CFileInStream(path.ToStdString(), IOUtil::BigEndian);
CFileInStream *pakfile = new CFileInStream(path.ToStdString(), IOUtil::eBigEndian);
if (!pakfile->IsValid())
{
Log::Error("Couldn't load pak file: " + path);
@ -115,7 +115,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
else
{
Source = mResSource.Path + ResID.ToString() + "." + type.ToString();
CFileInStream file(Source.ToStdString(), IOUtil::BigEndian);
CFileInStream file(Source.ToStdString(), IOUtil::eBigEndian);
if (!file.IsValid())
{
Log::Error("Couldn't open resource: " + ResID.ToString() + "." + type.ToString());
@ -129,7 +129,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
if (!pBuffer) return nullptr;
// Load resource
CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::BigEndian);
CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::eBigEndian);
mem.SetSourceString(*Source.GetFileName());
CResource *Res = nullptr;
bool SupportedFormat = true;
@ -170,7 +170,7 @@ CResource* CResCache::GetResource(const TString& ResPath)
if (got != mResourceCache.end())
return got->second;
CFileInStream file(ResPath.ToStdString(), IOUtil::BigEndian);
CFileInStream file(ResPath.ToStdString(), IOUtil::eBigEndian);
if (!file.IsValid())
{
Log::Error("Couldn't open resource: " + ResPath);

View File

@ -156,7 +156,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& TexCoord)
if (mTexelFormat == eDXT1 && mBufferExists)
{
CMemoryInStream Buffer(mImgDataBuffer, mImgDataSize, IOUtil::SystemEndianness);
CMemoryInStream Buffer(mImgDataBuffer, mImgDataSize, IOUtil::kSystemEndianness);
// 8 bytes per 4x4 16-pixel block, left-to-right top-to-bottom
u32 BlockIdxX = TexelX / 4;
@ -190,7 +190,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& TexCoord)
return 1.f;
}
bool CTexture::WriteDDS(COutputStream& out)
bool CTexture::WriteDDS(IOutputStream& out)
{
if (!out.IsValid()) return false;

View File

@ -38,7 +38,7 @@ public:
void Bind(u32 GLTextureUnit);
void Resize(u32 Width, u32 Height);
float ReadTexelAlpha(const CVector2f& TexCoord);
bool WriteDDS(COutputStream& out);
bool WriteDDS(IOutputStream& out);
// Getters
ETexelFormat TexelFormat();

View File

@ -6,7 +6,7 @@ CMaterialCooker::CMaterialCooker()
mpMat = nullptr;
}
void CMaterialCooker::WriteMatSetPrime(COutputStream& Out)
void CMaterialCooker::WriteMatSetPrime(IOutputStream& Out)
{
// Gather texture list from the materials before starting
mTextureIDs.clear();
@ -64,13 +64,13 @@ void CMaterialCooker::WriteMatSetPrime(COutputStream& Out)
Out.Seek(MatsEnd, SEEK_SET);
}
void CMaterialCooker::WriteMatSetCorruption(COutputStream&)
void CMaterialCooker::WriteMatSetCorruption(IOutputStream&)
{
// Not using parameter 1 (COutputStream& - Out)
// Not using parameter 1 (IOutputStream& - Out)
// todo
}
void CMaterialCooker::WriteMaterialPrime(COutputStream& Out)
void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
{
// Gather data from the passes before we start writing
u32 TexFlags = 0;
@ -320,14 +320,14 @@ void CMaterialCooker::WriteMaterialPrime(COutputStream& Out)
// Done!
}
void CMaterialCooker::WriteMaterialCorruption(COutputStream&)
void CMaterialCooker::WriteMaterialCorruption(IOutputStream&)
{
// Not using parameter 1 (COutputStream& - Out)
// Not using parameter 1 (IOutputStream& - Out)
// todo
}
// ************ STATIC ************
void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutputStream &Out)
void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream &Out)
{
CMaterialCooker Cooker;
Cooker.mpSet = pSet;
@ -344,7 +344,7 @@ void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutp
}
}
void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, COutputStream &Out)
void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream &Out)
{
CMaterialCooker Cooker;
Cooker.mpMat = pMat;

View File

@ -14,14 +14,14 @@ class CMaterialCooker
std::vector<u64> mMaterialHashes;
CMaterialCooker();
void WriteMatSetPrime(COutputStream& Out);
void WriteMatSetCorruption(COutputStream& Out);
void WriteMaterialPrime(COutputStream& Out);
void WriteMaterialCorruption(COutputStream& Out);
void WriteMatSetPrime(IOutputStream& Out);
void WriteMatSetCorruption(IOutputStream& Out);
void WriteMaterialPrime(IOutputStream& Out);
void WriteMaterialCorruption(IOutputStream& Out);
public:
static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, COutputStream& Out);
static void WriteCookedMaterial(CMaterial *pMat, EGame Version, COutputStream& Out);
static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream& Out);
static void WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream& Out);
};
#endif // CMATERIALCOOKER_H

View File

@ -60,11 +60,11 @@ void CModelCooker::GenerateSurfaceData()
mNumVertices = mVertices.size();
}
void CModelCooker::WriteEditorModel(COutputStream& /*Out*/)
void CModelCooker::WriteEditorModel(IOutputStream& /*Out*/)
{
}
void CModelCooker::WriteModelPrime(COutputStream& Out)
void CModelCooker::WriteModelPrime(IOutputStream& Out)
{
GenerateSurfaceData();
@ -232,7 +232,7 @@ void CModelCooker::WriteModelPrime(COutputStream& Out)
// Done!
}
void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, COutputStream& CMDL)
void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& CMDL)
{
CModelCooker Cooker;
Cooker.mpModel = pModel;
@ -249,7 +249,7 @@ void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, COutputStream
}
}
void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, COutputStream& /*EMDL*/)
void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, IOutputStream& /*EMDL*/)
{
}

View File

@ -18,12 +18,12 @@ class CModelCooker
CModelCooker();
void GenerateSurfaceData();
void WriteEditorModel(COutputStream& Out);
void WriteModelPrime(COutputStream& Out);
void WriteEditorModel(IOutputStream& Out);
void WriteModelPrime(IOutputStream& Out);
public:
static void WriteCookedModel(CModel *pModel, EGame Version, COutputStream& Out);
static void WriteUncookedModel(CModel *pModel, COutputStream& Out);
static void WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& Out);
static void WriteUncookedModel(CModel *pModel, IOutputStream& Out);
static u32 GetCMDLVersion(EGame Version);
};

View File

@ -13,20 +13,20 @@ void CSectionMgrOut::SetSectionCount(u32 Count)
mSectionSizes.resize(Count);
}
void CSectionMgrOut::Init(const COutputStream& OutputStream)
void CSectionMgrOut::Init(const IOutputStream& OutputStream)
{
mCurSectionStart = OutputStream.Tell();
mCurSectionIndex = 0;
}
void CSectionMgrOut::AddSize(COutputStream& OutputStream)
void CSectionMgrOut::AddSize(IOutputStream& OutputStream)
{
mSectionSizes[mCurSectionIndex] = OutputStream.Tell() - mCurSectionStart;
mCurSectionIndex++;
mCurSectionStart = OutputStream.Tell();
}
void CSectionMgrOut::WriteSizes(COutputStream& OutputStream)
void CSectionMgrOut::WriteSizes(IOutputStream& OutputStream)
{
for (u32 iSec = 0; iSec < mSectionCount; iSec++)
OutputStream.WriteLong(mSectionSizes[iSec]);

View File

@ -2,7 +2,7 @@
#define CBLOCKMGROUT_H
#include <Common/types.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IOutputStream.h>
#include <vector>
// Small class to manage file sections for CMDL/MREA output
@ -16,9 +16,9 @@ class CSectionMgrOut
public:
CSectionMgrOut();
void SetSectionCount(u32 Count);
void Init(const COutputStream& OutputStream);
void AddSize(COutputStream& OutputStream);
void WriteSizes(COutputStream& OutputStream);
void Init(const IOutputStream& OutputStream);
void AddSize(IOutputStream& OutputStream);
void WriteSizes(IOutputStream& OutputStream);
};
#endif // CBLOCKMGROUT_H

View File

@ -6,7 +6,7 @@ CTextureEncoder::CTextureEncoder()
mpTexture = nullptr;
}
void CTextureEncoder::WriteTXTR(COutputStream& TXTR)
void CTextureEncoder::WriteTXTR(IOutputStream& TXTR)
{
// Only DXT1->CMPR supported at the moment
TXTR.WriteLong(mOutputFormat);
@ -16,7 +16,7 @@ void CTextureEncoder::WriteTXTR(COutputStream& TXTR)
u32 MipW = mpTexture->Width() / 4;
u32 MipH = mpTexture->Height() / 4;
CMemoryInStream Image(mpTexture->mImgDataBuffer, mpTexture->mImgDataSize, IOUtil::LittleEndian);
CMemoryInStream Image(mpTexture->mImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
u32 MipOffset = Image.Tell();
for (u32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
@ -45,7 +45,7 @@ void CTextureEncoder::DetermineBestOutputFormat()
// todo
}
void CTextureEncoder::ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest)
void CTextureEncoder::ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest)
{
Dest.WriteShort(Source.ReadShort());
Dest.WriteShort(Source.ReadShort());
@ -58,7 +58,7 @@ void CTextureEncoder::ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest
}
// ************ STATIC ************
void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex)
void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex)
{
if (pTex->mTexelFormat != eDXT1)
{
@ -73,7 +73,7 @@ void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex)
Encoder.WriteTXTR(TXTR);
}
void CTextureEncoder::EncodeTXTR(COutputStream& TXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/)
void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/)
{
// todo: support for encoding a specific format
EncodeTXTR(TXTR, pTex);

View File

@ -13,13 +13,13 @@ class CTextureEncoder
ETexelFormat mOutputFormat;
CTextureEncoder();
void WriteTXTR(COutputStream& TXTR);
void WriteTXTR(IOutputStream& TXTR);
void DetermineBestOutputFormat();
void ReadSubBlockCMPR(CInputStream& Source, COutputStream& Dest);
void ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest);
public:
static void EncodeTXTR(COutputStream& TXTR, CTexture *pTex);
static void EncodeTXTR(COutputStream& TXTR, CTexture *pTex, ETexelFormat OutputFormat);
static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex);
static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat OutputFormat);
static ETexelFormat GetGXFormat(ETexelFormat Format);
static ETexelFormat GetFormat(ETexelFormat Format);
};

View File

@ -6,7 +6,7 @@ CAnimSetLoader::CAnimSetLoader()
{
}
CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(CInputStream& CHAR)
CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& CHAR)
{
// For now, we only read enough to fetch the model
CHAR.Seek(0x1, SEEK_CUR);
@ -18,7 +18,7 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(CInputStream& CHAR)
return set;
}
CAnimSet* CAnimSetLoader::LoadReturnsCHAR(CInputStream& CHAR)
CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& CHAR)
{
// For now, we only read enough to fetch the model
CHAR.Seek(0x16, SEEK_CUR);
@ -32,7 +32,7 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(CInputStream& CHAR)
return set;
}
void CAnimSetLoader::LoadPASDatabase(CInputStream& PAS4)
void CAnimSetLoader::LoadPASDatabase(IInputStream& PAS4)
{
// For now, just parse the data; don't store it
PAS4.Seek(0x4, SEEK_CUR); // Skipping PAS4 FourCC
@ -72,7 +72,7 @@ void CAnimSetLoader::LoadPASDatabase(CInputStream& PAS4)
}
// ************ STATIC ************
CAnimSet* CAnimSetLoader::LoadANCS(CInputStream& ANCS)
CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& ANCS)
{
if (!ANCS.IsValid()) return nullptr;
Log::Write("Loading " + ANCS.GetSourceString());
@ -169,7 +169,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(CInputStream& ANCS)
return loader.set;
}
CAnimSet* CAnimSetLoader::LoadCHAR(CInputStream &CHAR)
CAnimSet* CAnimSetLoader::LoadCHAR(IInputStream &CHAR)
{
if (!CHAR.IsValid()) return nullptr;
Log::Write("Loading " + CHAR.GetSourceString());

View File

@ -12,13 +12,13 @@ class CAnimSetLoader
EGame mVersion;
CAnimSetLoader();
CAnimSet* LoadCorruptionCHAR(CInputStream& CHAR);
CAnimSet* LoadReturnsCHAR(CInputStream& CHAR);
void LoadPASDatabase(CInputStream& PAS4);
CAnimSet* LoadCorruptionCHAR(IInputStream& CHAR);
CAnimSet* LoadReturnsCHAR(IInputStream& CHAR);
void LoadPASDatabase(IInputStream& PAS4);
public:
static CAnimSet* LoadANCS(CInputStream& ANCS);
static CAnimSet* LoadCHAR(CInputStream& CHAR);
static CAnimSet* LoadANCS(IInputStream& ANCS);
static CAnimSet* LoadCHAR(IInputStream& CHAR);
};
#endif // CCHARACTERLOADER_H

View File

@ -478,7 +478,7 @@ void CAreaLoader::Decompress()
}
TString Source = mpMREA->GetSourceString();
mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::BigEndian);
mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::eBigEndian);
mpMREA->SetSourceString(Source.ToStdString());
mBlockMgr->SetInputStream(mpMREA);
mHasDecompressedBuffer = true;
@ -540,7 +540,7 @@ void CAreaLoader::SetUpObjects()
}
// ************ STATIC ************
CGameArea* CAreaLoader::LoadMREA(CInputStream& MREA)
CGameArea* CAreaLoader::LoadMREA(IInputStream& MREA)
{
CAreaLoader Loader;

View File

@ -15,7 +15,7 @@ class CAreaLoader
// Area data
TResPtr<CGameArea> mpArea;
CInputStream *mpMREA;
IInputStream *mpMREA;
CBlockMgrIn *mBlockMgr;
EGame mVersion;
u32 mNumMeshes;
@ -78,7 +78,7 @@ class CAreaLoader
void SetUpObjects();
public:
static CGameArea* LoadMREA(CInputStream& MREA);
static CGameArea* LoadMREA(IInputStream& MREA);
static EGame GetFormatVersion(u32 version);
};

View File

@ -1,6 +1,6 @@
#include "CBlockMgrIn.h"
CBlockMgrIn::CBlockMgrIn(unsigned long count, CInputStream* src)
CBlockMgrIn::CBlockMgrIn(unsigned long count, IInputStream* src)
{
mpInputStream = src;
mBlockCount = count;
@ -52,7 +52,7 @@ long CBlockMgrIn::CurrentBlockSize()
return mBlockSizes[mCurBlock];
}
void CBlockMgrIn::SetInputStream(CInputStream *in)
void CBlockMgrIn::SetInputStream(IInputStream *in)
{
mpInputStream = in;
}

View File

@ -1,13 +1,13 @@
#ifndef CBLOCKMGRIN_H
#define CBLOCKMGRIN_H
#include <FileIO/CInputStream.h>
#include <FileIO/IInputStream.h>
#include <vector>
// The purpose of this class is to keep track of data block navigation - required to read CMDL and MREA files correctly
class CBlockMgrIn
{
CInputStream *mpInputStream;
IInputStream *mpInputStream;
unsigned long mBlockCount;
std::vector<unsigned long> mBlockSizes;
unsigned long mCurBlock;
@ -15,14 +15,14 @@ class CBlockMgrIn
unsigned long mBlocksStart;
public:
CBlockMgrIn(unsigned long count, CInputStream* src);
CBlockMgrIn(unsigned long count, IInputStream* src);
void Init();
void ToBlock(unsigned long block);
void ToNextBlock();
long NextOffset();
long CurrentBlock();
long CurrentBlockSize();
void SetInputStream(CInputStream *in);
void SetInputStream(IInputStream *in);
};
#endif // CBLOCKMGRIN_H

View File

@ -6,25 +6,22 @@ CCollisionLoader::CCollisionLoader()
{
}
CCollisionMesh::CCollisionOctree* CCollisionLoader::ParseOctree(CInputStream&)
CCollisionMesh::CCollisionOctree* CCollisionLoader::ParseOctree(IInputStream& /*src*/)
{
// Not using: Parameter 1 (CInputStream& - src)
return nullptr;
}
CCollisionMesh::CCollisionOctree::SBranch* CCollisionLoader::ParseOctreeBranch(CInputStream&)
CCollisionMesh::CCollisionOctree::SBranch* CCollisionLoader::ParseOctreeBranch(IInputStream& /*src*/)
{
// Not using: Parameter 1 (CInputStream& - src)
return nullptr;
}
CCollisionMesh::CCollisionOctree::SLeaf* CCollisionLoader::ParseOctreeLeaf(CInputStream&)
CCollisionMesh::CCollisionOctree::SLeaf* CCollisionLoader::ParseOctreeLeaf(IInputStream& /*src*/)
{
// Not using: Parameter 1 (CInputStream& - src)
return nullptr;
}
void CCollisionLoader::ParseOBBNode(CInputStream& DCLN)
void CCollisionLoader::ParseOBBNode(IInputStream& DCLN)
{
bool b = false;
@ -39,7 +36,7 @@ void CCollisionLoader::ParseOBBNode(CInputStream& DCLN)
DCLN.Seek(numFaces * 2, SEEK_CUR);
}
void CCollisionLoader::ReadPropertyFlags(CInputStream& src)
void CCollisionLoader::ReadPropertyFlags(IInputStream& src)
{
CCollisionMesh::SCollisionProperties property;
@ -64,7 +61,7 @@ void CCollisionLoader::ReadPropertyFlags(CInputStream& src)
mProperties.push_back(property);
}
void CCollisionLoader::LoadCollisionIndices(CInputStream &file, bool buildAABox)
void CCollisionLoader::LoadCollisionIndices(IInputStream &file, bool buildAABox)
{
// Properties
u32 propSetCount = file.ReadLong();
@ -131,7 +128,7 @@ void CCollisionLoader::LoadCollisionIndices(CInputStream &file, bool buildAABox)
}
// ************ STATIC ************
CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(CInputStream& MREA)
CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& MREA)
{
if (!MREA.IsValid()) return nullptr;
CCollisionLoader loader;
@ -162,7 +159,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(CInputStream& MREA)
return loader.mpGroup;
}
CCollisionMeshGroup* CCollisionLoader::LoadDCLN(CInputStream &DCLN)
CCollisionMeshGroup* CCollisionLoader::LoadDCLN(IInputStream &DCLN)
{
if (!DCLN.IsValid()) return nullptr;

View File

@ -13,16 +13,16 @@ class CCollisionLoader
std::vector<CCollisionMesh::SCollisionProperties> mProperties;
CCollisionLoader();
CCollisionMesh::CCollisionOctree* ParseOctree(CInputStream& src);
CCollisionMesh::CCollisionOctree::SBranch* ParseOctreeBranch(CInputStream& src);
CCollisionMesh::CCollisionOctree::SLeaf* ParseOctreeLeaf(CInputStream& src);
void ParseOBBNode(CInputStream& DCLN);
void ReadPropertyFlags(CInputStream& src);
void LoadCollisionIndices(CInputStream& file, bool buildAABox);
CCollisionMesh::CCollisionOctree* ParseOctree(IInputStream& src);
CCollisionMesh::CCollisionOctree::SBranch* ParseOctreeBranch(IInputStream& src);
CCollisionMesh::CCollisionOctree::SLeaf* ParseOctreeLeaf(IInputStream& src);
void ParseOBBNode(IInputStream& DCLN);
void ReadPropertyFlags(IInputStream& src);
void LoadCollisionIndices(IInputStream& file, bool buildAABox);
public:
static CCollisionMeshGroup* LoadAreaCollision(CInputStream& MREA);
static CCollisionMeshGroup* LoadDCLN(CInputStream& DCLN);
static CCollisionMeshGroup* LoadAreaCollision(IInputStream& MREA);
static CCollisionMeshGroup* LoadDCLN(IInputStream& DCLN);
static EGame GetFormatVersion(u32 version);
};

View File

@ -6,7 +6,7 @@ CFontLoader::CFontLoader()
{
}
CFont* CFontLoader::LoadFont(CInputStream& FONT)
CFont* CFontLoader::LoadFont(IInputStream& FONT)
{
// If I seek past a value without reading it, then it's because I don't know what it is
mpFont->mUnknown = FONT.ReadLong();
@ -79,7 +79,7 @@ CFont* CFontLoader::LoadFont(CInputStream& FONT)
return mpFont;
}
CFont* CFontLoader::LoadFONT(CInputStream& FONT)
CFont* CFontLoader::LoadFONT(IInputStream& FONT)
{
if (!FONT.IsValid()) return nullptr;
Log::Write("Loading " + FONT.GetSourceString());

View File

@ -11,10 +11,10 @@ class CFontLoader
EGame mVersion;
CFontLoader();
CFont* LoadFont(CInputStream& FONT);
CFont* LoadFont(IInputStream& FONT);
public:
static CFont* LoadFONT(CInputStream& FONT);
static CFont* LoadFONT(IInputStream& FONT);
static EGame GetFormatVersion(u32 Version);
};

View File

@ -591,7 +591,7 @@ CMaterial* CMaterialLoader::LoadAssimpMaterial(const aiMaterial *pAiMat)
}
// ************ STATIC ************
CMaterialSet* CMaterialLoader::LoadMaterialSet(CInputStream& Mat, EGame Version)
CMaterialSet* CMaterialLoader::LoadMaterialSet(IInputStream& Mat, EGame Version)
{
CMaterialLoader Loader;
Loader.mpSet = new CMaterialSet();

View File

@ -12,7 +12,7 @@ class CMaterialLoader
{
// Material data
CMaterialSet *mpSet;
CInputStream *mpFile;
IInputStream *mpFile;
EGame mVersion;
std::vector<TResPtr<CTexture>> mTextures;
bool mHasOPAC;
@ -38,7 +38,7 @@ class CMaterialLoader
// Static
public:
static CMaterialSet* LoadMaterialSet(CInputStream& Mat, EGame Version);
static CMaterialSet* LoadMaterialSet(IInputStream& Mat, EGame Version);
static CMaterialSet* ImportAssimpMaterials(const aiScene *pScene, EGame targetVersion);
};

View File

@ -12,7 +12,7 @@ CModelLoader::~CModelLoader()
{
}
void CModelLoader::LoadWorldMeshHeader(CInputStream &Model)
void CModelLoader::LoadWorldMeshHeader(IInputStream &Model)
{
// I don't really have any need for most of this data, so
Model.Seek(0x34, SEEK_CUR);
@ -20,7 +20,7 @@ void CModelLoader::LoadWorldMeshHeader(CInputStream &Model)
mpBlockMgr->ToNextBlock();
}
void CModelLoader::LoadAttribArrays(CInputStream& Model)
void CModelLoader::LoadAttribArrays(IInputStream& Model)
{
// Positions
if (mFlags & eShortPositions) // Shorts (DKCR only)
@ -105,7 +105,7 @@ void CModelLoader::LoadAttribArrays(CInputStream& Model)
}
}
void CModelLoader::LoadSurfaceOffsets(CInputStream& Model)
void CModelLoader::LoadSurfaceOffsets(IInputStream& Model)
{
mSurfaceCount = Model.ReadLong();
mSurfaceOffsets.resize(mSurfaceCount);
@ -116,7 +116,7 @@ void CModelLoader::LoadSurfaceOffsets(CInputStream& Model)
mpBlockMgr->ToNextBlock();
}
SSurface* CModelLoader::LoadSurface(CInputStream& Model)
SSurface* CModelLoader::LoadSurface(IInputStream& Model)
{
SSurface *pSurf = new SSurface;
@ -228,7 +228,7 @@ SSurface* CModelLoader::LoadSurface(CInputStream& Model)
return pSurf;
}
void CModelLoader::LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf)
void CModelLoader::LoadSurfaceHeaderPrime(IInputStream& Model, SSurface *pSurf)
{
pSurf->CenterPoint = CVector3f(Model);
pSurf->MaterialID = Model.ReadLong();
@ -252,7 +252,7 @@ void CModelLoader::LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf)
Model.SeekToBoundary(32);
}
void CModelLoader::LoadSurfaceHeaderDKCR(CInputStream& Model, SSurface *pSurf)
void CModelLoader::LoadSurfaceHeaderDKCR(IInputStream& Model, SSurface *pSurf)
{
pSurf->CenterPoint = CVector3f(Model);
Model.Seek(0xE, SEEK_CUR);
@ -375,7 +375,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet)
}
// ************ STATIC ************
CModel* CModelLoader::LoadCMDL(CInputStream& CMDL)
CModel* CModelLoader::LoadCMDL(IInputStream& CMDL)
{
CModelLoader Loader;
Log::Write("Loading " + CMDL.GetSourceString());
@ -486,7 +486,7 @@ CModel* CModelLoader::LoadCMDL(CInputStream& CMDL)
return pModel;
}
CModel* CModelLoader::LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version)
CModel* CModelLoader::LoadWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version)
{
CModelLoader Loader;
Loader.mpBlockMgr = &BlockMgr;
@ -519,7 +519,7 @@ CModel* CModelLoader::LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr,
return pModel;
}
CModel* CModelLoader::LoadCorruptionWorldModel(CInputStream &MREA, CBlockMgrIn &BlockMgr, CMaterialSet &MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version)
CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream &MREA, CBlockMgrIn &BlockMgr, CMaterialSet &MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version)
{
CModelLoader Loader;
Loader.mpBlockMgr = &BlockMgr;

View File

@ -45,19 +45,19 @@ private:
CModelLoader();
~CModelLoader();
void LoadWorldMeshHeader(CInputStream& Model);
void LoadAttribArrays(CInputStream& Model);
void LoadAttribArraysDKCR(CInputStream& Model);
void LoadSurfaceOffsets(CInputStream& Model);
SSurface* LoadSurface(CInputStream& Model);
void LoadSurfaceHeaderPrime(CInputStream& Model, SSurface *pSurf);
void LoadSurfaceHeaderDKCR(CInputStream& Model, SSurface *pSurf);
void LoadWorldMeshHeader(IInputStream& Model);
void LoadAttribArrays(IInputStream& Model);
void LoadAttribArraysDKCR(IInputStream& Model);
void LoadSurfaceOffsets(IInputStream& Model);
SSurface* LoadSurface(IInputStream& Model);
void LoadSurfaceHeaderPrime(IInputStream& Model, SSurface *pSurf);
void LoadSurfaceHeaderDKCR(IInputStream& Model, SSurface *pSurf);
SSurface* LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet);
public:
static CModel* LoadCMDL(CInputStream& CMDL);
static CModel* LoadWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version);
static CModel* LoadCorruptionWorldModel(CInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version);
static CModel* LoadCMDL(IInputStream& CMDL);
static CModel* LoadWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, EGame Version);
static CModel* LoadCorruptionWorldModel(IInputStream& MREA, CBlockMgrIn& BlockMgr, CMaterialSet& MatSet, u32 HeaderSecNum, u32 GPUSecNum, EGame Version);
static CModel* ImportAssimpNode(const aiNode *pNode, const aiScene *pScene, CMaterialSet& matSet);
static EGame GetFormatVersion(u32 Version);
};

View File

@ -6,7 +6,7 @@ CScanLoader::CScanLoader()
{
}
CScan* CScanLoader::LoadScanMP1(CInputStream &SCAN)
CScan* CScanLoader::LoadScanMP1(IInputStream &SCAN)
{
// Basic support at the moment - don't read animation/scan image data
SCAN.Seek(0x4, SEEK_CUR); // Skip FRME ID
@ -18,7 +18,7 @@ CScan* CScanLoader::LoadScanMP1(CInputStream &SCAN)
return mpScan;
}
CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN)
CScan* CScanLoader::LoadScanMP2(IInputStream& SCAN)
{
// The SCAN format in MP2 embeds a SNFO object using the same format as SCLY
// However since the contents of the file are consistent there's no need to delegate to CScriptLoader
@ -72,7 +72,7 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN)
return mpScan;
}
void CScanLoader::LoadParamsMP2(CInputStream& SCAN)
void CScanLoader::LoadParamsMP2(IInputStream& SCAN)
{
// Function begins after the SNFO property count
for (u32 iProp = 0; iProp < 20; iProp++)
@ -103,7 +103,7 @@ void CScanLoader::LoadParamsMP2(CInputStream& SCAN)
mpScan->mVersion = eEchoes;
}
void CScanLoader::LoadParamsMP3(CInputStream& SCAN)
void CScanLoader::LoadParamsMP3(IInputStream& SCAN)
{
// Function begins after the SNFO property count
// Function is near-identical to the MP2 one, but when I add support
@ -137,7 +137,7 @@ void CScanLoader::LoadParamsMP3(CInputStream& SCAN)
}
// ************ STATIC/PUBLIC ************
CScan* CScanLoader::LoadSCAN(CInputStream &SCAN)
CScan* CScanLoader::LoadSCAN(IInputStream &SCAN)
{
if (!SCAN.IsValid()) return nullptr;
Log::Write("Loading " + SCAN.GetSourceString());

View File

@ -10,13 +10,13 @@ class CScanLoader
EGame mVersion;
CScanLoader();
CScan* LoadScanMP1(CInputStream& SCAN);
CScan* LoadScanMP2(CInputStream& SCAN);
void LoadParamsMP2(CInputStream& SCAN);
void LoadParamsMP3(CInputStream& SCAN);
CScan* LoadScanMP1(IInputStream& SCAN);
CScan* LoadScanMP2(IInputStream& SCAN);
void LoadParamsMP2(IInputStream& SCAN);
void LoadParamsMP3(IInputStream& SCAN);
public:
static CScan* LoadSCAN(CInputStream& SCAN);
static CScan* LoadSCAN(IInputStream& SCAN);
};
#endif // CSCANLOADER_H

View File

@ -10,7 +10,7 @@ CScriptLoader::CScriptLoader()
mpObj = nullptr;
}
CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplate *pTemp)
CPropertyStruct* CScriptLoader::LoadStructMP1(IInputStream& SCLY, CStructTemplate *pTemp)
{
u32 structStart = SCLY.Tell();
CPropertyStruct *propStruct = new CPropertyStruct();
@ -143,7 +143,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
return propStruct;
}
CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY)
CScriptObject* CScriptLoader::LoadObjectMP1(IInputStream& SCLY)
{
u32 objStart = SCLY.Tell();
u8 type = SCLY.ReadByte();
@ -192,7 +192,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY)
return mpObj;
}
CScriptLayer* CScriptLoader::LoadLayerMP1(CInputStream &SCLY)
CScriptLayer* CScriptLoader::LoadLayerMP1(IInputStream &SCLY)
{
u32 LayerStart = SCLY.Tell();
@ -215,7 +215,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP1(CInputStream &SCLY)
return mpLayer;
}
void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp)
void CScriptLoader::LoadStructMP2(IInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp)
{
// Verify property count
u32 propCount = pTemp->Count();
@ -417,7 +417,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
}
}
CScriptObject* CScriptLoader::LoadObjectMP2(CInputStream& SCLY)
CScriptObject* CScriptLoader::LoadObjectMP2(IInputStream& SCLY)
{
u32 ObjStart = SCLY.Tell();
u32 ObjectID = SCLY.ReadLong();
@ -464,7 +464,7 @@ CScriptObject* CScriptLoader::LoadObjectMP2(CInputStream& SCLY)
return mpObj;
}
CScriptLayer* CScriptLoader::LoadLayerMP2(CInputStream& SCLY)
CScriptLayer* CScriptLoader::LoadLayerMP2(IInputStream& SCLY)
{
CFourCC SCLY_Magic(SCLY);
@ -496,7 +496,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP2(CInputStream& SCLY)
return mpLayer;
}
CScriptLayer* CScriptLoader::LoadLayer(CInputStream &SCLY, CGameArea *pArea, EGame version)
CScriptLayer* CScriptLoader::LoadLayer(IInputStream &SCLY, CGameArea *pArea, EGame version)
{
if (!SCLY.IsValid()) return nullptr;

View File

@ -17,18 +17,18 @@ class CScriptLoader
CScriptLoader();
CPropertyStruct* LoadStructMP1(CInputStream& SCLY, CStructTemplate *tmp);
CScriptObject* LoadObjectMP1(CInputStream& SCLY);
CScriptLayer* LoadLayerMP1(CInputStream& SCLY);
CPropertyStruct* LoadStructMP1(IInputStream& SCLY, CStructTemplate *tmp);
CScriptObject* LoadObjectMP1(IInputStream& SCLY);
CScriptLayer* LoadLayerMP1(IInputStream& SCLY);
void LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp);
CScriptObject* LoadObjectMP2(CInputStream& SCLY);
CScriptLayer* LoadLayerMP2(CInputStream& SCLY);
void LoadStructMP2(IInputStream& SCLY, CPropertyStruct *pStruct, CStructTemplate *pTemp);
CScriptObject* LoadObjectMP2(IInputStream& SCLY);
CScriptLayer* LoadLayerMP2(IInputStream& SCLY);
void SetupAttribs();
public:
static CScriptLayer* LoadLayer(CInputStream& SCLY, CGameArea *pArea, EGame version);
static CScriptLayer* LoadLayer(IInputStream& SCLY, CGameArea *pArea, EGame version);
};
#endif // CSCRIPTLOADER_H

View File

@ -5,7 +5,7 @@ CStringLoader::CStringLoader()
{
}
void CStringLoader::LoadPrimeDemoSTRG(CInputStream& STRG)
void CStringLoader::LoadPrimeDemoSTRG(IInputStream& STRG)
{
// This function starts at 0x4 in the file - right after the size
// This STRG version only supports one language per file
@ -32,7 +32,7 @@ void CStringLoader::LoadPrimeDemoSTRG(CInputStream& STRG)
}
}
void CStringLoader::LoadPrimeSTRG(CInputStream& STRG)
void CStringLoader::LoadPrimeSTRG(IInputStream& STRG)
{
// This function starts at 0x8 in the file, after magic/version
// Header
@ -80,7 +80,7 @@ void CStringLoader::LoadPrimeSTRG(CInputStream& STRG)
}
}
void CStringLoader::LoadCorruptionSTRG(CInputStream& STRG)
void CStringLoader::LoadCorruptionSTRG(IInputStream& STRG)
{
// This function starts at 0x8 in the file, after magic/version
// Header
@ -126,7 +126,7 @@ void CStringLoader::LoadCorruptionSTRG(CInputStream& STRG)
}
}
void CStringLoader::LoadNameTable(CInputStream& STRG)
void CStringLoader::LoadNameTable(IInputStream& STRG)
{
// Name table header
u32 NameCount = STRG.ReadLong();
@ -158,7 +158,7 @@ void CStringLoader::LoadNameTable(CInputStream& STRG)
}
// ************ STATIC ************
CStringTable* CStringLoader::LoadSTRG(CInputStream& STRG)
CStringTable* CStringLoader::LoadSTRG(IInputStream& STRG)
{
// Verify that this is a valid STRG
if (!STRG.IsValid()) return nullptr;

View File

@ -12,13 +12,13 @@ class CStringLoader
EGame mVersion;
CStringLoader();
void LoadPrimeDemoSTRG(CInputStream& STRG);
void LoadPrimeSTRG(CInputStream& STRG);
void LoadCorruptionSTRG(CInputStream& STRG);
void LoadNameTable(CInputStream& STRG);
void LoadPrimeDemoSTRG(IInputStream& STRG);
void LoadPrimeSTRG(IInputStream& STRG);
void LoadCorruptionSTRG(IInputStream& STRG);
void LoadNameTable(IInputStream& STRG);
public:
static CStringTable* LoadSTRG(CInputStream& STRG);
static CStringTable* LoadSTRG(IInputStream& STRG);
static EGame GetFormatVersion(u32 Version);
};

View File

@ -90,7 +90,7 @@ CTexture* CTextureDecoder::CreateTexture()
}
// ************ STATIC ************
CTexture* CTextureDecoder::LoadTXTR(CInputStream& TXTR)
CTexture* CTextureDecoder::LoadTXTR(IInputStream& TXTR)
{
CTextureDecoder Decoder;
Decoder.ReadTXTR(TXTR);
@ -98,7 +98,7 @@ CTexture* CTextureDecoder::LoadTXTR(CInputStream& TXTR)
return Decoder.CreateTexture();
}
CTexture* CTextureDecoder::DoFullDecode(CInputStream &TXTR)
CTexture* CTextureDecoder::DoFullDecode(IInputStream &TXTR)
{
CTextureDecoder Decoder;
Decoder.ReadTXTR(TXTR);
@ -109,7 +109,7 @@ CTexture* CTextureDecoder::DoFullDecode(CInputStream &TXTR)
return pTexture;
}
CTexture* CTextureDecoder::LoadDDS(CInputStream &DDS)
CTexture* CTextureDecoder::LoadDDS(IInputStream &DDS)
{
CTextureDecoder Decoder;
Decoder.ReadDDS(DDS);
@ -124,7 +124,7 @@ CTexture* CTextureDecoder::DoFullDecode(CTexture*)
}
// ************ READ ************
void CTextureDecoder::ReadTXTR(CInputStream& TXTR)
void CTextureDecoder::ReadTXTR(IInputStream& TXTR)
{
// Read TXTR header
Log::Write("Loading " + TXTR.GetSourceString());
@ -144,12 +144,12 @@ void CTextureDecoder::ReadTXTR(CInputStream& TXTR)
mPalettes.resize(PaletteEntryCount * 2);
TXTR.ReadBytes(mPalettes.data(), mPalettes.size());
mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), IOUtil::BigEndian);
mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), IOUtil::eBigEndian);
}
else mHasPalettes = false;
}
void CTextureDecoder::ReadDDS(CInputStream& DDS)
void CTextureDecoder::ReadDDS(IInputStream& DDS)
{
Log::Write("Loading " + DDS.GetSourceString());
@ -202,7 +202,7 @@ void CTextureDecoder::ReadDDS(CInputStream& DDS)
}
// ************ DECODE ************
void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR)
void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
{
// Get image data size, create output buffer
u32 ImageStart = TXTR.Tell();
@ -214,7 +214,7 @@ void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR)
if ((mHasPalettes) && (mPaletteFormat == ePalette_RGB5A3)) mDataBufferSize *= 2;
mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness);
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
@ -275,7 +275,7 @@ void CTextureDecoder::PartialDecodeGXTexture(CInputStream& TXTR)
}
}
void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
void CTextureDecoder::FullDecodeGXTexture(IInputStream& TXTR)
{
// Get image data size, create output buffer
u32 ImageStart = TXTR.Tell();
@ -286,7 +286,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
mDataBufferSize = ImageSize * (32 / gskSourceBpp[mTexelFormat]);
mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness);
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
@ -359,7 +359,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
}
}
void CTextureDecoder::DecodeDDS(CInputStream &DDS)
void CTextureDecoder::DecodeDDS(IInputStream &DDS)
{
// Get image data size, create output buffer
u32 ImageStart = DDS.Tell();
@ -373,7 +373,7 @@ void CTextureDecoder::DecodeDDS(CInputStream &DDS)
else mDataBufferSize *= 4;
mpDataBuffer = new u8[mDataBufferSize];
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::SystemEndianness);
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
// Initializing more stuff before we start the mipmap loop
u32 MipW = mWidth, MipH = mHeight;
@ -470,7 +470,7 @@ void CTextureDecoder::DecodeDDS(CInputStream &DDS)
}
// ************ READ PIXELS (PARTIAL DECODE) ************
void CTextureDecoder::ReadPixelsI4(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelsI4(IInputStream& src, IOutputStream& dst)
{
u8 px = src.ReadByte();
dst.WriteByte(Extend4to8(px >> 4));
@ -479,14 +479,14 @@ void CTextureDecoder::ReadPixelsI4(CInputStream& src, COutputStream& dst)
dst.WriteByte(Extend4to8(px));
}
void CTextureDecoder::ReadPixelI8(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelI8(IInputStream& src, IOutputStream& dst)
{
u8 px = src.ReadByte();
dst.WriteByte(px);
dst.WriteByte(px);
}
void CTextureDecoder::ReadPixelIA4(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelIA4(IInputStream& src, IOutputStream& dst)
{
// this can be left as-is for DDS conversion, but opengl doesn't support two components in one byte...
u8 byte = src.ReadByte();
@ -495,12 +495,12 @@ void CTextureDecoder::ReadPixelIA4(CInputStream& src, COutputStream& dst)
dst.WriteShort((l << 8) | a);
}
void CTextureDecoder::ReadPixelIA8(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelIA8(IInputStream& src, IOutputStream& dst)
{
dst.WriteShort(src.ReadShort());
}
void CTextureDecoder::ReadPixelsC4(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelsC4(IInputStream& src, IOutputStream& dst)
{
// This isn't how C4 works, but due to the way Retro packed font textures (which use C4)
// this is the only way to get them to decode correctly for now.
@ -529,7 +529,7 @@ void CTextureDecoder::ReadPixelsC4(CInputStream& src, COutputStream& dst)
}
}
void CTextureDecoder::ReadPixelC8(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelC8(IInputStream& src, IOutputStream& dst)
{
// DKCR fonts use C8 :|
u8 index = src.ReadByte();
@ -549,13 +549,13 @@ void CTextureDecoder::ReadPixelC8(CInputStream& src, COutputStream& dst)
else if (mPaletteFormat == ePalette_RGB5A3) ReadPixelRGB5A3(mPaletteInput, dst);
}
void CTextureDecoder::ReadPixelRGB565(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelRGB565(IInputStream& src, IOutputStream& dst)
{
// RGB565 can be used as-is.
dst.WriteShort(src.ReadShort());
}
void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelRGB5A3(IInputStream& src, IOutputStream& dst)
{
u16 px = src.ReadShort();
u8 r, g, b, a;
@ -580,7 +580,7 @@ void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst)
dst.WriteLong(c);
}
void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadPixelRGBA8(IInputStream& src, IOutputStream& dst)
{
u16 ar = src.ReadShort();
src.Seek(0x1E, SEEK_CUR);
@ -590,7 +590,7 @@ void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst)
dst.WriteLong(px);
}
void CTextureDecoder::ReadSubBlockCMPR(CInputStream& src, COutputStream& dst)
void CTextureDecoder::ReadSubBlockCMPR(IInputStream& src, IOutputStream& dst)
{
dst.WriteShort(src.ReadShort());
dst.WriteShort(src.ReadShort());
@ -629,7 +629,7 @@ CColor CTextureDecoder::DecodePixelIA8(u16 Short)
return CColor::Integral(Lum, Lum, Lum, Alpha);
}
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream)
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& PaletteStream)
{
if (WhichPixel == 1) Byte >>= 4;
Byte &= 0xF;
@ -641,7 +641,7 @@ CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& Pale
else return CColor::skTransparentBlack;
}
CColor CTextureDecoder::DecodePixelC8(u8 Byte, CInputStream& PaletteStream)
CColor CTextureDecoder::DecodePixelC8(u8 Byte, IInputStream& PaletteStream)
{
PaletteStream.Seek(Byte * 2, SEEK_SET);
if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(PaletteStream.ReadShort());
@ -678,7 +678,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
}
}
void CTextureDecoder::DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst, u16 Width)
void CTextureDecoder::DecodeSubBlockCMPR(IInputStream& src, IOutputStream& dst, u16 Width)
{
CColor Palettes[4];
u16 PaletteA = src.ReadShort();
@ -713,7 +713,7 @@ void CTextureDecoder::DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst,
}
}
void CTextureDecoder::DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32 Width)
void CTextureDecoder::DecodeBlockBC1(IInputStream& src, IOutputStream& dst, u32 Width)
{
// Very similar to the CMPR subblock function, but unfortunately a slight
// difference in the order the pixel indices are read requires a separate function
@ -750,7 +750,7 @@ void CTextureDecoder::DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32
}
}
void CTextureDecoder::DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32 Width)
void CTextureDecoder::DecodeBlockBC2(IInputStream& src, IOutputStream& dst, u32 Width)
{
CColor CPalettes[4];
u16 PaletteA = src.ReadShort();
@ -785,7 +785,7 @@ void CTextureDecoder::DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32
}
}
void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32 Width)
void CTextureDecoder::DecodeBlockBC3(IInputStream& src, IOutputStream& dst, u32 Width)
{
CColor Palettes[4];
u16 PaletteA = src.ReadShort();
@ -820,7 +820,7 @@ void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32
}
}
CColor CTextureDecoder::DecodeDDSPixel(CInputStream& /*DDS*/)
CColor CTextureDecoder::DecodeDDSPixel(IInputStream& /*DDS*/)
{
return CColor::skWhite;
}

View File

@ -38,48 +38,48 @@ class CTextureDecoder
CTexture* CreateTexture();
// Read
void ReadTXTR(CInputStream& TXTR);
void ReadDDS(CInputStream& DDS);
void ReadTXTR(IInputStream& TXTR);
void ReadDDS(IInputStream& DDS);
// Decode
void PartialDecodeGXTexture(CInputStream& TXTR);
void FullDecodeGXTexture(CInputStream& TXTR);
void DecodeDDS(CInputStream& DDS);
void PartialDecodeGXTexture(IInputStream& TXTR);
void FullDecodeGXTexture(IInputStream& TXTR);
void DecodeDDS(IInputStream& DDS);
// Decode Pixels (preserve compression)
void ReadPixelsI4(CInputStream& src, COutputStream& dst);
void ReadPixelI8(CInputStream& src, COutputStream& dst);
void ReadPixelIA4(CInputStream& src, COutputStream& dst);
void ReadPixelIA8(CInputStream& src, COutputStream& dst);
void ReadPixelsC4(CInputStream& src, COutputStream& dst);
void ReadPixelC8(CInputStream& src, COutputStream& dst);
void ReadPixelRGB565(CInputStream& src, COutputStream& dst);
void ReadPixelRGB5A3(CInputStream& src, COutputStream& dst);
void ReadPixelRGBA8(CInputStream& src, COutputStream& dst);
void ReadSubBlockCMPR(CInputStream& src, COutputStream& dst);
void ReadPixelsI4(IInputStream& src, IOutputStream& dst);
void ReadPixelI8(IInputStream& src, IOutputStream& dst);
void ReadPixelIA4(IInputStream& src, IOutputStream& dst);
void ReadPixelIA8(IInputStream& src, IOutputStream& dst);
void ReadPixelsC4(IInputStream& src, IOutputStream& dst);
void ReadPixelC8(IInputStream& src, IOutputStream& dst);
void ReadPixelRGB565(IInputStream& src, IOutputStream& dst);
void ReadPixelRGB5A3(IInputStream& src, IOutputStream& dst);
void ReadPixelRGBA8(IInputStream& src, IOutputStream& dst);
void ReadSubBlockCMPR(IInputStream& src, IOutputStream& dst);
// Decode Pixels (convert to RGBA8)
CColor DecodePixelI4(u8 Byte, u8 WhichPixel);
CColor DecodePixelI8(u8 Byte);
CColor DecodePixelIA4(u8 Byte);
CColor DecodePixelIA8(u16 Short);
CColor DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream);
CColor DecodePixelC8(u8 Byte, CInputStream& PaletteStream);
CColor DecodePixelC4(u8 Byte, u8 WhichPixel, IInputStream& PaletteStream);
CColor DecodePixelC8(u8 Byte, IInputStream& PaletteStream);
CColor DecodePixelRGB565(u16 Short);
CColor DecodePixelRGB5A3(u16 Short);
CColor DecodePixelRGBA8(CInputStream& src, COutputStream& dst);
void DecodeSubBlockCMPR(CInputStream& src, COutputStream& dst, u16 Width);
CColor DecodePixelRGBA8(IInputStream& src, IOutputStream& dst);
void DecodeSubBlockCMPR(IInputStream& src, IOutputStream& dst, u16 Width);
void DecodeBlockBC1(CInputStream& src, COutputStream& dst, u32 Width);
void DecodeBlockBC2(CInputStream& src, COutputStream& dst, u32 Width);
void DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32 Width);
CColor DecodeDDSPixel(CInputStream& DDS);
void DecodeBlockBC1(IInputStream& src, IOutputStream& dst, u32 Width);
void DecodeBlockBC2(IInputStream& src, IOutputStream& dst, u32 Width);
void DecodeBlockBC3(IInputStream& src, IOutputStream& dst, u32 Width);
CColor DecodeDDSPixel(IInputStream& DDS);
// Static
public:
static CTexture* LoadTXTR(CInputStream& TXTR);
static CTexture* LoadDDS(CInputStream& DDS);
static CTexture* DoFullDecode(CInputStream& TXTR);
static CTexture* LoadTXTR(IInputStream& TXTR);
static CTexture* LoadDDS(IInputStream& DDS);
static CTexture* DoFullDecode(IInputStream& TXTR);
static CTexture* DoFullDecode(CTexture *pTexture);
// Utility

View File

@ -7,7 +7,7 @@ CWorldLoader::CWorldLoader()
{
}
void CWorldLoader::LoadPrimeMLVL(CInputStream& MLVL)
void CWorldLoader::LoadPrimeMLVL(IInputStream& MLVL)
{
/**
* This function loads MLVL files from Prime 1/2
@ -218,7 +218,7 @@ void CWorldLoader::LoadPrimeMLVL(CInputStream& MLVL)
// todo: Layer ID support for MP3
}
void CWorldLoader::LoadReturnsMLVL(CInputStream& MLVL)
void CWorldLoader::LoadReturnsMLVL(IInputStream& MLVL)
{
mpWorld->mpWorldName = gResCache.GetResource(MLVL.ReadLongLong(), "STRG");
@ -280,7 +280,7 @@ void CWorldLoader::LoadReturnsMLVL(CInputStream& MLVL)
// todo: Layer ID support
}
CWorld* CWorldLoader::LoadMLVL(CInputStream& MLVL)
CWorld* CWorldLoader::LoadMLVL(IInputStream& MLVL)
{
if (!MLVL.IsValid()) return nullptr;
Log::Write("Loading " + MLVL.GetSourceString());

View File

@ -13,11 +13,11 @@ class CWorldLoader
EGame mVersion;
CWorldLoader();
void LoadPrimeMLVL(CInputStream& MLVL);
void LoadReturnsMLVL(CInputStream& MLVL);
void LoadPrimeMLVL(IInputStream& MLVL);
void LoadReturnsMLVL(IInputStream& MLVL);
public:
static CWorld* LoadMLVL(CInputStream& MLVL);
static CWorld* LoadMLVL(IInputStream& MLVL);
static EGame GetFormatVersion(u32 Version);
};

View File

@ -714,7 +714,7 @@ void CModelEditorWindow::on_actionConvert_to_DDS_triggered()
TResPtr<CTexture> pTex = (CTexture*) gResCache.GetResource(TexFilename);
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".dds";
CFileOutStream Out(OutName.ToStdString(), IOUtil::LittleEndian);
CFileOutStream Out(OutName.ToStdString(), IOUtil::eLittleEndian);
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output DDS!");
else
@ -751,7 +751,7 @@ void CModelEditorWindow::on_actionSave_triggered()
return;
}
CFileOutStream CMDLOut(mOutputFilename.toStdString(), IOUtil::BigEndian);
CFileOutStream CMDLOut(mOutputFilename.toStdString(), IOUtil::eBigEndian);
CModelCooker::WriteCookedModel(mpCurrentModel, ePrime, CMDLOut);
QMessageBox::information(this, "Saved", "Model saved!");
}
@ -866,7 +866,7 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
if (Input.isEmpty()) return;
TString TexFilename = TO_TSTRING(Input);
CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::LittleEndian));
CTexture *Tex = CTextureDecoder::LoadDDS(CFileInStream(TexFilename.ToStdString(), IOUtil::eLittleEndian));
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".txtr";
if ((Tex->TexelFormat() != eDXT1) || (Tex->NumMipMaps() > 1))
@ -874,7 +874,7 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
else
{
CFileOutStream Out(OutName.ToStdString(), IOUtil::BigEndian);
CFileOutStream Out(OutName.ToStdString(), IOUtil::eBigEndian);
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output TXTR!");
else

View File

@ -13,7 +13,7 @@ TestDialog::TestDialog(QWidget *parent) :
{
ui->setupUi(this);
CTexture *pTex = CTextureDecoder::LoadDDS(CFileInStream("E:/test2.dds", IOUtil::LittleEndian));
CTexture *pTex = CTextureDecoder::LoadDDS(CFileInStream("E:/test2.dds", IOUtil::eLittleEndian));
ui->widget->SetTexture(pTex);
}

View File

@ -2,28 +2,28 @@
CFileInStream::CFileInStream()
{
mFStream = nullptr;
mpFStream = nullptr;
}
CFileInStream::CFileInStream(std::string File)
CFileInStream::CFileInStream(const std::string& rkFile)
{
mFStream = nullptr;
Open(File, IOUtil::BigEndian);
mpFStream = nullptr;
Open(rkFile, IOUtil::eBigEndian);
}
CFileInStream::CFileInStream(std::string File, IOUtil::EEndianness FileEndianness)
CFileInStream::CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{
mFStream = nullptr;
Open(File, FileEndianness);
mpFStream = nullptr;
Open(rkFile, FileEndianness);
}
CFileInStream::CFileInStream(CFileInStream& src)
CFileInStream::CFileInStream(const CFileInStream& rkSrc)
{
mFStream = nullptr;
Open(src.mName, src.mDataEndianness);
mpFStream = nullptr;
Open(rkSrc.mName, rkSrc.mDataEndianness);
if (src.IsValid())
Seek(src.Tell(), SEEK_SET);
if (rkSrc.IsValid())
Seek(rkSrc.Tell(), SEEK_SET);
}
CFileInStream::~CFileInStream()
@ -32,13 +32,13 @@ CFileInStream::~CFileInStream()
Close();
}
void CFileInStream::Open(std::string File, IOUtil::EEndianness FileEndianness)
void CFileInStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{
if (IsValid())
Close();
fopen_s(&mFStream, File.c_str(), "rb");
mName = File;
fopen_s(&mpFStream, rkFile.c_str(), "rb");
mName = rkFile;
mDataEndianness = FileEndianness;
if (IsValid())
@ -50,45 +50,45 @@ void CFileInStream::Open(std::string File, IOUtil::EEndianness FileEndianness)
else
mFileSize = 0;
size_t EndPath = File.find_last_of("\\/");
SetSourceString(File.substr(EndPath + 1, File.length() - EndPath));
size_t EndPath = rkFile.find_last_of("\\/");
SetSourceString(rkFile.substr(EndPath + 1, rkFile.length() - EndPath));
}
void CFileInStream::Close()
{
if (IsValid())
fclose(mFStream);
mFStream = nullptr;
fclose(mpFStream);
mpFStream = nullptr;
}
void CFileInStream::ReadBytes(void *dst, unsigned long Count)
void CFileInStream::ReadBytes(void *pDst, unsigned long Count)
{
if (!IsValid()) return;
fread(dst, 1, Count, mFStream);
fread(pDst, 1, Count, mpFStream);
}
bool CFileInStream::Seek(long Offset, long Origin)
{
if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0);
return (fseek(mpFStream, Offset, Origin) != 0);
}
bool CFileInStream::Seek64(long long Offset, long Origin)
{
if (!IsValid()) return false;
return (_fseeki64(mFStream, Offset, Origin) != 0);
return (_fseeki64(mpFStream, Offset, Origin) != 0);
}
long CFileInStream::Tell() const
{
if (!IsValid()) return 0;
return ftell(mFStream);
return ftell(mpFStream);
}
long long CFileInStream::Tell64() const
{
if (!IsValid()) return 0;
return _ftelli64(mFStream);
return _ftelli64(mpFStream);
}
bool CFileInStream::EoF() const
@ -98,7 +98,7 @@ bool CFileInStream::EoF() const
bool CFileInStream::IsValid() const
{
return (mFStream != 0);
return (mpFStream != 0);
}
long CFileInStream::Size() const

View File

@ -1,26 +1,26 @@
#ifndef CFILEINSTREAM_H
#define CFILEINSTREAM_H
#include "CInputStream.h"
#include "IInputStream.h"
#include "IOUtil.h"
class CFileInStream : public CInputStream
class CFileInStream : public IInputStream
{
private:
FILE *mFStream;
FILE *mpFStream;
std::string mName;
long mFileSize;
public:
CFileInStream();
CFileInStream(std::string file);
CFileInStream(std::string file, IOUtil::EEndianness FileEndianness);
CFileInStream(CFileInStream& src);
CFileInStream(const std::string& rkFile);
CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
CFileInStream(const CFileInStream& rkSrc);
~CFileInStream();
void Open(std::string file, IOUtil::EEndianness FileEndianness);
void Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
void Close();
void ReadBytes(void *dst, unsigned long count);
void ReadBytes(void *pDst, unsigned long count);
bool Seek(long offset, long origin);
bool Seek64(long long offset, long origin);
long Tell() const;

View File

@ -2,29 +2,29 @@
CFileOutStream::CFileOutStream()
{
mFStream = nullptr;
mpFStream = nullptr;
mSize = 0;
}
CFileOutStream::CFileOutStream(std::string File)
CFileOutStream::CFileOutStream(const std::string& rkFile)
{
mFStream = nullptr;
Open(File, IOUtil::BigEndian);
mpFStream = nullptr;
Open(rkFile, IOUtil::eBigEndian);
}
CFileOutStream::CFileOutStream(std::string File, IOUtil::EEndianness FileEndianness)
CFileOutStream::CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{
mFStream = nullptr;
Open(File, FileEndianness);
mpFStream = nullptr;
Open(rkFile, FileEndianness);
}
CFileOutStream::CFileOutStream(CFileOutStream& src)
CFileOutStream::CFileOutStream(const CFileOutStream& rkSrc)
{
mFStream = nullptr;
Open(src.mName, src.mDataEndianness);
mpFStream = nullptr;
Open(rkSrc.mName, rkSrc.mDataEndianness);
if (src.IsValid())
Seek(src.Tell(), SEEK_SET);
if (rkSrc.IsValid())
Seek(rkSrc.Tell(), SEEK_SET);
}
CFileOutStream::~CFileOutStream()
@ -33,24 +33,24 @@ CFileOutStream::~CFileOutStream()
Close();
}
void CFileOutStream::Open(std::string File, IOUtil::EEndianness FileEndianness)
void CFileOutStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{
if (IsValid())
Close();
fopen_s(&mFStream, File.c_str(), "wb");
mName = File;
fopen_s(&mpFStream, rkFile.c_str(), "wb");
mName = rkFile;
mDataEndianness = FileEndianness;
mSize = 0;
}
void CFileOutStream::Update(std::string File, IOUtil::EEndianness FileEndianness)
void CFileOutStream::Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
{
if (IsValid())
Close();
fopen_s(&mFStream, File.c_str(), "rb+");
mName = File;
fopen_s(&mpFStream, rkFile.c_str(), "rb+");
mName = rkFile;
mDataEndianness = FileEndianness;
Seek(0x0, SEEK_END);
mSize = Tell();
@ -60,40 +60,40 @@ void CFileOutStream::Update(std::string File, IOUtil::EEndianness FileEndianness
void CFileOutStream::Close()
{
if (IsValid())
fclose(mFStream);
mFStream = nullptr;
fclose(mpFStream);
mpFStream = nullptr;
mSize = 0;
}
void CFileOutStream::WriteBytes(void *src, unsigned long Count)
void CFileOutStream::WriteBytes(void *pSrc, unsigned long Count)
{
if (!IsValid()) return;
fwrite(src, 1, Count, mFStream);
fwrite(pSrc, 1, Count, mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell();
}
bool CFileOutStream::Seek(long Offset, long Origin)
{
if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0);
return (fseek(mpFStream, Offset, Origin) != 0);
}
bool CFileOutStream::Seek64(long long Offset, long Origin)
{
if (!IsValid()) return false;
return (_fseeki64(mFStream, Offset, Origin) != 0);
return (_fseeki64(mpFStream, Offset, Origin) != 0);
}
long CFileOutStream::Tell() const
{
if (!IsValid()) return 0;
return ftell(mFStream);
return ftell(mpFStream);
}
long long CFileOutStream::Tell64() const
{
if (!IsValid()) return 0;
return _ftelli64(mFStream);
return _ftelli64(mpFStream);
}
bool CFileOutStream::EoF() const
@ -103,7 +103,7 @@ bool CFileOutStream::EoF() const
bool CFileOutStream::IsValid() const
{
return (mFStream != 0);
return (mpFStream != 0);
}
long CFileOutStream::Size() const

View File

@ -1,27 +1,27 @@
#ifndef CFILEOUTSTREAM_H
#define CFILEOUTSTREAM_H
#include "COutputStream.h"
#include "IOutputStream.h"
#include "IOUtil.h"
class CFileOutStream : public COutputStream
class CFileOutStream : public IOutputStream
{
private:
FILE *mFStream;
FILE *mpFStream;
std::string mName;
unsigned long mSize;
public:
CFileOutStream();
CFileOutStream(std::string file);
CFileOutStream(std::string file, IOUtil::EEndianness FileEndianness);
CFileOutStream(CFileOutStream& src);
CFileOutStream(const std::string& rkFile);
CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
CFileOutStream(const CFileOutStream& rkSrc);
~CFileOutStream();
void Open(std::string file, IOUtil::EEndianness);
void Update(std::string file, IOUtil::EEndianness FileEndianness);
void Open(const std::string& rkFile, IOUtil::EEndianness);
void Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
void Close();
void WriteBytes(void *src, unsigned long count);
void WriteBytes(void *pSrc, unsigned long count);
bool Seek(long offset, long origin);
bool Seek64(long long offset, long origin);
long Tell() const;

View File

@ -2,31 +2,31 @@
CMemoryInStream::CMemoryInStream()
{
mDataStart = nullptr;
mpDataStart = nullptr;
mDataSize = 0;
mPos = 0;
}
CMemoryInStream::CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness)
CMemoryInStream::CMemoryInStream(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{
SetData(Data, Size, DataEndianness);
SetData(pData, Size, DataEndianness);
}
CMemoryInStream::~CMemoryInStream()
{
}
void CMemoryInStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness)
void CMemoryInStream::SetData(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{
mDataStart = static_cast<char*>(Data);
mpDataStart = static_cast<char*>(pData);
mDataSize = Size;
mPos = 0;
mDataEndianness = DataEndianness;
}
void CMemoryInStream::ReadBytes(void *dst, unsigned long Count)
void CMemoryInStream::ReadBytes(void *pDst, unsigned long Count)
{
if (!IsValid()) return;
memcpy(dst, mDataStart + mPos, Count);
memcpy(pDst, mpDataStart + mPos, Count);
mPos += Count;
}
@ -76,7 +76,7 @@ bool CMemoryInStream::EoF() const
bool CMemoryInStream::IsValid() const
{
return (mDataStart != nullptr);
return (mpDataStart != nullptr);
}
long CMemoryInStream::Size() const
@ -93,10 +93,10 @@ void CMemoryInStream::SetSize(unsigned long Size)
void* CMemoryInStream::Data() const
{
return mDataStart;
return mpDataStart;
}
void* CMemoryInStream::DataAtPosition() const
{
return mDataStart + mPos;
return mpDataStart + mPos;
}

View File

@ -1,22 +1,22 @@
#ifndef CMEMORYINSTREAM_H
#define CMEMORYINSTREAM_H
#include "CInputStream.h"
#include "IInputStream.h"
#include "IOUtil.h"
class CMemoryInStream : public CInputStream
class CMemoryInStream : public IInputStream
{
char *mDataStart;
char *mpDataStart;
long mDataSize;
long mPos;
public:
CMemoryInStream();
CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness);
CMemoryInStream(void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
~CMemoryInStream();
void SetData(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness);
void SetData(void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
void ReadBytes(void *dst, unsigned long Count);
void ReadBytes(void *pDst, unsigned long Count);
bool Seek(long offset, long Origin);
long Tell() const;
bool EoF() const;

View File

@ -2,35 +2,35 @@
CMemoryOutStream::CMemoryOutStream()
{
mDataStart = nullptr;
mpDataStart = nullptr;
mDataSize = 0;
mPos = 0;
mUsed = 0;
}
CMemoryOutStream::CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness)
CMemoryOutStream::CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{
SetData(Data, Size, DataEndianness);
SetData(pData, Size, DataEndianness);
}
CMemoryOutStream::~CMemoryOutStream()
{
}
void CMemoryOutStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness)
void CMemoryOutStream::SetData(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
{
mDataStart = static_cast<char*>(Data);
mpDataStart = static_cast<char*>(pData);
mDataSize = Size;
mPos = 0;
mUsed = 0;
mDataEndianness = DataEndianness;
}
void CMemoryOutStream::WriteBytes(void *src, unsigned long Count)
void CMemoryOutStream::WriteBytes(void *pSrc, unsigned long Count)
{
if (!IsValid()) return;
memcpy(mDataStart + mPos, src, Count);
memcpy(mpDataStart + mPos, pSrc, Count);
mPos += Count;
if (mPos > mUsed) mUsed = mPos;
}
@ -82,7 +82,7 @@ bool CMemoryOutStream::EoF() const
bool CMemoryOutStream::IsValid() const
{
return (mDataStart != nullptr);
return (mpDataStart != nullptr);
}
long CMemoryOutStream::Size() const
@ -104,10 +104,10 @@ void CMemoryOutStream::SetSize(unsigned long Size)
void* CMemoryOutStream::Data() const
{
return mDataStart;
return mpDataStart;
}
void* CMemoryOutStream::DataAtPosition() const
{
return mDataStart + mPos;
return mpDataStart + mPos;
}

View File

@ -1,22 +1,22 @@
#ifndef CMEMORYOUTSTREAM_H
#define CMEMORYOUTSTREAM_H
#include "COutputStream.h"
#include "IOutputStream.h"
class CMemoryOutStream : public COutputStream
class CMemoryOutStream : public IOutputStream
{
char *mDataStart;
char *mpDataStart;
long mDataSize;
long mPos;
long mUsed;
public:
CMemoryOutStream();
CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness);
CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
~CMemoryOutStream();
void SetData(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness);
void SetData(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
void WriteBytes(void *src, unsigned long count);
void WriteBytes(void *pSrc, unsigned long count);
bool Seek(long offset, long origin);
long Tell() const;
bool EoF() const;

View File

@ -1,114 +0,0 @@
#include "COutputStream.h"
COutputStream::~COutputStream()
{
}
void COutputStream::WriteByte(char Val)
{
WriteBytes(&Val, 1);
}
void COutputStream::WriteShort(short Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 2);
}
void COutputStream::WriteLong(long Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void COutputStream::WriteLongLong(long long Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void COutputStream::WriteFloat(float Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void COutputStream::WriteDouble(double Val)
{
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void COutputStream::WriteString(std::string Val)
{
for (unsigned int i = 0; i < Val.size(); i++)
WriteByte(Val[i]);
if ((Val.empty()) || (Val.back() != '\0'))
WriteByte(0);
}
void COutputStream::WriteString(std::string Val, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteByte(Val[i]);
if (Terminate && (Val[Count-1] != '\0'))
WriteByte(0);
}
void COutputStream::WriteWString(std::wstring Val)
{
for (unsigned int i = 0; i < Val.size(); i++)
WriteShort(Val[i]);
if ((!Val.empty()) && (Val.back() != '\0'))
WriteShort(0);
}
void COutputStream::WriteWString(std::wstring Val, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteShort(Val[i]);
if (Terminate && (Val[Count-1] != 0))
WriteShort(0);
}
void COutputStream::WriteToBoundary(unsigned long Boundary, char Fill)
{
long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return;
for (int i = 0; i < Num; i++)
WriteByte(Fill);
}
void COutputStream::SetEndianness(IOUtil::EEndianness Endianness)
{
mDataEndianness = Endianness;
}
void COutputStream::SetDestString(const std::string &Dest)
{
mDataDest = Dest;
}
IOUtil::EEndianness COutputStream::GetEndianness() const
{
return mDataEndianness;
}
std::string COutputStream::GetDestString() const
{
return mDataDest;
}
bool COutputStream::Seek64(long long Offset, long Origin)
{
return Seek((long) Offset, Origin);
}
long long COutputStream::Tell64() const
{
return (long long) (Tell());
}

View File

@ -2,19 +2,19 @@
#include <stdarg.h>
#include <stdio.h>
CTextInStream::CTextInStream(std::string File)
CTextInStream::CTextInStream(const std::string& rkFile)
{
mFStream = nullptr;
Open(File);
mpFStream = nullptr;
Open(rkFile);
}
CTextInStream::CTextInStream(CTextInStream& src)
CTextInStream::CTextInStream(const CTextInStream& rkSrc)
{
mFStream = nullptr;
Open(src.mFileName);
mpFStream = nullptr;
Open(rkSrc.mFileName);
if (src.IsValid())
Seek(src.Tell(), SEEK_SET);
if (rkSrc.IsValid())
Seek(rkSrc.Tell(), SEEK_SET);
}
CTextInStream::~CTextInStream()
@ -23,13 +23,13 @@ CTextInStream::~CTextInStream()
Close();
}
void CTextInStream::Open(std::string File)
void CTextInStream::Open(const std::string& rkFile)
{
if (IsValid())
Close();
fopen_s(&mFStream, File.c_str(), "r");
mFileName = File;
fopen_s(&mpFStream, rkFile.c_str(), "r");
mFileName = rkFile;
if (IsValid())
{
@ -44,23 +44,23 @@ void CTextInStream::Open(std::string File)
void CTextInStream::Close()
{
if (IsValid())
fclose(mFStream);
mFStream = nullptr;
fclose(mpFStream);
mpFStream = nullptr;
}
void CTextInStream::Scan(const char *Format, ... )
void CTextInStream::Scan(const char *pkFormat, ... )
{
if (!IsValid()) return;
va_list Args;
va_start(Args, Format);
vfscanf(mFStream, Format, Args);
va_start(Args, pkFormat);
vfscanf(mpFStream, pkFormat, Args);
}
char CTextInStream::GetChar()
{
if (!IsValid()) return 0;
return (char) fgetc(mFStream);
return (char) fgetc(mpFStream);
}
std::string CTextInStream::GetString()
@ -68,20 +68,20 @@ std::string CTextInStream::GetString()
if (!IsValid()) return "";
char Buf[0x1000];
fgets(Buf, 0x1000, mFStream);
fgets(Buf, 0x1000, mpFStream);
return std::string(Buf);
}
long CTextInStream::Seek(long Offset, long Origin)
{
if (!IsValid()) return 1;
return fseek(mFStream, Offset, Origin);
return fseek(mpFStream, Offset, Origin);
}
long CTextInStream::Tell() const
{
if (!IsValid()) return 0;
return ftell(mFStream);
return ftell(mpFStream);
}
bool CTextInStream::EoF() const
@ -91,7 +91,7 @@ bool CTextInStream::EoF() const
bool CTextInStream::IsValid() const
{
return (mFStream != 0);
return (mpFStream != 0);
}
long CTextInStream::Size() const

View File

@ -6,19 +6,19 @@
class CTextInStream
{
FILE *mFStream;
FILE *mpFStream;
std::string mFileName;
long mFileSize;
public:
CTextInStream();
CTextInStream(std::string File);
CTextInStream(CTextInStream& src);
CTextInStream(const std::string& rkFile);
CTextInStream(const CTextInStream& rkSrc);
~CTextInStream();
void Open(std::string File);
void Open(const std::string& rkFile);
void Close();
void Scan(const char *Format, ... );
void Scan(const char *pkFormat, ... );
char GetChar();
std::string GetString();

View File

@ -3,23 +3,23 @@
CTextOutStream::CTextOutStream()
{
mFStream = nullptr;
mpFStream = nullptr;
mSize = 0;
}
CTextOutStream::CTextOutStream(std::string File)
CTextOutStream::CTextOutStream(const std::string& rkFile)
{
mFStream = nullptr;
Open(File.c_str());
mpFStream = nullptr;
Open(rkFile.c_str());
}
CTextOutStream::CTextOutStream(CTextOutStream& src)
CTextOutStream::CTextOutStream(const CTextOutStream& rkSrc)
{
mFStream = nullptr;
Open(src.mFileName);
mpFStream = nullptr;
Open(rkSrc.mFileName);
if (src.IsValid())
Seek(src.Tell(), SEEK_SET);
if (rkSrc.IsValid())
Seek(rkSrc.Tell(), SEEK_SET);
}
CTextOutStream::~CTextOutStream()
@ -28,54 +28,54 @@ CTextOutStream::~CTextOutStream()
Close();
}
void CTextOutStream::Open(std::string File)
void CTextOutStream::Open(const std::string& rkFile)
{
fopen_s(&mFStream, File.c_str(), "w");
mFileName = File;
fopen_s(&mpFStream, rkFile.c_str(), "w");
mFileName = rkFile;
mSize = 0;
}
void CTextOutStream::Close()
{
if (IsValid())
fclose(mFStream);
mFStream = nullptr;
fclose(mpFStream);
mpFStream = nullptr;
mSize = 0;
}
void CTextOutStream::Print(const char *Format, ... )
void CTextOutStream::Print(const char *pkFormat, ... )
{
if (!IsValid()) return;
va_list Args;
va_start(Args, Format);
vfprintf(mFStream, Format, Args);
va_start(Args, pkFormat);
vfprintf(mpFStream, pkFormat, Args);
}
void CTextOutStream::WriteChar(char c)
{
if (!IsValid()) return;
fputc(c, mFStream);
fputc(c, mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell();
}
void CTextOutStream::WriteString(std::string Str)
void CTextOutStream::WriteString(const std::string& rkStr)
{
if (!IsValid()) return;
fputs(Str.c_str(), mFStream);
fputs(rkStr.c_str(), mpFStream);
if ((unsigned long) Tell() > mSize) mSize = Tell();
}
bool CTextOutStream::Seek(long Offset, long Origin)
{
if (!IsValid()) return false;
return (fseek(mFStream, Offset, Origin) != 0);
return (fseek(mpFStream, Offset, Origin) != 0);
}
long CTextOutStream::Tell() const
{
if (!IsValid()) return 0;
return ftell(mFStream);
return ftell(mpFStream);
}
bool CTextOutStream::EoF() const
@ -85,7 +85,7 @@ bool CTextOutStream::EoF() const
bool CTextOutStream::IsValid() const
{
return (mFStream != 0);
return (mpFStream != 0);
}
long CTextOutStream::Size() const

View File

@ -5,21 +5,21 @@
class CTextOutStream
{
FILE *mFStream;
FILE *mpFStream;
std::string mFileName;
unsigned long mSize;
public:
CTextOutStream();
CTextOutStream(std::string File);
CTextOutStream(CTextOutStream& src);
CTextOutStream(const std::string& rkFile);
CTextOutStream(const CTextOutStream& rkSrc);
~CTextOutStream();
void Open(std::string file);
void Open(const std::string& file);
void Close();
void Print(const char *Format, ... );
void Print(const char *pkFormat, ... );
void WriteChar(char c);
void WriteString(std::string Str);
void WriteString(const std::string& Str);
bool Seek(long Offset, long Origin);
long Tell() const;

View File

@ -2,7 +2,7 @@
CVectorOutStream::CVectorOutStream()
{
mDataEndianness = IOUtil::BigEndian;
mDataEndianness = IOUtil::eBigEndian;
mPos = 0;
mUsed = 0;
}
@ -26,14 +26,14 @@ CVectorOutStream::~CVectorOutStream()
{
}
void CVectorOutStream::WriteBytes(void *src, unsigned long Count)
void CVectorOutStream::WriteBytes(void *pSrc, unsigned long Count)
{
if (!IsValid()) return;
if ((mPos + Count) > mVector.size())
mVector.resize(mPos + Count);
memcpy(mVector.data() + mPos, src, Count);
memcpy(mVector.data() + mPos, pSrc, Count);
mPos += Count;
if (mPos > mUsed) mUsed = mPos;
}

View File

@ -1,10 +1,10 @@
#ifndef CVECTOROUTSTREAM_H
#define CVECTOROUTSTREAM_H
#include "COutputStream.h"
#include "IOutputStream.h"
#include <vector>
class CVectorOutStream : public COutputStream
class CVectorOutStream : public IOutputStream
{
std::vector<char> mVector;
long mPos;
@ -16,7 +16,7 @@ public:
CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness);
~CVectorOutStream();
void WriteBytes(void *src, unsigned long Count);
void WriteBytes(void *pSrc, unsigned long Count);
bool Seek(long Offset, long Origin);
long Tell() const;
bool EoF() const;

View File

@ -3,12 +3,12 @@
#include "IOUtil.h"
#include "CInputStream.h"
#include "IInputStream.h"
#include "CFileInStream.h"
#include "CMemoryInStream.h"
#include "CTextInStream.h"
#include "COutputStream.h"
#include "IOutputStream.h"
#include "CFileOutStream.h"
#include "CMemoryOutStream.h"
#include "CVectorOutStream.h"

View File

@ -6,6 +6,7 @@
QT -= core gui
QMAKE_CXXFLAGS += /WX
DEFINES += PWE_FILEIO
CONFIG += staticlib
TEMPLATE = lib
@ -32,25 +33,25 @@ CONFIG (release, debug|release) {
HEADERS += \
CFileInStream.h \
CFileOutStream.h \
CInputStream.h \
CMemoryInStream.h \
CMemoryOutStream.h \
COutputStream.h \
CTextInStream.h \
CTextOutStream.h \
CVectorOutStream.h \
FileIO.h \
IOUtil.h
IOUtil.h \
IInputStream.h \
IOutputStream.h
# Source Files
SOURCES += \
CFileInStream.cpp \
CFileOutStream.cpp \
CInputStream.cpp \
CMemoryInStream.cpp \
CMemoryOutStream.cpp \
COutputStream.cpp \
CTextInStream.cpp \
CTextOutStream.cpp \
CVectorOutStream.cpp \
IOUtil.cpp
IOUtil.cpp \
IInputStream.cpp \
IOutputStream.cpp

View File

@ -1,57 +1,57 @@
#include "CInputStream.h"
#include "IInputStream.h"
CInputStream::~CInputStream()
IInputStream::~IInputStream()
{
}
char CInputStream::ReadByte()
char IInputStream::ReadByte()
{
char Val;
ReadBytes(&Val, 1);
return Val;
}
short CInputStream::ReadShort()
short IInputStream::ReadShort()
{
short Val;
ReadBytes(&Val, 2);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val;
}
long CInputStream::ReadLong()
long IInputStream::ReadLong()
{
long Val;
ReadBytes(&Val, 4);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val;
}
long long CInputStream::ReadLongLong()
long long IInputStream::ReadLongLong()
{
long long Val;
ReadBytes(&Val, 8);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val;
}
float CInputStream::ReadFloat()
float IInputStream::ReadFloat()
{
float Val;
ReadBytes(&Val, 4);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val;
}
double CInputStream::ReadDouble()
double IInputStream::ReadDouble()
{
double Val;
ReadBytes(&Val, 8);
if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val);
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
return Val;
}
std::string CInputStream::ReadString()
std::string IInputStream::ReadString()
{
std::string Str;
char c = 1;
@ -65,7 +65,7 @@ std::string CInputStream::ReadString()
return Str;
}
std::string CInputStream::ReadString(unsigned long Count)
std::string IInputStream::ReadString(unsigned long Count)
{
std::string Str(Count, 0);
@ -75,7 +75,7 @@ std::string CInputStream::ReadString(unsigned long Count)
return Str;
}
std::wstring CInputStream::ReadWString()
std::wstring IInputStream::ReadWString()
{
std::wstring WStr;
short c = 1;
@ -89,7 +89,7 @@ std::wstring CInputStream::ReadWString()
return WStr;
}
std::wstring CInputStream::ReadWString(unsigned long Count)
std::wstring IInputStream::ReadWString(unsigned long Count)
{
std::wstring WStr(Count, 0);
@ -100,81 +100,81 @@ std::wstring CInputStream::ReadWString(unsigned long Count)
}
char CInputStream::PeekByte()
char IInputStream::PeekByte()
{
char Val = ReadByte();
Seek(-1, SEEK_CUR);
return Val;
}
short CInputStream::PeekShort()
short IInputStream::PeekShort()
{
short Val = ReadShort();
Seek(-2, SEEK_CUR);
return Val;
}
long CInputStream::PeekLong()
long IInputStream::PeekLong()
{
long Val = ReadLong();
Seek(-4, SEEK_CUR);
return Val;
}
long long CInputStream::PeekLongLong()
long long IInputStream::PeekLongLong()
{
long long Val = ReadLongLong();
Seek(-8, SEEK_CUR);
return Val;
}
float CInputStream::PeekFloat()
float IInputStream::PeekFloat()
{
float Val = ReadFloat();
Seek(-4, SEEK_CUR);
return Val;
}
double CInputStream::PeekDouble()
double IInputStream::PeekDouble()
{
double Val = ReadDouble();
Seek(-8, SEEK_CUR);
return Val;
}
void CInputStream::SeekToBoundary(unsigned long Boundary)
void IInputStream::SeekToBoundary(unsigned long Boundary)
{
long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return;
else Seek(Num, SEEK_CUR);
}
void CInputStream::SetEndianness(IOUtil::EEndianness Endianness)
void IInputStream::SetEndianness(IOUtil::EEndianness Endianness)
{
mDataEndianness = Endianness;
}
void CInputStream::SetSourceString(const std::string& source)
void IInputStream::SetSourceString(const std::string& rkSource)
{
mDataSource = source;
mDataSource = rkSource;
}
IOUtil::EEndianness CInputStream::GetEndianness() const
IOUtil::EEndianness IInputStream::GetEndianness() const
{
return mDataEndianness;
}
std::string CInputStream::GetSourceString() const
std::string IInputStream::GetSourceString() const
{
return mDataSource;
}
bool CInputStream::Seek64(long long Offset, long Origin)
bool IInputStream::Seek64(long long Offset, long Origin)
{
return Seek((long) Offset, Origin);
}
long long CInputStream::Tell64() const
long long IInputStream::Tell64() const
{
return (long long) Tell();
}

View File

@ -1,11 +1,11 @@
#ifndef CINPUTSTREAM_H
#define CINPUTSTREAM_H
#ifndef IINPUTSTREAM_H
#define IINPUTSTREAM_H
#include "IOUtil.h"
#include <string>
#include <vector>
class CInputStream
class IInputStream
{
protected:
IOUtil::EEndianness mDataEndianness;
@ -32,12 +32,12 @@ public:
void SeekToBoundary(unsigned long boundary);
void SetEndianness(IOUtil::EEndianness endianness);
void SetSourceString(const std::string& source);
void SetSourceString(const std::string& rkSource);
IOUtil::EEndianness GetEndianness() const;
std::string GetSourceString() const;
virtual ~CInputStream();
virtual void ReadBytes(void *dst, unsigned long count) = 0;
virtual ~IInputStream();
virtual void ReadBytes(void *pDst, unsigned long count) = 0;
virtual bool Seek(long offset, long origin) = 0;
virtual bool Seek64(long long offset, long origin);
virtual long Tell() const = 0;
@ -47,4 +47,4 @@ public:
virtual long Size() const = 0;
};
#endif // CINPUTSTREAM_H
#endif // IINPUTSTREAM_H

View File

@ -8,72 +8,72 @@ namespace IOUtil
// 0x01000000 - Little Endian
// 0x00000001 - Big Endian
long EndianTest = 1;
if (*(char*)&EndianTest == 1) return LittleEndian;
else return BigEndian;
if (*(char*)&EndianTest == 1) return eLittleEndian;
else return eBigEndian;
}
const EEndianness SystemEndianness = FindSystemEndianness();
const EEndianness kSystemEndianness = FindSystemEndianness();
void SwapBytes(short& Val)
void SwapBytes(short& rVal)
{
Val = (((Val & 0x00FF) << 8) |
((Val & 0xFF00) >> 8));
rVal = (((rVal & 0x00FF) << 8) |
((rVal & 0xFF00) >> 8));
}
void SwapBytes(unsigned short& Val)
void SwapBytes(unsigned short& rVal)
{
Val = (((Val & 0x00FF) << 8) |
((Val & 0xFF00) >> 8));
rVal = (((rVal & 0x00FF) << 8) |
((rVal & 0xFF00) >> 8));
}
void SwapBytes(long& Val)
void SwapBytes(long& rVal)
{
Val = (((Val & 0x000000FF) << 24) |
((Val & 0x0000FF00) << 8) |
((Val & 0x00FF0000) >> 8) |
((Val & 0xFF000000) >> 24));
rVal = (((rVal & 0x000000FF) << 24) |
((rVal & 0x0000FF00) << 8) |
((rVal & 0x00FF0000) >> 8) |
((rVal & 0xFF000000) >> 24));
}
void SwapBytes(unsigned long& Val)
void SwapBytes(unsigned long& rVal)
{
Val = (((Val & 0x000000FF) << 24) |
((Val & 0x0000FF00) << 8) |
((Val & 0x00FF0000) >> 8) |
((Val & 0xFF000000) >> 24));
rVal = (((rVal & 0x000000FF) << 24) |
((rVal & 0x0000FF00) << 8) |
((rVal & 0x00FF0000) >> 8) |
((rVal & 0xFF000000) >> 24));
}
void SwapBytes(long long& Val)
void SwapBytes(long long& rVal)
{
Val = (((Val & 0x00000000000000FF) << 56) |
((Val & 0x000000000000FF00) << 40) |
((Val & 0x0000000000FF0000) << 24) |
((Val & 0x00000000FF000000) << 8) |
((Val & 0x000000FF00000000) >> 8) |
((Val & 0x0000FF0000000000) >> 24) |
((Val & 0x00FF000000000000) >> 40) |
((Val & 0xFF00000000000000) >> 56));
rVal = (((rVal & 0x00000000000000FF) << 56) |
((rVal & 0x000000000000FF00) << 40) |
((rVal & 0x0000000000FF0000) << 24) |
((rVal & 0x00000000FF000000) << 8) |
((rVal & 0x000000FF00000000) >> 8) |
((rVal & 0x0000FF0000000000) >> 24) |
((rVal & 0x00FF000000000000) >> 40) |
((rVal & 0xFF00000000000000) >> 56));
}
void SwapBytes(unsigned long long &Val)
void SwapBytes(unsigned long long& rVal)
{
Val = (((Val & 0x00000000000000FF) << 56) |
((Val & 0x000000000000FF00) << 40) |
((Val & 0x0000000000FF0000) << 24) |
((Val & 0x00000000FF000000) << 8) |
((Val & 0x000000FF00000000) >> 8) |
((Val & 0x0000FF0000000000) >> 24) |
((Val & 0x00FF000000000000) >> 40) |
((Val & 0xFF00000000000000) >> 56));
rVal = (((rVal & 0x00000000000000FF) << 56) |
((rVal & 0x000000000000FF00) << 40) |
((rVal & 0x0000000000FF0000) << 24) |
((rVal & 0x00000000FF000000) << 8) |
((rVal & 0x000000FF00000000) >> 8) |
((rVal & 0x0000FF0000000000) >> 24) |
((rVal & 0x00FF000000000000) >> 40) |
((rVal & 0xFF00000000000000) >> 56));
}
void SwapBytes(float& Val)
void SwapBytes(float& rVal)
{
long* ptr = (long*) &Val;
SwapBytes(*ptr);
long* pPtr = (long*) &rVal;
SwapBytes(*pPtr);
}
void SwapBytes(double& Val)
void SwapBytes(double& rVal)
{
long long* ptr = (long long*) &Val;
SwapBytes(*ptr);
long long* pPtr = (long long*) &rVal;
SwapBytes(*pPtr);
}
}

View File

@ -4,19 +4,19 @@
namespace IOUtil
{
enum EEndianness {
LittleEndian,
BigEndian
eLittleEndian,
eBigEndian
};
extern const EEndianness SystemEndianness;
extern const EEndianness kSystemEndianness;
void SwapBytes(short& Val);
void SwapBytes(unsigned short& Val);
void SwapBytes(long& Val);
void SwapBytes(unsigned long& Val);
void SwapBytes(long long& Val);
void SwapBytes(unsigned long long& Val);
void SwapBytes(float& Val);
void SwapBytes(double& Val);
void SwapBytes(short& rVal);
void SwapBytes(unsigned short& rVal);
void SwapBytes(long& rVal);
void SwapBytes(unsigned long& rVal);
void SwapBytes(long long& rVal);
void SwapBytes(unsigned long long& rVal);
void SwapBytes(float& rVal);
void SwapBytes(double& rVal);
}
#endif // IOUTIL_H

View File

@ -0,0 +1,114 @@
#include "IOutputStream.h"
IOutputStream::~IOutputStream()
{
}
void IOutputStream::WriteByte(char Val)
{
WriteBytes(&Val, 1);
}
void IOutputStream::WriteShort(short Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 2);
}
void IOutputStream::WriteLong(long Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void IOutputStream::WriteLongLong(long long Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void IOutputStream::WriteFloat(float Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 4);
}
void IOutputStream::WriteDouble(double Val)
{
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
WriteBytes(&Val, 8);
}
void IOutputStream::WriteString(const std::string& rkVal)
{
for (unsigned int i = 0; i < rkVal.size(); i++)
WriteByte(rkVal[i]);
if ((rkVal.empty()) || (rkVal.back() != '\0'))
WriteByte(0);
}
void IOutputStream::WriteString(const std::string& rkVal, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteByte(rkVal[i]);
if (Terminate && (rkVal[Count-1] != '\0'))
WriteByte(0);
}
void IOutputStream::WriteWideString(const std::wstring& rkVal)
{
for (unsigned int i = 0; i < rkVal.size(); i++)
WriteShort(rkVal[i]);
if ((!rkVal.empty()) && (rkVal.back() != '\0'))
WriteShort(0);
}
void IOutputStream::WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate)
{
for (unsigned int i = 0; i < Count; i++)
WriteShort(rkVal[i]);
if (Terminate && (rkVal[Count-1] != 0))
WriteShort(0);
}
void IOutputStream::WriteToBoundary(unsigned long Boundary, char Fill)
{
long Num = Boundary - (Tell() % Boundary);
if (Num == Boundary) return;
for (int i = 0; i < Num; i++)
WriteByte(Fill);
}
void IOutputStream::SetEndianness(IOUtil::EEndianness Endianness)
{
mDataEndianness = Endianness;
}
void IOutputStream::SetDestString(const std::string& rkDest)
{
mDataDest = rkDest;
}
IOUtil::EEndianness IOutputStream::GetEndianness() const
{
return mDataEndianness;
}
std::string IOutputStream::GetDestString() const
{
return mDataDest;
}
bool IOutputStream::Seek64(long long Offset, long Origin)
{
return Seek((long) Offset, Origin);
}
long long IOutputStream::Tell64() const
{
return (long long) (Tell());
}

View File

@ -1,10 +1,10 @@
#ifndef COUTPUTSTREAM_H
#define COUTPUTSTREAM_H
#ifndef IOUTPUTSTREAM_H
#define IOUTPUTSTREAM_H
#include "IOUtil.h"
#include <string>
class COutputStream
class IOutputStream
{
protected:
IOUtil::EEndianness mDataEndianness;
@ -17,19 +17,19 @@ public:
void WriteLongLong(long long Val);
void WriteFloat(float Val);
void WriteDouble(double Val);
void WriteString(std::string Val);
void WriteString(std::string Val, unsigned long Count, bool Terminate = false);
void WriteWString(std::wstring Val);
void WriteWString(std::wstring Val, unsigned long Count, bool Terminate = false);
void WriteString(const std::string& rkVal);
void WriteString(const std::string& rkVal, unsigned long Count, bool Terminate = false);
void WriteWideString(const std::wstring& rkVal);
void WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate = false);
void WriteToBoundary(unsigned long Boundary, char Fill);
void SetEndianness(IOUtil::EEndianness Endianness);
void SetDestString(const std::string& Dest);
void SetDestString(const std::string& rkDest);
IOUtil::EEndianness GetEndianness() const;
std::string GetDestString() const;
virtual ~COutputStream();
virtual void WriteBytes(void *src, unsigned long Count) = 0;
virtual ~IOutputStream();
virtual void WriteBytes(void *pSrc, unsigned long Count) = 0;
virtual bool Seek(long Offset, long Origin) = 0;
virtual bool Seek64(long long Offset, long Origin);
virtual long Tell() const = 0;

View File

@ -16,13 +16,13 @@ CAABox::CAABox(const CVector3f& Min, const CVector3f& Max)
mMax = Max;
}
CAABox::CAABox(CInputStream& input)
CAABox::CAABox(IInputStream& input)
{
mMin = CVector3f(input);
mMax = CVector3f(input);
}
void CAABox::Write(COutputStream& Output)
void CAABox::Write(IOutputStream& Output)
{
mMin.Write(Output);
mMax.Write(Output);

View File

@ -2,8 +2,8 @@
#define CAABOX_H
#include "CVector3f.h"
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
#include <utility>
class CRay;
@ -16,8 +16,8 @@ class CAABox
public:
CAABox();
CAABox(const CVector3f& Min, const CVector3f& Max);
CAABox(CInputStream& input);
void Write(COutputStream& Output);
CAABox(IInputStream& input);
void Write(IOutputStream& Output);
CVector3f Center() const;
CVector3f Size() const;
CVector3f Min() const;

View File

@ -10,7 +10,7 @@ CTransform4f::CTransform4f()
*this = skIdentity;
}
CTransform4f::CTransform4f(CInputStream& input)
CTransform4f::CTransform4f(IInputStream& input)
{
for (int v = 0; v < 12; v++)
_m[v] = input.ReadFloat();

View File

@ -20,7 +20,7 @@ class CTransform4f
public:
CTransform4f();
CTransform4f(CInputStream& input);
CTransform4f(IInputStream& input);
CTransform4f(float v);
CTransform4f(float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,

View File

@ -16,13 +16,13 @@ CVector2f::CVector2f(float _x, float _y)
y = _y;
}
CVector2f::CVector2f(CInputStream& Input)
CVector2f::CVector2f(IInputStream& Input)
{
x = Input.ReadFloat();
y = Input.ReadFloat();
}
void CVector2f::Write(COutputStream &Output)
void CVector2f::Write(IOutputStream &Output)
{
Output.WriteFloat(x);
Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR2F
#define CVECTOR2F
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
class CVector2f
{
@ -11,8 +11,8 @@ public:
CVector2f();
CVector2f(float xy);
CVector2f(float _x, float _y);
CVector2f(CInputStream& Input);
void Write(COutputStream& Output);
CVector2f(IInputStream& Input);
void Write(IOutputStream& Output);
float Magnitude() const;
float SquaredMagnitude() const;

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR2I_H
#define CVECTOR2I_H
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
class CVector2i
{

View File

@ -22,14 +22,14 @@ CVector3f::CVector3f(float _x, float _y, float _z)
z = _z;
}
CVector3f::CVector3f(CInputStream& Input)
CVector3f::CVector3f(IInputStream& Input)
{
x = Input.ReadFloat();
y = Input.ReadFloat();
z = Input.ReadFloat();
}
void CVector3f::Write(COutputStream &Output)
void CVector3f::Write(IOutputStream &Output)
{
Output.WriteFloat(x);
Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR3F_H
#define CVECTOR3F_H
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
#include <ostream>
class CMatrix4f;
@ -18,8 +18,8 @@ public:
CVector3f();
CVector3f(float xyz);
CVector3f(float _x, float _y, float _z);
CVector3f(CInputStream& Input);
void Write(COutputStream& Output);
CVector3f(IInputStream& Input);
void Write(IOutputStream& Output);
// Swizzle
CVector2f xy();

View File

@ -45,7 +45,7 @@ CVector4f::CVector4f(const CVector3f& xyz, float _w)
w = _w;
}
CVector4f::CVector4f(CInputStream& Input)
CVector4f::CVector4f(IInputStream& Input)
{
x = Input.ReadFloat();
y = Input.ReadFloat();
@ -53,7 +53,7 @@ CVector4f::CVector4f(CInputStream& Input)
w = Input.ReadFloat();
}
void CVector4f::Write(COutputStream &Output)
void CVector4f::Write(IOutputStream &Output)
{
Output.WriteFloat(x);
Output.WriteFloat(y);

View File

@ -1,8 +1,8 @@
#ifndef CVECTOR4F
#define CVECTOR4F
#include <FileIO/CInputStream.h>
#include <FileIO/COutputStream.h>
#include <FileIO/IInputStream.h>
#include <FileIO/IOutputStream.h>
class CMatrix4f;
class CTransform4f;
@ -20,8 +20,8 @@ public:
CVector4f(const CVector2f& xy, float _z, float _w);
CVector4f(const CVector3f& xyz);
CVector4f(const CVector3f& xyz, float _w);
CVector4f(CInputStream& Input);
void Write(COutputStream& Output);
CVector4f(IInputStream& Input);
void Write(IOutputStream& Output);
// Swizzle
CVector3f xyz();