-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathmain.cpp
53 lines (43 loc) · 1.29 KB
/
main.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
#include <fstream>
#include <sstream>
#include "json.hpp"
#include "GHDumper.h"
#include "zip.h"
void saveFile(nlohmann::json& config, const std::string& text, const std::string& extension)
{
// get filename from JSON
std::string filename = config["filename"];
// format full filename
std::stringstream ss;
ss << filename << "." << extension;
// write text file
std::ofstream file(ss.str());
file << text;
}
void saveReclassFile(nlohmann::json& config, const std::string& xml)
{
std::string reclassFilename = config["filename"];
reclassFilename += ".rcnet";
struct zip_t *zip = zip_open(reclassFilename.c_str(), ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
zip_entry_open(zip, "Data.xml");
zip_entry_write(zip, xml.c_str(), xml.size());
zip_entry_close(zip);
zip_close(zip);
}
int main()
{
// load json
std::ifstream file("config.json");
auto config = nlohmann::json::parse(file);
// dump
auto signatures = gh::DumpSignatures(config);
auto netvars = gh::DumpNetvars(config, signatures);
// format files as std::string
auto hpp = gh::FormatHeader(config, signatures, netvars);
auto ct = gh::FormatCheatEngine(config, signatures, netvars);
auto xml = gh::FormatReclass(config, netvars);
// save files
saveFile(config, hpp, "hpp");
saveFile(config, ct, "ct");
saveReclassFile(config, xml);
}