Unity Scopes API
XmlReader.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
17  */
18 
19 #pragma once
20 
21 #ifndef _ENABLE_QT_EXPERIMENTAL_
22 #error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23 #endif
24 
25 #include <QtCore/QUrl>
26 #include <QtCore/QXmlStreamReader>
27 
28 #include <memory>
29 #include <vector>
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 namespace qt
38 {
39 
40 class XmlAsyncReader;
41 
47 class XmlReader final
48 {
49 public:
51  XmlReader();
52  ~XmlReader() = default;
53 
54  typedef std::shared_ptr<QXmlStreamReader> QXmlStreamReaderSptr;
55 
56  typedef QVector<QPair<QString, QString>> QXmlStreamReaderParameters;
58 
65  QXmlStreamReaderSptr read(QUrl const& uri) const;
66 
74  QXmlStreamReaderSptr read(QString const& host, QXmlStreamReaderParameters const& parameters) const;
75 
76 private:
77  XmlReader(XmlReader const&) = delete;
78  XmlReader& operator=(XmlReader const&) = delete;
79 
80  std::shared_ptr<XmlAsyncReader> p_;
81 };
82 
83 } // namespace qt
84 
85 } // namespace scopes
86 
87 } // namespace unity
QXmlStreamReaderSptr read(QUrl const &uri) const
Downloads a remote XML document and returns a parser containing the data.
Class that downloads http XML files synchronously.
Definition: XmlReader.h:47
Top-level namespace for all things Unity-related.
Definition: Version.h:49