forked from ItsBranK/UE3SDKGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrinter.cpp
136 lines (118 loc) · 4.82 KB
/
Printer.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "Printer.hpp"
#include "Engine/Engine.hpp"
namespace Printer
{
void Empty(std::ostringstream& stream)
{
stream.str(std::string());
}
void FillRight(std::ostringstream& stream, const char& fill, uint64_t width)
{
stream << std::setfill(fill) << std::setw(width) << std::right;
}
void FillLeft(std::ostringstream& stream, const char& fill, uint64_t width)
{
stream << std::setfill(fill) << std::setw(width) << std::left;
}
void FillRight(std::ofstream& stream, const char& fill, uint64_t width)
{
stream << std::setfill(fill) << std::setw(width) << std::right;
}
void FillLeft(std::ofstream& stream, const char& fill, uint64_t width)
{
stream << std::setfill(fill) << std::setw(width) << std::left;
}
std::string Hex(uintptr_t address, uint64_t width)
{
std::ostringstream stream;
stream << "0x" << std::setfill('0') << std::setw(width) << std::right << std::uppercase << std::hex << address;
return stream.str();
}
std::string Decimal(uintptr_t address, uint64_t width)
{
std::ostringstream stream;
stream << std::setfill('0') << std::setw(width) << std::right << std::uppercase << std::dec << address;
return stream.str();
}
std::string Precision(float value, uint64_t precision)
{
std::ostringstream stream;
stream << std::setprecision(precision) << value;
return stream.str();
}
void Header(std::ostringstream& stream, const std::string& fileName, const std::string& fileExtension, bool pragmaPush)
{
stream << "/*\n";
stream << "#############################################################################################\n";
stream << "# " << Configuration::GameName << " (" << Configuration::GameVersion + ") SDK\n";
stream << "# Generated with the UE3SDKGenerator " << Engine::GeneratorVersion << "\n";
stream << "# ========================================================================================= #\n";
stream << "# File: " << fileName << "." << fileExtension << "\n";
stream << "# ========================================================================================= #\n";
stream << "# Credits: " << Engine::GeneratorCredits << "\n";
stream << "# Links: " << Engine::GeneratorLinks << "\n";
stream << "#############################################################################################\n";
stream << "*/\n";
if (fileName != "SdkHeaders")
{
if (fileExtension == "hpp" && fileName != "GameDefines")
{
stream << "#pragma once\n";
if (Configuration::UsingConstants)
{
stream << "#include \"../SdkConstants.hpp\"\n";
}
}
else if (fileExtension == "cpp" && fileName != "GameDefines")
{
stream << "#include \"../SdkHeaders.hpp\"\n";
}
}
if (pragmaPush)
{
stream << "\n#ifdef _MSC_VER\n";
stream << "\t#pragma pack(push, 0x" + std::to_string(Configuration::FinalAlignment) + ")\n";
stream << "#endif\n";
}
}
void Header(std::ofstream& stream, const std::string& fileName, const std::string& fileExtension, bool pragmaPush)
{
std::ostringstream sStream;
Header(sStream, fileName, fileExtension, pragmaPush);
stream << sStream.str();
}
void Section(std::ostringstream& stream, const std::string& sectionName)
{
stream << "\n/*\n";
stream << "# ========================================================================================= #\n";
stream << "# " << sectionName << "\n";
stream << "# ========================================================================================= #\n";
stream << "*/\n\n";
}
void Section(std::ofstream& stream, const std::string& sectionName)
{
std::ostringstream sStream;
Section(sStream, sectionName);
stream << sStream.str();
}
void Footer(std::ostringstream& stream, bool pragmaPop)
{
stream << "/*\n";
stream << "# ========================================================================================= #\n";
stream << "#\n";
stream << "# ========================================================================================= #\n";
stream << "*/\n";
if (pragmaPop)
{
stream << "\n#ifdef _MSC_VER\n";
stream << "\t#pragma pack(pop)\n";
stream << "#endif\n";
}
}
void Footer(std::ofstream& stream, bool pragmaPop)
{
std::ostringstream sStream;
Footer(sStream, pragmaPop);
stream << sStream.str();
}
}