QGIS API Documentation  2.99.0-Master (b8fd1fd)
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 #include <QNetworkReply>
23 
24 #include "qgis_core.h"
25 
36 class CORE_EXPORT QgsNetworkReplyParser : public QObject
37 {
38  Q_OBJECT
39 
40  public:
41  typedef QMap<QByteArray, QByteArray> RawHeaderMap;
42 
45  QgsNetworkReplyParser( QNetworkReply *reply );
46 
49  bool isValid() const { return mValid; }
50 
53  int parts() const { return mHeaders.size(); }
54 
59  QByteArray rawHeader( int part, const QByteArray &headerName ) const { return mHeaders.value( part ).value( headerName ); }
60 
62  QList< RawHeaderMap > headers() const { return mHeaders; }
63 
67  QByteArray body( int part ) const { return mBodies.value( part ); }
68 
70  QList<QByteArray> bodies() const { return mBodies; }
71 
73  QString error() const { return mError; }
74 
77  static bool isMultipart( QNetworkReply *reply );
78 
79  private:
80  QNetworkReply *mReply = nullptr;
81 
82  bool mValid;
83 
84  QString mError;
85 
86  /* List of header maps */
87  QList< RawHeaderMap > mHeaders;
88 
89  /* List of part bodies */
90  QList<QByteArray> mBodies;
91 };
92 
93 #endif
QByteArray rawHeader(int part, const QByteArray &headerName) const
Get part header.
int parts() const
Get number of parts.
QList< RawHeaderMap > headers() const
Get headers.
QMap< QByteArray, QByteArray > RawHeaderMap
QByteArray body(int part) const
Get part part body.
bool isValid() const
Indicates if successfully parsed.
QString error() const
Parsing error.
Multipart QNetworkReply parser.
QList< QByteArray > bodies() const
Get bodies.