mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-20 05:49:30 +08:00
add: base components for gamefree
This commit is contained in:
70
module/gamefree/bytearray/ByteArray.cpp
Normal file
70
module/gamefree/bytearray/ByteArray.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "ByteArray.hpp"
|
||||
|
||||
void ByteArray::writeContinuousData(const void* data, size_t length) {
|
||||
auto p = reinterpret_cast<const char*>(data);
|
||||
m_data.insert(m_data.end(), p, p + length);
|
||||
}
|
||||
|
||||
void ByteArray::writeChar(char data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeUChar(unsigned char data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeInt(int data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeUInt(unsigned int data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeLong(long data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeLongLong(long long data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeULong(unsigned long data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeULongLong(unsigned long long data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeFloat(float data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeDouble(double data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeLongDouble(long double data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeBool(bool data) {
|
||||
writeNumber(data);
|
||||
}
|
||||
|
||||
void ByteArray::writeString(const std::string_view& string) {
|
||||
writeContinuousData(string.data(), string.size());
|
||||
}
|
||||
|
||||
void ByteArray::writeBytes(const char* data, size_t length) {
|
||||
writeContinuousData(data, length);
|
||||
}
|
||||
|
||||
std::string ByteArray::toString() const {
|
||||
return std::string(m_data.data(), m_data.size());
|
||||
}
|
||||
|
||||
const std::vector<char>& ByteArray::data() const {
|
||||
return m_data;
|
||||
}
|
||||
Reference in New Issue
Block a user