RNAlib-2.4.14

Functions that provide dynamically buffered stream-like data structures. More...

Detailed Description

Functions that provide dynamically buffered stream-like data structures.

+ Collaboration diagram for Buffers:

Files

file  char_stream.h
 Implementation of a dynamic, buffered character stream.
 
file  stream_output.h
 An implementation of a buffered, ordered stream output data structure.
 

Typedefs

typedef struct vrna_ordered_stream_s * vrna_ostream_t
 An ordered output stream structure with unordered insert capabilities.
 
typedef void( vrna_callback_stream_output) (void *auxdata, unsigned int i, void *data)
 Ordered stream processing callback. More...
 

Functions

vrna_cstr_t vrna_cstr (size_t size, FILE *output)
 Create a dynamic char * stream data structure. More...
 
void vrna_cstr_free (vrna_cstr_t buf)
 Free the memory occupied by a dynamic char * stream data structure. More...
 
void vrna_cstr_close (vrna_cstr_t buf)
 Free the memory occupied by a dynamic char * stream and close the output stream. More...
 
void vrna_cstr_fflush (struct vrna_cstr_s *buf)
 Flush the dynamic char * output stream. More...
 
vrna_ostream_t vrna_ostream_init (vrna_callback_stream_output *output, void *auxdata)
 Get an initialized ordered output stream. More...
 
void vrna_ostream_free (vrna_ostream_t dat)
 Free an initialized ordered output stream. More...
 
void vrna_ostream_request (vrna_ostream_t dat, unsigned int num)
 Request index in ordered output stream. More...
 
void vrna_ostream_provide (vrna_ostream_t dat, unsigned int i, void *data)
 Provide output stream data for a particular index. More...
 

Typedef Documentation

typedef void( vrna_callback_stream_output) (void *auxdata, unsigned int i, void *data)

#include <ViennaRNA/datastructures/stream_output.h>

Ordered stream processing callback.

This callback will be processed in sequential order as soon as sequential data in the output stream becomes available.

Note
The callback must also release the memory occupied by the data passed since the stream will lose any reference to it after the callback has been executed.
Parameters
auxdataA shared pointer for all calls, as provided by the second argument to vrna_ostream_init()
iThe index number of the data passed to data
dataA block of data ready for processing

Function Documentation

vrna_cstr_t vrna_cstr ( size_t  size,
FILE *  output 
)

#include <ViennaRNA/datastructures/char_stream.h>

Create a dynamic char * stream data structure.

See also
vrna_cstr_free(), vrna_cstr_close(), vrna_cstr_fflush(), vrna_cstr_printf()
Parameters
sizeThe initial size of the buffer in characters
outputAn optional output file stream handle that is used to write the collected data to (defaults to stdout if NULL)
void vrna_cstr_free ( vrna_cstr_t  buf)

#include <ViennaRNA/datastructures/char_stream.h>

Free the memory occupied by a dynamic char * stream data structure.

This function first flushes any remaining character data within the stream and then free's the memory occupied by the data structure.

See also
vrna_cstr_close(), vrna_cstr_fflush(), vrna_cstr()
Parameters
bufThe dynamic char * stream data structure to free
void vrna_cstr_close ( vrna_cstr_t  buf)

#include <ViennaRNA/datastructures/char_stream.h>

Free the memory occupied by a dynamic char * stream and close the output stream.

This function first flushes any remaining character data within the stream then closes the attached output file stream (if any), and finally free's the memory occupied by the data structure.

See also
vrna_cstr_free(), vrna_cstr_fflush(), vrna_cstr()
Parameters
bufThe dynamic char * stream data structure to free
void vrna_cstr_fflush ( struct vrna_cstr_s *  buf)

#include <ViennaRNA/datastructures/char_stream.h>

Flush the dynamic char * output stream.

This function flushes the collected char * stream, either by writing to the attached file handle, or simply by writing to stdout if no file handle has been attached upon construction using vrna_cstr().

Postcondition
The stream buffer is empty after execution of this function
See also
vrna_cstr(), vrna_cstr_close(), vrna_cstr_free()
Parameters
bufThe dynamic char * stream data structure to flush
vrna_ostream_t vrna_ostream_init ( vrna_callback_stream_output output,
void *  auxdata 
)

#include <ViennaRNA/datastructures/stream_output.h>

Get an initialized ordered output stream.

See also
vrna_ostream_free(), vrna_ostream_request(), vrna_ostream_provide()
Parameters
outputA callback function that processes and releases data in the stream
auxdataA pointer to auxiliary data passed as first argument to the output callback
Returns
An initialized ordered output stream
void vrna_ostream_free ( vrna_ostream_t  dat)

#include <ViennaRNA/datastructures/stream_output.h>

Free an initialized ordered output stream.

See also
vrna_ostream_init()
Parameters
datThe output stream for which occupied memory should be free'd
void vrna_ostream_request ( vrna_ostream_t  dat,
unsigned int  num 
)

#include <ViennaRNA/datastructures/stream_output.h>

Request index in ordered output stream.

This function must be called prior to vrna_ostream_provide() to indicate that data associted with a certain index number is expected to be inserted into the stream in the future.

See also
vrna_ostream_init(), vrna_ostream_provide(), vrna_ostream_free()
Parameters
datThe output stream for which the index is requested
numThe index to request data for
void vrna_ostream_provide ( vrna_ostream_t  dat,
unsigned int  i,
void *  data 
)

#include <ViennaRNA/datastructures/stream_output.h>

Provide output stream data for a particular index.

Precondition
The index data is provided for must have been requested using vrna_ostream_request() beforehand.
See also
vrna_ostream_request()
Parameters
datThe output stream for which data is provided
iThe index of the provided data
dataThe data provided