QGIS API Documentation  2.13.0-Master
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 
34 class CORE_EXPORT QgsNetworkReplyParser : public QObject
35 {
36  Q_OBJECT
37 
38  public:
40 
44 
47  bool isValid() const { return mValid; }
48 
51  int parts() const { return mHeaders.size(); }
52 
57  QByteArray rawHeader( int part, const QByteArray & headerName ) const { return mHeaders.value( part ).value( headerName ); }
58 
60  QList< RawHeaderMap > headers() const { return mHeaders; }
61 
65  QByteArray body( int part ) const { return mBodies.value( part ); }
66 
68  QList<QByteArray> bodies() const { return mBodies; }
69 
71  QString error() const { return mError; }
72 
75  static bool isMultipart( QNetworkReply *reply );
76 
77  private:
78  QNetworkReply *mReply;
79 
80  bool mValid;
81 
82  QString mError;
83 
84  /* List of header maps */
85  QList< RawHeaderMap > mHeaders;
86 
87  /* List of part bodies */
88  QList<QByteArray> mBodies;
89 };
90 
91 #endif
QList< QByteArray > bodies() const
Get bodies.
bool isValid() const
Indicates if successfully parsed.
QMap< QByteArray, QByteArray > RawHeaderMap
int parts() const
Get number of parts.
QByteArray rawHeader(int part, const QByteArray &headerName) const
Get part header.
QByteArray body(int part) const
Get part part body.
QList< RawHeaderMap > headers() const
Get headers.
QString error() const
Parsing error.
Multipart QNetworkReply parser.