LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
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
16
namespace
LC::Util
17
{
18
struct
NetworkReplyError
19
{
20
QNetworkReply::NetworkError
Error_
;
21
QString
ErrorText_
;
22
QUrl
Url_
;
23
};
24
25
UTIL_THREADS_API
QDebug
operator<<
(QDebug debug,
const
NetworkReplyError
&);
26
27
struct
NetworkReplySuccess
28
{
29
QByteArray
Data_
;
30
31
QVariant
HeaderLocation_
;
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
:
40
explicit
NetworkReplyErrorException
(
NetworkReplyError
error);
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
50
class
UTIL_THREADS_API
NetworkResult
:
public
NRBase_t
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
}
LC::Util::Either
Definition
either.h:33
LC::Util::NetworkReplyErrorException
Definition
networkresult.h:37
LC::Util::NetworkReplyErrorException::GetError
const NetworkReplyError & GetError() const
Definition
networkresult.cpp:33
LC::Util::NetworkReplyErrorException::NetworkReplyErrorException
NetworkReplyErrorException(NetworkReplyError error)
Definition
networkresult.cpp:27
LC::Util::NetworkResult
Definition
networkresult.h:51
LC::Util::NetworkResult::IsError
std::optional< NetworkReplyError > IsError() const
Definition
networkresult.cpp:43
LC::Util::NetworkResult::ToEither
Either< QString, QByteArray > ToEither(const std::source_location &=std::source_location::current()) const
Definition
networkresult.cpp:57
LC::Util::NetworkResult::GetReplyData
QByteArray GetReplyData() const
Definition
networkresult.cpp:50
LC::Util
Definition
icoreproxy.h:34
LC::Util::operator<<
QDebug operator<<(QDebug dbg, const CtString< N, Char > &str)
Definition
ctstringutils.h:113
LC::Util::NRBase_t
std::variant< NetworkReplyError, NetworkReplySuccess > NRBase_t
Definition
networkresult.h:34
LC::Util::NetworkReplyError
Definition
networkresult.h:19
LC::Util::NetworkReplyError::Error_
QNetworkReply::NetworkError Error_
Definition
networkresult.h:20
LC::Util::NetworkReplyError::Url_
QUrl Url_
Definition
networkresult.h:22
LC::Util::NetworkReplyError::ErrorText_
QString ErrorText_
Definition
networkresult.h:21
LC::Util::NetworkReplySuccess
Definition
networkresult.h:28
LC::Util::NetworkReplySuccess::HeaderLocation_
QVariant HeaderLocation_
Definition
networkresult.h:31
LC::Util::NetworkReplySuccess::Data_
QByteArray Data_
Definition
networkresult.h:29
threadsconfig.h
UTIL_THREADS_API
#define UTIL_THREADS_API
Definition
threadsconfig.h:16
src
util
threads
coro
networkresult.h
Generated by
1.17.0