| e8555c89 Andy McCall |
1 |
#ifndef ADHOCCLICOMMPARSER_HH |
| 2 |
#define ADHOCCLICOMMPARSER_HH |
| 3 |
|
| 4 |
#include <cstdint> |
| 5 |
#include <functional> |
| 6 |
#include <span> |
| 7 |
#include <string> |
| 8 |
|
| 9 |
class AdhocCliCommParser |
| 10 |
{ |
| 11 |
public: |
| 12 |
explicit AdhocCliCommParser(std::function<void(const std::string&)> callback); |
| 13 |
void parse(std::span<const char> buf); |
| 14 |
|
| 15 |
private: |
| 16 |
void parse(char c); |
| 17 |
|
| 18 |
std::function<void(const std::string&)> callback; |
| 19 |
std::string command; |
| 20 |
uint32_t unicode; |
| 21 |
enum State : uint8_t { |
| 22 |
O0, |
| 23 |
O1, |
| 24 |
O2, |
| 25 |
O3, |
| 26 |
O4, |
| 27 |
O5, |
| 28 |
O6, |
| 29 |
O7, |
| 30 |
O8, |
| 31 |
C0, |
| 32 |
C1, |
| 33 |
C2, |
| 34 |
C3, |
| 35 |
C4, |
| 36 |
C5, |
| 37 |
C6, |
| 38 |
C7, |
| 39 |
C8, |
| 40 |
C9, |
| 41 |
A1, |
| 42 |
A2, |
| 43 |
A3, |
| 44 |
A4, |
| 45 |
P3, |
| 46 |
P4, |
| 47 |
P5, |
| 48 |
Q2, |
| 49 |
Q3, |
| 50 |
Q4, |
| 51 |
Q5, |
| 52 |
G2, |
| 53 |
G3, |
| 54 |
L2, |
| 55 |
L3, |
| 56 |
H2, |
| 57 |
H3, |
| 58 |
} state = O0; |
| 59 |
}; |
| 60 |
|
| 61 |
#endif |