OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DictRef.h
Go to the documentation of this file.
1 #ifndef DICTREF_H
2 #define DICTREF_H
3 
4 #include <cstdint>
5 #include <cstdlib>
6 #include <functional>
7 #include <string>
8 
9 struct dict_ref_t {
10  int32_t dbId;
11  int32_t dictId;
12 
13  static constexpr int32_t invalidDbId{-1};
14  static constexpr int32_t invalidDictId{-1};
15  static constexpr int32_t literalsDictId{0};
16 
18  dict_ref_t(int32_t db_id, int32_t dict_id) : dbId(db_id), dictId(dict_id) {}
19 
20  inline bool operator==(const struct dict_ref_t& rhs) const {
21  return this->dictId == rhs.dictId && this->dbId == rhs.dbId;
22  }
23 
24  inline struct dict_ref_t& operator=(const struct dict_ref_t& rhs) {
25  this->dbId = rhs.dbId;
26  this->dictId = rhs.dictId;
27  return *this;
28  };
29 
30  inline bool operator<(const struct dict_ref_t& rhs) const {
31  return (this->dbId < rhs.dbId)
32  ? true
33  : (this->dbId == rhs.dbId) ? this->dictId < rhs.dictId : false;
34  }
35 
36  inline size_t operator()(const struct dict_ref_t& ref) const noexcept {
37  std::hash<int32_t> int32_hash;
38  return int32_hash(ref.dictId) ^ (int32_hash(ref.dbId) << 2);
39  }
40 
41  inline std::string toString() const {
42  return "(db_id: " + std::to_string(dbId) + ", dict_id: " + std::to_string(dictId) +
43  ")";
44  }
45 
46  static dict_ref_t InvalidDictRef() { return dict_ref_t(); }
47 };
48 
49 using DictRef = struct dict_ref_t;
50 
51 #endif
dict_ref_t()
Definition: DictRef.h:17
bool operator<(const struct dict_ref_t &rhs) const
Definition: DictRef.h:30
static constexpr int32_t invalidDbId
Definition: DictRef.h:13
struct dict_ref_t & operator=(const struct dict_ref_t &rhs)
Definition: DictRef.h:24
std::string to_string(char const *&&v)
int32_t dictId
Definition: DictRef.h:11
static constexpr int32_t invalidDictId
Definition: DictRef.h:14
dict_ref_t(int32_t db_id, int32_t dict_id)
Definition: DictRef.h:18
int32_t dbId
Definition: DictRef.h:10
std::string toString() const
Definition: DictRef.h:41
static dict_ref_t InvalidDictRef()
Definition: DictRef.h:46
bool operator==(const struct dict_ref_t &rhs) const
Definition: DictRef.h:20
size_t operator()(const struct dict_ref_t &ref) const noexcept
Definition: DictRef.h:36
static constexpr int32_t literalsDictId
Definition: DictRef.h:15