2022-09-04 17:11:14 -04:00
|
|
|
//
|
|
|
|
// EuropaTools
|
|
|
|
//
|
|
|
|
// (C) 2021-2022 modeco80 <lily.modeco80@protonmail.ch>
|
|
|
|
//
|
2022-09-21 03:49:57 -04:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2022-09-04 17:11:14 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef EUROPA_IO_PAKREADER_H
|
|
|
|
#define EUROPA_IO_PAKREADER_H
|
|
|
|
|
2022-09-21 03:59:16 -04:00
|
|
|
#include <europa/io/PakFile.hpp>
|
|
|
|
#include <europa/structs/Pak.hpp>
|
2022-09-04 17:11:14 -04:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2023-08-01 18:18:40 -04:00
|
|
|
#include <variant>
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
namespace europa::io {
|
|
|
|
|
|
|
|
struct PakReader {
|
2022-09-07 05:07:40 -04:00
|
|
|
using MapType = std::unordered_map<std::string, PakFile>;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2023-08-01 18:18:40 -04:00
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
explicit PakReader(std::istream& is);
|
|
|
|
|
|
|
|
void ReadData();
|
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
void ReadFiles();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read in a specific file.
|
|
|
|
*/
|
|
|
|
void ReadFile(const std::string& file);
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
bool Invalid() const {
|
|
|
|
return invalid;
|
|
|
|
}
|
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
MapType& GetFiles();
|
|
|
|
const MapType& GetFiles() const;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2022-09-22 06:43:35 -04:00
|
|
|
// implement in cpp later, lazy and just wanna get this out :vvv
|
2023-08-01 18:18:40 -04:00
|
|
|
const structs::PakHeaderVariant& GetHeader() const { return header; }
|
2022-09-22 06:43:35 -04:00
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
private:
|
2023-08-01 18:18:40 -04:00
|
|
|
template<class T>
|
|
|
|
void ReadData_Impl();
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
std::istream& stream;
|
2022-09-05 20:59:46 -04:00
|
|
|
bool invalid { false };
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2023-08-01 18:18:40 -04:00
|
|
|
structs::PakVersion version;
|
|
|
|
structs::PakHeaderVariant header {};
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2022-09-07 05:07:40 -04:00
|
|
|
MapType files;
|
2022-09-04 17:11:14 -04:00
|
|
|
};
|
|
|
|
|
2022-09-05 20:59:46 -04:00
|
|
|
} // namespace europa::io
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
#endif // EUROPA_IO_PAKREADER_H
|