Basic Collection class unit test
[LibreOffice.git] / include / xmlscript / xml_helper.hxx
blob4baed88da3b25df1d3850b45ff7f29b8a660c25b
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 #include <vector>
22 #include <cppuhelper/implbase.hxx>
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
25 #include <xmlscript/xmlscriptdllapi.h>
27 namespace com::sun::star::xml::sax { class XDocumentHandler; }
28 namespace com::sun::star::io { class XInputStream; }
29 namespace com::sun::star::io { class XOutputStream; }
31 namespace xmlscript
34 /*##################################################################################################
36 EXPORTING
38 ##################################################################################################*/
41 class XMLElement
42 : public cppu::WeakImplHelper< css::xml::sax::XAttributeList >
44 public:
45 XMLElement( OUString const & name )
46 : _name( name )
49 /** Adds a sub element of element.
51 @param xElem element reference
53 void addSubElement(
54 css::uno::Reference< css::xml::sax::XAttributeList > const & xElem );
56 /** Gets sub element of given index. The index follows order in which sub elements were added.
58 @param nIndex index of sub element
60 css::uno::Reference< css::xml::sax::XAttributeList > const & getSubElement( sal_Int32 nIndex );
62 /** Adds an attribute to elements.
64 @param rAttrName qname of attribute
65 @param rValue value string of element
67 void addAttribute( OUString const & rAttrName, OUString const & rValue );
69 /** Dumps out element (and all sub elements).
71 @param xOut document handler to be written to
73 void dump(
74 css::uno::Reference< css::xml::sax::XDocumentHandler > const & xOut );
75 /** Dumps out sub elements (and all further sub elements).
77 @param xOut document handler to be written to
79 void dumpSubElements(
80 css::uno::Reference< css::xml::sax::XDocumentHandler > const & xOut );
82 // XAttributeList
83 virtual sal_Int16 SAL_CALL getLength() override;
84 virtual OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) override;
85 virtual OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) override;
86 virtual OUString SAL_CALL getTypeByName( OUString const & rName ) override;
87 virtual OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) override;
88 virtual OUString SAL_CALL getValueByName( OUString const & rName ) override;
90 protected:
91 ::std::vector< css::uno::Reference<
92 css::xml::sax::XAttributeList > > _subElems;
93 private:
94 OUString const _name;
95 ::std::vector< OUString > _attrNames;
96 ::std::vector< OUString > _attrValues;
101 /*##################################################################################################
103 STREAMING
105 ##################################################################################################*/
107 XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XInputStream >
108 createInputStream(
109 std::vector<sal_Int8>&& rInData );
111 XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XInputStream >
112 createInputStream(
113 const sal_Int8* pData, int len );
115 XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XOutputStream >
116 createOutputStream(
117 std::vector<sal_Int8> * pOutData );
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */