[ox/buffer] Add copy constructor to NodeBuffer
This commit is contained in:
parent
6236214be6
commit
a13b369792
18
deps/ox/src/ox/ptrarith/nodebuffer.hpp
vendored
18
deps/ox/src/ox/ptrarith/nodebuffer.hpp
vendored
@ -75,6 +75,8 @@ class __attribute__((packed)) NodeBuffer {
|
|||||||
public:
|
public:
|
||||||
NodeBuffer() = default;
|
NodeBuffer() = default;
|
||||||
|
|
||||||
|
NodeBuffer(const NodeBuffer &other);
|
||||||
|
|
||||||
explicit NodeBuffer(size_t size);
|
explicit NodeBuffer(size_t size);
|
||||||
|
|
||||||
const Iterator iterator() const;
|
const Iterator iterator() const;
|
||||||
@ -120,9 +122,11 @@ class __attribute__((packed)) NodeBuffer {
|
|||||||
*/
|
*/
|
||||||
size_t spaceNeeded(size_t size);
|
size_t spaceNeeded(size_t size);
|
||||||
|
|
||||||
private:
|
void compact(void (*cb)(ItemPtr itemMoved) = nullptr);
|
||||||
void compact(void (*cb)(ItemPtr itemMoved));
|
|
||||||
|
|
||||||
|
void truncate();
|
||||||
|
|
||||||
|
private:
|
||||||
uint8_t *data();
|
uint8_t *data();
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -132,6 +136,11 @@ NodeBuffer<size_t, Item>::NodeBuffer(size_t size) {
|
|||||||
m_header.size = size;
|
m_header.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename size_t, typename Item>
|
||||||
|
NodeBuffer<size_t, Item>::NodeBuffer(const NodeBuffer &other) {
|
||||||
|
ox_memcpy(this, &other, other.size());
|
||||||
|
}
|
||||||
|
|
||||||
template<typename size_t, typename Item>
|
template<typename size_t, typename Item>
|
||||||
const typename NodeBuffer<size_t, Item>::Iterator NodeBuffer<size_t, Item>::iterator() const {
|
const typename NodeBuffer<size_t, Item>::Iterator NodeBuffer<size_t, Item>::iterator() const {
|
||||||
return Iterator(this, firstItem());
|
return Iterator(this, firstItem());
|
||||||
@ -314,6 +323,11 @@ void NodeBuffer<size_t, Item>::compact(void (*cb)(ItemPtr)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename size_t, typename Item>
|
||||||
|
void NodeBuffer<size_t, Item>::truncate() {
|
||||||
|
m_header.size = m_header.bytesUsed;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename size_t, typename Item>
|
template<typename size_t, typename Item>
|
||||||
uint8_t *NodeBuffer<size_t, Item>::data() {
|
uint8_t *NodeBuffer<size_t, Item>::data() {
|
||||||
return reinterpret_cast<uint8_t*>(ptr(sizeof(*this)).get());
|
return reinterpret_cast<uint8_t*>(ptr(sizeof(*this)).get());
|
||||||
|
Loading…
Reference in New Issue
Block a user