'dynamic' namespace refactor + sensitivity is a NumberSetting now

This commit is contained in:
MihailRis
2024-03-31 17:30:02 +03:00
parent 398347bd81
commit 48982e3478
14 changed files with 168 additions and 140 deletions
+19 -15
View File
@@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include <memory>
#include <variant>
#include <unordered_map>
#include "../typedefs.h"
@@ -12,18 +13,21 @@ namespace dynamic {
class List;
class Value;
using number_t = double;
using integer_t = int64_t;
enum class valtype {
map, list, number, integer, string, boolean
none, map, list, number, integer, string, boolean
};
union valvalue {
Map* map;
List* list;
std::string* str;
double decimal;
int64_t integer;
uint64_t boolean;
};
using valvalue = std::variant<
Map*,
List*,
std::string,
number_t,
bool,
integer_t
>;
class Value {
public:
@@ -39,8 +43,8 @@ namespace dynamic {
~List();
std::string str(size_t index) const;
double num(size_t index) const;
int64_t integer(size_t index) const;
number_t num(size_t index) const;
integer_t integer(size_t index) const;
Map* map(size_t index) const;
List* list(size_t index) const;
bool flag(size_t index) const;
@@ -78,13 +82,13 @@ namespace dynamic {
~Map();
std::string getStr(std::string key) const;
double getNum(std::string key) const;
int64_t getInt(std::string key) const;
number_t getNum(std::string key) const;
integer_t getInt(std::string key) const;
bool getBool(std::string key) const;
std::string getStr(std::string key, const std::string& def) const;
double getNum(std::string key, double def) const;
int64_t getInt(std::string key, int64_t def) const;
number_t getNum(std::string key, double def) const;
integer_t getInt(std::string key, integer_t def) const;
bool getBool(std::string key, bool def) const;
void str(std::string key, std::string& dst) const;