QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
33 class CORE_EXPORT QgsNetworkReplyParser : public QObject
34 {
35  Q_OBJECT
36 
37  public:
38  typedef QMap<QByteArray, QByteArray> RawHeaderMap;
39 
42  QgsNetworkReplyParser( QNetworkReply *reply );
43 
46  bool isValid() const { return mValid; }
47 
50  int parts() const { return mHeaders.size(); }
51 
56  QByteArray rawHeader( int part, const QByteArray & headerName ) const { return mHeaders.value( part ).value( headerName ); }
57 
59  QList< RawHeaderMap > headers() const { return mHeaders; }
60 
64  QByteArray body( int part ) const { return mBodies.value( part ); }
65 
67  QList<QByteArray> bodies() const { return mBodies; }
68 
70  QString error() const { return mError; }
71 
74  static bool isMultipart( QNetworkReply *reply );
75 
76  private:
77  QNetworkReply *mReply;
78 
79  bool mValid;
80 
81  QString mError;
82 
83  /* List of header maps */
84  QList< RawHeaderMap > mHeaders;
85 
86  /* List of part bodies */
87  QList<QByteArray> mBodies;
88 };
89 
90 #endif
QList< QByteArray > bodies() const
Get bodies.
Definition: qgsnetworkreplyparser.h:67
bool isValid() const
Indicates if successfully parsed.
Definition: qgsnetworkreplyparser.h:46
QMap< QByteArray, QByteArray > RawHeaderMap
Definition: qgsnetworkreplyparser.h:38
int parts() const
Get number of parts.
Definition: qgsnetworkreplyparser.h:50
QByteArray rawHeader(int part, const QByteArray &headerName) const
Get part header.
Definition: qgsnetworkreplyparser.h:56
QByteArray body(int part) const
Get part part body.
Definition: qgsnetworkreplyparser.h:64
QList< RawHeaderMap > headers() const
Get headers.
Definition: qgsnetworkreplyparser.h:59
QString error() const
Parsing error.
Definition: qgsnetworkreplyparser.h:70
Multipart QNetworkReply parser.
Definition: qgsnetworkreplyparser.h:33