resonance 1.0.1
Loading...
Searching...
No Matches
hxstrtransfer.h File Reference
#include "os/hxstr.h"
#include "stream/ibstream.h"
#include "stream/obstream.h"
Include dependency graph for hxstrtransfer.h:

Go to the source code of this file.

Functions

OBStream & SaveHxStr (OBStream &stream, const HxStr &text)
 Write a string as a four-byte length followed by its text, with no terminator.
IBStream & LoadHxStr (IBStream &stream, HxStr &text)
 Read a string written by SaveHxStr() back in place.

Function Documentation

◆ SaveHxStr()

OBStream & SaveHxStr ( OBStream & stream,
const HxStr & text )
inline

Write a string as a four-byte length followed by its text, with no terminator.

Every packet that carries a string open-codes this sequence, and the image holds no out-of-line copy, which is the shape of an inline function. The call sites are GameChatPacket::saveGuts() at 0x003e8458, its second emission at 0x003e8720 in TestArbiterPacket's table, and SPJoinDenyPacket::saveGuts() at 0x003e5d58. The name and the placement are inferred. The length goes through OBStream::WriteLE() and the text through OBStream::Write() on the same stream, and only the second call's result is returned.

Parameters
streamThe stream to write to.
textThe string to write.
Returns
The stream Write() returned.

◆ LoadHxStr()

IBStream & LoadHxStr ( IBStream & stream,
HxStr & text )
inline

Read a string written by SaveHxStr() back in place.

The string is resized through HxStr::Alloc() to the length read, and the text is then read into its buffer. An empty string has no buffer, so the zero-byte read targets the shared empty literal instead, exactly as the open-coded sequences do. The call sites are the restoreGuts() members paired with the saveGuts() members listed on SaveHxStr().

Parameters
streamThe stream to read from.
textThe string to fill.
Returns
The stream Read() returned.