All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
as_stream Struct Reference

Detailed Description

Stream Interface

To use the stream interface, you will need to create an instance via one of the implementations.

Definition at line 56 of file as_stream.h.

#include "as_stream.h"

+ Collaboration diagram for as_stream:

Data Fields

void * data
 
bool free
 
const struct as_stream_hooks_s * hooks
 

Related Symbols

(Note that these are not member symbols.)

static void as_stream_destroy (as_stream *stream)
 
static as_streamas_stream_init (as_stream *stream, void *data, const as_stream_hooks *hooks)
 
static as_streamas_stream_new (void *data, const as_stream_hooks *hooks)
 
static as_valas_stream_read (const as_stream *stream)
 
static bool as_stream_readable (const as_stream *stream)
 
static void * as_stream_source (const as_stream *stream)
 
static bool as_stream_writable (const as_stream *stream)
 
static as_stream_status as_stream_write (const as_stream *stream, as_val *value)
 

Friends And Related Symbol Documentation

◆ as_stream_destroy()

static void as_stream_destroy ( as_stream * stream)
related

Destroy the as_stream and associated resources.

Parameters
streamThe stream to destroy.

Definition at line 160 of file as_stream.h.

References as_stream_free(), as_util_hook, and free.

◆ as_stream_init()

static as_stream * as_stream_init ( as_stream * stream,
void * data,
const as_stream_hooks * hooks )
related

Initializes a stack allocated as_stream for a given source and hooks.

Parameters
streamThe stream to initialize.
dataThe source feeding the stream
hooksThe hooks that interface with the source
Returns
On success, the initialized stream. Otherwise NULL.

Definition at line 122 of file as_stream.h.

References data, data, free, and hooks.

◆ as_stream_new()

static as_stream * as_stream_new ( void * data,
const as_stream_hooks * hooks )
related

Creates a new heap allocated as_stream for a given source and hooks.

Parameters
dataThe source feeding the stream
hooksThe hooks that interface with the source
Returns
On success, a new stream. Otherwise NULL.

Definition at line 142 of file as_stream.h.

References as_stream_malloc(), data, data, free, and hooks.

◆ as_stream_read()

static as_val * as_stream_read ( const as_stream * stream)
related

Reads a value from the stream

Parameters
streamThe stream to be read.
Returns
the element read from the stream or STREAM_END

Definition at line 195 of file as_stream.h.

References as_util_hook.

◆ as_stream_readable()

static bool as_stream_readable ( const as_stream * stream)
related

Is the stream readable? Tests whether the stream has a read function.

Parameters
streamThe stream to test.
Returns
true if the stream can be read from

Definition at line 209 of file as_stream.h.

References hooks.

◆ as_stream_source()

static void * as_stream_source ( const as_stream * stream)
related

Get the source for the stream

Parameters
streamThe stream to get the source from
Returns
pointer to the source of the stream

Definition at line 181 of file as_stream.h.

References data.

◆ as_stream_writable()

static bool as_stream_writable ( const as_stream * stream)
related

Is the stream writable? Tests whether the stream has a write function.

Parameters
streamThe stream to test.
Returns
true if the stream can be written to.

Definition at line 239 of file as_stream.h.

References hooks.

◆ as_stream_write()

static as_stream_status as_stream_write ( const as_stream * stream,
as_val * value )
related

Write a value to the stream

Parameters
streamThe stream to write to.
valueThe element to write to the stream.
Returns
AS_STREAM_OK on success, otherwise is failure.

Definition at line 224 of file as_stream.h.

References AS_STREAM_ERR, and as_util_hook.

Field Documentation

◆ data

void* as_stream::data

Context data for the stream.

Definition at line 67 of file as_stream.h.

◆ free

bool as_stream::free

Specifies whether the cf_free() can be used on this stream.

Definition at line 62 of file as_stream.h.

◆ hooks

const struct as_stream_hooks_s* as_stream::hooks

Hooks for the stream

Definition at line 72 of file as_stream.h.


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