From 650fb016ce36cfda2e8073764196655ee6a50567 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 11 Jul 2015 14:30:14 +0200 Subject: o Adding a parser::finish() method that indicates that the stream is done and any possibly buffered data should be parsed and processed. --- sensor/include/trygvis/sensor/io.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'sensor/include') diff --git a/sensor/include/trygvis/sensor/io.h b/sensor/include/trygvis/sensor/io.h index f86f2d9..b69bd7a 100644 --- a/sensor/include/trygvis/sensor/io.h +++ b/sensor/include/trygvis/sensor/io.h @@ -206,8 +206,9 @@ private: class SampleStreamParser { public: - // TODO: return number of samples found for progress indication? - virtual void process(mutable_buffers_1 &buffer) = 0; + virtual int process(mutable_buffers_1 &buffer) = 0; + + virtual int finish() = 0; virtual sample_format_type type() { return type_; @@ -233,10 +234,12 @@ public: line(make_shared>()) { } - void process(mutable_buffers_1 &buffer) override; + int process(mutable_buffers_1 &buffer) override; + + int finish() override; private: - void process_line(shared_ptr> packet); + void process_line(shared_ptr> &packet); static const uint8_t packet_delimiter = '\n'; shared_ptr output; @@ -247,7 +250,9 @@ class AutoSampleParser : public SampleStreamParser { public: AutoSampleParser(shared_ptr output, KeyDictionary &dict); - virtual void process(mutable_buffers_1 &buffer) override; + virtual int process(mutable_buffers_1 &buffer) override; + + virtual int finish() override; private: unique_ptr parser; -- cgit v1.2.3