[ox/mc] Make read take const buffers
This commit is contained in:
parent
772cc7d954
commit
394d13df9b
2
deps/ox/src/ox/mc/intops.hpp
vendored
2
deps/ox/src/ox/mc/intops.hpp
vendored
@ -114,7 +114,7 @@ static_assert(countBytes(0b01111111) == 8);
|
||||
static_assert(countBytes(0b11111111) == 9);
|
||||
|
||||
template<typename I>
|
||||
Result<I> decodeInteger(uint8_t buff[9], std::size_t buffLen, std::size_t *bytesRead) noexcept {
|
||||
Result<I> decodeInteger(const uint8_t buff[9], std::size_t buffLen, std::size_t *bytesRead) noexcept {
|
||||
const auto bytes = countBytes(buff[0]);
|
||||
if (bytes == 9) {
|
||||
*bytesRead = bytes;
|
||||
|
5
deps/ox/src/ox/mc/presenceindicator.cpp
vendored
5
deps/ox/src/ox/mc/presenceindicator.cpp
vendored
@ -12,8 +12,9 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
FieldPresenceIndicator::FieldPresenceIndicator(uint8_t *mask, std::size_t maxLen) {
|
||||
m_mask = mask;
|
||||
FieldPresenceIndicator::FieldPresenceIndicator(const uint8_t *mask, std::size_t maxLen) {
|
||||
// TODO: have separate read only version of this class
|
||||
m_mask = const_cast<uint8_t*>(mask);
|
||||
m_maskLen = maxLen;
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/mc/presenceindicator.hpp
vendored
2
deps/ox/src/ox/mc/presenceindicator.hpp
vendored
@ -20,7 +20,7 @@ class FieldPresenceIndicator {
|
||||
std::size_t m_fields = 0;
|
||||
|
||||
public:
|
||||
FieldPresenceIndicator(uint8_t *mask, std::size_t maxLen);
|
||||
FieldPresenceIndicator(const uint8_t *mask, std::size_t maxLen);
|
||||
|
||||
Result<bool> get(std::size_t i) const;
|
||||
|
||||
|
2
deps/ox/src/ox/mc/read.cpp
vendored
2
deps/ox/src/ox/mc/read.cpp
vendored
@ -14,7 +14,7 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
MetalClawReader::MetalClawReader(uint8_t *buff, std::size_t buffLen, int unionIdx, MetalClawReader *parent) noexcept:
|
||||
MetalClawReader::MetalClawReader(const uint8_t *buff, std::size_t buffLen, int unionIdx, MetalClawReader *parent) noexcept:
|
||||
m_fieldPresence(buff, buffLen),
|
||||
m_unionIdx(unionIdx),
|
||||
m_buffLen(buffLen),
|
||||
|
6
deps/ox/src/ox/mc/read.hpp
vendored
6
deps/ox/src/ox/mc/read.hpp
vendored
@ -31,11 +31,11 @@ class MetalClawReader {
|
||||
int m_unionIdx = -1;
|
||||
std::size_t m_buffIt = 0;
|
||||
std::size_t m_buffLen = 0;
|
||||
uint8_t *m_buff = nullptr;
|
||||
const uint8_t *m_buff = nullptr;
|
||||
MetalClawReader *m_parent = nullptr;
|
||||
|
||||
public:
|
||||
MetalClawReader(uint8_t *buff, std::size_t buffLen, int unionIdx = -1, MetalClawReader *parent = nullptr) noexcept;
|
||||
MetalClawReader(const uint8_t *buff, std::size_t buffLen, int unionIdx = -1, MetalClawReader *parent = nullptr) noexcept;
|
||||
|
||||
~MetalClawReader() noexcept;
|
||||
|
||||
@ -273,7 +273,7 @@ void MetalClawReader::setTypeInfo(const char*, int fields) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Error readMC(uint8_t *buff, std::size_t buffLen, T *val) {
|
||||
Error readMC(const uint8_t *buff, std::size_t buffLen, T *val) {
|
||||
MetalClawReader reader(buff, buffLen);
|
||||
return model(&reader, val);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user