Skip to content

Commit 943b5b4

Browse files
authored
Merge pull request #685 from evoskuil/master
Add data_slab cast operator to accessor, accommodates system change.
2 parents 33e1752 + 1e87c0c commit 943b5b4

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

include/bitcoin/database/impl/memory/accessor.ipp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,25 @@ inline ptrdiff_t CLASS::size() const NOEXCEPT
6666
}
6767

6868
TEMPLATE
69-
inline uint8_t* CLASS::begin() NOEXCEPT
69+
inline uint8_t* CLASS::data() const NOEXCEPT
70+
{
71+
return begin();
72+
}
73+
74+
TEMPLATE
75+
inline CLASS::operator system::data_slab() const NOEXCEPT
76+
{
77+
return { begin(), end() };
78+
};
79+
80+
TEMPLATE
81+
inline uint8_t* CLASS::begin() const NOEXCEPT
7082
{
7183
return begin_;
7284
}
7385

7486
TEMPLATE
75-
inline uint8_t* CLASS::end() NOEXCEPT
87+
inline uint8_t* CLASS::end() const NOEXCEPT
7688
{
7789
return end_;
7890
}

include/bitcoin/database/memory/accessor.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ class accessor
5050
/// The logical buffer size (from begin to end).
5151
inline ptrdiff_t size() const NOEXCEPT override;
5252

53-
/// Get logical buffer (guarded against remap only).
54-
inline uint8_t* begin() NOEXCEPT override;
55-
inline uint8_t* end() NOEXCEPT override;
56-
5753
/// Alias for begin.
58-
inline uint8_t* data() NOEXCEPT override { return begin(); }
54+
inline uint8_t* data() const NOEXCEPT override;
55+
56+
/// Get logical buffer (guarded against remap only).
57+
inline operator system::data_slab() const NOEXCEPT override;
58+
inline uint8_t* begin() const NOEXCEPT override;
59+
inline uint8_t* end() const NOEXCEPT override;
5960

6061
private:
6162
uint8_t* begin_{};

include/bitcoin/database/memory/interfaces/memory.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ class memory
4141
/// The logical buffer size (from begin to end).
4242
virtual ptrdiff_t size() const NOEXCEPT = 0;
4343

44-
/// Get logical buffer.
45-
virtual uint8_t* begin() NOEXCEPT = 0;
46-
virtual uint8_t* end() NOEXCEPT = 0;
47-
4844
/// Alias begin.
49-
virtual uint8_t* data() NOEXCEPT = 0;
45+
virtual uint8_t* data() const NOEXCEPT = 0;
46+
47+
/// Get logical buffer.
48+
virtual operator system::data_slab() const NOEXCEPT = 0;
49+
virtual uint8_t* begin() const NOEXCEPT = 0;
50+
virtual uint8_t* end() const NOEXCEPT = 0;
5051
};
5152

5253
typedef memory::ptr memory_ptr;

0 commit comments

Comments
 (0)