mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-08 22:07:10 +00:00
18295017c1
use template function Update GeneralUtils.cpp consolidate duplicate code Update GeneralUtils.cpp Update BinaryIO.cpp compilers
27 lines
601 B
C++
27 lines
601 B
C++
#include "BinaryIO.h"
|
|
#include <string>
|
|
|
|
//For reading null-terminated strings
|
|
template<typename StringType>
|
|
StringType ReadString(std::istream& instream) {
|
|
StringType toReturn{};
|
|
typename StringType::value_type buffer{};
|
|
|
|
BinaryIO::BinaryRead(instream, buffer);
|
|
|
|
while (buffer != 0x00) {
|
|
toReturn += buffer;
|
|
BinaryIO::BinaryRead(instream, buffer);
|
|
}
|
|
|
|
return toReturn;
|
|
}
|
|
|
|
std::string BinaryIO::ReadString(std::istream& instream) {
|
|
return ::ReadString<std::string>(instream);
|
|
}
|
|
|
|
std::u8string BinaryIO::ReadU8String(std::istream& instream) {
|
|
return ::ReadString<std::u8string>(instream);
|
|
}
|