From fa40f6facc5c500cae8bf890e66a7bf5d490387e Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 12:39:06 +0000 Subject: Rename util to json_helper --- src/main/util/util.cpp | 35 ----------------------------------- src/main/util/util.h | 19 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 src/main/util/util.cpp delete mode 100644 src/main/util/util.h (limited to 'src/main/util') diff --git a/src/main/util/util.cpp b/src/main/util/util.cpp deleted file mode 100644 index 7e7de8d..0000000 --- a/src/main/util/util.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by thecharlesblake on 11/13/17. -// - -#include -#include - -#include "util.h" - -using namespace std; -using namespace rapidjson; - -Document util::get_file_json(const string& filename) { - // Reads the file into a string - std::ifstream ifstr(filename); - std::stringstream buf; - buf << ifstr.rdbuf(); - - if (ifstr.fail()) { - throw runtime_error("could not read file " + filename); - } else { - Document d; - - d.Parse(buf.str().c_str()); - if (d.HasParseError()) { - throw runtime_error(filename + " not valid json"); - } else { - return d; - } - } -} - -void util::json_parse_err(const string& msg) { - throw runtime_error("Error in JSON doc: " + msg); -} diff --git a/src/main/util/util.h b/src/main/util/util.h deleted file mode 100644 index de2a94d..0000000 --- a/src/main/util/util.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Created by thecharlesblake on 11/13/17. -// - -#ifndef SOLVITAIRE_UTIL_H -#define SOLVITAIRE_UTIL_H - -#include - -#include - -class util { -public: - static rapidjson::Document get_file_json(const std::string&); - static void json_parse_err(const std::string& msg); -}; - - -#endif //SOLVITAIRE_UTIL_H -- cgit v1.2.1