aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/main/game/sol_rules.cpp32
-rw-r--r--src/main/input-output/deal_parser.cpp6
-rw-r--r--src/main/input-output/json_helper.cpp (renamed from src/main/util/util.cpp)6
-rw-r--r--src/main/input-output/json_helper.h (renamed from src/main/util/util.h)2
-rw-r--r--src/main/main.cpp4
-rw-r--r--src/test/test_helper.cpp4
7 files changed, 28 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9afe98b..93420bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ set(sources src/main/input-output/command_line_helper.cpp
src/main/game/card.cpp src/main/input-output/deal_parser.h src/main/input-output/deal_parser.cpp
src/main/solver/solver.cpp src/main/solver/solver.h src/main/game/game_state.cpp
src/main/game/game_state.h src/main/game/sol_rules.h src/main/game/sol_rules.cpp
- src/main/game/pile.cpp src/main/game/pile.h src/main/util/util.cpp src/main/util/util.h src/main/input-output/sol_preset_types.h src/main/input-output/sol_preset_types.cpp)
+ src/main/game/pile.cpp src/main/game/pile.h src/main/input-output/json_helper.cpp src/main/input-output/json_helper.h src/main/input-output/sol_preset_types.h src/main/input-output/sol_preset_types.cpp)
set(sources_test src/test/test_helper.cpp
src/test/test_helper.h
src/test/spanish_patience_test.cpp
diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp
index a1567f7..28c2af7 100644
--- a/src/main/game/sol_rules.cpp
+++ b/src/main/game/sol_rules.cpp
@@ -9,7 +9,7 @@
#include "rapidjson/error/en.h"
#include "sol_rules.h"
-#include "../util/util.h"
+#include "../input-output/json_helper.h"
#include "../input-output/sol_preset_types.h"
using namespace std;
@@ -24,7 +24,7 @@ typedef sol_rules::build_policy pol;
const sol_rules sol_rules::from_file(const string rules_file) {
sol_rules sr = get_default();
- Document d = util::get_file_json(rules_file);
+ Document d = json_helper::get_file_json(rules_file);
modify_sol_rules(sr, d);
@@ -59,7 +59,7 @@ sol_rules sol_rules::get_default() {
void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (!d.IsObject()) {
- util::json_parse_err("JSON doc must be object");
+ json_helper::json_parse_err("JSON doc must be object");
}
if (d.HasMember("tableau piles")) {
@@ -69,7 +69,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["tableau piles"]["count"].IsInt()) {
sr.tableau_pile_count = static_cast<uint8_t>(d["tableau piles"]["count"].GetInt());
} else {
- util::json_parse_err("[tableau piles][count] must be an integer");
+ json_helper::json_parse_err("[tableau piles][count] must be an integer");
}
}
@@ -82,11 +82,11 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
} else if (bo_str == "descending") {
sr.build_ord = build_order::DESCENDING;
} else {
- util::json_parse_err("[tableau piles][build order] is invalid");
+ json_helper::json_parse_err("[tableau piles][build order] is invalid");
}
} else {
- util::json_parse_err("[tableau piles][build order] must be an string");
+ json_helper::json_parse_err("[tableau piles][build order] must be an string");
}
}
@@ -103,11 +103,11 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
} else if (bp_str == "no-build") {
sr.build_pol = build_policy::NO_BUILD;
} else {
- util::json_parse_err("[tableau piles][build policy] is invalid");
+ json_helper::json_parse_err("[tableau piles][build policy] is invalid");
}
} else {
- util::json_parse_err("[tableau piles][build policy] must be an string");
+ json_helper::json_parse_err("[tableau piles][build policy] must be an string");
}
}
@@ -120,16 +120,16 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
} else if (sp_str == "no-build") {
sr.spaces_pol = spaces_policy::NO_BUILD;
} else {
- util::json_parse_err("[tableau piles][spaces policy] is invalid");
+ json_helper::json_parse_err("[tableau piles][spaces policy] is invalid");
}
} else {
- util::json_parse_err("[tableau piles][spaces policy] must be an string");
+ json_helper::json_parse_err("[tableau piles][spaces policy] must be an string");
}
}
} else {
- util::json_parse_err("[tableau piles] must be an object");
+ json_helper::json_parse_err("[tableau piles] must be an object");
}
}
@@ -137,7 +137,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["max rank"].IsInt()) {
sr.max_rank = static_cast<card::rank_t>(d["max rank"].GetInt());
} else {
- util::json_parse_err("[max rank] must be an integer");
+ json_helper::json_parse_err("[max rank] must be an integer");
}
}
@@ -145,7 +145,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["hole"].IsBool()) {
sr.hole = d["hole"].GetBool();
} else {
- util::json_parse_err("[hole] must be a boolean");
+ json_helper::json_parse_err("[hole] must be a boolean");
}
}
@@ -153,7 +153,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["foundations"].IsBool()) {
sr.foundations = d["foundations"].GetBool();
} else {
- util::json_parse_err("[foundations] must be a boolean");
+ json_helper::json_parse_err("[foundations] must be a boolean");
}
}
@@ -161,7 +161,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["cells"].IsInt()) {
sr.cells = static_cast<uint8_t>(d["cells"].GetInt());
} else {
- util::json_parse_err("[cells] must be an integer");
+ json_helper::json_parse_err("[cells] must be an integer");
}
}
@@ -169,7 +169,7 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) {
if (d["stock size"].IsInt()) {
sr.stock_size = static_cast<uint8_t>(d["stock size"].GetInt());
} else {
- util::json_parse_err("[stock size] must be an integer");
+ json_helper::json_parse_err("[stock size] must be an integer");
}
}
}
diff --git a/src/main/input-output/deal_parser.cpp b/src/main/input-output/deal_parser.cpp
index c876e91..8637649 100644
--- a/src/main/input-output/deal_parser.cpp
+++ b/src/main/input-output/deal_parser.cpp
@@ -4,7 +4,7 @@
#include "deal_parser.h"
#include "../game/game_state.h"
-#include "../util/util.h"
+#include "json_helper.h"
using namespace std;
using namespace rapidjson;
@@ -35,7 +35,7 @@ void deal_parser::parse_tableau_piles(game_state &gs, const rapidjson::Document&
assert(json_tab_piles.IsArray());
if (gs.tableau_piles.size() != gs.rules.tableau_pile_count) {
- util::json_parse_err("Incorrect number of tableau piles");
+ json_helper::json_parse_err("Incorrect number of tableau piles");
}
for (auto p = std::make_pair(begin(json_tab_piles.GetArray()), begin(gs.tableau_piles));
@@ -67,7 +67,7 @@ void deal_parser::parse_cells(game_state &gs, const Document& doc) {
if (json_cell_arr.Empty()) return;
else if (gs.rules.cells != json_cell_arr.Size()) {
- util::json_parse_err("Incorrect number of cells");
+ json_helper::json_parse_err("Incorrect number of cells");
}
for (auto p = std::make_pair(begin(json_cell_arr), begin(gs.cells));
diff --git a/src/main/util/util.cpp b/src/main/input-output/json_helper.cpp
index 7e7de8d..89f4564 100644
--- a/src/main/util/util.cpp
+++ b/src/main/input-output/json_helper.cpp
@@ -5,12 +5,12 @@
#include <fstream>
#include <sstream>
-#include "util.h"
+#include "json_helper.h"
using namespace std;
using namespace rapidjson;
-Document util::get_file_json(const string& filename) {
+Document json_helper::get_file_json(const string& filename) {
// Reads the file into a string
std::ifstream ifstr(filename);
std::stringstream buf;
@@ -30,6 +30,6 @@ Document util::get_file_json(const string& filename) {
}
}
-void util::json_parse_err(const string& msg) {
+void json_helper::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/input-output/json_helper.h
index de2a94d..5ab24bc 100644
--- a/src/main/util/util.h
+++ b/src/main/input-output/json_helper.h
@@ -9,7 +9,7 @@
#include <rapidjson/schema.h>
-class util {
+class json_helper {
public:
static rapidjson::Document get_file_json(const std::string&);
static void json_parse_err(const std::string& msg);
diff --git a/src/main/main.cpp b/src/main/main.cpp
index e07e566..342cdd0 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -5,7 +5,7 @@
#include "input-output/command_line_helper.h"
#include "solver/solver.h"
#include "input-output/log_helper.h"
-#include "util/util.h"
+#include "input-output/json_helper.h"
using namespace rapidjson;
@@ -72,7 +72,7 @@ void solve_input_files(const vector<string> input_files, const sol_rules& rules)
for (const string& input_file : input_files) {
try {
// Reads in the input file to a json doc
- const Document in_doc = util::get_file_json(input_file);
+ const Document in_doc = json_helper::get_file_json(input_file);
// Attempts to create a game state object from the json
game_state gs(rules, in_doc);
diff --git a/src/test/test_helper.cpp b/src/test/test_helper.cpp
index 9c258a3..59e7584 100644
--- a/src/test/test_helper.cpp
+++ b/src/test/test_helper.cpp
@@ -7,13 +7,13 @@
#include "test_helper.h"
#include "../main/game/game_state.h"
#include "../main/solver/solver.h"
-#include "../main/util/util.h"
+#include "../main/input-output/json_helper.h"
using namespace rapidjson;
using namespace std;
bool test_helper::is_solvable(const std::string& input_file, const std::string& preset_type) {
- const Document in_doc = util::get_file_json(input_file);
+ const Document in_doc = json_helper::get_file_json(input_file);
const sol_rules rules = sol_rules::from_preset(preset_type);
game_state gs(rules, in_doc);