Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald\include\herald\datatype\target_identifier.h
Line
Count
Source (jump to first uncovered line)
1
//  Copyright 2020-2021 Herald Project Contributors
2
//  SPDX-License-Identifier: Apache-2.0
3
//
4
5
#ifndef HERALD_TARGET_IDENTIFIER_H
6
#define HERALD_TARGET_IDENTIFIER_H
7
8
#include "data.h"
9
10
#include <string>
11
#include <memory>
12
#include <iosfwd>
13
14
namespace herald {
15
namespace datatype {
16
17
class TargetIdentifier {
18
public:
19
  TargetIdentifier();
20
  TargetIdentifier(const Data& data);
21
  TargetIdentifier(const TargetIdentifier& from); // copy ctor
22
  TargetIdentifier& operator=(const TargetIdentifier& from); // copy assign
23
  ~TargetIdentifier();
24
25
  bool operator==(const TargetIdentifier& other) const noexcept;
26
  bool operator==(const Data& other) const noexcept;
27
  bool operator!=(const TargetIdentifier& other) const noexcept;
28
  bool operator!=(const Data& other) const noexcept;
29
  bool operator<(const TargetIdentifier& other) const noexcept; // required for std::less
30
  bool operator>(const TargetIdentifier& other) const noexcept; // required for std::less
31
32
  std::size_t hashCode() const;
33
34
  operator std::string() const;
35
36
  operator Data() const;
37
38
  Data underlyingData() const;
39
40
private:
41
  Data value;
42
43
};
44
45
} // end namespace
46
} // end namespace
47
48
49
50
namespace std {
51
  inline std::ostream& operator<<(std::ostream &os, const herald::datatype::TargetIdentifier& d)
52
11
  {
53
11
    return os << d.underlyingData().reversed().hexEncodedString();
54
11
  }
55
56
  template<>
57
  struct hash<herald::datatype::TargetIdentifier>
58
  {
59
    size_t operator()(const herald::datatype::TargetIdentifier& v) const
60
0
    {
61
0
      return v.hashCode();
62
0
    }
63
  };
64
} // end namespace
65
66
#endif