ABWXMLHelper.h Source File documentation

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
20namespace libabw
21{
22
23// An exception-safe wrapper around xmlChar *
24 class ABWXMLString
25{
26public:
27 ABWXMLString(xmlChar *xml);
28
29 const xmlChar *get() const;
30
31 operator const char *() const;
32
33private:
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
42public:
43 ABWXMLProgressWatcher();
44
45 void setReader(xmlTextReaderPtr reader);
46
47 bool isStuck() const;
48 void signalError();
49
50private:
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
59std::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
Definition: ABWXMLHelper.h:38
libabw::ABWXMLProgressWatcher::isStuck
bool isStuck() const
Definition: ABWXMLHelper.cpp:109
libabw::ABWXMLProgressWatcher::m_reader
xmlTextReaderPtr m_reader
Definition: ABWXMLHelper.h:51
libabw::ABWXMLProgressWatcher::ABWXMLProgressWatcher
ABWXMLProgressWatcher()
Definition: ABWXMLHelper.cpp:95
libabw::ABWXMLProgressWatcher::setReader
void setReader(xmlTextReaderPtr reader)
Definition: ABWXMLHelper.cpp:104
libabw::ABWXMLProgressWatcher::m_isStuck
bool m_isStuck
Definition: ABWXMLHelper.h:55
libabw::ABWXMLProgressWatcher::m_wasError
bool m_wasError
Definition: ABWXMLHelper.h:54
libabw::ABWXMLProgressWatcher::ABWXMLProgressWatcher
ABWXMLProgressWatcher(const ABWXMLProgressWatcher &)=delete
libabw::ABWXMLProgressWatcher::operator=
ABWXMLProgressWatcher & operator=(const ABWXMLProgressWatcher &)=delete
libabw::ABWXMLProgressWatcher::m_line
int m_line
Definition: ABWXMLHelper.h:52
libabw::ABWXMLProgressWatcher::m_col
int m_col
Definition: ABWXMLHelper.h:53
libabw::ABWXMLProgressWatcher::signalError
void signalError()
Definition: ABWXMLHelper.cpp:114
libabw::ABWXMLString
Definition: ABWXMLHelper.h:25
libabw::ABWXMLString::m_xml
std::shared_ptr< xmlChar > m_xml
Definition: ABWXMLHelper.h:34
libabw::ABWXMLString::get
const xmlChar * get() const
Definition: ABWXMLHelper.cpp:85
libabw::ABWXMLString::ABWXMLString
ABWXMLString(xmlChar *xml)
Definition: ABWXMLHelper.cpp:80
libabw
Definition: AbiDocument.cpp:17
libabw::xmlReaderForStream
std::unique_ptr< xmlTextReader, void(*)(xmlTextReaderPtr)> xmlReaderForStream(librevenge::RVNGInputStream *input, ABWXMLProgressWatcher *watcher)
Definition: ABWXMLHelper.cpp:131