summaryrefslogtreecommitdiff
path: root/include/tools/XmlWriter.hxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-11-01 12:46:35 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-11-01 23:42:02 +0100
commit1f8c3e3b78e0abb96d06a51eca354ae7ade5deb2 (patch)
tree6c402b0638d4294315444e72899e66c8ff5d93f9 /include/tools/XmlWriter.hxx
parentecbaf980625a9e7b06abe91c7c70e78f6ad469a7 (diff)
Extract XmlWriter and XmlWalker from opencl into tools
In opencl we read and writer the profile xml with custom classes XmlWriter and XmlWalker for reading. This classes are useful in other places (very similar XmlWriter is used in test), so extract the code from opencl and move it to a more common place - tools. Refactoring of other usages will follow. Change-Id: I8363e87b7c30083d299080adec3f99cb33ebe4cc Reviewed-on: https://gerrit.libreoffice.org/44149 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include/tools/XmlWriter.hxx')
-rw-r--r--include/tools/XmlWriter.hxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx
new file mode 100644
index 000000000000..c454f4139803
--- /dev/null
+++ b/include/tools/XmlWriter.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_TOOLS_XMLWRITER_HXX
+#define INCLUDED_TOOLS_XMLWRITER_HXX
+
+#include <tools/toolsdllapi.h>
+#include <tools/stream.hxx>
+#include <memory>
+
+namespace tools {
+
+struct XmlWriterImpl;
+
+/**
+ * XmlWriter writes a XML to a SvStream. It uses libxml2 for writing but hides
+ * all the internal libxml2 workings and uses types that are native for LO
+ * development.
+ *
+ * The codepage used for XML is always "utf-8" and the output is indented so it
+ * is easier to read.
+ *
+ */
+class TOOLS_DLLPUBLIC XmlWriter final
+{
+private:
+ std::unique_ptr<XmlWriterImpl> mpImpl;
+public:
+
+ XmlWriter(SvStream* pStream);
+
+ ~XmlWriter();
+
+ bool startDocument();
+ void endDocument();
+
+ void startElement(const OString& sName);
+ void endElement();
+
+ void attribute(const OString& sTagName, const OString& aValue);
+ void attribute(const OString& sTagName, const OUString& aValue);
+ void attribute(const OString& sTagName, sal_Int32 aNumber);
+
+ void content(const OString& sValue);
+ void content(const OUString& sValue);
+};
+
+} // end tools namespace
+
+#endif // INCLUDED_TOOLS_XMLWRITER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */