resonance 1.0.1
Loading...
Searching...
No Matches
messageio.h File Reference
#include "msg/message.h"
#include "stream/obstream.h"
Include dependency graph for messageio.h:

Go to the source code of this file.

Functions

OBStream & operator<< (OBStream &stream, Message *pMsg)
 Write a message through a stream, with a flag for the null case.
OBStream & operator<< (OBStream &stream, Message &msg)
 Write a message that is known to exist through the stream, preceded by the byte 1.
IBStream & operator>> (IBStream &stream, Message &msg)
 Read a message's payload back into an existing message.
IBStream & operator>> (IBStream &stream, Message *&pMsg)
 Read a message back through the stream and construct it from the factory list.

Function Documentation

◆ operator<<() [1/2]

OBStream & operator<< ( OBStream & stream,
Message * pMsg )

Write a message through a stream, with a flag for the null case.

Writes the single byte 0 and returns for a null message. Otherwise it writes the byte 1, then the message's identity as four bytes and its payload through the message's own virtuals. The two bytes are the ASCII digits rather than 0 and 1, which the immediates 0x30 and 0x31 fix.

Parameters
streamThe stream to write to.
pMsgThe message, which may be null.
Returns
The stream, allowing calls to be chained.
Ghidra address:
NTSC-U/C: 0x00556508
Ghidra address:
PAL: 0x00596b90

◆ operator<<() [2/2]

OBStream & operator<< ( OBStream & stream,
Message & msg )

Write a message that is known to exist through the stream, preceded by the byte 1.

The identity goes out as two bytes here rather than the four of the pointer form, and Type() is dispatched twice with the first result discarded. The shipped program does not call it.

Parameters
streamThe stream to write to.
msgThe message.
Returns
The stream, allowing calls to be chained.
Ghidra address:
NTSC-U/C: 0x00556448
Ghidra address:
PAL: 0x00596ad0

◆ operator>>() [1/2]

IBStream & operator>> ( IBStream & stream,
Message & msg )

Read a message's payload back into an existing message.

The presence byte and a two-byte identity are read together. A presence byte other than 1 and an identity other than the message's own Type() are each reported through Fatal(). The shipped program does not call it.

Parameters
streamThe stream to read from.
msgThe message to fill.
Returns
The stream, allowing calls to be chained.
Ghidra address:
NTSC-U/C: 0x00555a18
Ghidra address:
PAL: 0x005960a0

◆ operator>>() [2/2]

IBStream & operator>> ( IBStream & stream,
Message *& pMsg )

Read a message back through the stream and construct it from the factory list.

The presence byte 0, and an end of data after it, both produce a null result. Any byte other than 0 or 1 is reported through Fatal() and returns without writing pMsg. An unregistered identity is reported through Fatal() as well.

Parameters
streamThe stream to read from.
pMsgReceives the new message, or null.
Returns
The stream, allowing calls to be chained.
Ghidra address:
NTSC-U/C: 0x00555b10
Ghidra address:
PAL: 0x00596198