Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
cmd_parser.h
Go to the documentation of this file.
1
4#pragma once
5
6#include <array>
7#include <cstddef>
8#include <cstdint>
9
11
12namespace lampda {
13namespace common {
14namespace cli {
15
17{
18 static constexpr uint8_t maxArgumentCount = 8;
19
20 bsp::text_in::Inputs::Command buffer {};
21
22 uint8_t commandOffset = 0;
23 std::array<uint8_t, maxArgumentCount> argumentOffsets {};
24 uint8_t argumentCount = 0;
25
27 const char* name() const;
28
30 const char* argument(const size_t index) const;
31
34};
35
37namespace argument {
38
40bool parse_uint8(const ParsedCommand& command, const size_t index, uint8_t& value);
41
43bool parse_uint16(const ParsedCommand& command, const size_t index, uint16_t& value);
44
45} // namespace argument
46
50ParsedCommand parseCommand(const bsp::text_in::Inputs::Command& input);
51
52} // namespace cli
53} // namespace common
54} // namespace lampda
bool parse_uint8(const ParsedCommand &command, const size_t index, uint8_t &value)
Parse an argument as a 8 bit unsigned number.
Definition: cmd_parser.cpp:60
bool parse_uint16(const ParsedCommand &command, const size_t index, uint16_t &value)
Parse an argument as a 16 bit unsigned number.
Definition: cmd_parser.cpp:74
Program scope.
Definition: control_fixed_modes.hpp:12
Definition: cmd_parser.h:17
const char * argument(const size_t index) const
Return the argument at the desired index, or nullptr if it do not exist.
Definition: cmd_parser.cpp:15
const char * name() const
Return the name of the command.
Definition: cmd_parser.cpp:13
ParsedCommand shift_to_first_parameter() const
Create a new command shifted by one argument.
Definition: cmd_parser.cpp:23
Handle user text inputs.