LeechCraft
0.6.70-16373-g319c272718
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 <variant>
12
#include <QNetworkReply>
13
#include "
../threadsconfig.h
"
14
15
namespace
LC::Util
16
{
17
struct
NetworkReplyError
18
{
19
QNetworkReply::NetworkError
Error_
;
20
QString
ErrorText_
;
21
QUrl
Url_
;
22
};
23
24
UTIL_THREADS_API
QDebug
operator<<
(
QDebug
debug
,
const
NetworkReplyError
&);
25
26
struct
NetworkReplySuccess
27
{
28
QByteArray
Data_
;
29
30
QVariant
HeaderLocation_
;
31
};
32
33
using
NRBase_t
= std::variant<NetworkReplyError, NetworkReplySuccess>;
34
35
class
UTIL_THREADS_API
NetworkReplyErrorException
:
public
std::runtime_error
36
{
37
NetworkReplyError
Error_;
38
public
:
39
explicit
NetworkReplyErrorException
(
NetworkReplyError
error);
40
41
const
NetworkReplyError
& GetError ()
const
;
42
};
43
44
UTIL_THREADS_API
QDebug
operator<<
(
QDebug
debug
,
const
NetworkReplyErrorException
&);
45
46
template
<
typename
,
typename
>
47
class
Either
;
48
49
class
UTIL_THREADS_API
NetworkResult
:
public
NRBase_t
50
{
51
public
:
52
using
NRBase_t::variant;
53
54
std::optional<NetworkReplyError> IsError ()
const
;
55
QByteArray GetReplyData ()
const
;
56
57
Either<QString, QByteArray>
ToEither (
const
QString& errorContext)
const
;
58
};
59
60
UTIL_THREADS_API
QDebug
operator<<
(
QDebug
debug
,
const
NetworkResult
&);
61
}
LC::Util::Either
Definition
either.h:22
LC::Util::NetworkReplyErrorException
Definition
networkresult.h:36
LC::Util::NetworkResult
Definition
networkresult.h:50
LC::Util
Definition
icoreproxy.h:34
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:118
LC::Util::operator<<
QDebug operator<<(QDebug dbg, const CtString< N, Char > &str)
Definition
ctstringutils.h:86
LC::Util::NRBase_t
std::variant< NetworkReplyError, NetworkReplySuccess > NRBase_t
Definition
networkresult.h:33
LC::Util::NetworkReplyError
Definition
networkresult.h:18
LC::Util::NetworkReplyError::Error_
QNetworkReply::NetworkError Error_
Definition
networkresult.h:19
LC::Util::NetworkReplyError::Url_
QUrl Url_
Definition
networkresult.h:21
LC::Util::NetworkReplyError::ErrorText_
QString ErrorText_
Definition
networkresult.h:20
LC::Util::NetworkReplySuccess
Definition
networkresult.h:27
LC::Util::NetworkReplySuccess::HeaderLocation_
QVariant HeaderLocation_
Definition
networkresult.h:30
LC::Util::NetworkReplySuccess::Data_
QByteArray Data_
Definition
networkresult.h:28
threadsconfig.h
UTIL_THREADS_API
#define UTIL_THREADS_API
Definition
threadsconfig.h:16
src
util
threads
coro
networkresult.h
Generated by
1.10.0