init
This commit is contained in:
47
expkg/src/BinaryOPT/BinaryReader.h
Normal file
47
expkg/src/BinaryOPT/BinaryReader.h
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// Created by sfd on 25-8-4.
|
||||
//
|
||||
|
||||
#ifndef BINARYREADER_H
|
||||
#define BINARYREADER_H
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "../Core.h"
|
||||
|
||||
namespace PKG
|
||||
{
|
||||
using pos_type = long long;
|
||||
|
||||
class PKG_API BinaryReader
|
||||
{
|
||||
public:
|
||||
BinaryReader() = delete;
|
||||
explicit BinaryReader(const std::filesystem::path& fileName);
|
||||
~BinaryReader();
|
||||
|
||||
int32_t ReadInt32();
|
||||
uint32_t ReadUInt32();
|
||||
char ReadChar();
|
||||
std::string ReadString(uint32_t length);
|
||||
std::string ReadNString(int32_t maxLength = -1);
|
||||
void ReadData(std::string& data, uint32_t length);
|
||||
void ReadData(std::vector<uint8_t>& data, uint32_t length);
|
||||
|
||||
void seekg(const pos_type pos) { m_File.seekg(pos); }
|
||||
pos_type tellg() { return m_File.tellg(); }
|
||||
|
||||
std::string GetFilePath() const { return m_FilePath; }
|
||||
std::string GetFileName() const { return m_FilePath.substr(m_FilePath.find_last_of("\\/") + 1); }
|
||||
|
||||
private:
|
||||
std::ifstream m_File;
|
||||
|
||||
std::string m_FilePath;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //BINARYREADER_H
|
||||
Reference in New Issue
Block a user