bsa::tes4::archive class final

Represents the TES4 revision of the bsa format.

Base classes

template<class T, bool RECURSE>
class bsa::components::hashmap<directory, true>
Establishes a basic mapping between a key and its associated files.

Archive flags

auto archive_flags() const -> archive_flag noexcept
Retrieves the current archive flags.
void archive_flags(archive_flag a_flags) noexcept
Sets the current archive flags.
auto compressed() const -> bool noexcept
Checks if archive_flag::compressed is set.
auto directory_strings() const -> bool noexcept
Checks if archive_flag::directory_strings is set.
auto embedded_file_names() const -> bool noexcept
Checks if archive_flag::embedded_file_names is set.
auto file_strings() const -> bool noexcept
Checks if archive_flag::file_strings is set.
auto retain_directory_names() const -> bool noexcept
Checks if archive_flag::retain_directory_names is set.
auto retain_file_name_offsets() const -> bool noexcept
Checks if archive_flag::retain_file_name_offsets is set.
auto retain_file_names() const -> bool noexcept
Checks if archive_flag::retain_file_names is set.
auto retain_strings_during_startup() const -> bool noexcept
Checks if archive_flag::retain_strings_during_startup is set.
auto xbox_archive() const -> bool noexcept
Checks if archive_flag::xbox_archive is set.
auto xbox_compressed() const -> bool noexcept
Checks if archive_flag::xbox_compressed is set.

Archive types

auto archive_types() const -> archive_type noexcept
Retrieves the current archive types.
void archive_types(archive_type a_types) noexcept
Sets the current archive types.
auto fonts() const -> bool noexcept
Checks if archive_type::fonts is set.
auto menus() const -> bool noexcept
Checks if archive_type::menus is set.
auto meshes() const -> bool noexcept
Checks if archive_type::meshes is set.
auto misc() const -> bool noexcept
Checks if archive_type::misc is set.
auto shaders() const -> bool noexcept
Checks if archive_type::shaders is set.
auto sounds() const -> bool noexcept
Checks if archive_type::sounds is set.
auto textures() const -> bool noexcept
Checks if archive_type::textures is set.
auto trees() const -> bool noexcept
Checks if archive_type::trees is set.
auto voices() const -> bool noexcept
Checks if archive_type::voices is set.

Capacity

auto empty() const -> bool noexcept
Checks if the container is empty.
auto size() const -> std::size_t noexcept
Returns the number of elements in the container.

Doxygen only

auto doxygen_read() -> version protected
void doxygen_write(version a_version) const protected

Iterators

auto begin() -> iterator noexcept
Obtains an interator to the beginning of the container.
auto begin() const -> const_iterator noexcept
Obtains an interator to the beginning of the container.
auto cbegin() const -> const_iterator noexcept
Obtains an interator to the beginning of the container.
auto cend() const -> const_iterator noexcept
Obtains an iterator to the end of the container.
auto end() -> iterator noexcept
Obtains an iterator to the end of the container.
auto end() const -> const_iterator noexcept
Obtains an iterator to the end of the container.

Lookup

auto find(const key_type& a_key) -> iterator noexcept
Finds a value_type with the given key within the container.
auto find(const key_type& a_key) const -> const_iterator noexcept
Finds a value_type with the given key within the container.
auto operator[](const key_type& a_key) -> index noexcept
Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.
auto operator[](const key_type& a_key) const -> const_index noexcept
Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.

Member types

using const_index = index_t<const mapped_type>
using const_iterator = typename container_type::const_iterator
using index = index_t<mapped_type>
using iterator = typename container_type::iterator
using key_compare = typename container_type::key_compare
using key_type = typename T::key
using mapped_type = directory
using value_type = std::pair<const key_type, mapped_type>

Modifiers

void clear() noexcept
Clears the contents, flags, and file types of the archive.
auto erase(const key_type& a_key) -> bool noexcept
Erases any element with the given key from the container.
auto insert(key_type a_key, mapped_type a_value) -> std::pair<iterator, bool> noexcept
Inserts a_value into the container with the given a_key.

Reading

auto read(std::filesystem::path a_path) -> version
Reads the contents of the source.
auto read(std::span<const std::byte> a_src, copy_type a_copy = copy_type::deep) -> version
Reads the contents of the source.

Verification

auto verify_offsets(version a_version) const -> bool noexcept
Verifies that offsets within the archive will be valid when written to disk.

Writing

void write(std::filesystem::path a_path, version a_version) const
Writes the contents of the object to the destination.
void write(binary_io::any_ostream& a_dst, version a_version) const
Writes the contents of the object to the destination.

Typedef documentation

using bsa::tes4::archive::const_index = index_t<const mapped_type>

using bsa::tes4::archive::const_iterator = typename container_type::const_iterator

using bsa::tes4::archive::index = index_t<mapped_type>

using bsa::tes4::archive::iterator = typename container_type::iterator

using bsa::tes4::archive::key_compare = typename container_type::key_compare

using bsa::tes4::archive::key_type = typename T::key

using bsa::tes4::archive::mapped_type = directory

using bsa::tes4::archive::value_type = std::pair<const key_type, mapped_type>

Function documentation

bool bsa::tes4::archive::empty() const noexcept

Checks if the container is empty.

std::size_t bsa::tes4::archive::size() const noexcept

Returns the number of elements in the container.

version bsa::tes4::archive::doxygen_read() protected

Returns The version of the archive that was read.

void bsa::tes4::archive::doxygen_write(version a_version) const protected

Parameters
a_version The version format to write the archive in.

iterator bsa::tes4::archive::begin() noexcept

Obtains an interator to the beginning of the container.

const_iterator bsa::tes4::archive::begin() const noexcept

Obtains an interator to the beginning of the container.

const_iterator bsa::tes4::archive::cbegin() const noexcept

Obtains an interator to the beginning of the container.

const_iterator bsa::tes4::archive::cend() const noexcept

Obtains an iterator to the end of the container.

iterator bsa::tes4::archive::end() noexcept

Obtains an iterator to the end of the container.

const_iterator bsa::tes4::archive::end() const noexcept

Obtains an iterator to the end of the container.

iterator bsa::tes4::archive::find(const key_type& a_key) noexcept

Finds a value_type with the given key within the container.

const_iterator bsa::tes4::archive::find(const key_type& a_key) const noexcept

Finds a value_type with the given key within the container.

index bsa::tes4::archive::operator[](const key_type& a_key) noexcept

Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.

const_index bsa::tes4::archive::operator[](const key_type& a_key) const noexcept

Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.

bool bsa::tes4::archive::erase(const key_type& a_key) noexcept

Erases any element with the given key from the container.

Returns Returns true if the element was successfully deleted, false otherwise.

std::pair<iterator, bool> bsa::tes4::archive::insert(key_type a_key, mapped_type a_value) noexcept

Inserts a_value into the container with the given a_key.

Parameters
a_key The key of the value_type.
a_value The value of the value_type.
Returns Returns an iterator to the position at which the given value_type was inserted, and a bool to indicate if the insertion was successful.

version bsa::tes4::archive::read(std::filesystem::path a_path)

Reads the contents of the source.

Parameters
a_path The path to the given archive on the native filesystem.
Returns The version of the archive that was read.
Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.
bsa::exception Thrown when archive parsing errors are encountered.
std::system_error Thrown when filesystem errors are encountered.

version bsa::tes4::archive::read(std::span<const std::byte> a_src, copy_type a_copy = copy_type::deep)

Reads the contents of the source.

Parameters
a_src The source to read from.
a_copy The method to use when copying data from a_src.
Returns The version of the archive that was read.
Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.
bsa::exception Thrown when archive parsing errors are encountered.

bool bsa::tes4::archive::verify_offsets(version a_version) const noexcept

Verifies that offsets within the archive will be valid when written to disk.

Parameters
a_version The version format to check for.
Returns Returns true is the archive passes validation, false otherwise.

void bsa::tes4::archive::write(std::filesystem::path a_path, version a_version) const

Writes the contents of the object to the destination.

Parameters
a_path The path to write the archive to on the native filesystem.
a_version The version format to write the archive in.
Exceptions
std::system_error Thrown when filesystem errors are encountered.
binary_io::buffer_exhausted Thrown when the output buffer is exhausted.

void bsa::tes4::archive::write(binary_io::any_ostream& a_dst, version a_version) const

Writes the contents of the object to the destination.

Parameters
a_dst The stream to write the archive to.
a_version The version format to write the archive in.
Exceptions
std::system_error Thrown when filesystem errors are encountered.
binary_io::buffer_exhausted Thrown when the output buffer is exhausted.