class final
#include <bsa/tes4.hpp>
file Represents a file within the TES4 virtual filesystem.
Base classes
- class bsa::components::compressed_byte_container
- A byte storage container with compression support.
Public types
- struct compression_params
- Common parameters to configure how files are compressed/decompressed.
- struct read_params
- Common parameters to configure how files are read.
- struct write_params
- Common parameters to configure how files are written.
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(const compression_
params& a_params) - Compresses the object.
-
auto compress_bound(const compression_
params& a_params) const -> std:: size_t - Returns an upper bound on the storage size required to compress the object.
-
auto compress_into(std::
span<std:: byte> a_out, const compression_ params& a_params) const -> std:: size_t - Compresses the object into the given buffer.
Decompression
-
void decompress(const compression_
params& a_params) - Decompresses the object.
-
void decompress_into(std::
span<std:: byte> a_out, const compression_ params& a_params) const - Decompresses the object into the given buffer.
-
auto decompressed_size() const -> std::
size_t noexcept - Retrieves the decompressed size of the compressed storage.
Element access
Member types
-
using key = components::
key<hashing:: hash, hashing:: hash_file_in_place> - The key used to indentify a file.
Modifiers
- void clear() noexcept
- Clears the contents of the file.
-
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.
Reading
-
void read(read_
source a_source, const read_ params& a_params) - Reads the contents of the source.
Writing
-
void write(write_
sink a_sink, const write_ params& a_params) const - Writes the contents of the object to the destination.
Function documentation
bool bsa:: tes4:: file:: empty() const noexcept
#include <bsa/detail/common.hpp>
Checks if the underlying byte container is empty.
std:: size_t bsa:: tes4:: file:: size() const noexcept
#include <bsa/detail/common.hpp>
Returns the size of the underlying byte container.
void bsa:: tes4:: file:: compress(const compression_ params& a_params)
Compresses the object.
Parameters | |
---|---|
a_params | Extra configuration options. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: tes4:: file:: compress_bound(const compression_ params& a_params) const
Returns an upper bound on the storage size required to compress the object.
Parameters | |
---|---|
a_params | Extra configuration options. |
Returns | Returns the size required to successfully compress the object. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: tes4:: file:: compress_into(std:: span<std:: byte> a_out,
const compression_ params& a_params) const
Compresses the object into the given buffer.
Parameters | |
---|---|
a_out | The buffer to compress the object into. |
a_params | Extra configuration options. |
Returns | The final size of the compressed buffer. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
void bsa:: tes4:: file:: decompress(const compression_ params& a_params)
Decompresses the object.
Parameters | |
---|---|
a_params | Extra configuration options. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
void bsa:: tes4:: file:: decompress_into(std:: span<std:: byte> a_out,
const compression_ params& a_params) const
Decompresses the object into the given buffer.
Parameters | |
---|---|
a_out | The buffer to decompress the object into. |
a_params | Extra configuration options. |
Exceptions | |
bsa:: |
Thrown when any backend compression library errors are encountered. |
std:: size_t bsa:: tes4:: file:: 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:: tes4:: file:: as_bytes() const noexcept
#include <bsa/detail/common.hpp>
Retrieves an immutable view into the underlying bytes.
const std:: byte* bsa:: tes4:: file:: data() const noexcept
#include <bsa/detail/common.hpp>
Retrieves an immutable pointer to the underlying bytes.
void bsa:: tes4:: file:: 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:: tes4:: file:: 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:: tes4:: file:: compressed() const noexcept
#include <bsa/detail/common.hpp>
Checks if the underlying bytes are compressed.
void bsa:: tes4:: file:: read(read_ source a_source,
const read_ params& a_params)
Reads the contents of the source.
Parameters | |
---|---|
a_source | Where/how to read the given file. |
a_params | Extra configuration options. |
Exceptions | |
binary_io::buffer_exhausted | Thrown when reads index out of bounds. |
void bsa:: tes4:: file:: write(write_ sink a_sink,
const write_ params& a_params) const
Writes the contents of the object to the destination.
Parameters | |
---|---|
a_sink | Where/how to write the given file. |
a_params | Extra configuration options. |
Exceptions | |
std:: |
Thrown when filesystem errors are encountered. |
binary_io::buffer_exhausted | Thrown when the output buffer is exhausted. |