1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SAX_TOKENMAP_HXX_ 29 #define _SAX_TOKENMAP_HXX_ 30 31 #include <rtl/ref.hxx> 32 #include <rtl/ustring.hxx> 33 #include "sax/dllapi.h" 34 #include "sax/tools/saxobject.hxx" 35 36 namespace sax 37 { 38 /** type for a token identifier */ 39 typedef sal_uInt32 SaxToken; 40 41 /** this class maps a set of ascii/utf-8 strings to token identifier */ 42 class SAX_DLLPUBLIC SaxTokenMap : public SaxObject 43 { 44 public: 45 /** constant do indicate an unknown token */ 46 const static SaxToken InvalidToken = (SaxToken)-1; 47 48 /** returns the token identifier for the given ascii string or SaxTokenMap::InvalidToken */ 49 virtual SaxToken GetToken( const sal_Char* pChar, sal_uInt32 nLength = 0 ) const = 0; 50 51 /** returns the token identifier for the given unicode string or SaxTokenMap::InvalidToken */ 52 virtual SaxToken GetToken( const ::rtl::OUString& rToken ) const = 0; 53 54 /** returns the unicode string for the given token identifier */ 55 virtual const ::rtl::OUString& GetToken( SaxToken nToken ) const = 0; 56 57 /** returns if the given unicode string equals the given token identifier */ 58 bool IsToken( const ::rtl::OUString& rToken, SaxToken nToken ) const { return GetToken( rToken ) == nToken; } 59 }; 60 61 /** reference type to a SaxTokenMap */ 62 typedef rtl::Reference< SaxTokenMap > SaxTokenMapRef; 63 } 64 65 #endif // _SAX_TOKENMAP_HXX_ 66