libdballe 9.6
utils.h
1#ifndef DBALLE_DB_V7_UTILS_H
2#define DBALLE_DB_V7_UTILS_H
3
4#include <wreport/varinfo.h>
5#include <unordered_set>
6
7namespace dballe {
8namespace db {
9namespace v7 {
10
12{
13 int id;
14 wreport::Varcode varcode;
15
16 IdVarcode(int id, wreport::Varcode varcode)
17 : id(id), varcode(varcode)
18 {
19 }
20
21 bool operator==(const IdVarcode& o) const { return std::tie(id, varcode) == std::tie(o.id, o.varcode); }
22 bool operator!=(const IdVarcode& o) const { return std::tie(id, varcode) != std::tie(o.id, o.varcode); }
23 bool operator<(const IdVarcode& o) const { return std::tie(id, varcode) < std::tie(o.id, o.varcode); }
24 bool operator>(const IdVarcode& o) const { return std::tie(id, varcode) > std::tie(o.id, o.varcode); }
25};
26
27}
28}
29}
30
31namespace std
32{
33 template<> struct hash<dballe::db::v7::IdVarcode>
34 {
36 typedef std::size_t result_type;
37 result_type operator()(argument_type const& s) const noexcept
38 {
39 result_type const h1 ( std::hash<int>{}(s.id) );
40 result_type const h2 ( std::hash<wreport::Varcode>{}(s.varcode) );
41 return h1 ^ (h2 << 1);
42 }
43 };
44}
45
46
47#endif
uint16_t Varcode
Definition: utils.h:12