mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-27 16:16:35 +03:00
initial sqlite, store user
This commit is contained in:
@@ -1,17 +1,12 @@
|
||||
#pragma once
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <optional>
|
||||
#include "../util.hpp"
|
||||
|
||||
namespace detail { // more or less because idk what to name this stuff
|
||||
template<typename T>
|
||||
struct is_optional : ::std::false_type {};
|
||||
|
||||
template<typename T>
|
||||
struct is_optional<::std::optional<T>> : ::std::true_type {};
|
||||
|
||||
template<typename T>
|
||||
inline void json_direct(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
if constexpr (is_optional<T>::value)
|
||||
if constexpr (::util::is_optional<T>::value)
|
||||
val = j.at(key).get<typename T::value_type>();
|
||||
else
|
||||
j.at(key).get_to(val);
|
||||
@@ -19,7 +14,7 @@ inline void json_direct(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
|
||||
template<typename T>
|
||||
inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
if constexpr (is_optional<T>::value) {
|
||||
if constexpr (::util::is_optional<T>::value) {
|
||||
if (j.contains(key))
|
||||
val = j.at(key).get<typename T::value_type>();
|
||||
else
|
||||
@@ -32,7 +27,7 @@ inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
|
||||
template<typename T>
|
||||
inline void json_nullable(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
if constexpr (is_optional<T>::value) {
|
||||
if constexpr (::util::is_optional<T>::value) {
|
||||
const auto &at = j.at(key);
|
||||
if (!at.is_null())
|
||||
val = at.get<typename T::value_type>();
|
||||
@@ -47,7 +42,7 @@ inline void json_nullable(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
|
||||
template<typename T>
|
||||
inline void json_optional_nullable(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
if constexpr (is_optional<T>::value) {
|
||||
if constexpr (::util::is_optional<T>::value) {
|
||||
if (j.contains(key)) {
|
||||
const auto &at = j.at(key);
|
||||
if (!at.is_null())
|
||||
@@ -68,7 +63,7 @@ inline void json_optional_nullable(const ::nlohmann::json &j, const char *key, T
|
||||
|
||||
template<typename T>
|
||||
inline void json_update_optional_nullable(const ::nlohmann::json &j, const char *key, T &val) {
|
||||
if constexpr (is_optional<T>::value) {
|
||||
if constexpr (::util::is_optional<T>::value) {
|
||||
if (j.contains(key)) {
|
||||
const auto &at = j.at(key);
|
||||
if (!at.is_null())
|
||||
@@ -89,7 +84,7 @@ inline void json_update_optional_nullable(const ::nlohmann::json &j, const char
|
||||
|
||||
template<typename T, typename U>
|
||||
inline void json_update_optional_nullable_default(const ::nlohmann::json &j, const char *key, T &val, const U &fallback) {
|
||||
if constexpr (is_optional<T>::value) {
|
||||
if constexpr (::util::is_optional<T>::value) {
|
||||
if (j.contains(key)) {
|
||||
const auto &at = j.at(key);
|
||||
if (at.is_null())
|
||||
|
||||
Reference in New Issue
Block a user