AGirs
|
Simple class for parsing stuff from an (input) Stream. More...
#include <StreamParser.h>
Public Member Functions | |
StreamParser (Stream &stream) | |
Constructor. More... | |
virtual | ~StreamParser () |
Destructor. More... | |
IrSignal * | parseIrSignal () |
Reads the stream and parses it into an IrSignal. More... | |
IrSignal * | parsePronto () |
Reads a Pronto Hex format IR signal. More... | |
int32_t | parseAbsInt () |
Reads a number and returns it as 16 bit unsigned. More... | |
int32_t | parseAbsIntDefault (int32_t fallback) |
Reads a number and returns it as 16 bit unsigned. More... | |
const char * | parseWord (char *buf, size_t buflen) |
Returns a word (separated by whitespace). More... | |
const char * | getLine (char *buf, size_t buflen) |
Stream & | getStream () |
void | flushLine () |
microseconds_t * | parseData (microseconds_t *buffer, size_t length) |
Static Public Member Functions | |
static IrSignal * | parse (Stream &stream) |
Convenience function: combines the constructor and parseIrSignal. More... | |
Static Public Attributes | |
static constexpr int | invalid = -1 |
Simple class for parsing stuff from an (input) Stream.
The reads are blocking. To be used instead instead of parseInt() and such, since they do not offer enough flexibility. This is not written to be used outside of the package.
Definition at line 13 of file StreamParser.h.
StreamParser::StreamParser | ( | Stream & | stream | ) |
Constructor.
stream | Stream, assumed already opened. |
Definition at line 5 of file StreamParser.cpp.
|
inlinevirtual |
void StreamParser::flushLine | ( | ) |
Definition at line 178 of file StreamParser.cpp.
const char * StreamParser::getLine | ( | char * | buf, |
size_t | buflen | ||
) |
Definition at line 55 of file StreamParser.cpp.
|
inline |
Definition at line 72 of file StreamParser.h.
|
static |
Convenience function: combines the constructor and parseIrSignal.
Blocking.
stream |
Definition at line 21 of file StreamParser.cpp.
int32_t StreamParser::parseAbsInt | ( | ) |
Reads a number and returns it as 16 bit unsigned.
Blocking. Signs are ignored.
Definition at line 96 of file StreamParser.cpp.
int32_t StreamParser::parseAbsIntDefault | ( | int32_t | fallback | ) |
Reads a number and returns it as 16 bit unsigned.
Blocking. Signs are ignored. If no valid character remains before line end, return the fallback argument.
fallback | Default value |
Definition at line 84 of file StreamParser.cpp.
microseconds_t * StreamParser::parseData | ( | microseconds_t * | buffer, |
size_t | length | ||
) |
Definition at line 200 of file StreamParser.cpp.
IrSignal * StreamParser::parseIrSignal | ( | ) |
Reads the stream and parses it into an IrSignal.
Blocking. Expected format: frequency length_irsequence length_repeat length_ending data... Signs are allowed and ignored.
Definition at line 8 of file StreamParser.cpp.
IrSignal * StreamParser::parsePronto | ( | ) |
Reads a Pronto Hex format IR signal.
stream |
Definition at line 138 of file StreamParser.cpp.
const char * StreamParser::parseWord | ( | char * | buf, |
size_t | buflen | ||
) |
Returns a word (separated by whitespace).
buf | |
buflen |
Definition at line 26 of file StreamParser.cpp.
|
staticconstexpr |
Definition at line 85 of file StreamParser.h.