2021-12-05 17:54:36 +00:00
|
|
|
#include "BinaryIO.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
//For reading null-terminated strings
|
2024-12-24 22:09:39 +00:00
|
|
|
template<typename StringType>
|
|
|
|
StringType ReadString(std::istream& instream) {
|
|
|
|
StringType toReturn{};
|
|
|
|
typename StringType::value_type buffer{};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
BinaryIO::BinaryRead(instream, buffer);
|
|
|
|
|
|
|
|
while (buffer != 0x00) {
|
|
|
|
toReturn += buffer;
|
2024-12-24 22:09:39 +00:00
|
|
|
BinaryIO::BinaryRead(instream, buffer);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
}
|
2024-12-24 22:09:39 +00:00
|
|
|
|
|
|
|
std::string BinaryIO::ReadString(std::istream& instream) {
|
|
|
|
return ::ReadString<std::string>(instream);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::u8string BinaryIO::ReadU8String(std::istream& instream) {
|
|
|
|
return ::ReadString<std::u8string>(instream);
|
|
|
|
}
|