use json for region map sections

- update nlohmann/json and pantor/inja in tools/
  - create new inja template
This commit is contained in:
garakmon
2022-04-04 23:22:43 -04:00
parent 5160520639
commit 3fe423a6f4
8 changed files with 14642 additions and 12588 deletions

View File

@@ -7,6 +7,9 @@
#include <string>
using std::string; using std::to_string;
#include <algorithm>
using std::replace_if;
#include <inja.hpp>
using namespace inja;
using json = nlohmann::json;
@@ -33,6 +36,7 @@ int main(int argc, char *argv[])
string outputFilepath = argv[3];
Environment env;
env.set_trim_blocks(true);
// Add custom command callbacks.
env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
@@ -96,6 +100,19 @@ int main(int argc, char *argv[])
return args.at(0)->empty();
});
env.add_callback("isEmptyString", 1, [](Arguments& args) {
return args.at(0)->get<string>().empty();
});
env.add_callback("cleanString", 1, [](Arguments& args) {
string badChars = ".'{} \n\t-_\u00e9";
string str = args.at(0)->get<string>();
str.erase(remove_if(str.begin(), str.end(), [&badChars](const char &c) {
return badChars.find(c) != std::string::npos;
}), str.end());
return str;
});
try
{
env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);