Add generic IO (#3)
Reviewed-on: #3 Co-authored-by: Persson-dev <sim16.prib@gmail.com> Co-committed-by: Persson-dev <sim16.prib@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
33
include/sp/io/File.h
Normal file
33
include/sp/io/File.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <sp/io/IOInterface.h>
|
||||
|
||||
namespace sp {
|
||||
namespace io {
|
||||
|
||||
struct FileTag {
|
||||
enum OpenMode {
|
||||
In = 1,
|
||||
Out = 1 << 1,
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
class IOInterface<FileTag> {
|
||||
private:
|
||||
std::unique_ptr<std::ifstream> m_FileInput;
|
||||
std::unique_ptr<std::ofstream> m_FileOutput;
|
||||
|
||||
public:
|
||||
IOInterface(const std::string& a_FilePath, unsigned int a_OpenMode);
|
||||
IOInterface(IOInterface&& other);
|
||||
|
||||
DataBuffer Read(std::size_t a_Amount);
|
||||
void Write(const sp::DataBuffer& a_Data);
|
||||
};
|
||||
|
||||
using File = IOInterface<FileTag>;
|
||||
|
||||
} // namespace io
|
||||
} // namespace sp
|
||||
Reference in New Issue
Block a user