SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
WAD3.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "../PackFile.h"
6
7namespace vpkpp {
8
9constexpr int8_t WAD3_FILENAME_MAX_SIZE = 16;
11constexpr std::string_view WAD3_EXTENSION = ".wad";
12
16class WAD3 : public PackFile {
17public:
19 static std::unique_ptr<PackFile> create(const std::string& path);
20
22 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
23
24 static constexpr inline std::string_view GUID = "1B4D626A278F47B9B2D4ADB244218B03";
25
26 [[nodiscard]] constexpr std::string_view getGUID() const override {
27 return WAD3::GUID;
28 }
29
30 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
31
32 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
33
34 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
35
36protected:
38
39 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
40
41private:
43};
44
45} // namespace vpkpp
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition: PackFile.h:242
This class represents the metadata that a file has inside a PackFile.
Definition: Entry.h:14
EntryCallbackBase< void > EntryCallback
Definition: PackFile.h:30
PackFile(const PackFile &other)=delete
Valve GoldSrc WAD3 file.
Definition: WAD3.h:16
static constexpr std::string_view GUID
Definition: WAD3.h:24
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a WAD3 file.
Definition: WAD3.cpp:61
static std::unique_ptr< PackFile > create(const std::string &path)
Create a WAD3 file.
Definition: WAD3.cpp:52
bool bake(const std::string &outputDir_, BakeOptions options, const EntryCallback &callback) override
If output folder is an empty string, it will overwrite the original.
Definition: WAD3.cpp:146
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition: WAD3.cpp:118
constexpr std::string_view getGUID() const override
Get the GUID corresponding to the pack file type.
Definition: WAD3.h:26
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition: WAD3.cpp:225
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition: WAD3.cpp:139
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition: Binary.h:18
Definition: Attribute.h:5
constexpr int8_t WAD3_FILENAME_MAX_SIZE
Definition: WAD3.h:9
constexpr auto WAD3_SIGNATURE
Definition: WAD3.h:10
Attribute
Definition: Attribute.h:7
constexpr std::string_view WAD3_EXTENSION
Definition: WAD3.h:11