libassetmap  1.0.0
Hash-table based archive format containing compressed data
Public Member Functions | List of all members
AssetMap::MemMappedBucketEntry Class Reference

Public Member Functions

 MemMappedBucketEntry (uint8_t *data, ICompress &comp)
 Constructor to reference available space for writing. More...
 
 MemMappedBucketEntry (uint8_t *data, IDecompress &decomp)
 Constructor to reference an existing entry for reading. More...
 
 MemMappedBucketEntry (std::nullptr_t)
 Constructs an instance not pointing to any data. More...
 
lam_size_t FileSize () const noexcept
 Obtains the (compressed) size of this entry's file. More...
 
lam_size_t DecompressedSize () const noexcept
 Obtains the size that would be required to fully decompress. More...
 
size_t InMemorySize () const noexcept
 
std::string_view Name () const noexcept
 Obtains the name of this entry. More...
 
size_t Populate (std::string_view name, const uint8_t *ptr, size_t len) noexcept
 Initialises this entry by compressing and writing the input data to ptr. More...
 
size_t MakeNull () noexcept
 Initializes this entry to a size of zero and an empty name. More...
 
std::pair< std::unique_ptr< uint8_t[]>, size_t > Retrieve ()
 Allocates and returns the decompressed data and its size. More...
 
size_t Retrieve (uint8_t *buf, size_t len)
 Decompresses the data into buf up to a limit of len. More...
 
MemMappedBucketEntry & operator++ () noexcept
 Increments this entry to point to the next entry space. More...
 
bool operator== (const MemMappedBucketEntry &rhs) const noexcept
 compares this instance to another instance for equality More...
 
bool operator!= (const MemMappedBucketEntry &rhs) const noexcept
 compares this instance to another instance for inequality More...
 
 operator bool () const noexcept
 Tests if this entry is valid. More...
 

Constructor & Destructor Documentation

◆ MemMappedBucketEntry() [1/3]

AssetMap::MemMappedBucketEntry::MemMappedBucketEntry ( uint8_t *  data,
ICompress &  comp 
)

Constructor to reference available space for writing.

Parameters
dataA pointer to the location where entry data is to be written.
compA valid instance of a compressor to compress the data.

◆ MemMappedBucketEntry() [2/3]

AssetMap::MemMappedBucketEntry::MemMappedBucketEntry ( uint8_t *  data,
IDecompress &  decomp 
)

Constructor to reference an existing entry for reading.

Parameters
dataA pointer to the location where an entry (may) exist.
decompA valid instance of a decompressor to extract the data.

◆ MemMappedBucketEntry() [3/3]

AssetMap::MemMappedBucketEntry::MemMappedBucketEntry ( std::nullptr_t  )
explicit

Constructs an instance not pointing to any data.

Postcondition
Calling anything other than the comparison operators results in undefined behaviour.
Parameters
nullptr_trequires you to pass nullptr - nothing else is valid

Member Function Documentation

◆ DecompressedSize()

lam_size_t AssetMap::MemMappedBucketEntry::DecompressedSize ( ) const
noexcept

Obtains the size that would be required to fully decompress.

Returns
the number of bytes needed to fully decompress the data.

◆ FileSize()

lam_size_t AssetMap::MemMappedBucketEntry::FileSize ( ) const
noexcept

Obtains the (compressed) size of this entry's file.

Returns
the size of this entry's file.

◆ InMemorySize()

size_t AssetMap::MemMappedBucketEntry::InMemorySize ( ) const
noexcept

Obtains the full size (in bytes) of this entry, including padding.

Returns
the full size of this entry. Generally used to calculate the appropriate address to store the next entry.

◆ MakeNull()

size_t AssetMap::MemMappedBucketEntry::MakeNull ( )
noexcept

Initializes this entry to a size of zero and an empty name.

Returns
The total in-memory size of this entire entry.

◆ Name()

std::string_view AssetMap::MemMappedBucketEntry::Name ( ) const
noexcept

Obtains the name of this entry.

Returns
the name of this entry.

◆ operator bool()

AssetMap::MemMappedBucketEntry::operator bool ( ) const
explicitnoexcept

Tests if this entry is valid.

Returns true if this entry points to a valid address and has a non-empty name.

Returns
whether or not the instance is valid.

◆ operator!=()

bool AssetMap::MemMappedBucketEntry::operator!= ( const MemMappedBucketEntry &  rhs) const
noexcept

compares this instance to another instance for inequality

Elements compare inequal if operator== would return false.

Parameters
rhsany instance.
Returns
true if the instance are not equivalent.

◆ operator++()

MemMappedBucketEntry& AssetMap::MemMappedBucketEntry::operator++ ( )
noexcept

Increments this entry to point to the next entry space.

Precondition
This instance must currently have a valid name and size.
Returns
a reference to *this.

◆ operator==()

bool AssetMap::MemMappedBucketEntry::operator== ( const MemMappedBucketEntry &  rhs) const
noexcept

compares this instance to another instance for equality

Elements compare equal if they point to the same location.

Parameters
rhsany instance.
Returns
true if the instances are equivalent.

◆ Populate()

size_t AssetMap::MemMappedBucketEntry::Populate ( std::string_view  name,
const uint8_t *  ptr,
size_t  len 
)
noexcept

Initialises this entry by compressing and writing the input data to ptr.

Precondition
name must not be empty.
Parameters
nameThe name of the file
ptrThe source data to compress and write to the file
lenThe length of the source data (in bytes)
Returns
The total in-memory size of this entire entry.
See also
InMemorySize()

◆ Retrieve() [1/2]

std::pair<std::unique_ptr<uint8_t[]>, size_t> AssetMap::MemMappedBucketEntry::Retrieve ( )

Allocates and returns the decompressed data and its size.

Returns
a pair containing the data and its size.

◆ Retrieve() [2/2]

size_t AssetMap::MemMappedBucketEntry::Retrieve ( uint8_t *  buf,
size_t  len 
)

Decompresses the data into buf up to a limit of len.

Returns
the number of bytes written to buf

The documentation for this class was generated from the following file: