Permalink
Browse files

Add submodules, namespace json to prepare for the addition of rapidjs…

…on (sigh)
  • Loading branch information...
hrydgard committed Aug 12, 2018
1 parent 42f4d7b commit eddaf9793834dfba80605a04e0455fef93fb21af
@@ -19,3 +19,9 @@
[submodule "ext/SPIRV-Cross"]
path = ext/SPIRV-Cross
url = https://github.com/KhronosGroup/SPIRV-Cross.git
[submodule "ext/discord-rpc"]
path = ext/discord-rpc
url = https://github.com/discordapp/discord-rpc.git
[submodule "ext/rapidjson"]
path = ext/rapidjson
url = https://github.com/Tencent/rapidjson.git
@@ -1162,8 +1162,8 @@ void Config::DownloadCompletedCallback(http::Download &download) {
return;
}
JsonReader reader(data.c_str(), data.size());
const JsonGet root = reader.root();
json::JsonReader reader(data.c_str(), data.size());
const json::JsonGet root = reader.root();
if (!root) {
ERROR_LOG(LOADER, "Failed to parse json");
return;
@@ -24,6 +24,8 @@
#include "net/websocket_server.h"
#include "Common/Log.h"
using namespace json;
static inline void DebuggerJsonAddTicket(JsonWriter &writer, const JsonGet &data) {
const JsonNode *value = data.get("ticket");
if (value)
@@ -82,6 +82,8 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
std::string json;
result.TakeAll(&json);
using namespace json;
JsonReader reader(json.c_str(), json.size());
if (!reader.ok()) {
return false;
@@ -391,6 +391,7 @@ void StoreScreen::update() {
}
void StoreScreen::ParseListing(std::string json) {
using namespace json;
JsonReader reader(json.c_str(), json.size());
if (!reader.ok() || !reader.root()) {
ELOG("Error parsing JSON from store");
@@ -540,8 +541,8 @@ std::string StoreScreen::GetStoreJsonURL(std::string storePath) const {
return path;
}
std::string StoreScreen::GetTranslatedString(const JsonGet json, std::string key, const char *fallback) const {
JsonGet dict = json.getDict("en_US");
std::string StoreScreen::GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback) const {
json::JsonGet dict = json.getDict("en_US");
if (dict && json.hasChild(lang_.c_str(), JSON_OBJECT)) {
if (json.getDict(lang_.c_str()).hasChild(key.c_str(), JSON_STRING)) {
dict = json.getDict(lang_.c_str());
@@ -29,7 +29,10 @@
// set game specific settings, etc.
// Uses GameInfoCache heavily to implement the functionality.
struct JsonGet;
namespace json {
struct JsonGet;
}
class ProductItemView;
enum EntryType {
@@ -79,7 +82,7 @@ class StoreScreen : public UIDialogScreenWithBackground {
std::vector<StoreEntry> FilterEntries();
std::string GetStoreJsonURL(std::string storePath) const;
std::string GetTranslatedString(const JsonGet json, std::string key, const char *fallback = nullptr) const;
std::string GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback = nullptr) const;
std::shared_ptr<http::Download> listing_;
std::shared_ptr<http::Download> image_;
Submodule discord-rpc added at 3d3ae7
@@ -2,6 +2,8 @@
#include "file/vfs.h"
#include "json/json_reader.h"
namespace json {
JsonReader::JsonReader(const std::string &filename) {
size_t buf_size;
buffer_ = (char *)VFSReadFile(filename.c_str(), &buf_size);
@@ -117,3 +119,5 @@ bool JsonGet::getBool(const char *child_name, bool default_value) const {
}
return default_value;
}
} // namespace json
@@ -1,9 +1,12 @@
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/logging.h"
#include "ext/gason/gason.h"
namespace json {
struct JsonGet {
JsonGet(const JsonValue &value) : value_(value) {
}
@@ -83,3 +86,5 @@ class JsonReader {
DISALLOW_COPY_AND_ASSIGN(JsonReader);
};
} // namespace json
@@ -1,9 +1,12 @@
#include <iomanip>
#include <cmath>
#include <cstring>
#include "json/json_reader.h"
#include "json/json_writer.h"
namespace json {
JsonWriter::JsonWriter(int flags) {
pretty_ = (flags & PRETTY) != 0;
str_.imbue(std::locale::classic());
@@ -383,3 +386,5 @@ static void json_stringify_array(JsonWriter &writer, const JsonNode *node) {
break;
}
}
} // namespace json
@@ -13,6 +13,10 @@
#include <vector>
#include <sstream>
struct JsonNode;
namespace json {
class JsonWriter {
public:
JsonWriter(int flags = NORMAL);
@@ -79,5 +83,6 @@ class JsonWriter {
bool pretty_;
};
struct JsonNode;
std::string json_stringify(const JsonNode *json);
} // namespace json
Submodule rapidjson added at 73063f

0 comments on commit eddaf97

Please sign in to comment.