monotone

monotone Mtn Source Tree

Root/vocab_hash.hh

1#ifndef __VOCAB_HASH_HH__
2#define __VOCAB_HASH_HH__
3
4// Copyright 2007 Timothy Brownawell <tbrownaw@gmail.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include "vocab.hh"
14#include "hash_map.hh"
15
16#define ENCODING(enc) \
17 namespace hashmap { \
18 template<typename INNER> \
19 struct hash<enc<INNER> > \
20 { \
21size_t operator()(enc<INNER> const & t) const \
22{ \
23 return hash<std::string>()(t()); \
24} \
25 }; \
26 }
27#define ENCODING_NOVERIFY(enc) ENCODING(enc)
28
29#define DECORATE(dec) \
30 namespace hashmap { \
31 template<typename INNER> \
32 struct hash<dec<INNER> > \
33 { \
34size_t operator()(dec<INNER> const & t) const \
35{ \
36 return hash<INNER>()(t.inner()); \
37} \
38 }; \
39 }
40
41#define ATOMIC(ty) \
42 namespace hashmap { \
43 template<> \
44 struct hash<ty> \
45 { \
46size_t operator()(ty const & t) const \
47{ \
48 return hash<std::string>()(t()); \
49} \
50 }; \
51 }
52
53#define ATOMIC_BINARY(ty) \
54 namespace hashmap { \
55 template<> \
56 struct hash<ty> \
57 { \
58size_t operator()(ty const & t) const \
59{ \
60 return hash<std::string>()(t()); \
61} \
62 }; \
63 }
64#define ATOMIC_HOOKED(ty,hook) ATOMIC(ty)
65#define ATOMIC_NOVERIFY(ty) ATOMIC(ty)
66
67#include "vocab_terms.hh"
68
69#undef ENCODING
70#undef ENCODING_NOVERIFY
71#undef DECORATE
72#undef ATOMIC
73#undef ATOMIC_HOOKED
74#undef ATOMIC_NOVERIFY
75
76#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status