Fix: Remove circular dependencies in headers (#295)

* Remove circular dependencies in headers

* Fix unit test includes and test data directory location
This commit is contained in:
Vladislav Navrocky
2025-02-11 11:03:42 +03:00
committed by GitHub
parent 17ba53cb9e
commit 384a6bef3f
17 changed files with 97 additions and 69 deletions

View File

@@ -7,12 +7,13 @@
#include <string>
#include <string_view>
#include "json.hpp"
#include "config.hpp"
#include "function_storage.hpp"
#include "inja.hpp"
#include "parser.hpp"
#include "renderer.hpp"
#include "template.hpp"
#include "throw.hpp"
namespace inja {

View File

@@ -8,7 +8,7 @@
#include <utility>
#include <vector>
#include "inja.hpp"
#include "json.hpp"
namespace inja {

View File

@@ -25,32 +25,8 @@ SOFTWARE.
#ifndef INCLUDE_INJA_INJA_HPP_
#define INCLUDE_INJA_INJA_HPP_
#include <nlohmann/json.hpp>
namespace inja {
#ifndef INJA_DATA_TYPE
using json = nlohmann::json;
#else
using json = INJA_DATA_TYPE;
#endif
} // namespace inja
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
#ifndef INJA_THROW
#define INJA_THROW(exception) throw exception
#endif
#else
#include <cstdlib>
#ifndef INJA_THROW
#define INJA_THROW(exception) \
std::abort(); \
std::ignore = exception
#endif
#ifndef INJA_NOEXCEPTION
#define INJA_NOEXCEPTION
#endif
#endif
#include "json.hpp"
#include "throw.hpp"
#include "environment.hpp"
#include "exceptions.hpp"
#include "parser.hpp"

14
include/inja/json.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef INCLUDE_INJA_JSON_HPP_
#define INCLUDE_INJA_JSON_HPP_
#include <nlohmann/json.hpp>
namespace inja {
#ifndef INJA_DATA_TYPE
using json = nlohmann::json;
#else
using json = INJA_DATA_TYPE;
#endif
} // namespace inja
#endif // INCLUDE_INJA_JSON_HPP_

View File

@@ -9,8 +9,8 @@
#include <vector>
#include "function_storage.hpp"
#include "inja.hpp"
#include "utils.hpp"
#include "json.hpp"
namespace inja {

View File

@@ -14,10 +14,10 @@
#include "config.hpp"
#include "exceptions.hpp"
#include "function_storage.hpp"
#include "inja.hpp"
#include "lexer.hpp"
#include "node.hpp"
#include "template.hpp"
#include "throw.hpp"
#include "token.hpp"
namespace inja {

View File

@@ -18,9 +18,9 @@
#include "config.hpp"
#include "exceptions.hpp"
#include "function_storage.hpp"
#include "inja.hpp"
#include "node.hpp"
#include "template.hpp"
#include "throw.hpp"
#include "utils.hpp"
namespace inja {

20
include/inja/throw.hpp Normal file
View File

@@ -0,0 +1,20 @@
#ifndef INCLUDE_INJA_THROW_HPP_
#define INCLUDE_INJA_THROW_HPP_
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
#ifndef INJA_THROW
#define INJA_THROW(exception) throw exception
#endif
#else
#include <cstdlib>
#ifndef INJA_THROW
#define INJA_THROW(exception) \
std::abort(); \
std::ignore = exception
#endif
#ifndef INJA_NOEXCEPTION
#define INJA_NOEXCEPTION
#endif
#endif
#endif // INCLUDE_INJA_THROW_HPP_