AGirs
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
StreamParser Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ StreamParser()

StreamParser::StreamParser ( Stream &  stream)

Constructor.

Parameters
streamStream, assumed already opened.

Definition at line 5 of file StreamParser.cpp.

◆ ~StreamParser()

virtual StreamParser::~StreamParser ( )
inlinevirtual

Destructor.

Does not close or destroy the stream.

Definition at line 31 of file StreamParser.h.

Member Function Documentation

◆ flushLine()

void StreamParser::flushLine ( )

Definition at line 178 of file StreamParser.cpp.

◆ getLine()

const char * StreamParser::getLine ( char *  buf,
size_t  buflen 
)

Definition at line 55 of file StreamParser.cpp.

◆ getStream()

Stream& StreamParser::getStream ( )
inline

Definition at line 72 of file StreamParser.h.

◆ parse()

IrSignal * StreamParser::parse ( Stream &  stream)
static

Convenience function: combines the constructor and parseIrSignal.

Blocking.

Parameters
stream
Returns

Definition at line 21 of file StreamParser.cpp.

◆ parseAbsInt()

int32_t StreamParser::parseAbsInt ( )

Reads a number and returns it as 16 bit unsigned.

Blocking. Signs are ignored.

Returns
int16_t

Definition at line 96 of file StreamParser.cpp.

◆ parseAbsIntDefault()

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.

Parameters
fallbackDefault value
Returns
int16_t

Definition at line 84 of file StreamParser.cpp.

◆ parseData()

microseconds_t * StreamParser::parseData ( microseconds_t *  buffer,
size_t  length 
)

Definition at line 200 of file StreamParser.cpp.

◆ parseIrSignal()

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.

Returns
pointer to IrSignal

Definition at line 8 of file StreamParser.cpp.

◆ parsePronto()

IrSignal * StreamParser::parsePronto ( )

Reads a Pronto Hex format IR signal.

Parameters
stream
Returns

Definition at line 138 of file StreamParser.cpp.

◆ parseWord()

const char * StreamParser::parseWord ( char *  buf,
size_t  buflen 
)

Returns a word (separated by whitespace).

Parameters
buf
buflen
Returns
Parsed word

Definition at line 26 of file StreamParser.cpp.

Member Data Documentation

◆ invalid

constexpr int StreamParser::invalid = -1
staticconstexpr

Definition at line 85 of file StreamParser.h.


The documentation for this class was generated from the following files: