QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsnetworkreplyparser.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnetworkreplyparser.h - Multipart QNetworkReply parser
3  -------------------
4  begin : 4 January, 2013
5  copyright : (C) 2013 by Radim Blazek
6  email : radim dot blazek at gmail.com
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSNETWORKREPLYPARSER_H
20 #define QGSNETWORKREPLYPARSER_H
21 
22 #define SIP_NO_FILE
23 
24 #include <QNetworkReply>
25 
26 #include "qgis_core.h"
27 
38 class CORE_EXPORT QgsNetworkReplyParser : public QObject
39 {
40  Q_OBJECT
41 
42  public:
43  typedef QMap<QByteArray, QByteArray> RawHeaderMap;
44 
49  QgsNetworkReplyParser( QNetworkReply *reply );
50 
55  bool isValid() const { return mValid; }
56 
61  int parts() const { return mHeaders.size(); }
62 
69  QByteArray rawHeader( int part, const QByteArray &headerName ) const { return mHeaders.value( part ).value( headerName ); }
70 
72  QList< RawHeaderMap > headers() const { return mHeaders; }
73 
79  QByteArray body( int part ) const { return mBodies.value( part ); }
80 
82  QList<QByteArray> bodies() const { return mBodies; }
83 
85  QString error() const { return mError; }
86 
91  static bool isMultipart( QNetworkReply *reply );
92 
93  private:
94  QNetworkReply *mReply = nullptr;
95 
96  bool mValid;
97 
98  QString mError;
99 
100  /* List of header maps */
101  QList< RawHeaderMap > mHeaders;
102 
103  /* List of part bodies */
104  QList<QByteArray> mBodies;
105 };
106 
107 #endif
QgsNetworkReplyParser::parts
int parts() const
Gets number of parts.
Definition: qgsnetworkreplyparser.h:61
QgsNetworkReplyParser::body
QByteArray body(int part) const
Gets part part body.
Definition: qgsnetworkreplyparser.h:79
QgsNetworkReplyParser::isValid
bool isValid() const
Indicates if successfully parsed.
Definition: qgsnetworkreplyparser.h:55
QgsNetworkReplyParser::headers
QList< RawHeaderMap > headers() const
Gets headers.
Definition: qgsnetworkreplyparser.h:72
QgsNetworkReplyParser::RawHeaderMap
QMap< QByteArray, QByteArray > RawHeaderMap
Definition: qgsnetworkreplyparser.h:43
QgsNetworkReplyParser::rawHeader
QByteArray rawHeader(int part, const QByteArray &headerName) const
Gets part header.
Definition: qgsnetworkreplyparser.h:69
QgsNetworkReplyParser::bodies
QList< QByteArray > bodies() const
Gets bodies.
Definition: qgsnetworkreplyparser.h:82
QgsNetworkReplyParser::error
QString error() const
Parsing error.
Definition: qgsnetworkreplyparser.h:85
QgsNetworkReplyParser
Multipart QNetworkReply parser.
Definition: qgsnetworkreplyparser.h:38