14 static constexpr size_t linelen = 128;
18 void recv(uint8_t b) {
20 if (b ==
'\n' || b ==
'\r') {
21 if (l.
len == 0)
return;
26 if (l.
len + 1 > linelen) {
38 for (
auto b: source.
pop()) {
64 if (b.len + 1 <= b.size) {
65 p.
push(std::move(b.append(
'\n')));
simple pipe that will append a newline to every data packet
Definition line.h:48
void push(Buffer< uint8_t > &&b) override
move semantics does not check for space. guard by using 'if (!full) { ... }'
Definition line.h:63
void push(const Buffer< uint8_t > &b) override
copy semantics does not check for space. guard by using 'if (!full) { ... }'
Definition line.h:56
LineDelimiter(Sink< Buffer< uint8_t > > &p)
set underlying Sink
Definition line.h:52
bool full() override
check if sink is full
Definition line.h:53
simple example of a pipe that receives bytes as they come in and splits them into \n delimited lines.
Definition line.h:13
LineFilter(Source< Buffer< uint8_t > > &p)
set underlying Source
Definition line.h:35
bool empty() override
check if source is empty
Definition line.h:36
Buffer< uint8_t > pop() override
pull object from source does not check for data. guard by using 'if (!empty) { ......
Definition line.h:44
simple Buffer backed queue implementation
Definition queue.h:12
T pop() override
remove front of queue and return it
Definition queue.h:65
bool empty() override
check if queue is empty
Definition queue.h:83
bool full() override
return true if queue is full
Definition queue.h:87
dynamically allocated, but fixed-size buffer template
Definition buffer.h:18
Buffer & append(T b)
simple append single item
Definition buffer.h:44
size_t size
total capacity of buffer
Definition buffer.h:23
size_t len
number of items stored in buffer
Definition buffer.h:21
generic object sink, i.e.
Definition streams.h:15
virtual bool full()=0
check if sink is full
void trypush(T &&t)
use this if you don't care if it's going to be successful. data gets discarded if sink is full.
Definition streams.h:28
virtual void push(const T &t)
copy semantics does not check for space. guard by using 'if (!full) { ... }'
Definition streams.h:20
generic object source, i.e.
Definition streams.h:40
virtual T pop()=0
pull object from source does not check for data. guard by using 'if (!empty) { ......
virtual bool empty()=0
check if source is empty