migrate from dynamic::Value to dv::value & total erase namespace 'dynamic'

This commit is contained in:
MihailRis
2024-09-18 23:31:18 +03:00
parent d3ba4b2e3e
commit 34d2e6d400
69 changed files with 1247 additions and 2248 deletions
+6 -7
View File
@@ -11,7 +11,6 @@
#include "coders/gzip.hpp"
#include "coders/json.hpp"
#include "coders/toml.hpp"
#include "data/dynamic.hpp"
#include "util/stringutil.hpp"
namespace fs = std::filesystem;
@@ -116,30 +115,30 @@ bool files::write_string(const fs::path& filename, const std::string content) {
}
bool files::write_json(
const fs::path& filename, const dynamic::Map* obj, bool nice
const fs::path& filename, const dv::value& obj, bool nice
) {
return files::write_string(filename, json::stringify(obj, nice, " "));
}
bool files::write_binary_json(
const fs::path& filename, const dynamic::Map* obj, bool compression
const fs::path& filename, const dv::value& obj, bool compression
) {
auto bytes = json::to_binary(obj, compression);
return files::write_bytes(filename, bytes.data(), bytes.size());
}
std::shared_ptr<dynamic::Map> files::read_json(const fs::path& filename) {
dv::value files::read_json(const fs::path& filename) {
std::string text = files::read_string(filename);
return json::parse(filename.string(), text);
}
std::shared_ptr<dynamic::Map> files::read_binary_json(const fs::path& file) {
dv::value files::read_binary_json(const fs::path& file) {
size_t size;
std::unique_ptr<ubyte[]> bytes(files::read_bytes(file, size));
auto bytes = files::read_bytes(file, size);
return json::from_binary(bytes.get(), size);
}
std::shared_ptr<dynamic::Map> files::read_toml(const fs::path& file) {
dv::value files::read_toml(const fs::path& file) {
return toml::parse(file.u8string(), files::read_string(file));
}