Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
IMCStream Class Referenceabstract

Stream interface. More...

#include <stream.h>

Inheritance diagram for IMCStream:
CipherStream MemoryStream NetSocketStream ZLibStream

Public Member Functions

virtual void read (std::byte *buffer, std::size_t offset, std::size_t len)=0
 Reads data from the sub-class.
 
virtual void write (const std::byte *buffer, std::size_t offset, std::size_t len)=0
 Writes data to the sub-class.
 
virtual void flush ()=0
 Flushes the stream.
 
virtual size_t available ()=0
 Gets the number of available bytes.
 
virtual void finishPacketWrite (const std::byte *packetData, size_t len)=0
 Finishes packet write to stream.
 
bool readBoolean ()
 Reads a Boolean.
 
void writeBoolean (bool b)
 Writes a Boolean.
 
std::int8_t readByte ()
 Reads a Byte.
 
void writeByte (std::int8_t b)
 Writes a Byte.
 
std::uint8_t readUnsignedByte ()
 Reads an Unsigned Byte.
 
void writeUnsignedByte (std::uint8_t b)
 Writes an Unsigned Byte.
 
std::int16_t readShort ()
 Reads a Short.
 
void writeShort (std::int16_t s)
 Writes a Short.
 
std::uint16_t readUnsignedShort ()
 Reads an Unsigned Short.
 
void writeUnsignedShort (std::uint16_t s)
 Writes an Unsigned short.
 
std::int32_t readInt ()
 Reads an Integer.
 
void writeInt (std::int32_t i)
 Writes a Integer.
 
std::int64_t readLong ()
 Reads a Long.
 
void writeLong (std::int64_t l)
 Writes a Long.
 
float readFloat ()
 Reads a Float.
 
void writeFloat (float f)
 Writes a Float.
 
double readDouble ()
 Reads a Double.
 
void writeDouble (double d)
 Writes a Double.
 
std::string readString ()
 Reads a String.
 
void writeString (const std::string &s)
 Writes a String.
 
ChatMessage readChat ()
 Reads a Chat Message.
 
void writeChat (const ChatMessage &c)
 Writes a Chat Message.
 
std::int32_t readVarInt ()
 Reads a Variable Integer.
 
void writeVarInt (std::int32_t i)
 Writes a Variable Integer.
 
std::int64_t readVarLong ()
 Reads a Variable Long.
 
void writeVarLong (std::int64_t l)
 Writes a Variable Long.
 
MinecraftUUID readUUID ()
 Reads an MinecraftUUID.
 
void writeUUID (const MinecraftUUID &uuid)
 Writes an MinecraftUUID.
 

Detailed Description

Stream interface.

The interface that all the streams should implement, and it has the necessary functions for IO using the Minecraft protocol.

Member Function Documentation

◆ available()

virtual size_t IMCStream::available ( )
pure virtual

Gets the number of available bytes.

Returns
size_t the number of available bytes

Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.

◆ finishPacketWrite()

virtual void IMCStream::finishPacketWrite ( const std::byte * packetData,
size_t len )
pure virtual

Finishes packet write to stream.

Parameters
packetDatathe packet data (id + data)
lenthe length of the data

Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.

◆ flush()

virtual void IMCStream::flush ( )
pure virtual

Flushes the stream.

Empties the buffer, sending it correctly, resets any offset / data.

Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.

◆ read()

virtual void IMCStream::read ( std::byte * buffer,
std::size_t offset,
std::size_t len )
pure virtual

Reads data from the sub-class.

Standard-compliant way of reading from a stream. Will write len bytes of data at maximum to the buffer starting at offset

Parameters
bufferthe buffer to write to
offsetthe offset to start writing at
lenthe maximum length to write

Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.

◆ readBoolean()

bool IMCStream::readBoolean ( )

Reads a Boolean.

Reads a boolean from the stream in a Minecrafty way.

◆ readByte()

std::int8_t IMCStream::readByte ( )

Reads a Byte.

Reads a byte from the stream in a Minecrafty way.

◆ readChat()

ChatMessage IMCStream::readChat ( )

Reads a Chat Message.

Reads a chat message from the stream in a Minecrafty way.

◆ readDouble()

double IMCStream::readDouble ( )

Reads a Double.

Reads a double from the stream in a Minecrafty way.

◆ readFloat()

float IMCStream::readFloat ( )

Reads a Float.

Reads a float from the stream in a Minecrafty way.

◆ readInt()

std::int32_t IMCStream::readInt ( )

Reads an Integer.

Reads an integer from the stream in a Minecrafty way.

◆ readLong()

std::int64_t IMCStream::readLong ( )

Reads a Long.

Reads a long from the stream in a Minecrafty way.

◆ readShort()

std::int16_t IMCStream::readShort ( )

Reads a Short.

Reads a short from the stream in a Minecrafty way.

◆ readString()

std::string IMCStream::readString ( )

Reads a String.

Reads a string from the stream in a Minecrafty way.

◆ readUnsignedByte()

std::uint8_t IMCStream::readUnsignedByte ( )

Reads an Unsigned Byte.

Reads an unsigned byte from the stream in a Minecrafty way.

◆ readUnsignedShort()

std::uint16_t IMCStream::readUnsignedShort ( )

Reads an Unsigned Short.

Reads an unsigned short from the stream in a Minecrafty way.

◆ readUUID()

MinecraftUUID IMCStream::readUUID ( )

Reads an MinecraftUUID.

Reads 16 bytes from the stream and interprets them as an MinecraftUUID.

Returns
MinecraftUUID the uuid read from the stream

◆ readVarInt()

std::int32_t IMCStream::readVarInt ( )

Reads a Variable Integer.

Reads a variable integer from the stream in a Minecrafty way, following google's standard on Variable Integers.

◆ readVarLong()

std::int64_t IMCStream::readVarLong ( )

Reads a Variable Long.

Reads a variable long from the stream in a Minecrafty way, following google's standard on Variable Longs.

◆ write()

virtual void IMCStream::write ( const std::byte * buffer,
std::size_t offset,
std::size_t len )
pure virtual

Writes data to the sub-class.

Standard-compliant way of writing to a stream. Will read a maximum of len bytes from buffer starting at offset

Parameters
bufferthe buffer to read from
offsetthe offset to start reading from
lenthe maximum read length

Implemented in MemoryStream, NetSocketStream, CipherStream, and ZLibStream.

◆ writeBoolean()

void IMCStream::writeBoolean ( bool b)

Writes a Boolean.

Writes a boolean to the stream in a Minecraft way.

Parameters
bthe boolean to write

◆ writeByte()

void IMCStream::writeByte ( std::int8_t b)

Writes a Byte.

Writes a byte to the stream in a Minecraft way.

Parameters
bthe byte to write

◆ writeChat()

void IMCStream::writeChat ( const ChatMessage & c)

Writes a Chat Message.

Writes a chat message to the stream in a Minecraft way.

Parameters
cthe chat message to write

◆ writeDouble()

void IMCStream::writeDouble ( double d)

Writes a Double.

Writes a double to the stream in a Minecraft way.

Parameters
dthe double to write

◆ writeFloat()

void IMCStream::writeFloat ( float f)

Writes a Float.

Writes a float to the stream in a Minecraft way.

Parameters
fthe float to write

◆ writeInt()

void IMCStream::writeInt ( std::int32_t i)

Writes a Integer.

Writes an integer to the stream in a Minecraft way.

Parameters
ithe integer to write

◆ writeLong()

void IMCStream::writeLong ( std::int64_t l)

Writes a Long.

Writes a long to the stream in a Minecraft way.

Parameters
lthe long to write

◆ writeShort()

void IMCStream::writeShort ( std::int16_t s)

Writes a Short.

Writes a short to the stream in a Minecraft way.

Parameters
sthe short to write

◆ writeString()

void IMCStream::writeString ( const std::string & s)

Writes a String.

Writes a string to the stream in a Minecraft way.

Parameters
sthe string to write

◆ writeUnsignedByte()

void IMCStream::writeUnsignedByte ( std::uint8_t b)

Writes an Unsigned Byte.

Writes an unsigned byte to the stream in a Minecraft way.

Parameters
bthe unsigned byte to write

◆ writeUnsignedShort()

void IMCStream::writeUnsignedShort ( std::uint16_t s)

Writes an Unsigned short.

Writes a unsigned short to the stream in a Minecraft way.

Parameters
sthe unsigned short to write

◆ writeUUID()

void IMCStream::writeUUID ( const MinecraftUUID & uuid)

Writes an MinecraftUUID.

Writes an MinecraftUUID to the stream.

Parameters
uuidthe MinecraftUUID to write

◆ writeVarInt()

void IMCStream::writeVarInt ( std::int32_t i)

Writes a Variable Integer.

Writes a variable integer to the stream in a Minecraft way, following google's standard on Variable Integers.

Parameters
ithe variable integer to write

◆ writeVarLong()

void IMCStream::writeVarLong ( std::int64_t l)

Writes a Variable Long.

Writes a variable long to the stream in a Minecraft way, following google's standard on Variable Longs.

Parameters
lthe variable long to write

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