Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
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

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
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
template<uint16_t BUFSIZE>
void LineBuffer< BUFSIZE >::clear ( )
inline

Clear contents of buffer.

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
template<uint16_t BUFSIZE>
char* LineBuffer< BUFSIZE >::getBuffer ( )
inline

Get the text, nul-terminated.

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

Get number of characters in the text line.

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