LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
networkresult.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <source_location>
12#include <variant>
13#include <QtNetwork/QNetworkReply>
14#include "../threadsconfig.h"
15
16namespace LC::Util
17{
19 {
20 QNetworkReply::NetworkError Error_;
21 QString ErrorText_;
22 QUrl Url_;
23 };
24
25 UTIL_THREADS_API QDebug operator<< (QDebug debug, const NetworkReplyError&);
26
28 {
29 QByteArray Data_;
30
32 };
33
34 using NRBase_t = std::variant<NetworkReplyError, NetworkReplySuccess>;
35
36 class UTIL_THREADS_API NetworkReplyErrorException : public std::runtime_error
37 {
38 NetworkReplyError Error_;
39 public:
41
42 const NetworkReplyError& GetError () const;
43 };
44
45 UTIL_THREADS_API QDebug operator<< (QDebug debug, const NetworkReplyErrorException&);
46
47 template<typename, typename>
48 class Either;
49
51 {
52 public:
53 using NRBase_t::variant;
54
55 std::optional<NetworkReplyError> IsError () const;
56 QByteArray GetReplyData () const;
57
58 Either<QString, QByteArray> ToEither (const std::source_location& = std::source_location::current ()) const;
59 Either<QString, QByteArray> ToEither (const QString& errorContext) const;
60 };
61
62 UTIL_THREADS_API QDebug operator<< (QDebug debug, const NetworkResult&);
63}
const NetworkReplyError & GetError() const
NetworkReplyErrorException(NetworkReplyError error)
std::optional< NetworkReplyError > IsError() const
Either< QString, QByteArray > ToEither(const std::source_location &=std::source_location::current()) const
QByteArray GetReplyData() const
QDebug operator<<(QDebug dbg, const CtString< N, Char > &str)
std::variant< NetworkReplyError, NetworkReplySuccess > NRBase_t
QNetworkReply::NetworkError Error_
#define UTIL_THREADS_API