MHVLib  20111011
An efficiency oriented runtime library for AVR microcontrollers
MHV_RingBuffer Class Reference

#include <MHV_RingBuffer.h>

List of all members.

Public Member Functions

 MHV_RingBuffer (char *buffer, uint8_t length)
bool append (char c)
bool append (const void *p, uint8_t pLength)
uint8_t length ()
uint8_t size ()
bool full ()
bool full (uint8_t blockLength)
void flush ()
int peekHead ()
int consume ()
bool consume (void *p, uint8_t length)
void copyLine (char *, uint8_t length)

Detailed Description

Definition at line 35 of file MHV_RingBuffer.h.


Constructor & Destructor Documentation

MHV_RingBuffer::MHV_RingBuffer ( char *  buffer,
uint8_t  size 
)

Create a new ringbuffer

Parameters:
buffermemory to use for the ringbuffer
sizethe size of the available memory

Definition at line 36 of file MHV_RingBuffer.cpp.


Member Function Documentation

bool MHV_RingBuffer::append ( char  c)

Append a character to the buffer

Returns:
false if we succeeded, true otherwise

Definition at line 61 of file MHV_RingBuffer.cpp.

bool MHV_RingBuffer::append ( const void *  p,
uint8_t  pLength 
)

Append a block of data to the buffer

Parameters:
pthe pointer to append from
pLengththe number of bytes to append
Returns:
false if we succeeded, true otherwise

Definition at line 81 of file MHV_RingBuffer.cpp.

int MHV_RingBuffer::consume ( )

Pop a byte off the ringbuffer

Definition at line 99 of file MHV_RingBuffer.cpp.

bool MHV_RingBuffer::consume ( void *  p,
uint8_t  pLength 
)

Pop a block off the ringbuffer

Parameters:
pwhere to write the block
pLengththe length of the block
Returns:
false if we succeeded, true otherwise

Definition at line 115 of file MHV_RingBuffer.cpp.

void MHV_RingBuffer::copyLine ( char *  ,
uint8_t  length 
)
void MHV_RingBuffer::flush ( )

Discard the contents of the ringbuffer

Definition at line 134 of file MHV_RingBuffer.cpp.

bool MHV_RingBuffer::full ( )

Check if the ringbuffer is full

Returns:
true if the ringbuffer is full

Definition at line 164 of file MHV_RingBuffer.cpp.

bool MHV_RingBuffer::full ( uint8_t  blockLength)

Check if an object can fit in the ringbuffer

Parameters:
blockLengththe length of the object to fit in
Returns:
true if the ringbuffer is full

Definition at line 173 of file MHV_RingBuffer.cpp.

uint8_t MHV_RingBuffer::length ( )

Get the length of the contents of the ringbuffer Return the number of bytes in the ringbuffer

Definition at line 150 of file MHV_RingBuffer.cpp.

int MHV_RingBuffer::peekHead ( )

Check the first character in the buffer

Returns:
the character, or -1 if the buffer is empty

Definition at line 182 of file MHV_RingBuffer.cpp.

uint8_t MHV_RingBuffer::size ( )

Get the size of the ringbuffer

Returns:
the size of the ringbuffer

Definition at line 142 of file MHV_RingBuffer.cpp.


The documentation for this class was generated from the following files: