wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::formats::StringBlock Class Reference

#include <wowlib/formats/common/string_block.hpp>

Classes

struct  Entry
 One decoded string and the blob byte offset other chunks reference it by. More...

Public Member Functions

 StringBlock ()=default
Result< void > read (std::span< const std::byte > payload)
 Decode a chunk payload (the serializer's read hook): every run of non-zero bytes becomes an entry at its offset; zero bytes between runs are padding and are reproduced by write().
Result< void > write (FileBuffer &out) const
 Blobify (the serializer's write hook): append size() zero bytes to out, then lay each entry's characters down at its offset — the zero fill provides the terminators and the padding.
std::string_view at (std::uint32_t offset) const
 The string at a byte offset another chunk stored; empty if the offset lands on padding or out of range.
std::uint32_t add (std::string_view string)
 Append a string; existing offsets never move.
const std::vector< Entry > & entries () const
 The decoded entries, in blob order.
bool empty () const
 Whether the on-disk blob holds any bytes.
std::size_t size () const
 The on-disk blob size in bytes, trailing padding included.

Detailed Description

Definition at line 23 of file string_block.hpp.

Constructor & Destructor Documentation

◆ StringBlock()

wowlib::formats::StringBlock::StringBlock ( )
default

Member Function Documentation

◆ add()

std::uint32_t wowlib::formats::StringBlock::add ( std::string_view string)
inline

Append a string; existing offsets never move.

Returns
the offset the new string starts at - the value to store in referencing chunks
Parameters
stringthe string to append (no embedded zero bytes)

Definition at line 90 of file string_block.hpp.

◆ at()

std::string_view wowlib::formats::StringBlock::at ( std::uint32_t offset) const
inlinenodiscard

The string at a byte offset another chunk stored; empty if the offset lands on padding or out of range.

Returns
the referenced string (a mid-entry offset yields the suffix)
Parameters
offsetbyte offset into the on-disk blob

Definition at line 76 of file string_block.hpp.

References wowlib::formats::StringBlock::Entry::offset, and wowlib::formats::StringBlock::Entry::value.

Referenced by wowlib::db::detail::decodeInlineRecord().

◆ empty()

bool wowlib::formats::StringBlock::empty ( ) const
inlinenodiscard

Whether the on-disk blob holds any bytes.

Definition at line 109 of file string_block.hpp.

◆ entries()

const std::vector< Entry > & wowlib::formats::StringBlock::entries ( ) const
inlinenodiscard

The decoded entries, in blob order.

Returns
the (offset, value) entries

Definition at line 103 of file string_block.hpp.

◆ read()

Result< void > wowlib::formats::StringBlock::read ( std::span< const std::byte > payload)
inline

Decode a chunk payload (the serializer's read hook): every run of non-zero bytes becomes an entry at its offset; zero bytes between runs are padding and are reproduced by write().

Parameters
payloadthe chunk payload bytes.
Returns
nothing; every byte pattern decodes.

Definition at line 41 of file string_block.hpp.

Referenced by wowlib::db::readWdb2(), and wowlib::db::readWdbc().

◆ size()

std::size_t wowlib::formats::StringBlock::size ( ) const
inline

The on-disk blob size in bytes, trailing padding included.

Definition at line 114 of file string_block.hpp.

Referenced by wowlib::db::writeWdb2(), and wowlib::db::writeWdbc().

◆ write()

Result< void > wowlib::formats::StringBlock::write ( FileBuffer & out) const
inline

Blobify (the serializer's write hook): append size() zero bytes to out, then lay each entry's characters down at its offset — the zero fill provides the terminators and the padding.

Parameters
outthe destination buffer (appended, not cleared).
Returns
nothing; emitting the blob cannot fail.

Definition at line 63 of file string_block.hpp.

Referenced by wowlib::db::writeWdb2(), and wowlib::db::writeWdbc().


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