ABWXMLHelper.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libabw project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10 #ifndef __ABWXMLHELPER_H__
11 #define __ABWXMLHELPER_H__
12
13 #include <memory>
14
15 #include <librevenge-stream/librevenge-stream.h>
16
17 #include <libxml/xmlreader.h>
18 #include <libxml/xmlstring.h>
19
20 namespace libabw
21 {
22
23 // An exception-safe wrapper around xmlChar *
24 class ABWXMLString
25 {
26 public:
27 ABWXMLString(xmlChar *xml);
28
29 const xmlChar *get() const;
30
31 operator const char *() const;
32
33 private:
34 std::shared_ptr<xmlChar> m_xml;
35 };
36
37 class ABWXMLProgressWatcher
38 {
39 ABWXMLProgressWatcher(const ABWXMLProgressWatcher &) = delete;
40 ABWXMLProgressWatcher &operator=(const ABWXMLProgressWatcher &) = delete;
41
42 public:
43 ABWXMLProgressWatcher();
44
45 void setReader(xmlTextReaderPtr reader);
46
47 bool isStuck() const;
48 void signalError();
49
50 private:
51 xmlTextReaderPtr m_reader;
52 int m_line;
53 int m_col;
54 bool m_wasError;
55 bool m_isStuck;
56 };
57
58 // create an xmlTextReader pointer from a librevenge::RVNGInputStream pointer
59 std::unique_ptr<xmlTextReader, void(*)(xmlTextReaderPtr)> xmlReaderForStream(librevenge::RVNGInputStream *input, ABWXMLProgressWatcher *watcher = nullptr);
60
61 } // namespace libabw
62
63 #endif // __ABWXMLHELPER_H__
64 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libabw::ABWXMLProgressWatcher::isStuck
bool isStuck() const
Definition: ABWXMLHelper.cpp:109
libabw::ABWXMLProgressWatcher::m_line
int m_line
Definition: ABWXMLHelper.h:52
libabw::ABWXMLProgressWatcher::m_col
int m_col
Definition: ABWXMLHelper.h:53
libabw::ABWXMLProgressWatcher::operator=
ABWXMLProgressWatcher & operator=(const ABWXMLProgressWatcher &)=delete
libabw::xmlReaderForStream
std::unique_ptr< xmlTextReader, void(*)(xmlTextReaderPtr)> xmlReaderForStream(librevenge::RVNGInputStream *input, ABWXMLProgressWatcher *watcher=nullptr)
Definition: ABWXMLHelper.h:59
libabw::ABWXMLProgressWatcher
Definition: ABWXMLHelper.h:37
libabw::ABWXMLProgressWatcher::m_wasError
bool m_wasError
Definition: ABWXMLHelper.h:54
libabw
Definition: AbiDocument.cpp:16
libabw::ABWXMLString::m_xml
std::shared_ptr< xmlChar > m_xml
Definition: ABWXMLHelper.h:34
libabw::ABWXMLProgressWatcher::ABWXMLProgressWatcher
ABWXMLProgressWatcher()
Definition: ABWXMLHelper.cpp:95
libabw::ABWXMLProgressWatcher::m_reader
xmlTextReaderPtr m_reader
Definition: ABWXMLHelper.h:51
libabw::ABWXMLProgressWatcher::setReader
void setReader(xmlTextReaderPtr reader)
Definition: ABWXMLHelper.cpp:104
libabw::ABWXMLString::get
const xmlChar * get() const
Definition: ABWXMLHelper.cpp:85
libabw::ABWXMLString
Definition: ABWXMLHelper.h:24
libabw::ABWXMLProgressWatcher::signalError
void signalError()
Definition: ABWXMLHelper.cpp:114
libabw::ABWXMLString::ABWXMLString
ABWXMLString(xmlChar *xml)
Definition: ABWXMLHelper.cpp:80
libabw::ABWXMLProgressWatcher::m_isStuck
bool m_isStuck
Definition: ABWXMLHelper.h:55