From e6634ed26c50e99f6ccd285235fe477cb4168b06 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sat, 9 May 2020 15:51:15 +0100 Subject: Update submodules (#4727) Closes #4708 This updates jsoncpp, mbedtls, TCLAP and SQLiteCpp to their latest stable release. A few additional changes were needed: * jsoncpp deprecated Reader, FastWriter and StyledWriter which I've replaced with some helper functions in JsonUtils.cpp * SQLiteCpp changed how it builds with external sqlite libraries, now expecting them to be installed. The simplest path was to remove sqlite from cuberite's submodule and just use SQLiteCpp's internal version. --- src/JsonUtils.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/JsonUtils.cpp (limited to 'src/JsonUtils.cpp') diff --git a/src/JsonUtils.cpp b/src/JsonUtils.cpp new file mode 100644 index 000000000..6c70e70d3 --- /dev/null +++ b/src/JsonUtils.cpp @@ -0,0 +1,43 @@ +#include "Globals.h" + +#include "JsonUtils.h" +#include "json/json.h" + +#include + + +namespace JsonUtils +{ + +AString WriteFastString(const Json::Value & a_Root) +{ + Json::StreamWriterBuilder Builder; + Builder["commentStyle"] = "None"; + Builder["indentation"] = ""; + return Json::writeString(Builder, a_Root); +} + + + + + +AString WriteStyledString(const Json::Value & a_Root) +{ + Json::StreamWriterBuilder Builder; + return Json::writeString(Builder, a_Root); +} + + + + + +bool ParseString(const AString & a_JsonStr, Json::Value & a_Root, AString * a_ErrorMsg) +{ + Json::CharReaderBuilder Builder; + std::unique_ptr Reader(Builder.newCharReader()); + + const char * Doc = a_JsonStr.data(); + return Reader->parse(Doc, Doc + a_JsonStr.size(), &a_Root, a_ErrorMsg); +} + +} // namespace JsonUtils -- cgit v1.2.3