opengenerals/processor/pc/BinaryBuffer.cpp
szdytom f0445542ce
Add procedure call impl
Signed-off-by: szdytom <szdytom@qq.com>
2024-02-04 13:47:53 +08:00

37 lines
649 B
C++

#include "BinaryBuffer.h"
#include <cstdint>
BinaryBuffer::BinaryBuffer() {}
BinaryBuffer& BinaryBuffer::operator<<(const std::string_view& x) {
std::uint32_t len = x.size();
*this << len;
for (char c : x)
*this << c;
return *this;
}
BinaryBuffer& BinaryBuffer::operator>>(std::string& x) {
std::uint32_t len;
*this >> len;
x.resize(len);
for (char& c : x)
*this >> c;
return *this;
}
std::size_t BinaryBuffer::size() const {
return data.size();
}
bool BinaryBuffer::empty() const {
return data.empty();
}
std::ostream& operator<<(std::ostream &out, const BinaryBuffer &x) {
for (auto v : x.data)
out.put(v);
return out;
}