byte_stream: Remove template specialization in class scope

This commit is contained in:
sephiroth99 2015-12-30 11:05:04 -05:00
parent a743c12e72
commit d982b54bda
2 changed files with 27 additions and 21 deletions

View File

@ -36,4 +36,24 @@ void ByteStream::Write(const uint8_t* buf, size_t len) {
Advance(len);
}
template <>
std::string ByteStream::Read() {
std::string str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len);
return str;
}
template <>
std::wstring ByteStream::Read() {
std::wstring str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len * 2);
return str;
}
} // namespace xe

View File

@ -46,26 +46,6 @@ class ByteStream {
return data;
}
template <>
std::string Read() {
std::string str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len);
return str;
}
template <>
std::wstring Read() {
std::wstring str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len * 2);
return str;
}
template <typename T>
void Write(T data) {
Write(reinterpret_cast<uint8_t*>(&data), sizeof(T));
@ -87,6 +67,12 @@ class ByteStream {
size_t offset_ = 0;
};
template <>
std::string ByteStream::Read();
template <>
std::wstring ByteStream::Read();
} // namespace xe
#endif // XENIA_BASE_BYTE_STREAM_H_