SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
TAB.h
Go to the documentation of this file.
1
// ReSharper disable CppRedundantQualifier
2
3
#pragma once
4
5
#include <
sourcepp/parser/Binary.h
>
6
7
#include "
../PackFile.h
"
8
9
namespace
vpkpp
{
10
11
constexpr
std::string_view
TAB_EXTENSION
=
".tab"
;
12
13
constexpr
auto
TAB_FILENAME_MAX_SIZE
= 128;
14
constexpr
std::string_view
TAB_HASHED_FILEPATH_PREFIX
=
"__hashed__/"
;
15
16
constexpr
std::string_view
ARC_EXTENSION
=
".arc"
;
17
19
constexpr
uint32_t
ARC_CHUNK_SIZE
= 1024 * 1024 * 1024;
20
21
class
TAB
:
public
PackFile
{
22
public
:
23
enum class
Version
{
24
JC1_LE
,
25
JC1_BE
,
26
};
27
29
static
std::unique_ptr<PackFile>
create
(
const
std::string& path,
Version
version
=
Version::JC1_LE
, uint32_t
sectorSize
= 2048);
30
32
[[nodiscard]]
static
std::unique_ptr<PackFile>
open
(
const
std::string& path,
const
EntryCallback
& callback =
nullptr
);
33
34
[[nodiscard]] std::optional<std::vector<std::byte>>
readEntry
(
const
std::string& path_)
const override
;
35
36
bool
bake
(
const
std::string& outputDir_
/*= ""*/
,
BakeOptions
options
/*= {}*/
,
const
EntryCallback
& callback
/*= nullptr*/
)
override
;
37
38
[[nodiscard]]
Attribute
getSupportedEntryAttributes
()
const override
;
39
40
[[nodiscard]]
explicit
operator
std::string()
const override
;
41
42
[[nodiscard]]
Version
getVersion
()
const
;
43
44
void
setVersion
(
Version
version_);
45
46
[[nodiscard]] uint32_t
getSectorSize
()
const
;
47
48
void
setSectorSize
(uint32_t sectorSize_);
49
50
[[nodiscard]]
static
uint32_t
hashFilePath
(
const
std::string& filepath);
51
52
protected
:
53
using
PackFile::PackFile
;
54
55
void
addEntryInternal
(
Entry
& entry,
const
std::string& path, std::vector<std::byte>& buffer,
EntryOptions
options)
override
;
56
57
Version
version
=
Version::JC1_LE
;
58
uint32_t
sectorSize
= 0;
59
uint32_t
numArchives
= 0;
60
61
private
:
62
VPKPP_REGISTER_PACKFILE_OPEN
(
TAB_EXTENSION
, &
TAB::open
);
63
};
64
65
}
// namespace vpkpp
Binary.h
PackFile.h
VPKPP_REGISTER_PACKFILE_OPEN
#define VPKPP_REGISTER_PACKFILE_OPEN(extension, function)
Definition
PackFile.h:254
vpkpp::Entry
This class represents the metadata that a file has inside a PackFile.
Definition
Entry.h:14
vpkpp::PackFile::EntryCallback
EntryCallbackBase< void > EntryCallback
Definition
PackFile.h:38
vpkpp::PackFile::bake
bool bake()
If output folder is an empty string, it will overwrite the original.
Definition
PackFile.cpp:369
vpkpp::PackFile::PackFile
PackFile(const PackFile &other)=delete
vpkpp::TAB
Definition
TAB.h:21
vpkpp::TAB::open
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a TAB file.
Definition
TAB.cpp:39
vpkpp::TAB::setVersion
void setVersion(Version version_)
Definition
TAB.cpp:288
vpkpp::TAB::getSectorSize
uint32_t getSectorSize() const
Definition
TAB.cpp:292
vpkpp::TAB::numArchives
uint32_t numArchives
Definition
TAB.h:59
vpkpp::TAB::sectorSize
uint32_t sectorSize
Definition
TAB.h:58
vpkpp::TAB::addEntryInternal
void addEntryInternal(Entry &entry, const std::string &path, std::vector< std::byte > &buffer, EntryOptions options) override
Definition
TAB.cpp:149
vpkpp::TAB::setSectorSize
void setSectorSize(uint32_t sectorSize_)
Definition
TAB.cpp:296
vpkpp::TAB::getSupportedEntryAttributes
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
Definition
TAB.cpp:275
vpkpp::TAB::readEntry
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
Definition
TAB.cpp:130
vpkpp::TAB::hashFilePath
static uint32_t hashFilePath(const std::string &filepath)
Definition
TAB.cpp:300
vpkpp::TAB::version
Version version
Definition
TAB.h:57
vpkpp::TAB::PackFile
PackFile(const PackFile &other)=delete
vpkpp::TAB::Version
Version
Definition
TAB.h:23
vpkpp::TAB::Version::JC1_BE
@ JC1_BE
Definition
TAB.h:25
vpkpp::TAB::Version::JC1_LE
@ JC1_LE
Definition
TAB.h:24
vpkpp::TAB::getVersion
Version getVersion() const
Definition
TAB.cpp:284
vpkpp::TAB::create
static std::unique_ptr< PackFile > create(const std::string &path, Version version=Version::JC1_LE, uint32_t sectorSize=2048)
Create a TAB file.
Definition
TAB.cpp:27
vpkpp
Definition
Attribute.h:5
vpkpp::ARC_EXTENSION
constexpr std::string_view ARC_EXTENSION
Definition
TAB.h:16
vpkpp::ARC_CHUNK_SIZE
constexpr uint32_t ARC_CHUNK_SIZE
Chunk size in bytes (1gb).
Definition
TAB.h:19
vpkpp::TAB_FILENAME_MAX_SIZE
constexpr auto TAB_FILENAME_MAX_SIZE
Definition
TAB.h:13
vpkpp::Attribute
Attribute
Definition
Attribute.h:7
vpkpp::TAB_EXTENSION
constexpr std::string_view TAB_EXTENSION
Definition
TAB.h:11
vpkpp::TAB_HASHED_FILEPATH_PREFIX
constexpr std::string_view TAB_HASHED_FILEPATH_PREFIX
Definition
TAB.h:14
vpkpp::BakeOptions
Definition
Options.h:20
vpkpp::EntryOptions
Definition
Options.h:34
include
vpkpp
format
TAB.h
Generated on
for SourcePP by
1.17.0