10 #define BOTAN_PIPE_H__
12 #include <botan/data_src.h>
13 #include <botan/filter.h>
14 #include <botan/exceptn.h>
15 #include <initializer_list>
66 void write(
const uint8_t in[],
size_t length);
73 { write(in.data(), in.size()); }
79 void write(
const std::vector<uint8_t>& in)
80 { write(in.data(), in.size()); }
86 void write(
const std::string& in);
98 void write(uint8_t in);
105 void process_msg(
const uint8_t in[],
size_t length);
117 void process_msg(
const std::vector<uint8_t>& in);
123 void process_msg(
const std::string& in);
148 size_t read(uint8_t output[],
size_t length) override BOTAN_WARN_UNUSED_RESULT;
159 size_t read(uint8_t output[],
size_t length, message_id msg) BOTAN_WARN_UNUSED_RESULT;
170 size_t read(uint8_t& output, message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
177 secure_vector<uint8_t> read_all(message_id msg = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
184 std::
string read_all_as_string(message_id = DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT;
195 size_t peek(uint8_t output[],
size_t length,
size_t offset) const override BOTAN_WARN_UNUSED_RESULT;
206 size_t peek(uint8_t output[],
size_t length,
207 size_t offset, message_id msg) const BOTAN_WARN_UNUSED_RESULT;
217 size_t peek(uint8_t& output,
size_t offset,
218 message_id msg = DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT;
223 size_t get_bytes_read() const override;
228 size_t get_bytes_read(message_id msg) const;
230 bool check_available(
size_t n) override;
231 bool check_available_msg(
size_t n, message_id msg);
236 size_t default_msg()
const {
return m_default_read; }
243 void set_default_msg(message_id msg);
249 message_id message_count()
const;
255 bool end_of_data()
const override;
272 void prepend(
Filter* filt);
278 void append(
Filter* filt);
301 explicit Pipe(std::initializer_list<Filter*> filters);
304 Pipe& operator=(
const Pipe&) =
delete;
310 void find_endpoints(
Filter*);
311 void clear_endpoints(
Filter*);
313 message_id get_message_no(
const std::string&, message_id)
const;
317 message_id m_default_read;
327 BOTAN_DLL std::ostream&
operator<<(std::ostream& out, Pipe& pipe);
335 BOTAN_DLL std::istream&
operator>>(std::istream& in, Pipe& pipe);
339 #if defined(BOTAN_HAS_PIPE_UNIXFD_IO)
340 #include <botan/fd_unix.h>
std::istream & operator>>(std::istream &in, X509_DN &dn)
Invalid_Message_Number(const std::string &where, message_id msg)
std::ostream & operator<<(std::ostream &out, const X509_DN &dn)
#define BOTAN_WARN_UNUSED_RESULT
static const message_id DEFAULT_MESSAGE
std::vector< T, secure_allocator< T >> secure_vector
static const message_id LAST_MESSAGE
void write(const secure_vector< uint8_t > &in)
void write(const std::vector< uint8_t > &in)
std::string to_string(const secure_vector< uint8_t > &bytes)