Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / tools / XmlWriter.hxx
blobe8f6579b0e9599d66844b2003acbe40628850bb7
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/string.hxx>
15 #include <memory>
16 #include <string_view>
17 #include <vector>
19 class SvStream;
21 namespace tools
23 struct XmlWriterImpl;
25 /**
26 * XmlWriter writes a XML to a SvStream. It uses libxml2 for writing but hides
27 * all the internal libxml2 workings and uses types that are native for LO
28 * development.
30 * The codepage used for XML is always "utf-8" and the output is indented by
31 * default so it is easier to read.
34 class TOOLS_DLLPUBLIC XmlWriter final
36 private:
37 std::unique_ptr<XmlWriterImpl> mpImpl;
39 public:
40 XmlWriter(SvStream* pStream);
42 ~XmlWriter();
44 bool startDocument(sal_Int32 nIndent = 2, bool bWriteXmlHeader = true);
45 void endDocument();
47 void startElement(const OString& sName);
48 void startElement(const OString& sPrefix, const OString& sName, const OString& sNamespaceUri);
49 void endElement();
51 void attribute(const OString& sTagName, const OString& aValue);
52 void attribute(const OString& sTagName, std::u16string_view aValue);
53 void attribute(const OString& sTagName, sal_Int32 aNumber);
54 void attributeDouble(const OString& sTagName, double aNumber);
55 void attributeBase64(const OString& sTagName, std::vector<sal_uInt8> const& rValueInBytes);
56 void attributeBase64(const OString& sTagName, std::vector<char> const& rValueInBytes);
58 void content(const OString& sValue);
59 void content(std::u16string_view sValue);
61 void element(const OString& sName);
64 } // end tools namespace
66 #endif // INCLUDED_TOOLS_XMLWRITER_HXX
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */