QGIS API Documentation  2.6.0-Brighton
 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