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