-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBodyTypesHash.hpp
More file actions
68 lines (57 loc) · 1.54 KB
/
Copy pathBodyTypesHash.hpp
File metadata and controls
68 lines (57 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* C++ code produced by gperf version 3.0.4 */
/* Command-line: gperf -t --output-file=BodyTypesHash.hpp body_types.gperf */
/* Computed positions: -k'' */
#line 1 "body_types.gperf"
#include "GalaxyStructs.hpp"
#line 14 "body_types.gperf"
struct BodyTypeHash {
const char* name;
BodyTypes type;
};
/* maximum key range = 3, duplicates = 0 */
class BodyTypeKey
{
private:
static inline unsigned int hash (const char *str, unsigned int len);
public:
static const struct BodyTypeHash *Lookup (const char *str, unsigned int len);
};
inline /*ARGSUSED*/
unsigned int
BodyTypeKey::hash (register const char *str, register unsigned int len)
{
return len;
}
const struct BodyTypeHash *
BodyTypeKey::Lookup (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 2,
MIN_WORD_LENGTH = 4,
MAX_WORD_LENGTH = 6,
MIN_HASH_VALUE = 4,
MAX_HASH_VALUE = 6
};
static const struct BodyTypeHash wordlist[] =
{
{"",BodyTypes::star}, {"",BodyTypes::star},
{"",BodyTypes::star}, {"",BodyTypes::star},
#line 20 "body_types.gperf"
{"Star", BodyTypes::star},
{"",BodyTypes::star},
#line 21 "body_types.gperf"
{"Planet", BodyTypes::planet}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (*str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
return 0;
}