This source file includes following definitions.
- to_string
- hash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 namespace isimud { namespace exchanges { namespace common {
22
23 inline
24 ISIN_t::ISIN_t() noexcept(true) {
25 }
26
27 inline
28 ISIN_t::ISIN_t(block_t const &b) noexcept(true) {
29 jmmcg::memcpy_opt(b, value.block);
30 }
31
32 template<std::size_t Sz>
33 inline
34 ISIN_t::ISIN_t(block_t::value_type const (&b)[Sz]) noexcept(true) {
35 BOOST_MPL_ASSERT_RELATION(sizeof(block_t), ==, Sz-1);
36 jmmcg::memcpy_opt(reinterpret_cast<block_t const &>(b), value.block);
37 }
38
39 inline bool
40 ISIN_t::operator==(ISIN_t const &i) const noexcept(true) {
41 return value.block==i.value.block;
42 }
43
44 inline std::string
45 ISIN_t::to_string() const noexcept(false) {
46 return std::string{value.block.begin(), value.block.end()};
47 }
48
49 inline uint64_t
50 ISIN_t::hash() const noexcept(true) {
51 const union {
52 ISIN_t isin;
53 uint64_t conv[(sizeof(ISIN_t)+sizeof(uint64_t)-1)/sizeof(uint64_t)];
54 } c={
55 *this
56 };
57 return c.conv[0]^c.conv[1];
58 }
59
60 inline std::ostream &
61 operator<<(std::ostream &os, ISIN_t const &i) noexcept(false) {
62 os<<i.value.block;
63 return os;
64 }
65
66 inline std::istream &
67 operator>>(std::istream &is, ISIN_t &i) noexcept(false) {
68 std::string tmp;
69 is>>tmp;
70 assert(tmp.size()<=sizeof(ISIN_t));
71 jmmcg::memcpy_opt(reinterpret_cast<ISIN_t::block_t const &>(*tmp.data()), i.value.block);
72 return is;
73 }
74
75 } } }