From 99a1b09e257325bd05b53f85dece82a283ca33f7 Mon Sep 17 00:00:00 2001 From: VoltZ <47382115+SuperSaiyajinVoltZ@users.noreply.github.com> Date: Sun, 3 Nov 2019 21:14:27 +0100 Subject: [PATCH] Don't show those notes with the json stuff and get rid of `pase.cpp/.hpp` Part 3/3. --- source/utils/parse.cpp | 70 ------------------------------------------ 1 file changed, 70 deletions(-) delete mode 100644 source/utils/parse.cpp diff --git a/source/utils/parse.cpp b/source/utils/parse.cpp deleted file mode 100644 index 3db0c28..0000000 --- a/source/utils/parse.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include "json.hpp" - - -std::string get(nlohmann::json json, const std::string &key, const std::string &key2) { - if(!json.contains(key)) return "MISSING: " + key; - if(!json.at(key).is_object()) return "NOT OBJECT: " + key; - - if(!json.at(key).contains(key2)) return "MISSING: " + key + "." + key2; - if(!json.at(key).at(key2).is_string()) return "NOT STRING: " + key + "." + key2; - - return json.at(key).at(key2).get_ref(); -} - -void parse(std::string fileName) { - FILE* file = fopen(fileName.c_str(), "rt"); - if(!file) { - printf("File not found\n"); - fclose(file); - return; - } - nlohmann::json json = nlohmann::json::parse(file, nullptr, false); - fclose(file); - - std::string title = get(json, "info", "title"); - std::string description = get(json, "info", "description"); - - printf("%s\n", title.c_str()); - printf("%s\n", description.c_str()); - printf("------------------------------------------------------------------------------------------\n"); - - printf("Options:\n"); - for(auto it = json.begin();it != json.end(); it++) { - if(it.key() != "info") { - printf("> %s\n", it.key().c_str()); - } - } - printf("------------------------------------------------------------------------------------------\n"); - - char choise[16]; - while(!json.contains(choise)) { - printf("Choose an option: "); - scanf("%s", choise); - } - - printf("Parsing %s...\n", choise); - for(int i=0;i