1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 18:49:25 +08:00
Files
Alas/module/gamefree/bytearray/PyByteArray.cpp
2025-08-02 18:08:20 +08:00

93 lines
2.0 KiB
C++

#include "PyByteArray.hpp"
PyByteArray& PyByteArray::writeChar(char data) {
m_data.writeChar(data);
return *this;
}
PyByteArray& PyByteArray::writeUChar(unsigned char data) {
m_data.writeUChar(data);
return *this;
}
PyByteArray& PyByteArray::writeInt(int data) {
m_data.writeInt(data);
return *this;
}
PyByteArray& PyByteArray::writeUInt(unsigned int data) {
m_data.writeUInt(data);
return *this;
}
PyByteArray& PyByteArray::writeUInt8(unsigned _int8 data) {
m_data.writeUInt8(data);
return *this;
}
PyByteArray& PyByteArray::writeUInt16(unsigned _int16 data) {
m_data.writeUInt16(data);
return *this;
}
PyByteArray& PyByteArray::writeLong(long data) {
m_data.writeLong(data);
return *this;
}
PyByteArray& PyByteArray::writeLongLong(long long data) {
m_data.writeLongLong(data);
return *this;
}
PyByteArray& PyByteArray::writeULong(unsigned long data) {
m_data.writeULong(data);
return *this;
}
PyByteArray& PyByteArray::writeULongLong(unsigned long long data) {
m_data.writeULongLong(data);
return *this;
}
PyByteArray& PyByteArray::writeFloat(float data) {
m_data.writeFloat(data);
return *this;
}
PyByteArray& PyByteArray::writeDouble(double data) {
m_data.writeDouble(data);
return *this;
}
PyByteArray& PyByteArray::writeLongDouble(long double data) {
m_data.writeLongDouble(data);
return *this;
}
PyByteArray& PyByteArray::writeBool(bool data) {
m_data.writeBool(data);
return *this;
}
PyByteArray& PyByteArray::writeString(const std::string_view& string) {
m_data.writeString(string);
return *this;
}
PyByteArray& PyByteArray::writeBytes(const pybind11::bytes& data) {
auto size = PYBIND11_BYTES_SIZE(data.ptr());
auto buffer = PYBIND11_BYTES_AS_STRING(data.ptr());
m_data.writeBytes(buffer, size);
return *this;
}
std::string PyByteArray::toString() const {
return m_data.toString();
}
pybind11::bytes PyByteArray::toBytes() const {
const auto& d = m_data.data();
return pybind11::bytes(d.data(), d.size());
}