GATE
gate_memstream_t Interface Reference

A stream to read and write from in-memory data. More...

#include <streams.h>

Inheritance diagram for gate_memstream_t:
gate_stream_t gate_object_t

Public Member Functions

char const * get_data ()
 Returns a pointer to the begin of the readable memory block.
 
gate_size_t size ()
 Returns the total size of readable bytes.
 
gate_result_t reserve (gate_size_t space)
 Ensures that the given amount of space is preallocated at the end of the internal buffer.
 
gate_result_t fill (char fillitem, gate_size_t fillsize)
 Adds a field of characters at the write-end of the internal buffer.
 
gate_size_t discard (gate_size_t bytestodiscard)
 Removes the given amount of bytes from the read buffer at the beginning.
 
gate_size_t discard_back (gate_size_t bytestodiscard)
 Removes the given amount of bytes at the end of the internal buffer (removes previously written bytes)
 
gate_result_t reset ()
 Clears the readable area from the stream, discards all bytes.
 
- Public Member Functions inherited from gate_stream_t
gate_result_t read (char *buffer, gate_size_t bufferlength, gate_size_t *returned)
 Read bytes from stream and stores them in the given buffer.
 
gate_result_t peek (char *buffer, gate_size_t bufferlength, gate_size_t *returned)
 Tries to read bytes from the stream, but leaves them in its input buffer to be read again.
 
gate_result_t write (char const *buffer, gate_size_t bufferlength, gate_size_t *written)
 Writes bytes from the given buffer into the stream.
 
gate_result_t flush ()
 Instructs the stream to flush its internal buffers and make current status persistent.
 
- Public Member Functions inherited from gate_object_t
char const * get_interface_name ()
 Returns on object's interface path name.
 
void release ()
 Decrease object's reference counter, releases the object when count reaches zero.
 
int retain ()
 Increase object's reference counter.
 

Detailed Description

A stream to read and write from in-memory data.

gate_stream_t::write() appends data to the internal memory buffer at the end gate_stream_t::read() extracts data from the internal memory buffer from the beginning gate_memstream_t is a FIFO buffer. Data appended by write() are retrieved with read()

Member Function Documentation

◆ discard()

gate_size_t discard ( gate_size_t bytestodiscard)

Removes the given amount of bytes from the read buffer at the beginning.

Parameters
[in]bytestodiscardAmount of bytes to discard
Returns
real amount of bytes that were discarded

◆ discard_back()

gate_size_t discard_back ( gate_size_t bytestodiscard)

Removes the given amount of bytes at the end of the internal buffer (removes previously written bytes)

Parameters
[in]bytestodiscardAmount of bytes to discard
Returns
real amount of bytes that were discarded

◆ fill()

gate_result_t fill ( char fillitem,
gate_size_t fillsize )

Adds a field of characters at the write-end of the internal buffer.

Parameters
[in]fillitemCharacter to be used repeated to fill the buffer
[in]fillsizeAmount of characters to fill the write buffer at the end
Returns
GATE_RESULT_* result code

◆ get_data()

char const * get_data ( )

Returns a pointer to the begin of the readable memory block.

Returns
Pointer to current data in internal buffer

◆ reserve()

gate_result_t reserve ( gate_size_t space)

Ensures that the given amount of space is preallocated at the end of the internal buffer.

Parameters
[in]spaceAmount of bytes to be reserved (preallocated) of writing
Returns
GATE_RESULT_* result code

◆ reset()

gate_result_t reset ( )

Clears the readable area from the stream, discards all bytes.

Returns
GATE_RESULT_* result code

◆ size()

gate_size_t size ( )

Returns the total size of readable bytes.

Returns
Amount of bytes currently in accessible read buffer

The documentation for this interface was generated from the following file: