From 71cfb21e618b6aca150cc9d4bf8bed4fd3076c0f Mon Sep 17 00:00:00 2001 From: pantor Date: Tue, 15 May 2018 20:23:09 +0200 Subject: [PATCH] include nlohmann/json in inja directly --- README.md | 6 +++--- src/inja.hpp | 6 +----- {test/thirdparty => src}/nlohmann/LICENSE.MIT | 0 {test/thirdparty => src}/nlohmann/json.hpp | 0 test/meson.build | 3 +-- test/{thirdparty => src}/catch/LICENSE.txt | 0 test/{thirdparty => src}/catch/catch.hpp | 0 test/src/unit-files.cpp | 2 +- test/src/unit-renderer.cpp | 2 +- test/src/unit-string-helper.cpp | 2 +- 10 files changed, 8 insertions(+), 13 deletions(-) rename {test/thirdparty => src}/nlohmann/LICENSE.MIT (100%) rename {test/thirdparty => src}/nlohmann/json.hpp (100%) rename test/{thirdparty => src}/catch/LICENSE.txt (100%) rename test/{thirdparty => src}/catch/catch.hpp (100%) diff --git a/README.md b/README.md index 628c075..4bb870c 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,11 @@ inja::render("Hello {{ name }}!", data); // Returns "Hello world!" ## Integration -Inja is a headers only library, which can be downloaded from the [releases](https://github.com/pantor/inja/releases) or directly from the `src/` folder. Inja uses json by nlohmann as its single dependency, so make sure that it is included before inja. json can be found [here](https://github.com/nlohmann/json/releases). +Inja is a headers only library, which can be downloaded from the [releases](https://github.com/pantor/inja/releases) or directly from the `src/` folder. Inja uses `nlohmann/json.hpp` as its single dependency, so make sure it can be included from `inja.hpp`. json can be downloaded [here](https://github.com/nlohmann/json/releases). Then integration is as easy as: ```c++ -#include "json.hpp" -#include "inja.hpp" +#include +#include // For convenience using namespace inja; diff --git a/src/inja.hpp b/src/inja.hpp index 1c6639d..f2c27da 100644 --- a/src/inja.hpp +++ b/src/inja.hpp @@ -33,16 +33,12 @@ SOFTWARE. #define PANTOR_INJA_VERSION_PATCH 1 -#ifndef NLOHMANN_JSON_HPP - static_assert(false, "nlohmann/json not found."); -#endif - - #include #include #include #include #include +#include #include #include #include diff --git a/test/thirdparty/nlohmann/LICENSE.MIT b/src/nlohmann/LICENSE.MIT similarity index 100% rename from test/thirdparty/nlohmann/LICENSE.MIT rename to src/nlohmann/LICENSE.MIT diff --git a/test/thirdparty/nlohmann/json.hpp b/src/nlohmann/json.hpp similarity index 100% rename from test/thirdparty/nlohmann/json.hpp rename to src/nlohmann/json.hpp diff --git a/test/meson.build b/test/meson.build index ee6d295..5e364d8 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,8 +4,7 @@ unit_test = executable( 'src/unit-files.cpp', 'src/unit-renderer.cpp', 'src/unit-string-helper.cpp', - dependencies: inja_dep, - include_directories: include_directories('thirdparty') + dependencies: inja_dep ) test('Inja unit test', unit_test) diff --git a/test/thirdparty/catch/LICENSE.txt b/test/src/catch/LICENSE.txt similarity index 100% rename from test/thirdparty/catch/LICENSE.txt rename to test/src/catch/LICENSE.txt diff --git a/test/thirdparty/catch/catch.hpp b/test/src/catch/catch.hpp similarity index 100% rename from test/thirdparty/catch/catch.hpp rename to test/src/catch/catch.hpp diff --git a/test/src/unit-files.cpp b/test/src/unit-files.cpp index 60b1352..9d71a88 100644 --- a/test/src/unit-files.cpp +++ b/test/src/unit-files.cpp @@ -1,6 +1,6 @@ #include "catch/catch.hpp" -#include "nlohmann/json.hpp" #include "inja.hpp" +#include "nlohmann/json.hpp" using json = nlohmann::json; diff --git a/test/src/unit-renderer.cpp b/test/src/unit-renderer.cpp index d2f8a88..58c2d23 100644 --- a/test/src/unit-renderer.cpp +++ b/test/src/unit-renderer.cpp @@ -1,6 +1,6 @@ #include "catch/catch.hpp" -#include "nlohmann/json.hpp" #include "inja.hpp" +#include "nlohmann/json.hpp" diff --git a/test/src/unit-string-helper.cpp b/test/src/unit-string-helper.cpp index 87f4618..5e026dd 100644 --- a/test/src/unit-string-helper.cpp +++ b/test/src/unit-string-helper.cpp @@ -1,6 +1,6 @@ #include "catch/catch.hpp" -#include "nlohmann/json.hpp" #include "inja.hpp" +#include "nlohmann/json.hpp"