mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(big): add SBigFromBinary
This commit is contained in:
parent
902ddcf7d8
commit
6c83070380
7 changed files with 66 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ uint32_t BigBuffer::operator[](uint32_t index) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void BigBuffer::Clear() {
|
||||
this->m_data.SetCount(this->m_offset);
|
||||
}
|
||||
|
||||
uint32_t BigBuffer::Count() const {
|
||||
return this->m_data.Count() - this->m_offset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class BigBuffer {
|
|||
// Member functions
|
||||
uint32_t& operator[](uint32_t index);
|
||||
uint32_t operator[](uint32_t index) const;
|
||||
void Clear();
|
||||
uint32_t Count() const;
|
||||
void GrowToFit(uint32_t index);
|
||||
int32_t IsUsed(uint32_t index) const;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ uint32_t ExtractLowPartSx(uint64_t& value) {
|
|||
return low;
|
||||
}
|
||||
|
||||
void FromBinary(BigBuffer& buffer, const void* data, uint32_t bytes) {
|
||||
buffer.Clear();
|
||||
|
||||
for (uint32_t i = 0; i < bytes; i++) {
|
||||
auto byte = static_cast<const uint8_t*>(data)[i];
|
||||
auto v7 = (i & 3) ? buffer[i / 4] : 0;
|
||||
buffer[i / 4] = v7 + (byte << (8 * (i & 3)));
|
||||
}
|
||||
}
|
||||
|
||||
void FromUnsigned(BigBuffer& buffer, uint32_t value) {
|
||||
buffer[0] = value;
|
||||
buffer.SetCount(1);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ uint32_t ExtractLowPart(uint64_t& value);
|
|||
|
||||
uint32_t ExtractLowPartSx(uint64_t& value);
|
||||
|
||||
void FromBinary(BigBuffer& buffer, const void* value, uint32_t bytes);
|
||||
|
||||
void FromUnsigned(BigBuffer& buffer, uint32_t value);
|
||||
|
||||
uint64_t MakeLarge(uint32_t low, uint32_t high);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue