chore: remove unused files

This commit is contained in:
Ben Allfree
2025-11-07 01:25:19 -08:00
parent cc632676de
commit b08087a175
2 changed files with 0 additions and 199 deletions

View File

@@ -1,129 +0,0 @@
#include "CommandParser.h"
#include <cctype>
#include <cstdint>
CommandParser::CommandParser(const uint8_t *buffer, size_t size)
: payload(buffer), payloadSize(size), position(0), argsStartPos(0)
{
// Skip the '/' if present and find where arguments start
if (isCommand() && payloadSize > 1) {
// Find the first space after the command name
size_t pos = 1; // Start after '/'
while (pos < payloadSize && payload[pos] != ' ' && payload[pos] != '\0') {
pos++;
}
// Skip the space
while (pos < payloadSize && payload[pos] == ' ') {
pos++;
}
argsStartPos = pos;
position = pos;
}
}
bool CommandParser::isCommand() const
{
return payloadSize > 0 && payload[0] == '/';
}
bool CommandParser::commandName(char *buffer, size_t bufferSize) const
{
if (!isCommand() || bufferSize == 0) {
return false;
}
// Start after '/'
size_t srcPos = 1;
size_t dstPos = 0;
// Copy until space, null terminator, or end of payload
while (srcPos < payloadSize && dstPos < bufferSize - 1) {
char c = payload[srcPos];
if (c == ' ' || c == '\0') {
break;
}
buffer[dstPos++] = c;
srcPos++;
}
buffer[dstPos] = '\0';
return dstPos > 0;
}
bool CommandParser::nextWord(char *buffer, size_t bufferSize)
{
if (bufferSize == 0 || position >= payloadSize) {
return false;
}
// Skip leading spaces
while (position < payloadSize && payload[position] == ' ') {
position++;
}
if (position >= payloadSize) {
return false;
}
// Copy the word
size_t dstPos = 0;
while (position < payloadSize && dstPos < bufferSize - 1) {
char c = payload[position];
if (c == ' ' || c == '\0') {
break;
}
buffer[dstPos++] = c;
position++;
}
buffer[dstPos] = '\0';
return dstPos > 0;
}
bool CommandParser::rest(char *buffer, size_t bufferSize) const
{
if (bufferSize == 0 || position >= payloadSize) {
buffer[0] = '\0';
return false;
}
// Skip leading spaces
size_t srcPos = position;
while (srcPos < payloadSize && payload[srcPos] == ' ') {
srcPos++;
}
if (srcPos >= payloadSize) {
buffer[0] = '\0';
return false;
}
// Copy the rest
size_t dstPos = 0;
while (srcPos < payloadSize && dstPos < bufferSize - 1) {
char c = payload[srcPos];
if (c == '\0') {
break;
}
buffer[dstPos++] = c;
srcPos++;
}
buffer[dstPos] = '\0';
return dstPos > 0;
}
void CommandParser::reset()
{
position = argsStartPos;
}
bool CommandParser::hasMore() const
{
// Check if there's non-space content remaining
size_t pos = position;
while (pos < payloadSize && payload[pos] == ' ') {
pos++;
}
return pos < payloadSize && payload[pos] != '\0';
}

View File

@@ -1,70 +0,0 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstring>
/**
* CommandParser - Parse text commands from mesh packets
*
* Commands start with '/' followed by command name, then optional arguments.
* Example: "/hi alice mypassword"
*/
class CommandParser
{
public:
/**
* Initialize parser with a payload buffer
* @param buffer Pointer to the payload bytes
* @param size Size of the payload
*/
CommandParser(const uint8_t *buffer, size_t size);
/**
* Check if this is a command (starts with '/')
* @return true if payload starts with '/'
*/
bool isCommand() const;
/**
* Get the command name (everything after '/' until first space or end)
* @param buffer Buffer to store command name (null-terminated)
* @param bufferSize Size of the buffer
* @return true if command name extracted successfully
*/
bool commandName(char *buffer, size_t bufferSize) const;
/**
* Get the next word from the current position
* Advances internal position pointer
* @param buffer Buffer to store the word (null-terminated)
* @param bufferSize Size of the buffer
* @return true if word extracted successfully, false if no more words
*/
bool nextWord(char *buffer, size_t bufferSize);
/**
* Get the rest of the string from current position
* @param buffer Buffer to store the rest (null-terminated)
* @param bufferSize Size of the buffer
* @return true if there's content remaining
*/
bool rest(char *buffer, size_t bufferSize) const;
/**
* Reset the parser position to start of arguments (after command name)
*/
void reset();
/**
* Check if there are more arguments to parse
* @return true if more content available
*/
bool hasMore() const;
private:
const uint8_t *payload;
size_t payloadSize;
size_t position; // Current parsing position
size_t argsStartPos; // Position where arguments start (after command name)
};