use json for region map sections
- update nlohmann/json and pantor/inja in tools/ - create new inja template
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
CXX ?= g++
|
||||
|
||||
CXXFLAGS := -Wall -std=c++11 -O2
|
||||
CXXFLAGS := -Wall -std=c++17 -O2
|
||||
|
||||
INCLUDES := -I .
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user