mirror of
https://github.com/pantor/inja.git
synced 2026-11-21 23:12:41 +00:00
unify json data type
This commit is contained in:
1 parent
4505fd0508
commit
12a2c9bbf2
8 files changed
+16
-31
No files matched your search
@@ -7,8 +7,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "function_storage.hpp"
|
#include "function_storage.hpp"
|
||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
@@ -19,8 +17,6 @@
|
|||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Class for changing the configuration.
|
* \brief Class for changing the configuration.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
using Arguments = std::vector<const json *>;
|
using Arguments = std::vector<const json *>;
|
||||||
using CallbackFunction = std::function<json(Arguments &args)>;
|
using CallbackFunction = std::function<json(Arguments &args)>;
|
||||||
using VoidCallbackFunction = std::function<void(Arguments &args)>;
|
using VoidCallbackFunction = std::function<void(Arguments &args)>;
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
namespace inja {
|
||||||
|
using json = nlohmann::json;
|
||||||
|
}
|
||||||
|
|
||||||
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
|
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
|
||||||
#ifndef INJA_THROW
|
#ifndef INJA_THROW
|
||||||
#define INJA_THROW(exception) throw exception
|
#define INJA_THROW(exception) throw exception
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include "function_storage.hpp"
|
#include "function_storage.hpp"
|
||||||
#include "string_view.hpp"
|
#include "string_view.hpp"
|
||||||
|
|
||||||
@@ -100,9 +98,9 @@ public:
|
|||||||
|
|
||||||
class LiteralNode : public ExpressionNode {
|
class LiteralNode : public ExpressionNode {
|
||||||
public:
|
public:
|
||||||
const nlohmann::json value;
|
const json value;
|
||||||
|
|
||||||
explicit LiteralNode(const nlohmann::json& value, size_t pos) : ExpressionNode(pos), value(value) { }
|
explicit LiteralNode(const json& value, size_t pos) : ExpressionNode(pos), value(value) { }
|
||||||
|
|
||||||
void accept(NodeVisitor& v) const {
|
void accept(NodeVisitor& v) const {
|
||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "token.hpp"
|
#include "token.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
#include "node.hpp"
|
#include "node.hpp"
|
||||||
@@ -689,7 +687,7 @@ class Renderer : public NodeVisitor {
|
|||||||
std::string ptr = node.key;
|
std::string ptr = node.key;
|
||||||
replace_substring(ptr, ".", "/");
|
replace_substring(ptr, ".", "/");
|
||||||
ptr = "/" + ptr;
|
ptr = "/" + ptr;
|
||||||
json_additional_data[nlohmann::json::json_pointer(ptr)] = *eval_expression_list(node.expression);
|
json_additional_data[json::json_pointer(ptr)] = *eval_expression_list(node.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
namespace inja {
|
||||||
|
using json = nlohmann::json;
|
||||||
|
}
|
||||||
|
|
||||||
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
|
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
|
||||||
#ifndef INJA_THROW
|
#ifndef INJA_THROW
|
||||||
#define INJA_THROW(exception) throw exception
|
#define INJA_THROW(exception) throw exception
|
||||||
@@ -51,8 +55,6 @@ SOFTWARE.
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
// #include "config.hpp"
|
// #include "config.hpp"
|
||||||
#ifndef INCLUDE_INJA_CONFIG_HPP_
|
#ifndef INCLUDE_INJA_CONFIG_HPP_
|
||||||
#define INCLUDE_INJA_CONFIG_HPP_
|
#define INCLUDE_INJA_CONFIG_HPP_
|
||||||
@@ -1562,8 +1564,6 @@ struct RenderConfig {
|
|||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
using Arguments = std::vector<const json *>;
|
using Arguments = std::vector<const json *>;
|
||||||
using CallbackFunction = std::function<json(Arguments &args)>;
|
using CallbackFunction = std::function<json(Arguments &args)>;
|
||||||
using VoidCallbackFunction = std::function<void(Arguments &args)>;
|
using VoidCallbackFunction = std::function<void(Arguments &args)>;
|
||||||
@@ -2367,8 +2367,6 @@ public:
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
// #include "function_storage.hpp"
|
// #include "function_storage.hpp"
|
||||||
|
|
||||||
// #include "string_view.hpp"
|
// #include "string_view.hpp"
|
||||||
@@ -2465,9 +2463,9 @@ public:
|
|||||||
|
|
||||||
class LiteralNode : public ExpressionNode {
|
class LiteralNode : public ExpressionNode {
|
||||||
public:
|
public:
|
||||||
const nlohmann::json value;
|
const json value;
|
||||||
|
|
||||||
explicit LiteralNode(const nlohmann::json& value, size_t pos) : ExpressionNode(pos), value(value) { }
|
explicit LiteralNode(const json& value, size_t pos) : ExpressionNode(pos), value(value) { }
|
||||||
|
|
||||||
void accept(NodeVisitor& v) const {
|
void accept(NodeVisitor& v) const {
|
||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
@@ -2860,7 +2858,6 @@ using TemplateStorage = std::map<std::string, Template>;
|
|||||||
// #include "utils.hpp"
|
// #include "utils.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
@@ -3498,8 +3495,6 @@ public:
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
// #include "config.hpp"
|
// #include "config.hpp"
|
||||||
|
|
||||||
// #include "exceptions.hpp"
|
// #include "exceptions.hpp"
|
||||||
@@ -4185,7 +4180,7 @@ class Renderer : public NodeVisitor {
|
|||||||
std::string ptr = node.key;
|
std::string ptr = node.key;
|
||||||
replace_substring(ptr, ".", "/");
|
replace_substring(ptr, ".", "/");
|
||||||
ptr = "/" + ptr;
|
ptr = "/" + ptr;
|
||||||
json_additional_data[nlohmann::json::json_pointer(ptr)] = *eval_expression_list(node.expression);
|
json_additional_data[json::json_pointer(ptr)] = *eval_expression_list(node.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -4221,8 +4216,6 @@ public:
|
|||||||
|
|
||||||
namespace inja {
|
namespace inja {
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Class for changing the configuration.
|
* \brief Class for changing the configuration.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
-3
@@ -3,14 +3,13 @@
|
|||||||
#include "hayai/hayai.hpp"
|
#include "hayai/hayai.hpp"
|
||||||
#include <inja/inja.hpp>
|
#include <inja/inja.hpp>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
inja::Environment env;
|
inja::Environment env;
|
||||||
|
|
||||||
const std::string test_file_directory {"../test/data/benchmark/"};
|
const std::string test_file_directory {"../test/data/benchmark/"};
|
||||||
|
|
||||||
json small_data = env.load_json(test_file_directory + "small_data.json");
|
auto small_data = env.load_json(test_file_directory + "small_data.json");
|
||||||
json large_data = env.load_json(test_file_directory + "large_data.json");
|
auto large_data = env.load_json(test_file_directory + "large_data.json");
|
||||||
std::string medium_template = env.load_file(test_file_directory + "medium_template.txt");
|
std::string medium_template = env.load_file(test_file_directory + "medium_template.txt");
|
||||||
std::string large_template = env.load_file(test_file_directory + "large_template.txt");
|
std::string large_template = env.load_file(test_file_directory + "large_template.txt");
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user