bsa::fo4::file class final
#include <bsa/fo4.hpp>

Represents a file within the FO4 virtual filesystem.

Public types

struct header_t
Unique to format::directx.
struct read_params
Common parameters to configure how files are read.
struct write_params
Common parameters to configure how files are written.

Public variables

struct bsa::fo4::file::header_t header

Assignment

auto operator=(const file&) -> file& defaulted noexcept
auto operator=(file&&) -> file& defaulted noexcept

Capacity

auto capacity() const -> std::size_t noexcept
Returns the number of chunks the file can store without reallocating.
auto empty() const -> bool noexcept
Checks if the file is empty.
void reserve(std::size_t a_count) noexcept
Reserves storage for a_count chunks.
void shrink_to_fit() noexcept
Shrinks the file's capacity to its size.
auto size() const -> std::size_t noexcept
Returns the number of chunks in the file.

Constructors

file() defaulted noexcept
file(const file&) defaulted noexcept
file(file&&) defaulted noexcept

Destructors

~file() defaulted noexcept

Element access

auto back() -> value_type& noexcept
Returns a reference to the chunk at the back of the file.
auto back() const -> const value_type& noexcept
Returns a reference to the chunk at the back of the file.
auto front() -> value_type& noexcept
Returns a reference to the chunk at the front of the file.
auto front() const -> const value_type& noexcept
Returns a reference to the chunk at the front of the file.
auto operator[](std::size_t a_pos) -> value_type& noexcept
Returns the chunk at the given position.
auto operator[](std::size_t a_pos) const -> const value_type& noexcept
Returns the chunk at the given position.

Iterators

auto begin() -> iterator noexcept
Returns an iterator to the beginning of the file.
auto begin() const -> const_iterator noexcept
Returns an iterator to the beginning of the file.
auto cbegin() const -> const_iterator noexcept
Returns an iterator to the beginning of the file.
auto cend() const -> const_iterator noexcept
Returns an iterator to the end of the file.
auto end() -> iterator noexcept
Returns an iterator to the end of the file.
auto end() const -> const_iterator noexcept
Returns an iterator to the end of the file.

Member types

using const_iterator = container_type::const_iterator
using iterator = container_type::iterator
using key = components::key<hashing::hash, hashing::hash_file_in_place>
The key used to indentify a file.
using value_type = chunk

Modifiers

void clear() noexcept
Clears the chunks and header of the file.
template <class... Args>
auto emplace_back(Args && ... a_args) -> value_type& noexcept
Constructs a chunk in-place, inside the file.
void pop_back() noexcept
Removes a chunk from the file.
void push_back(value_type a_value) noexcept
Appends a chunk to the file.

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

value_type& bsa::fo4::file::back() noexcept

Returns a reference to the chunk at the back of the file.

const value_type& bsa::fo4::file::back() const noexcept

Returns a reference to the chunk at the back of the file.

value_type& bsa::fo4::file::front() noexcept

Returns a reference to the chunk at the front of the file.

const value_type& bsa::fo4::file::front() const noexcept

Returns a reference to the chunk at the front of the file.

value_type& bsa::fo4::file::operator[](std::size_t a_pos) noexcept

Returns the chunk at the given position.

const value_type& bsa::fo4::file::operator[](std::size_t a_pos) const noexcept

Returns the chunk at the given position.

void bsa::fo4::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::fo4::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::system_error Thrown when filesystem errors are encountered.
binary_io::buffer_exhausted Thrown when the output buffer is exhausted.