semf
tabulator.h
Go to the documentation of this file.
1
10#ifndef SEMF_COMMUNICATION_ESH_TABULATOR_H_
11#define SEMF_COMMUNICATION_ESH_TABULATOR_H_
12
18#include <array>
19#include <cstdlib>
20#include <string_view>
21
22namespace semf::esh
23{
28{
29public:
33 enum class ErrorCode : uint8_t
34 {
35 Start_IsBusy = 0,
36 };
45 Tabulator(Printer& printer, const LinkedList<Command>& commands, char lineBuffer[], size_t lineBufferSize, std::string_view prompt);
46 Tabulator(const Tabulator& other) = delete;
47 virtual ~Tabulator() = default;
53 void start(size_t charCount);
58 bool isBusy() const;
60 SEMF_SIGNAL(done, size_t);
63
64private:
71 bool prefixMatch(std::string_view sub, std::string_view str) const;
73 void searchMatches();
75 void printCommandName();
77 void continueSearch();
79 void updatePrompt();
81 void printCommand();
83 void onDone();
85 Printer& m_printer;
87 const LinkedList<Command>& m_commands;
89 char* const m_lineBuffer;
91 const size_t m_lineBufferSize;
93 const std::string_view kPrompt;
99 bool m_busy = false;
101 size_t m_charCount = 0;
103 uint32_t m_matchCount = 0;
105 SEMF_SLOT(m_printCommandNameSlot, Tabulator, *this, printCommandName);
107 SEMF_SLOT(m_continueSearchSlot, Tabulator, *this, continueSearch);
109 SEMF_SLOT(m_updatePromptSlot, Tabulator, *this, updatePrompt);
111 SEMF_SLOT(m_printCommandSlot, Tabulator, *this, printCommand);
113 SEMF_SLOT(m_onDoneSlot, Tabulator, *this, onDone);
115 static constexpr Error::ClassID kSemfClassId = Error::ClassID::Tabulator;
116};
117} // namespace semf::esh
118#endif // SEMF_COMMUNICATION_ESH_TABULATOR_H_
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
Definition: error.h:22
ClassID
Semf class IDs.
Definition: error.h:28
Implementation of a bidirectional constant iterator for LinkedList.
Definition: linkedlist.h:231
LinkedList is an managed double linked list implementation.
Definition: linkedlist.h:43
Class for string related UART communication. Using this class outside of an esh-context can make sens...
Definition: printer.h:25
Handles the command auto completion.
Definition: tabulator.h:28
virtual ~Tabulator()=default
Tabulator(const Tabulator &other)=delete
void start(size_t charCount)
Starts the auto completion.
Definition: tabulator.cpp:24
bool isBusy() const
Returns the busy-flag.
Definition: tabulator.cpp:39
ErrorCode
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring...
Definition: tabulator.h:34
Tabulator(Printer &printer, const LinkedList< Command > &commands, char lineBuffer[], size_t lineBufferSize, std::string_view prompt)
Constructor.
Definition: tabulator.cpp:15
SEMF_SIGNAL(error, Error)
SEMF_SIGNAL(done, size_t)