Merge pull request #34 from scaryrawr/char-reader

Switch to Json::CharReader
This commit is contained in:
Sergey Naumov
2020-10-25 21:05:25 +03:00
committed by GitHub

View File

@@ -2,6 +2,7 @@
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
#include <memory>
#include <auss.hpp> #include <auss.hpp>
#include <json/json.h> #include <json/json.h>
@@ -22,9 +23,11 @@ std::vector<std::ostream*> g_logging_err_outs = {
#define IPC_JSON_READ(ROOT) \ #define IPC_JSON_READ(ROOT) \
{ \ { \
Json::Reader reader; \ Json::CharReaderBuilder builder; \
if (!reader.parse(std::string(buf->payload, buf->header->size), ROOT, false)) { \ std::unique_ptr<Json::CharReader> reader{builder.newCharReader()}; \
throw invalid_reply_payload_error(auss_t() << "Failed to parse reply on \"" i3IPC_TYPE_STR "\": " << reader.getFormattedErrorMessages()); \ std::string error;\
if (!reader->parse(buf->payload, buf->payload + buf->header->size, &ROOT, &error)) { \
throw invalid_reply_payload_error(auss_t() << "Failed to parse reply on \"" i3IPC_TYPE_STR "\": " << error); \
} \ } \
} }