LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
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 {
18  {
19  QNetworkReply::NetworkError Error_;
20  QString ErrorText_;
21  QUrl Url_;
22  };
23 
24  UTIL_THREADS_API QDebug operator<< (QDebug debug, const NetworkReplyError&);
25 
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:
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 
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 }
std::variant< NetworkReplyError, NetworkReplySuccess > NRBase_t
Definition: networkresult.h:33
#define UTIL_THREADS_API
Definition: threadsconfig.h:16
QNetworkReply::NetworkError Error_
Definition: networkresult.h:19
QDebug operator<<(QDebug dbg, const CtString< N, Char > &str)
Definition: ctstringutils.h:86