Class List > eosio :: datastream

A data stream for reading and writing data in the form of bytes. More...

Public Functions

Type Name
datastream (T start, size_t s)
Construct a new datastream object.
void skip (size_t s)
Skips a specific number of bytes from this stream.
bool read (char * d, size_t s)
Reads a specified number of bytes from this stream into a buffer.
bool write (const char * d, size_t s)
Writes a specified number of bytes into the stream from a buffer.
bool put (char c)
Writes a byte into the stream.
bool get (unsigned char & c)
Reads a byte from the stream.
bool get (char & c)
Reads a byte from the stream.
T pos () const
Retrieves the current position of the stream.
bool valid () const
bool seekp (size_t p)
Sets the position within the current stream.
size_t tellp () const
Gets the position within the current stream.
size_t remaining () const
Returns the number of remaining bytes that can be read/skipped.

Detailed Description

A data stream for reading and writing data in the form of bytes

Template parameters:

  • T - Type of the datastream buffer

Public Functions Documentation

function datastream

eosio::datastream< T >::datastream(
    T start,
    size_t s
)

Construct a new datastream object.

Construct a new datastream object given the size of the buffer and start position of the buffer

Parameters:

  • start - The start position of the buffer
  • s - The size of the buffer

function skip

void eosio::datastream< T >::skip(
    size_t s
)

Skips a specific number of bytes from this stream.

Skips a specified number of bytes from this stream

Parameters:

  • s - The number of bytes to skip

function read

bool eosio::datastream< T >::read(
    char * d,
    size_t s
)

Reads a specified number of bytes from this stream into a buffer.

Reads a specified number of bytes from the stream into a buffer

Parameters:

  • d - The pointer to the destination buffer
  • s - the number of bytes to read

Returns:

true

function write

bool eosio::datastream< T >::write(
    const char * d,
    size_t s
)

Writes a specified number of bytes into the stream from a buffer.

Writes a specified number of bytes into the stream from a buffer

Parameters:

  • d - The pointer to the source buffer
  • s - The number of bytes to write

Returns:

true

function put

bool eosio::datastream< T >::put(
    char c
)

Writes a byte into the stream.

Writes a byte into the stream

Parameters:

  • c byte to write

Returns:

true

function get (1/2)

bool eosio::datastream< T >::get(
    unsigned char & c
)

Reads a byte from the stream.

Reads a byte from the stream

Parameters:

  • c - The reference to destination byte

Returns:

true

function get (2/2)

bool eosio::datastream< T >::get(
    char & c
)

Reads a byte from the stream.

Reads a byte from the stream

Parameters:

  • c - The reference to destination byte

Returns:

true

function pos

T eosio::datastream< T >::pos() const

Retrieves the current position of the stream.

Retrieves the current position of the stream

Returns:

T - The current position of the stream

function valid

bool eosio::datastream< T >::valid() const

function seekp

bool eosio::datastream< T >::seekp(
    size_t p
)

Sets the position within the current stream.

Sets the position within the current stream

Parameters:

  • p - The offset relative to the origin

Returns:

true if p is within the range

Returns:

false if p is not within the rawnge

function tellp

size_t eosio::datastream< T >::tellp() const

Gets the position within the current stream.

Gets the position within the current stream

Returns:

p - The position within the current stream

function remaining

size_t eosio::datastream< T >::remaining() const

Returns the number of remaining bytes that can be read/skipped.

Returns the number of remaining bytes that can be read/skipped

Returns:

size_t - The number of remaining bytes


The documentation for this class was generated from the following file: libraries/eosiolib/datastream.hpp