mirror-chatterino2/src/common/NetworkResult.hpp

32 lines
785 B
C++
Raw Normal View History

#pragma once
#include <rapidjson/document.h>
#include <QJsonObject>
namespace chatterino {
class NetworkResult
{
public:
NetworkResult(const QByteArray &data, int status);
2019-09-03 23:32:22 +02:00
/// Parses the result as json and returns the root as an object.
/// Returns empty object if parsing failed.
QJsonObject parseJson() const;
2019-09-03 23:32:22 +02:00
/// Parses the result as json and returns the root as an array.
/// Returns empty object if parsing failed.
QJsonArray parseJsonArray() const;
/// Parses the result as json and returns the document.
rapidjson::Document parseRapidJson() const;
2018-08-02 14:23:27 +02:00
const QByteArray &getData() const;
int status() const;
static constexpr int timedoutStatus = -2;
2018-08-02 14:23:27 +02:00
private:
int status_;
2018-08-02 14:23:27 +02:00
QByteArray data_;
};
} // namespace chatterino