Important Update:

- Still testing
- Separate Rolling Buffer from PortCore to BufferCore
- Implement BufferCore in PortCore
- Add additional Rolling Buffer functions for future
This commit is contained in:
Charl Wentzel
2016-05-18 15:09:02 +02:00
parent f987ea2224
commit c50766021a
5 changed files with 508 additions and 48 deletions

64
BufferCore.h Normal file
View File

@@ -0,0 +1,64 @@
/*
* BufferCore.h
*
* Created on: 18 May 2016
* Author: wentzelc
*/
#ifndef REDACORE_BUFFERCORE_H_
#define REDACORE_BUFFERCORE_H_
// redA Libraries
/* none */
// Standard C/C++ Libraries
/* none */
//---------------------------------------------------------------------------
class CBuffer
{
private:
// Buffer Definition
char * Buffer; // Memory allocated to buffer
int BufSize; // Size of allocated buffer
// Buffer pointers
int BufStart; // First unread characters on buffer
int BufEnd; // Next write position for new data (End of unread data + 1)
int BufLen; // Total unread characters on buffer
// Temporary output buffer
char * OutBuffer; // Temporary output buffer for "stitched" (rollover) data
public:
// Life Cycle
CBuffer( int BufferSize );
~CBuffer();
// Direct Operations
int Reset();
int Set( char * Data, int Len );
int Get( char ** Data, int MaxLen = -1 );
int Clear( int ClearLen );
// FiFo operations
int Push( char * Data, int Len );
int Pop( char ** Data, int MaxLen = -1 );
// File operations
int ReadFD( int Handle, int MaxRead = -1 );
int WriteFD( int Handle, int MaxWrite = -1 );
// Character Operations
char GetChar( int Pos );
bool FindChar( char SearchChar, int &Pos );
// Miscellaneous
int Size() { return BufSize; };
int Len() { return BufLen; };
};
//---------------------------------------------------------------------------
#endif /* REDACORE_BUFFERCORE_H_ */