1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_TOOLS_XMLWRITER_HXX
11 #define INCLUDED_TOOLS_XMLWRITER_HXX
13 #include <tools/toolsdllapi.h>
14 #include <rtl/string.hxx>
16 #include <string_view>
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
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
37 std::unique_ptr
<XmlWriterImpl
> mpImpl
;
40 XmlWriter(SvStream
* pStream
);
44 bool startDocument(sal_Int32 nIndent
= 2, bool bWriteXmlHeader
= true);
47 void startElement(const OString
& sName
);
48 void startElement(const OString
& sPrefix
, const OString
& sName
, const OString
& sNamespaceUri
);
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: */