1 #pragma once
2 
3 #include "GameSettings.h"
4 #include "rapidjson/document.h"
5 #include <string_theory/string>
6 
7 #include <vector>
8 
9 
10 namespace JsonUtility
11 {
12 	/** Write list of strings to file. */
13 	bool writeToFile(const char *name, const std::vector<ST::string> &strings);
14 
15 	/** Parse json to a list of strings. */
16 	bool parseJsonToListStrings(const char* jsonData, std::vector<ST::string> &strings);
17 
18 	/** Parse value as list of strings. */
19 	bool parseListStrings(const rapidjson::Value &value, std::vector<ST::string> &strings);
20 
21 	/** Parse a sector string to sector ID */
22 	uint8_t parseSectorID(const ST::string& sectorShortString);
23 
24 	/** Parse a given string field to sector ID */
25 	uint8_t parseSectorID(const rapidjson::Value& json, const char* fieldName);
26 
27 	/** Parse a given string array field to list of sector IDs */
28 	std::vector<uint8_t> parseSectorList(const rapidjson::Value& json, const char* fieldName);
29 
30 	/** Parse a given integer array field into a list keyed by game difficulty */
31 	std::array<uint8_t, NUM_DIF_LEVELS> readIntArrayByDiff(const rapidjson::Value& obj, const char* fieldName);
32 }
33