25#include "../../abi/json.hpp"
26#include "../../abi/vector.hpp"
36namespace essence::globalization::abstract {
43 requires(!std::same_as<std::decay_t<T>,
compiler>)
44 explicit compiler(T&& value) : wrapper_{std::make_shared<wrapper<T>>(std::forward<T>(value))} {}
50 [[nodiscard]] std::uint32_t
version()
const {
51 return wrapper_->version();
59 void to_file(
const abi::json& json, std::string_view path)
const {
60 wrapper_->to_file(json, path);
68 [[nodiscard]] abi::vector<std::byte>
to_bytes(
const abi::json& json)
const {
69 return wrapper_->to_bytes(json);
77 [[nodiscard]] abi::string
to_base64(
const abi::json& json)
const {
78 return wrapper_->to_base64(json);
83 virtual ~base() =
default;
84 virtual std::uint32_t version() = 0;
85 virtual void to_file(
const abi::json& json, std::string_view path) = 0;
86 virtual abi::vector<std::byte> to_bytes(
const abi::json& json) = 0;
87 virtual abi::string to_base64(
const abi::json& json) = 0;
91 class wrapper final :
public base {
93 template <std::convertible_to<T> U>
94 explicit wrapper(U&& value) : value_{std::forward<U>(value)} {}
96 std::uint32_t version()
override {
97 return value_.version();
100 void to_file(
const abi::json&
json, std::string_view path)
override {
101 value_.to_file(
json, path);
104 abi::vector<std::byte> to_bytes(
const abi::json&
json)
override {
105 return value_.to_bytes(
json);
108 abi::string to_base64(
const abi::json&
json)
override {
109 return value_.to_base64(
json);
116 std::shared_ptr<base> wrapper_;
namespace for Niels Lohmann
Definition json.hpp:19415
A compiler to translate globalized texts into particular binary sequences.
Definition compiler.hpp:40
std::uint32_t version() const
Gets the version of the compiler.
Definition compiler.hpp:50
abi::string to_base64(const abi::json &json) const
Compiles a JSON value into a base64 string.
Definition compiler.hpp:77
abi::vector< std::byte > to_bytes(const abi::json &json) const
Compiles a JSON value into a byte array.
Definition compiler.hpp:68
void to_file(const abi::json &json, std::string_view path) const
Compiles a JSON value into a language file.
Definition compiler.hpp:59