LineBufferBase Class Reference
Class to enable buffering of a single line of text, with simple editing. More...
#include <LineBuffer.h>
Inheritance diagram for LineBufferBase:
Public Types | |
enum class | Action { none , clear , echo , backspace , submit } |
Returned from processKey method directing caller. More... | |
Public Member Functions | |
LineBufferBase (char *buffer, uint16_t size) | |
Action | process (Stream &input, ReadWriteStream &output) |
Process all available data from input More... | |
Action | processKey (char key, ReadWriteStream *output=nullptr) |
Process a keypress in a consistent manner for console editing. More... | |
char | addChar (char c) |
Add a character to the buffer. More... | |
void | clear () |
Clear contents of buffer. More... | |
operator bool () const | |
operator String () const | |
Copy buffer contents into a String. 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... | |
size_t | printTo (Print &p) const |
Detailed Description
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 Enumeration Documentation
◆ Action
|
strong |
Constructor & Destructor Documentation
◆ LineBufferBase()
|
inline |
Member Function Documentation
◆ addChar()
char LineBufferBase::addChar | ( | char | c | ) |
Add a character to the buffer.
- Return values
-
char Character added to buffer, '\0' if ignored, '
' if line is complete
◆ backspace()
bool LineBufferBase::backspace | ( | ) |
Remove last character from buffer.
- Return values
-
bool true if character was removed, false if buffer is empty
◆ clear()
|
inline |
Clear contents of buffer.
◆ contains()
bool LineBufferBase::contains | ( | const char * | text | ) | const |
Check for matching text anywhere in line, case-sensitive.
- Parameters
-
text
- Return values
-
bool true if match found
◆ getBuffer()
|
inline |
Get the text, nul-terminated.
◆ getLength()
|
inline |
Get number of characters in the text line.
◆ operator bool()
|
inlineexplicit |
◆ operator String()
|
inlineexplicit |
◆ printTo()
|
inline |
◆ process()
Action LineBufferBase::process | ( | Stream & | input, |
ReadWriteStream & | output | ||
) |
Process all available data from input
- Parameters
-
input Source of keystrokes output The output stream (e.g. Serial) for echoing
- Return values
-
Action none, clear or submit
◆ processKey()
Action LineBufferBase::processKey | ( | char | key, |
ReadWriteStream * | output = nullptr |
||
) |
Process a keypress in a consistent manner for console editing.
- Parameters
-
key The keypress value output The output stream (e.g. Serial) for echoing, if required
- Return values
-
Action
◆ startsWith()
bool LineBufferBase::startsWith | ( | const char * | text | ) | const |
Check for matching text at start of line, case-sensitive.
- Parameters
-
text
- Return values
-
bool true if match found
The documentation for this class was generated from the following file: