feat: saving entities (WIP)

This commit is contained in:
MihailRis
2024-07-05 05:16:31 +03:00
parent 019a88ef84
commit f0270d3391
24 changed files with 290 additions and 101 deletions
+5 -22
View File
@@ -1,42 +1,22 @@
#ifndef DATA_DYNAMIC_HPP_
#define DATA_DYNAMIC_HPP_
#include "../typedefs.hpp"
#include "dynamic_fwd.hpp"
#include <cmath>
#include <string>
#include <vector>
#include <memory>
#include <ostream>
#include <variant>
#include <stdexcept>
#include <unordered_map>
namespace dynamic {
class Map;
class List;
enum class Type {
none=0, map, list, string, number, boolean, integer
};
using Map_sptr = std::shared_ptr<Map>;
using List_sptr = std::shared_ptr<List>;
struct none {};
inline constexpr none NONE = {};
using Value = std::variant<
none,
Map_sptr,
List_sptr,
std::string,
number_t,
bool,
integer_t
>;
const std::string& type_name(const Value& value);
List_sptr create_list(std::initializer_list<Value> values={});
Map_sptr create_map(std::initializer_list<std::pair<const std::string, Value>> entries={});
@@ -153,6 +133,9 @@ namespace dynamic {
Map& put(std::string key, int64_t value) {
return put(key, Value(static_cast<integer_t>(value)));
}
Map& put(std::string key, uint64_t value) {
return put(key, Value(static_cast<integer_t>(value)));
}
Map& put(std::string key, float value) {
return put(key, Value(static_cast<number_t>(value)));
}