8#include <botan/filter.h>
10#include <botan/exceptn.h>
32 bool nothing_attached =
true;
33 for(
size_t j = 0; j != total_ports(); ++j) {
35 if(!m_write_queue.empty()) {
36 m_next[j]->write(m_write_queue.data(), m_write_queue.size());
38 m_next[j]->write(input, length);
39 nothing_attached =
false;
43 if(nothing_attached) {
44 m_write_queue += std::make_pair(input, length);
46 m_write_queue.clear();
53void Filter::new_msg() {
55 for(
size_t j = 0; j != total_ports(); ++j) {
65void Filter::finish_msg() {
67 for(
size_t j = 0; j != total_ports(); ++j) {
69 m_next[j]->finish_msg();
77void Filter::attach(Filter* new_filter) {
80 while(last->get_next()) {
81 last = last->get_next();
83 last->m_next[last->current_port()] = new_filter;
90void Filter::set_port(
size_t new_port) {
91 if(new_port >= total_ports()) {
92 throw Invalid_Argument(
"Filter: Invalid port number");
94 m_port_num = new_port;
100Filter* Filter::get_next()
const {
101 if(m_port_num < m_next.size()) {
102 return m_next[m_port_num];
110void Filter::set_next(Filter* filters[],
size_t size) {
116 while(size && filters && (filters[size - 1] ==
nullptr)) {
120 if(filters && size) {
121 m_next.assign(filters, filters + size);
128size_t Filter::total_ports()
const {
129 return m_next.size();
virtual void send(const uint8_t in[], size_t length)