xref: /trunk/main/sax/inc/sax/fastattribs.hxx (revision 8d192041)
1*8d192041SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*8d192041SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*8d192041SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*8d192041SAndrew Rist  * distributed with this work for additional information
6*8d192041SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*8d192041SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*8d192041SAndrew Rist  * "License"); you may not use this file except in compliance
9*8d192041SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*8d192041SAndrew Rist  *
11*8d192041SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*8d192041SAndrew Rist  *
13*8d192041SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*8d192041SAndrew Rist  * software distributed under the License is distributed on an
15*8d192041SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8d192041SAndrew Rist  * KIND, either express or implied.  See the License for the
17*8d192041SAndrew Rist  * specific language governing permissions and limitations
18*8d192041SAndrew Rist  * under the License.
19*8d192041SAndrew Rist  *
20*8d192041SAndrew Rist  *************************************************************/
21*8d192041SAndrew Rist 
22*8d192041SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SAX_FASTATTRIBS_HXX_
25cdf0e10cSrcweir #define _SAX_FASTATTRIBS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
28cdf0e10cSrcweir #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
29cdf0e10cSrcweir #include <com/sun/star/xml/Attribute.hpp>
30cdf0e10cSrcweir #include <com/sun/star/xml/FastAttribute.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
33cdf0e10cSrcweir #include "sax/dllapi.h"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <map>
36cdf0e10cSrcweir #include <vector>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace sax_fastparser
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir struct UnknownAttribute
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	::rtl::OUString maNamespaceURL;
44cdf0e10cSrcweir 	::rtl::OString maName;
45cdf0e10cSrcweir 	::rtl::OString maValue;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	UnknownAttribute( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	UnknownAttribute( const ::rtl::OString& rName, const ::rtl::OString& rValue );
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 	void FillAttribute( ::com::sun::star::xml::Attribute* pAttrib ) const;
52cdf0e10cSrcweir };
53cdf0e10cSrcweir 
54cdf0e10cSrcweir typedef std::map< sal_Int32, ::rtl::OString > FastAttributeMap;
55cdf0e10cSrcweir typedef std::vector< UnknownAttribute > UnknownAttributeList;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir class SAX_DLLPUBLIC FastAttributeList : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastAttributeList >
58cdf0e10cSrcweir {
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir 	FastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xTokenHandler );
61cdf0e10cSrcweir 	virtual ~FastAttributeList();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	void clear();
64cdf0e10cSrcweir 	void add( sal_Int32 nToken, const ::rtl::OString& rValue );
65cdf0e10cSrcweir 	void addUnknown( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
66cdf0e10cSrcweir 	void addUnknown( const ::rtl::OString& rName, const ::rtl::OString& rValue );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     // XFastAttributeList
69cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
70cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL getValueToken( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL getOptionalValueToken( ::sal_Int32 Token, ::sal_Int32 Default ) throw (::com::sun::star::uno::RuntimeException);
72cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getValue( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
73cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getOptionalValue( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::Attribute > SAL_CALL getUnknownAttributes(  ) throw (::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::FastAttribute > SAL_CALL getFastAttributes() throw (::com::sun::star::uno::RuntimeException);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir private:
78cdf0e10cSrcweir 	FastAttributeMap maAttributes;
79cdf0e10cSrcweir 	UnknownAttributeList maUnknownAttributes;
80cdf0e10cSrcweir 	FastAttributeMap::iterator maLastIter;
81cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler > mxTokenHandler;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #endif
88