v0.1.0
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
Data Fields
gmio_stream Struct Reference

Stream that can get input from an arbitrary data source or can write output to an arbitrary data sink. More...

Data Fields

void * cookie
 Opaque pointer on the user stream, passed as first argument to hook functions. More...
 
bool(* func_at_end )(void *cookie)
 Pointer on a function that checks end-of-stream indicator. More...
 
int(* func_error )(void *cookie)
 Pointer on a function that checks error indicator. More...
 
size_t(* func_read )(void *cookie, void *ptr, size_t size, size_t count)
 Pointer on a function that reads block of data from stream. More...
 
size_t(* func_write )(void *cookie, const void *ptr, size_t size, size_t count)
 Pointer on a function that writes block of data to stream. More...
 
gmio_streamsize_t(* func_size )(void *cookie)
 Pointer on a function that returns the size(in bytes) of the stream. More...
 
int(* func_get_pos )(void *cookie, struct gmio_streampos *pos)
 Pointer on a function that retrieves the current position in the stream. More...
 
int(* func_set_pos )(void *cookie, const struct gmio_streampos *pos)
 Pointer on a function that restores the current position in the stream to pos. More...
 

Detailed Description

Stream that can get input from an arbitrary data source or can write output to an arbitrary data sink.

It can be seen as generalization of the standard FILE*, and is pretty much the same as custom streams in the GNU C Library

It uses a cookie being basically an opaque pointer on a hidden data type.

The custom stream is implemented by defining hook functions that know how to read/write the data.

Examples:
/examples/stl_get_infos.c.

Field Documentation

void* gmio_stream::cookie

Opaque pointer on the user stream, passed as first argument to hook functions.

bool(* gmio_stream::func_at_end)(void *cookie)

Pointer on a function that checks end-of-stream indicator.

Checks whether the end-of-stream indicator associated with stream pointed by cookie is set, returning true if is.

The function should behaves like C standard feof()

int(* gmio_stream::func_error)(void *cookie)

Pointer on a function that checks error indicator.

Checks if the error indicator associated with stream pointed by cookie is set, returning a value different from zero if it is.

The function should behaves like C standard ferror()

int(* gmio_stream::func_get_pos)(void *cookie, struct gmio_streampos *pos)

Pointer on a function that retrieves the current position in the stream.

Return values
0on success
!=0on error
size_t(* gmio_stream::func_read)(void *cookie, void *ptr, size_t size, size_t count)

Pointer on a function that reads block of data from stream.

Reads an array of count elements, each one with a size of size bytes, from the stream pointed by cookie and stores them in the block of memory specified by ptr

The function should behaves like C standard fread()

Returns
The total number of elements successfully read
int(* gmio_stream::func_set_pos)(void *cookie, const struct gmio_streampos *pos)

Pointer on a function that restores the current position in the stream to pos.

Return values
0on success
!=0on error
gmio_streamsize_t(* gmio_stream::func_size)(void *cookie)

Pointer on a function that returns the size(in bytes) of the stream.

size_t(* gmio_stream::func_write)(void *cookie, const void *ptr, size_t size, size_t count)

Pointer on a function that writes block of data to stream.

Writes an array of count elements, each one with a size of size bytes, from the block of memory pointed by ptr to the current position in the stream pointed by cookie

The function should behaves like C standard fwrite()

Returns
The total number of elements successfully written

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