class final
#include <bsa/fo4.hpp>
chunk Represents a chunk of a file within the FO4 virtual filesystem.
Base classes
- class bsa::components::compressed_byte_container
- A byte storage container with compression support.
Public types
- struct mips_t
- Unique to format::
directx.
Public variables
-
struct bsa::
fo4:: chunk:: mips_t mips
Capacity
- auto empty() const -> bool noexcept
- Checks if the underlying byte container is empty.
-
auto size() const -> std::
size_t noexcept - Returns the size of the underlying byte container.
Compression
-
void compress(compression_
level a_level = compression_level:: normal) - Compresses the file.
-
auto compress_bound() const -> std::
size_t - Returns an upper bound on the storage size required to compress the file.
-
auto compress_into(std::
span<std:: byte> a_out, compression_ level a_level = compression_level:: normal) const -> std:: size_t - Compresses the file into the given buffer.
Decompression
- void decompress()
- Decompresses the file.
-
void decompress_into(std::
span<std:: byte> a_out) const - Decompresses the file into the given buffer.
-
auto decompressed_size() const -> std::
size_t noexcept - Retrieves the decompressed size of the compressed storage.
Element access
Modifiers
- void clear() noexcept
- Clears the data and mips of the chunk.
-
void set_data(std::
span<const std:: byte> a_data, std:: optional<std:: size_t> a_decompressedSize = std::nullopt) noexcept - Assigns the underlying container to be a non-owning view into the given data.
-
void set_data(std::
vector<std:: byte> a_data, std:: optional<std:: size_t> a_decompressedSize = std::nullopt) noexcept - Assigns the underlying container to be an owning view into the given data.
Observers
- auto compressed() const -> bool noexcept
- Checks if the underlying bytes are compressed.
Function documentation
bool bsa:: fo4:: chunk:: empty() const noexcept
#include <bsa/detail/common.hpp>
Checks if the underlying byte container is empty.
std:: size_t bsa:: fo4:: chunk:: size() const noexcept
#include <bsa/detail/common.hpp>
Returns the size of the underlying byte container.
void bsa:: fo4:: chunk:: compress(compression_ level a_level = compression_level:: normal)
Compresses the file.
Parameters | |
---|---|
a_level | The level to compress the data at. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: fo4:: chunk:: compress_bound() const
Returns an upper bound on the storage size required to compress the file.
Returns | Returns the size required to successfully compress the file. |
---|---|
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: fo4:: chunk:: compress_into(std:: span<std:: byte> a_out,
compression_ level a_level = compression_level:: normal) const
Compresses the file into the given buffer.
Parameters | |
---|---|
a_out | The buffer to compress the file into. |
a_level | The level to compress the data at. |
Returns | The final size of the compressed buffer. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
void bsa:: fo4:: chunk:: decompress()
Decompresses the file.
Exceptions | |
---|---|
bsa:: |
Thrown when any backend compression library errors are encountered. |
void bsa:: fo4:: chunk:: decompress_into(std:: span<std:: byte> a_out) const
Decompresses the file into the given buffer.
Parameters | |
---|---|
a_out | The buffer to decompress the file into. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: fo4:: chunk:: decompressed_size() const noexcept
#include <bsa/detail/common.hpp>
Retrieves the decompressed size of the compressed storage.
Only valid if the container is compressed.
std:: span<const std:: byte> bsa:: fo4:: chunk:: as_bytes() const noexcept
#include <bsa/detail/common.hpp>
Retrieves an immutable view into the underlying bytes.
const std:: byte* bsa:: fo4:: chunk:: data() const noexcept
#include <bsa/detail/common.hpp>
Retrieves an immutable pointer to the underlying bytes.
void bsa:: fo4:: chunk:: set_data(std:: span<const std:: byte> a_data,
std:: optional<std:: size_t> a_decompressedSize = std::nullopt) noexcept
#include <bsa/detail/common.hpp>
Assigns the underlying container to be a non-owning view into the given data.
Parameters | |
---|---|
a_data | The data to store a view to. |
a_decompressedSize | The decompressed size of the data, if the given data is compressed. |
void bsa:: fo4:: chunk:: set_data(std:: vector<std:: byte> a_data,
std:: optional<std:: size_t> a_decompressedSize = std::nullopt) noexcept
#include <bsa/detail/common.hpp>
Assigns the underlying container to be an owning view into the given data.
Parameters | |
---|---|
a_data | The data to take ownership of. |
a_decompressedSize | The decompressed size of the data, if the given data is compressed. |
bool bsa:: fo4:: chunk:: compressed() const noexcept
#include <bsa/detail/common.hpp>
Checks if the underlying bytes are compressed.