-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fully working test implementation of #1
- Loading branch information
Alex Dunn
committed
Aug 18, 2014
1 parent
600db53
commit 1958c69
Showing
327 changed files
with
54,544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
x64/ | ||
x86/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# Roslyn cache directories | ||
*.ide/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
#NUNIT | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
[Rr]eleasePS/ | ||
dlldata.c | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.svclog | ||
*.scc | ||
|
||
# Chutzpah Test files | ||
_Chutzpah* | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# TFS 2012 Local Workspace | ||
$tf/ | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# JustCode is a .NET coding addin-in | ||
.JustCode | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
_NCrunch_* | ||
.*crunch*.local.xml | ||
|
||
# MightyMoose | ||
*.mm.* | ||
AutoTest.Net/ | ||
|
||
# Web workbench (sass) | ||
.sass-cache/ | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.[Pp]ublish.xml | ||
*.azurePubxml | ||
# TODO: Comment the next line if you want to checkin your web deploy settings | ||
# but database connection strings (with potential passwords) will be unencrypted | ||
*.pubxml | ||
*.publishproj | ||
|
||
# NuGet Packages | ||
*.nupkg | ||
# The packages folder can be ignored because of Package Restore | ||
**/packages/* | ||
# except build/, which is used as an MSBuild target. | ||
!**/packages/build/ | ||
# If using the old MSBuild-Integrated Package Restore, uncomment this: | ||
#!**/packages/repositories.config | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.dbproj.schemaview | ||
*.pfx | ||
*.publishsettings | ||
node_modules/ | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file | ||
# to a newer Visual Studio version. Backup files are not needed, | ||
# because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
*.mdf | ||
*.ldf | ||
|
||
# Business Intelligence projects | ||
*.rdl.data | ||
*.bim.layout | ||
*.bim_*.settings | ||
|
||
# Microsoft Fakes | ||
FakesAssemblies/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "IArchive.h" | ||
#include "IErrors.h" | ||
|
||
#if ENABLE_IDYNAMICCREATE | ||
|
||
IDynamic * IArchive::iterator::Instantiate(void) | ||
{ | ||
IDataSubStream subStream(owner->theStream, GetDataOffset(), GetDataLength()); | ||
|
||
return IClassRegistry::Instantiate(GetTypeID(), &subStream); | ||
} | ||
|
||
void * IArchive::iterator::GetBuffer(UInt32 * outLength) | ||
{ | ||
HeaderEntry * entry = GetData(); | ||
UInt8 * buf = new UInt8[entry->dataLength]; | ||
|
||
owner->theStream->SetOffset(entry->dataOffset); | ||
owner->theStream->ReadBuf(buf, entry->dataLength); | ||
|
||
if(outLength) | ||
*outLength = entry->dataLength; | ||
|
||
return buf; | ||
} | ||
|
||
void IArchive::iterator::NextOfType(UInt32 typeID) | ||
{ | ||
idx++; | ||
|
||
while((GetData()->typeID != typeID) && (idx < owner->header.numEntries)) | ||
idx++; | ||
} | ||
|
||
void IArchive::iterator::PrevOfType(UInt32 typeID) | ||
{ | ||
idx--; | ||
|
||
while((GetData()->typeID != typeID) && (idx > 0)) | ||
idx--; | ||
} | ||
|
||
IArchive::IArchive() | ||
:theStream(NULL), entries(NULL), nameTable(NULL) | ||
{ | ||
|
||
} | ||
|
||
IArchive::IArchive(IDataStream * stream) | ||
:theStream(NULL), entries(NULL), nameTable(NULL) | ||
{ | ||
AttachStream(stream); | ||
} | ||
|
||
IArchive::~IArchive() | ||
{ | ||
Dispose(); | ||
} | ||
|
||
void IArchive::AttachStream(IDataStream * inStream) | ||
{ | ||
Dispose(); | ||
|
||
theStream = inStream; | ||
} | ||
|
||
void IArchive::Dispose(void) | ||
{ | ||
if(entries) | ||
{ | ||
delete entries; | ||
entries = NULL; | ||
} | ||
|
||
if(nameTable) | ||
{ | ||
delete nameTable; | ||
nameTable = NULL; | ||
} | ||
} | ||
|
||
void IArchive::ReadHeader(void) | ||
{ | ||
ASSERT(theStream); | ||
|
||
theStream->Rewind(); | ||
|
||
theStream->ReadBuf(&header, sizeof(FileHeader)); | ||
|
||
entries = new HeaderEntry[header.numEntries]; | ||
theStream->ReadBuf(entries, header.numEntries * sizeof(HeaderEntry)); | ||
|
||
if(header.nameTableLength) | ||
{ | ||
nameTable = new char[header.nameTableLength]; | ||
|
||
theStream->SetOffset(header.nameTableOffset); | ||
theStream->ReadBuf(nameTable, header.nameTableLength); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#pragma once | ||
|
||
#include "common/IDataStream.h" | ||
#include "common/IDynamicCreate.h" | ||
|
||
#if ENABLE_IDYNAMICCREATE | ||
|
||
/** | ||
* An object archive | ||
* | ||
* This class implements reading and instantiating objects from an object archive. | ||
*/ | ||
class IArchive | ||
{ | ||
public: | ||
class iterator; | ||
friend iterator; | ||
|
||
IArchive(); | ||
IArchive(IDataStream * inStream); | ||
~IArchive(); | ||
|
||
void AttachStream(IDataStream * inStream); | ||
void Dispose(void); | ||
|
||
iterator begin(void) { return iterator(0, this); } | ||
iterator end(void) { return iterator(header.numEntries, this); } | ||
|
||
static const UInt32 kFileID = CHAR_CODE(0x00, 'A', 'R', 0x01); | ||
static const UInt32 kCurrentVersion = VERSION_CODE(1, 0, 0); | ||
|
||
private: | ||
struct FileHeader | ||
{ | ||
UInt32 fileID; // IArchive::kFileID | ||
UInt32 version; // IArchive::kCurrentVersion | ||
UInt32 numEntries; | ||
UInt32 nameTableOffset; | ||
UInt32 nameTableLength; | ||
}; | ||
|
||
struct HeaderEntry | ||
{ | ||
UInt32 typeID; | ||
UInt32 subID; | ||
UInt32 dataOffset; | ||
UInt32 dataLength; | ||
UInt32 nameOffset; | ||
}; | ||
|
||
void ReadHeader(void); | ||
|
||
IDataStream * theStream; | ||
|
||
FileHeader header; | ||
HeaderEntry * entries; | ||
|
||
char * nameTable; | ||
|
||
public: | ||
class iterator | ||
{ | ||
public: | ||
iterator() { idx = 0; owner = NULL; } | ||
iterator(UInt32 inIdx, IArchive * inArchive) { idx = inIdx; owner = inArchive; } | ||
~iterator() { } | ||
|
||
IDynamic * Instantiate(void); | ||
|
||
UInt32 GetTypeID(void) { return GetData()->typeID; } | ||
UInt32 GetSubID(void) { return GetData()->subID; } | ||
UInt32 GetDataLength(void) { return GetData()->dataLength; } | ||
char * GetName(void) { return &owner->nameTable[GetData()->nameOffset]; } | ||
void * GetBuffer(UInt32 * outLength); | ||
|
||
iterator & operator++() { Next(); return *this; } | ||
iterator & operator--() { Prev(); return *this; } | ||
|
||
void NextOfType(UInt32 typeID); | ||
void Next(void) { idx++; } | ||
|
||
void PrevOfType(UInt32 typeID); | ||
void Prev(void) { idx--; } | ||
|
||
private: | ||
HeaderEntry * GetData(void) { return &owner->entries[idx]; } | ||
|
||
UInt32 GetDataOffset(void) { return GetData()->dataOffset; } | ||
|
||
UInt32 idx; | ||
IArchive * owner; | ||
}; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.