Dump wild_encounter data to C/JSON

This commit is contained in:
PikalaxALT
2019-10-31 20:05:10 -04:00
parent 079310c70b
commit 3f7c66703b
10 changed files with 12971 additions and 7286 deletions
+21 -3
View File
@@ -5,7 +5,7 @@
#include <map>
#include <string>
using std::string;
using std::string; using std::to_string;
#include <inja.hpp>
using namespace inja;
@@ -36,7 +36,14 @@ int main(int argc, char *argv[])
// Add custom command callbacks.
env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
return "//\n// DO NOT MODIFY THIS FILE! IT IS AUTO-GENERATED FROM " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
});
env.add_callback("subtract", 2, [](Arguments& args) {
int minuend = args.at(0)->get<int>();
int subtrahend = args.at(1)->get<int>();
return minuend - subtrahend;
});
env.add_callback("setVar", 2, [=](Arguments& args) {
@@ -46,6 +53,13 @@ int main(int argc, char *argv[])
return "";
});
env.add_callback("setVarInt", 2, [=](Arguments& args) {
string key = args.at(0)->get<string>();
string value = to_string(args.at(1)->get<int>());
set_custom_var(key, value);
return "";
});
env.add_callback("getVar", 1, [=](Arguments& args) {
string key = args.at(0)->get<string>();
return get_custom_var(key);
@@ -67,7 +81,6 @@ int main(int argc, char *argv[])
return rawValue.erase(0, prefix.length());
});
// Add custom command callbacks.
env.add_callback("removeSuffix", 2, [](Arguments& args) {
string rawValue = args.at(0)->get<string>();
string suffix = args.at(1)->get<string>();
@@ -78,6 +91,11 @@ int main(int argc, char *argv[])
return rawValue.substr(0, i);
});
// single argument is a json object
env.add_callback("isEmpty", 1, [](Arguments& args) {
return args.at(0)->empty();
});
try
{
env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);