Bump version to 21.06.18.1
[LibreOffice.git] / include / tools / XmlWriter.hxx
blob7efe3a57353a35870616405e3b68974384dee490
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_TOOLS_XMLWRITER_HXX
11 #define INCLUDED_TOOLS_XMLWRITER_HXX
13 #include <tools/toolsdllapi.h>
14 #include <rtl/ustring.hxx>
15 #include <memory>
16 #include <vector>
18 class SvStream;
20 namespace tools
22 struct XmlWriterImpl;
24 /**
25 * XmlWriter writes a XML to a SvStream. It uses libxml2 for writing but hides
26 * all the internal libxml2 workings and uses types that are native for LO
27 * development.
29 * The codepage used for XML is always "utf-8" and the output is indented by
30 * default so it is easier to read.
33 class TOOLS_DLLPUBLIC XmlWriter final
35 private:
36 std::unique_ptr<XmlWriterImpl> mpImpl;
38 public:
39 XmlWriter(SvStream* pStream);
41 ~XmlWriter();
43 bool startDocument(sal_Int32 nIndent = 2, bool bWriteXmlHeader = true);
44 void endDocument();
46 void startElement(const OString& sName);
47 void startElement(const OString& sPrefix, const OString& sName, const OString& sNamespaceUri);
48 void endElement();
50 void attribute(const OString& sTagName, const OString& aValue);
51 void attribute(const OString& sTagName, const OUString& aValue);
52 void attribute(const OString& sTagName, sal_Int32 aNumber);
53 void attributeDouble(const OString& sTagName, double aNumber);
54 void attributeBase64(const OString& sTagName, std::vector<sal_uInt8> const& rValueInBytes);
55 void attributeBase64(const OString& sTagName, std::vector<char> const& rValueInBytes);
57 void content(const OString& sValue);
58 void content(const OUString& sValue);
60 void element(const OString& sName);
63 } // end tools namespace
65 #endif // INCLUDED_TOOLS_XMLWRITER_HXX
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */