mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
'dynamic' namespace refactor (step 2)
This commit is contained in:
parent
d33edd4cd9
commit
8e83a07094
10 changed files with 44 additions and 51 deletions
|
|
@ -246,22 +246,10 @@ Value::~Value() {
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Value> Value::boolean(bool value) {
|
||||
std::unique_ptr<Value> dynamic::value_of(const valvalue& value) {
|
||||
return std::make_unique<Value>(value);
|
||||
}
|
||||
|
||||
std::unique_ptr<Value> Value::of(number_u value) {
|
||||
if (std::holds_alternative<integer_t>(value)) {
|
||||
return std::make_unique<Value>(std::get<integer_t>(value));
|
||||
} else {
|
||||
return std::make_unique<Value>(std::get<number_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Value> Value::of(const std::string& value) {
|
||||
return std::make_unique<Value>(value);
|
||||
}
|
||||
|
||||
std::unique_ptr<Value> Value::of(std::unique_ptr<Map> value) {
|
||||
std::unique_ptr<Value> dynamic::value_of(std::unique_ptr<Map> value) {
|
||||
return std::make_unique<Value>(value.release());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,12 +34,9 @@ namespace dynamic {
|
|||
valvalue value;
|
||||
Value(valvalue value);
|
||||
~Value();
|
||||
|
||||
static std::unique_ptr<Value> boolean(bool value);
|
||||
static std::unique_ptr<Value> of(number_u value);
|
||||
static std::unique_ptr<Value> of(const std::string& value);
|
||||
static std::unique_ptr<Value> of(std::unique_ptr<Map> value);
|
||||
};
|
||||
std::unique_ptr<Value> value_of(const valvalue& value);
|
||||
std::unique_ptr<Value> value_of(std::unique_ptr<Map> value);
|
||||
|
||||
class List {
|
||||
public:
|
||||
|
|
@ -121,7 +118,7 @@ namespace dynamic {
|
|||
return put(key, std::make_unique<Value>(value));
|
||||
}
|
||||
Map& put(std::string key, uint64_t value) {
|
||||
return put(key, Value::of(static_cast<integer_t>(value)));
|
||||
return put(key, value_of(static_cast<integer_t>(value)));
|
||||
}
|
||||
|
||||
Map& put(std::string key, std::unique_ptr<Value> value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue