2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace BinaryIO {
|
|
|
|
template<typename T>
|
|
|
|
std::ostream& BinaryWrite(std::ostream& stream, const T& value) {
|
|
|
|
return stream.write(reinterpret_cast<const char*>(&value), sizeof(T));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2022-07-28 13:39:57 +00:00
|
|
|
std::istream& BinaryRead(std::istream& stream, T& value) {
|
|
|
|
if (!stream.good())
|
2021-12-05 17:54:36 +00:00
|
|
|
printf("bla");
|
|
|
|
|
|
|
|
return stream.read(reinterpret_cast<char*>(&value), sizeof(T));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteString(const std::string& stringToWrite, std::ofstream& outstream);
|
2022-07-28 13:39:57 +00:00
|
|
|
std::string ReadString(std::ifstream& instream);
|
2021-12-05 17:54:36 +00:00
|
|
|
std::string ReadString(std::ifstream& instream, size_t size);
|
|
|
|
std::string ReadWString(std::ifstream& instream);
|
|
|
|
|
|
|
|
inline bool DoesFileExist(const std::string& name) {
|
|
|
|
std::ifstream f(name.c_str());
|
|
|
|
return f.good();
|
|
|
|
}
|
|
|
|
}
|