AGirs
StreamParser.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "IrSignal.h"
12 
13 class StreamParser {
14 public:
19  StreamParser(Stream &stream);
20 #ifndef DOXYGEN
21  StreamParser() = delete;
22  StreamParser(const StreamParser&) = delete;
23  StreamParser(StreamParser&&) = delete;
24  StreamParser& operator=(const StreamParser&) = delete;
25  StreamParser& operator=(StreamParser&&) = delete;
26 #endif
27 
31  virtual ~StreamParser() {};
32 
39  IrSignal* parseIrSignal();
40 
46  IrSignal* parsePronto();
47 
52  int32_t parseAbsInt();
53 
60  int32_t parseAbsIntDefault(int32_t fallback);
61 
68  const char* parseWord(char* buf, size_t buflen);
69 
70  const char* getLine(char* buf, size_t buflen);
71 
72  Stream& getStream() { return stream; }
73 
74  void flushLine();
75 
81  static IrSignal* parse(Stream &stream);
82 
83  microseconds_t* parseData(microseconds_t* buffer, size_t length);
84 
85  static constexpr int invalid = -1;
86 
87 private:
88 
89  //static constexpr int32_t invalidInt = -1L;
90 
91  Stream &stream;
92  microseconds_t* parseData(size_t length);
93  int32_t parseAbsInt(char initial);
94  char customReadChar();
95  void disposeUntilWhitespace();
96  static unsigned int parseHex(char c);
101  uint16_t parseProntoNumber();
102 };
Simple class for parsing stuff from an (input) Stream.
Definition: StreamParser.h:13
int32_t parseAbsInt()
Reads a number and returns it as 16 bit unsigned.
static IrSignal * parse(Stream &stream)
Convenience function: combines the constructor and parseIrSignal.
const char * getLine(char *buf, size_t buflen)
int32_t parseAbsIntDefault(int32_t fallback)
Reads a number and returns it as 16 bit unsigned.
const char * parseWord(char *buf, size_t buflen)
Returns a word (separated by whitespace).
IrSignal * parseIrSignal()
Reads the stream and parses it into an IrSignal.
Definition: StreamParser.cpp:8
StreamParser(Stream &stream)
Constructor.
Definition: StreamParser.cpp:5
microseconds_t * parseData(microseconds_t *buffer, size_t length)
IrSignal * parsePronto()
Reads a Pronto Hex format IR signal.
virtual ~StreamParser()
Destructor.
Definition: StreamParser.h:31
static constexpr int invalid
Definition: StreamParser.h:85
Stream & getStream()
Definition: StreamParser.h:72