resonance 1.0.1
Loading...
Searching...
No Matches
hxstr.h File Reference
#include <iostream>
#include "os/mem.h"
Include dependency graph for hxstr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  HxStr
 Heap-allocated NUL-terminated string. More...

Functions

HxStr operator+ (const HxStr &left, const HxStr &right)
 Concatenate two strings.
HxStr operator+ (const HxStr &left, const char *pszRight)
 Concatenate a string and a C string.
HxStr operator+ (const HxStr &left, char ch)
 Concatenate a string and one character.
std::ostream & operator<< (std::ostream &stream, const HxStr &text)
 Write a string to a stream.

Variables

const char * g_szEmptyString
 Text an empty HxStr points at, and the substitute for a null buffer.
const unsigned g_nHxStrNoPosition
 Sentinel a search returns when it finds nothing.

Function Documentation

◆ operator+() [1/3]

HxStr operator+ ( const HxStr & left,
const HxStr & right )
inline

Concatenate two strings.

Every call site inlines the body, so the operator has no address of its own. The body is recovered from that emission rather than invented. A concatenation compiles to a copy construction of the left operand into a temporary, the matching operator+=() on the temporary, and a second copy construction of the result into the destination. 0x0017a79c through 0x0017a7b4 in SaveRemixMCT::ListRemixDir() and 0x00179de8 through 0x00179e08 are the two clearest copies, and the first temporary is released immediately afterwards at each one.

Whether the original wrote a free function or a const member cannot be settled, because a member taking one operand and a free function taking two compile the same way once both are inlined. The free form is used here for the same reason the comparison operators use the member form, which is that one of the two has to be chosen.

Parameters
leftThe string the result starts with.
rightThe string appended to it.
Returns
The concatenation.

◆ operator+() [2/3]

HxStr operator+ ( const HxStr & left,
const char * pszRight )
inline

Concatenate a string and a C string.

Recovered on the same evidence as the overload above, from the triple at 0x0017a80c through 0x0017a824 and the one at 0x0038b1d4 through 0x0038b1ec in Rnd::MetScreen::ResolveContainerViews(). The middle call of each triple is the C string operator+=() at 0x0010edb0 rather than the string one at 0x004b7c68, which is what distinguishes this overload from a call site converting its operand first.

Parameters
leftThe string the result starts with.
pszRightThe text appended to it.
Returns
The concatenation.

◆ operator+() [3/3]

HxStr operator+ ( const HxStr & left,
char ch )
inline

Concatenate a string and one character.

Recovered on the same evidence as the overloads above, from the triple at 0x0043a8b4 through 0x0043a8cc in the TnlPointer constructor, whose middle call is the character operator+=() at 0x004b7d28.

Parameters
leftThe string the result starts with.
chThe character appended to it.
Returns
The concatenation.

◆ operator<<()

std::ostream & operator<< ( std::ostream & stream,
const HxStr & text )

Write a string to a stream.

The buffer is passed to the stream without a null check. An empty string therefore arrives at the stream as a null pointer, or in the PAL build as g_szEmptyString.

Parameters
streamThe stream to write to.
textThe string to write.
Returns
The stream.
Ghidra address:
NTSC-U/C: 0x004b8e28
Ghidra address:
PAL: 0x004f6da0

Variable Documentation

◆ g_szEmptyString

const char* g_szEmptyString
extern

Text an empty HxStr points at, and the substitute for a null buffer.

In the North American release a string whose mStr is null is the empty representation, and a caller handing that string to an interface taking a plain pointer substitutes this global rather than passing null. Twenty routines across unrelated subsystems read it through the same idiom. The European release points every empty HxStr at this text instead of storing null, and its asserts call the global kNullStr.

Ghidra address:
NTSC-U/C: 0x006fbd10
Ghidra address:
PAL: 0x0073f788

◆ g_nHxStrNoPosition

const unsigned g_nHxStrNoPosition
extern

Sentinel a search returns when it finds nothing.

The word is all ones and sits one word past the empty string in the same literal pool. Its six readers span unrelated subsystems, including the glyph mesh builder and the PyCXX sequence binding, whose released form returns the standard string's own no-position constant from the member that reads it here.

Ghidra address:
NTSC-U/C: 0x008211bc
Ghidra address:
PAL: 0x00863d2c