#include "DumpSource.h" #include #include #include #include #include #include #include #include "Killmail.h" using json = nlohmann::json; using tm = std::tm; void from_json(const json& j, tm& d); void from_json(const json& j, Killmail& km); NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(LongVector3, x, y, z) DumpSource::DumpSource(const char* filename) : m_killmails {} { if (!FileExists(filename)) throw "File does not exist"; char* text = LoadFileText(filename); auto dump = json::parse(text); dump.at("killmails").get_to(m_killmails); UnloadFileText(text); } std::vector DumpSource::killmails() const { return m_killmails; } void from_json(const json& j, tm& d) { std::istringstream str(j.get()); str >> std::get_time(&d, "%Y-%m-%dT%H:%M:%SZ"); } void from_json(const json& j, Killmail& km) { j.at("victim").at("position").get_to(km.position); j.at("killmail_time").get_to(km.time); }