xref: /aoo4110/main/sax/inc/sax/tools/tokenmap.hxx (revision b1cdbd2c)
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_TOKENMAP_HXX_
25 #define _SAX_TOKENMAP_HXX_
26 
27 #include <rtl/ref.hxx>
28 #include <rtl/ustring.hxx>
29 #include "sax/dllapi.h"
30 #include "sax/tools/saxobject.hxx"
31 
32 namespace sax
33 {
34 	/** type for a token identifier */
35 	typedef sal_uInt32 SaxToken;
36 
37 	/** this class maps a set of ascii/utf-8 strings to token identifier */
38 	class SAX_DLLPUBLIC SaxTokenMap : public SaxObject
39 	{
40 	public:
41 		/** constant do indicate an unknown token */
42 		const static SaxToken InvalidToken = (SaxToken)-1;
43 
44 		/** returns the token identifier for the given ascii string or SaxTokenMap::InvalidToken */
45 		virtual SaxToken GetToken( const sal_Char* pChar, sal_uInt32 nLength  = 0 ) const = 0;
46 
47 		/** returns the token identifier for the given unicode string or SaxTokenMap::InvalidToken */
48 		virtual SaxToken GetToken( const ::rtl::OUString& rToken ) const = 0;
49 
50 		/** returns the unicode string for the given token identifier */
51 		virtual const ::rtl::OUString& GetToken( SaxToken nToken ) const = 0;
52 
53 		/** returns if the given unicode string equals the given token identifier */
IsToken(const::rtl::OUString & rToken,SaxToken nToken) const54 		bool IsToken( const ::rtl::OUString& rToken, SaxToken nToken ) const { return GetToken( rToken ) == nToken; }
55 	};
56 
57 	/** reference type to a SaxTokenMap */
58 	typedef rtl::Reference< SaxTokenMap > SaxTokenMapRef;
59 }
60 
61 #endif // _SAX_TOKENMAP_HXX_
62