mirror-chatterino2/src/common/NetworkResult.hpp

28 lines
685 B
C++
Raw Normal View History

#pragma once
#include <rapidjson/document.h>
#include <QJsonObject>
namespace chatterino {
class NetworkResult
{
public:
NetworkResult(const QByteArray &data);
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;
private:
QByteArray data_;
};
} // namespace chatterino