OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
plain-text-reader.hpp
Go to the documentation of this file.
1
6#ifndef OPENEV_READERS_PLAIN_TEXT_READER_HPP
7#define OPENEV_READERS_PLAIN_TEXT_READER_HPP
8
10#include <cstddef>
11#include <fstream>
12#include <stdint.h>
13#include <string>
14#include <vector>
15
16namespace ev {
17[[maybe_unused]] constexpr bool USING_PLAIN_TEXT_READER_HPP = true;
18
19enum PlainTextReaderColumns : uint8_t {
20 TXYP,
21 XYTP,
22 PTXY,
23 PXYT
24};
25
29class PlainTextReader : public AbstractReader_ {
30public:
31 explicit PlainTextReader(const std::string &filename, const PlainTextReaderColumns columns = PlainTextReaderColumns::TXYP, const std::string &separator = " ");
32 ~PlainTextReader() override;
33
35 PlainTextReader(const PlainTextReader &) = delete;
36 PlainTextReader(PlainTextReader &&) noexcept = delete;
37 PlainTextReader &operator=(const PlainTextReader &) = delete;
38 PlainTextReader &operator=(PlainTextReader &&) noexcept = delete;
40
41protected:
42 std::size_t read_(Event *events, const std::size_t max) override;
43 void reset_() override;
44
45private:
46 std::fstream file_;
47 PlainTextReaderColumns columns_;
48 char sep_char_; // non-zero when separator is a single non-space char
49 std::string sep_str_; // non-empty when separator is multi-char
50 std::string line_; // reused across calls
51 std::vector<char> chunk_;
52 std::size_t pos_{0};
53 std::size_t end_{0};
54 bool exhausted_{false};
55 bool failed_{false};
56
57 bool nextLine_(const char *&line, const char *&lineEnd);
58};
59
60} // namespace ev
61
62#endif // OPENEV_READERS_PLAIN_TEXT_READER_HPP
Abstract base class for event readers.
This is an auxiliary class. This class cannot be instanced.
Definition abstract-reader.hpp:28
ConcurrentQueue & events(const std::size_t n=0)
Read a given number of events, add them to the queue, and return it.
Definition abstract-reader.hpp:46
Eventi Event
Definition types.hpp:262