From efeb50a46ad824aa258472f6ac8da74810f05a55 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 31 Mar 2018 13:16:02 +0900 Subject: Move source files to a separate folder It's been long overdue to separate them from the rest of the stuff (docs etc.). Also, this allows installing to a directory within the checked out git tree (say, ./install/, similar to ./build/). --- lib/jobs/requestdata.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/jobs/requestdata.cpp (limited to 'lib/jobs/requestdata.cpp') diff --git a/lib/jobs/requestdata.cpp b/lib/jobs/requestdata.cpp new file mode 100644 index 00000000..5cb62221 --- /dev/null +++ b/lib/jobs/requestdata.cpp @@ -0,0 +1,38 @@ +#include "requestdata.h" + +#include +#include +#include +#include +#include + +using namespace QMatrixClient; + +auto fromData(const QByteArray& data) +{ + auto source = std::make_unique(); + source->open(QIODevice::WriteOnly); + source->write(data); + source->close(); + return source; +} + +template +inline auto fromJson(const JsonDataT& jdata) +{ + return fromData(QJsonDocument(jdata).toJson(QJsonDocument::Compact)); +} + +RequestData::RequestData(const QByteArray& a) + : _source(fromData(a)) +{ } + +RequestData::RequestData(const QJsonObject& jo) + : _source(fromJson(jo)) +{ } + +RequestData::RequestData(const QJsonArray& ja) + : _source(fromJson(ja)) +{ } + +RequestData::~RequestData() = default; -- cgit v1.2.3