uBlink  0.0.1
TheBlinkProtocol
blink_stream

Description

Configurable IO streams.

Functions

bool BLINK_Stream_write (blink_stream_t self, const void *buf, size_t nbyte)
 Write to a stream. More...
 
bool BLINK_Stream_read (blink_stream_t self, void *buf, size_t nbyte)
 Read from a stream. More...
 
bool BLINK_Stream_peek (blink_stream_t self, void *buf)
 Read next byte in stream without removing it. More...
 
blink_stream_t BLINK_Stream_initBufferReadOnly (struct blink_stream *self, const void *buf, uint32_t max)
 Init a read only buffer stream. More...
 
blink_stream_t BLINK_Stream_initBuffer (struct blink_stream *self, void *buf, uint32_t max)
 Init a read/write buffer stream. More...
 
blink_stream_t BLINK_Stream_initUser (struct blink_stream *self, void *state, struct blink_stream_user fn)
 Init a user defined stream. More...
 
blink_stream_t BLINK_Stream_initBounded (struct blink_stream *self, blink_stream_t stream, uint32_t max)
 Init a bounded stream. More...
 
uint32_t BLINK_Stream_tell (blink_stream_t self)
 Get current position. More...
 
bool BLINK_Stream_seekSet (blink_stream_t self, uint32_t offset)
 Set position to offset. More...
 
bool BLINK_Stream_seekCur (blink_stream_t self, int32_t offset)
 Add offset to current position. More...
 
bool BLINK_Stream_eof (blink_stream_t self)
 Check if stream has reached EOF. More...
 
size_t BLINK_Stream_max (blink_stream_t self)
 Return the maximum position of the stream. More...
 

Data Structures

struct  blink_stream_user
 

Typedefs

typedef struct blink_streamblink_stream_t
 

Data Structure Documentation

Function Documentation

bool BLINK_Stream_eof ( blink_stream_t  self)

Check if stream has reached EOF.

Parameters
[in]self
Returns
true if at EOF
blink_stream_t BLINK_Stream_initBounded ( struct blink_stream self,
blink_stream_t  stream,
uint32_t  max 
)

Init a bounded stream.

Parameters
[in]self
[in]streamstream to bound
[in]maxstream is allowed to read/seek within range (cur .. cur + max) bytes
Returns
stream
blink_stream_t BLINK_Stream_initBuffer ( struct blink_stream self,
void *  buf,
uint32_t  max 
)

Init a read/write buffer stream.

Parameters
[in]self
[in]bufbuffer
[in]maxlength of buffer
Returns
stream
Examples:
tc_blink_compact_encode.c, and tc_blink_stream_write.c.
blink_stream_t BLINK_Stream_initBufferReadOnly ( struct blink_stream self,
const void *  buf,
uint32_t  max 
)

Init a read only buffer stream.

Parameters
[in]self
[in]bufbuffer
[in]maxlength of buffer
Returns
stream
Examples:
tc_blink_compact_decode.c, tc_blink_group_iskindof.c, tc_blink_lexer_gettoken.c, tc_blink_schema_getgroupbyid.c, tc_blink_schema_getgroupbyname.c, tc_blink_schema_new.c, and tc_blink_stream_read.c.
blink_stream_t BLINK_Stream_initUser ( struct blink_stream self,
void *  state,
struct blink_stream_user  fn 
)

Init a user defined stream.

Parameters
[in]self
[in]useruser state
[in]fnuser defined functions
Returns
stream
size_t BLINK_Stream_max ( blink_stream_t  self)

Return the maximum position of the stream.

Parameters
[in]self
Returns
maximum byte position
Return values
0stream doesn't have a maximum
bool BLINK_Stream_peek ( blink_stream_t  self,
void *  buf 
)

Read next byte in stream without removing it.

Parameters
[in]selfinput stream
[out]bufsingle byte buffer
Returns
true if successful
bool BLINK_Stream_read ( blink_stream_t  self,
void *  buf,
size_t  nbyte 
)

Read from a stream.

Parameters
[in]selfstream
[out]bufbuffer of at least nbyte bytes
[in]nbytenumber of bytes to read
Returns
true if successful
Examples:
tc_blink_stream_read.c.
bool BLINK_Stream_seekCur ( blink_stream_t  self,
int32_t  offset 
)

Add offset to current position.

i.e. seek relative to current stream position

Parameters
[in]self
[in]offsetbyte offset to add to current position
Returns
true if position could be modified by offset
bool BLINK_Stream_seekSet ( blink_stream_t  self,
uint32_t  offset 
)

Set position to offset.

i.e. seek relative to start of stream

Parameters
[in]self
[in]offsetbyte offset from origin
Returns
true if position could be set to offset
uint32_t BLINK_Stream_tell ( blink_stream_t  self)

Get current position.

Parameters
[in]self
Returns
stream position from origin
bool BLINK_Stream_write ( blink_stream_t  self,
const void *  buf,
size_t  nbyte 
)

Write to a stream.

Parameters
[in]selfstream
[in]bufbuffer to write
[in]nbytenumber of bytes to write
Returns
true if successful
Examples:
tc_blink_stream_write.c.