LineBuffer< BUFSIZE > Class Template Reference

Class to enable buffering of a single line of text, with simple editing. More...

#include <LineBuffer.h>

Public Member Functions

char addChar (char c)
 Add a character to the buffer. More...
 
void clear ()
 Clear contents of buffer. More...
 
char * getBuffer ()
 Get the text, nul-terminated. More...
 
unsigned getLength () const
 Get number of characters in the text line. More...
 
bool startsWith (const char *text) const
 Check for matching text at start of line, case-sensitive. More...
 
bool contains (const char *text) const
 Check for matching text anywhere in line, case-sensitive. More...
 
bool backspace ()
 Remove last character from buffer. More...
 

Detailed Description

template<uint16_t BUFSIZE>
class LineBuffer< BUFSIZE >

Class to enable buffering of a single line of text, with simple editing.

Note
We define this as a template class for simplicity, no need for separate buffer memory management

Member Function Documentation

◆ addChar()

template<uint16_t BUFSIZE>
char LineBuffer< BUFSIZE >::addChar ( char  c)

Add a character to the buffer.

Return values
charCharacter added to buffer, '\0' if ignored, '
' if line is complete

◆ backspace()

template<uint16_t BUFSIZE>
bool LineBuffer< BUFSIZE >::backspace

Remove last character from buffer.

Return values
booltrue if character was removed, false if buffer is empty

◆ clear()

template<uint16_t BUFSIZE>
void LineBuffer< BUFSIZE >::clear ( )
inline

Clear contents of buffer.

◆ contains()

template<uint16_t BUFSIZE>
bool LineBuffer< BUFSIZE >::contains ( const char *  text) const

Check for matching text anywhere in line, case-sensitive.

Parameters
text
Return values
booltrue if match found

◆ getBuffer()

template<uint16_t BUFSIZE>
char* LineBuffer< BUFSIZE >::getBuffer ( )
inline

Get the text, nul-terminated.

◆ getLength()

template<uint16_t BUFSIZE>
unsigned LineBuffer< BUFSIZE >::getLength ( ) const
inline

Get number of characters in the text line.

◆ startsWith()

template<uint16_t BUFSIZE>
bool LineBuffer< BUFSIZE >::startsWith ( const char *  text) const

Check for matching text at start of line, case-sensitive.

Parameters
text
Return values
booltrue if match found

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