LCOV - code coverage report
Current view: top level - src/MIDI_Parsers - StreamPuller.hpp (source / functions) Hit Total Coverage
Test: 3a807a259ebe0769dd942f7f612dca5273937539 Lines: 6 6 100.0 %
Date: 2024-03-24 17:16:54 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AH/Arduino-Wrapper.h> // Stream
       4             : #include <Settings/NamespaceSettings.hpp>
       5             : 
       6             : BEGIN_CS_NAMESPACE
       7             : 
       8             : /**
       9             :  * @brief   Helper that pulls bytes out of an Arduino stream.
      10             :  * 
      11             :  * @ingroup MIDIParsers
      12             :  */
      13             : class StreamPuller {
      14             :   public:
      15          31 :     StreamPuller(Stream &stream) : stream(stream) {}
      16             : 
      17             :     /// Pull a byte out of the stream.
      18             :     /// @param[out] c
      19             :     ///             A new character from the stream (if available).
      20             :     /// @return True if a character was available, false otherwise.
      21         351 :     bool pull(uint8_t &c) {
      22         351 :         int read = stream.read();
      23         351 :         if (read >= 0)
      24         346 :             c = read;
      25         351 :         return read >= 0;
      26             :     }
      27             : 
      28             :     Stream &stream;
      29             : };
      30             : 
      31             : END_CS_NAMESPACE

Generated by: LCOV version 1.15