-
Notifications
You must be signed in to change notification settings - Fork 2
/
AtlasFile.h
94 lines (80 loc) · 3.1 KB
/
AtlasFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include <cstdio>
#include <string>
#include <map>
#include <iterator>
#include "Table.h"
#include "PointerHandler.h"
#include "AtlasExtension.h"
using namespace std;
static const unsigned int STR_ENDTERM = 0;
static const unsigned int STR_PASCAL = 1;
static const unsigned int StringTypeCount = 2;
static const char* StringTypes[StringTypeCount] = { "ENDTERM", "PASCAL" };
class AtlasFile
{
public:
AtlasFile();
~AtlasFile();
bool AutoWrite(PointerList* List, string& EndTag);
bool AutoWrite(PointerTable* Tbl, string& EndTag);
bool AutoWrite(AtlasExtension* Ext, string& FuncName, string& EndTag);
bool DisableAutoExtension(string& FuncName, string& EndTag);
bool DisableWrite(string& EndTag, bool isPointerTable);
// File functions. T for text file, P for pointer file
bool OpenFileT(const char* Filename);
bool OpenFileP(const char* Filename);
void CloseFileT();
void CloseFileP();
void MoveT(const unsigned int Pos, const unsigned int ScriptBound);
void MoveT(const unsigned int Pos);
void WriteP(const void* Data, const unsigned int Size, const unsigned int DataCount, const unsigned int Pos);
void WriteT(const void* Data, const unsigned int Size, const unsigned int DataCount, const unsigned int Pos);
void WriteT(const void* Data, const unsigned int Size, const unsigned int DataCount);
void FillT(const unsigned char Data, const unsigned int DataCount);
int InsertBinaryT(string Filename, const unsigned int StartOffset, const unsigned int Size);
unsigned int GetPosT();
void FillBlock();
unsigned int GetMaxBound() { return MaxScriptPos; }
unsigned int GetBytesInserted() { return BytesInserted; }
unsigned int GetBytesOverflowed() { return TotalBytesSkipped; }
void SetTable(Table* Tbl);
bool SetStringType(string& Type);
bool SetPascalLength(unsigned int Length);
bool SetFixedLength(unsigned int StrLength, unsigned int PadValue);
void EnableFillBlock(unsigned char FillByte);
bool InsertText(string& Text, unsigned int Line);
bool FlushText();
inline unsigned int GetMaxWritableBytes();
FILE* GetFileT();
FILE* GetFileP();
void GetScriptBuf(list<TBL_STRING>& Strings);
void SetScriptBuf(list<TBL_STRING>& Strings);
unsigned int GetStringType();
private:
FILE* tfile; // Target file for script
FILE* pfile; // Pointer write file
Table* ActiveTbl;
PointerHandler* PtrHandler;
map<string, PointerList*> ListAutoWrite;
map<string, PointerTable*> TblAutoWrite;
map<string, ExtensionFunction> ExtAutoWrite;
map<string, PointerList*>::iterator ListIt;
map<string, PointerTable*>::iterator TblIt;
map<string, ExtensionFunction>::iterator ExtIt;
inline bool WriteString(string& text);
inline unsigned int WriteNullString(string& text);
inline unsigned int WritePascalString(string& text);
inline void AlignString();
unsigned int MaxScriptPos;
unsigned int BytesInserted;
unsigned int TotalBytesSkipped;
unsigned int TotalBytes;
unsigned int StrType;
unsigned int PascalLength;
unsigned int StringLength;
unsigned char FixedPadValue;
string CurTextString; // Used to keep track and report text that overflows the FIXEDLENGTH value
bool FillBlocks;
unsigned char FillValue;
};