LCOV - code coverage report
Current view: top level - AP_CSVReader - AP_CSVReader.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 8 100.0 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : // Note: term is always null-terminated so a final line with no cr/lf
       4             : // on it can still be fetched by the caller
       5             : 
       6             : #include <stdint.h>
       7             : 
       8             : class AP_CSVReader
       9             : {
      10             : 
      11             : public:
      12             : 
      13       21464 :     AP_CSVReader(uint8_t *_term, uint8_t _term_len, uint8_t _separator=',') :
      14       21464 :         separator{_separator},
      15       21464 :         term{_term},
      16       21464 :         term_len{_term_len}
      17       21464 :         {}
      18             : 
      19             :     enum class RetCode : uint8_t {
      20             :         OK,
      21             :         ERROR,
      22             :         TERM_DONE,
      23             :         VECTOR_DONE,
      24             :     };
      25             : 
      26             :     RetCode feed(uint8_t c);
      27             : //    RetCode feed(const uint8_t *buffer, uint8_t len);
      28             : 
      29             : private:
      30             : 
      31             :     enum class State : uint8_t {
      32             :         START_OF_START_OF_TERM = 46,
      33             :         START_OF_TERM = 47,
      34             :         END_OF_VECTOR_CR = 48,
      35             :         IN_UNQUOTED_TERM = 49,
      36             :         IN_QUOTED_TERM = 50,
      37             :         END_OF_QUOTED_TERM = 51,
      38             :     } state = State::START_OF_START_OF_TERM;
      39             : 
      40             :     // term separator
      41             :     const uint8_t separator;
      42             : 
      43             :     // pointer to memory where term will be assembled
      44             :     uint8_t *term;
      45             : 
      46             :     // amount of memory term points to
      47             :     const uint8_t term_len;
      48             : 
      49             :     // offset into term for next character
      50             :     uint8_t term_ofs;
      51             : 
      52         152 :     void set_state(State newstate) {
      53         152 :         state = newstate;
      54         152 :     }
      55             : 
      56             :     AP_CSVReader::RetCode handle_unquoted_term(uint8_t c);
      57             :     AP_CSVReader::RetCode handle_quoted_term(uint8_t c);
      58             : };

Generated by: LCOV version 1.14