diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:42:50 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:42:50 +0300 |
| commit | 5fad10f89c485cfdc7b99011f07609f8871160d4 (patch) | |
| tree | 1860b39753b652dfe54d3cbbc80c875f40198d1f /json4cpp/tools/macro_builder | |
| parent | 292baed7ac0cf84263263966ed32ed113cae857f (diff) | |
| parent | 9a737481aed085fd289f82dff1fa8c3c66627a7e (diff) | |
| download | Project-Tick-5fad10f89c485cfdc7b99011f07609f8871160d4.tar.gz Project-Tick-5fad10f89c485cfdc7b99011f07609f8871160d4.zip | |
Add 'json4cpp/' from commit '9a737481aed085fd289f82dff1fa8c3c66627a7e'
git-subtree-dir: json4cpp
git-subtree-mainline: 292baed7ac0cf84263263966ed32ed113cae857f
git-subtree-split: 9a737481aed085fd289f82dff1fa8c3c66627a7e
Diffstat (limited to 'json4cpp/tools/macro_builder')
| -rw-r--r-- | json4cpp/tools/macro_builder/main.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/json4cpp/tools/macro_builder/main.cpp b/json4cpp/tools/macro_builder/main.cpp new file mode 100644 index 0000000000..e676daaccc --- /dev/null +++ b/json4cpp/tools/macro_builder/main.cpp @@ -0,0 +1,43 @@ +#include <cstdlib> +#include <iostream> +#include <sstream> + +using namespace std; + +void build_code(int max_args) +{ + stringstream ss; + ss << "#define NLOHMANN_JSON_EXPAND( x ) x" << endl; + ss << "#define NLOHMANN_JSON_GET_MACRO("; + for (int i = 0 ; i < max_args ; i++) + ss << "_" << i + 1 << ", "; + ss << "NAME,...) NAME" << endl; + + ss << "#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \\" << endl; + for (int i = max_args ; i > 1 ; i--) + ss << "NLOHMANN_JSON_PASTE" << i << ", \\" << endl; + ss << "NLOHMANN_JSON_PASTE1)(__VA_ARGS__))" << endl; + + ss << "#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)" << endl; + for (int i = 3 ; i <= max_args ; i++) + { + ss << "#define NLOHMANN_JSON_PASTE" << i << "(func, "; + for (int j = 1 ; j < i -1 ; j++) + ss << "v" << j << ", "; + ss << "v" << i-1 << ") NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE" << i-1 << "(func, "; + for (int j = 2 ; j < i-1 ; j++) + ss << "v" << j << ", "; + ss << "v" << i-1 << ")" << endl; + } + + cout << ss.str() << endl; +} + +int main(int argc, char** argv) +{ + int max_args = 64; + build_code(max_args); + + return 0; +} + |
