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// ReSharper disable CppRedundantQualifier
2
3#pragma once
4
6
7#include "../PackFile.h"
8
9namespace vpkpp {
10
11constexpr int8_t WAD3_FILENAME_MAX_SIZE = 16;
13constexpr std::string_view WAD3_EXTENSION = ".wad";
14
18class WAD3 : public PackFile {
19public:
21 static std::unique_ptr<PackFile> create(const std::string& path);
22
24 [[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
25
26 static constexpr std::string_view GUID = "1B4D626A278F47B9B2D4ADB244218B03";
27
28 [[nodiscard]] constexpr std::string_view getGUID() const override {
29 return WAD3::GUID;
30 }
31
32 [[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
33
34 bool bake(const std::string& outputDir_ /*= ""*/, BakeOptions options /*= {}*/, const EntryCallback& callback /*= nullptr*/) override;
35
36 [[nodiscard]] Attribute getSupportedEntryAttributes() const override;
37
38protected:
40
41 void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
42
43private:
45};
46
47} // namespace vpkpp
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition PackFile.h:255
This class represents the metadata that a file has inside a PackFile.
Definition Entry.h:14
EntryCallbackBase< void > EntryCallback
Definition PackFile.h:38
PackFile(const PackFile &other)=delete
Valve GoldSrc WAD3 file.
Definition WAD3.h:18
static constexpr std::string_view GUID
Definition WAD3.h:26
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:28
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
PackFile(const PackFile &other)=delete
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:20
constexpr int8_t WAD3_FILENAME_MAX_SIZE
Definition WAD3.h:11
constexpr auto WAD3_SIGNATURE
Definition WAD3.h:12
Attribute
Definition Attribute.h:7
constexpr std::string_view WAD3_EXTENSION
Definition WAD3.h:13