libQuotient
A Qt library for building matrix clients
requestdata.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net>
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 
4 #pragma once
5 
6 #include <Quotient/util.h>
7 
8 class QJsonObject;
9 class QJsonArray;
10 class QJsonDocument;
11 class QIODevice;
12 
13 namespace Quotient {
14 /**
15  * A simple wrapper that represents the request body.
16  * Provides a unified interface to dump an unstructured byte stream
17  * as well as JSON (and possibly other structures in the future) to
18  * a QByteArray consumed by QNetworkAccessManager request methods.
19  */
20 class QUOTIENT_API RequestData {
21 public:
22  Q_IMPLICIT RequestData(const QByteArray& a = {});
23  Q_IMPLICIT RequestData(const QJsonObject& jo);
24  Q_IMPLICIT RequestData(const QJsonArray& ja);
25  Q_IMPLICIT RequestData(QIODevice* source);
26 
27  QIODevice* source() const { return _source.get(); }
28 
29 private:
30  ImplPtr<QIODevice> _source;
31 };
32 } // namespace Quotient