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