1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 #ifndef ZORBA_UTILS_HASHMAP_ZSTRING
18 #define ZORBA_UTILS_HASHMAP_ZSTRING
19 
20 #include "zorbautils/hashmap.h"
21 #include "zorbatypes/zstring.h"
22 
23 #include "util/utf8_util.h"
24 
25 
26 namespace zorba
27 {
28 
29 /***************************************************************************//**
30   Class to privide the equality and hash functions for the HashMapZString
31   class defined below.
32 *******************************************************************************/
33 class HashMapZStringCmp
34 {
35 public:
hash(const zstring & str)36   static uint32_t hash(const zstring& str)
37   {
38     return utf8::hash(str);
39   }
40 
equal(const zstring & s1,const zstring & s2)41   static bool equal(const zstring& s1, const zstring& s2)
42   {
43     return s1 == s2;
44   }
45 };
46 
47 
48 #define ZSTRING_HASH_MAP(ValueType, MapType) \
49 typedef HashMap<zstring, ValueType, HashMapZStringCmp> MapType;
50 
51 
52 }
53 
54 #endif
55 
56 /*
57  * Local variables:
58  * mode: c++
59  * End:
60  */
61 /* vim:set et sw=2 ts=2: */
62