1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SAX_ATTRIBUTEMAP_HXX_ 25 #define _SAX_ATTRIBUTEMAP_HXX_ 26 27 #include "sax/dllapi.h" 28 29 #include <map> 30 #include "sax/tools/tokenmap.hxx" 31 32 namespace sax 33 { 34 class SaxTokenMap; 35 36 typedef std::map< sal_uInt32, rtl::OString > AttributeMapBase; 37 38 /** a map for a set of xml attributes, identified with integer tokens. 39 Attribute values are stored in utf-8 encoding. */ 40 class SAX_DLLPUBLIC AttributeMap : public AttributeMapBase 41 { 42 public: 43 AttributeMap( const SaxTokenMap& rTokenMap ); 44 ~AttributeMap(); 45 46 /** returns a unicode string, if the token does not exists the string is empty */ 47 ::rtl::OUString getString( SaxToken nToken ) const; 48 49 /** returns true if the attribute with the token nToken is part of this map */ 50 bool has( SaxToken nToken ) const; 51 52 /** converts the attribute with the token nToken to sal_Int32 or returns 53 nDefault if this attribute does not exists */ 54 sal_Int32 getInt32( SaxToken nToken, sal_Int32 nDefault = 0 ) const; 55 56 /** converts the attribute with the token nToken to a token or returns 57 nDefault if this attribute does not exists */ 58 sal_uInt32 getToken( SaxToken nToken, SaxToken nDefault ) const; 59 60 private: 61 const SaxTokenMap& mrTokenMap; 62 }; 63 64 } 65 66 #endif // _SAX_ATTRIBUTEMAP_HXX_ 67