Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
Botan::Pipe Class Referencefinal

`#include <pipe.h>`

Inheritance diagram for Botan::Pipe:

## Classes
class | Invalid_Message_Number

## Public Types
typedef size_t | message_id

## Public Member Functions
void | append (Filter *filt)
void | append_filter (Filter *filt)
bool | check_available (size_t n) override
bool | check_available_msg (size_t n, message_id msg)
size_t | default_msg () const
size_t | discard_next (size_t N)
void | end_msg ()
bool | end_of_data () const override
size_t | get_bytes_read () const override
size_t | get_bytes_read (message_id msg) const
virtual std::string | id () const
message_id | message_count () const
Pipe & | operator= (const Pipe &)=delete
size_t | peek (uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT
size_t | peek (uint8_t output[], size_t length, size_t offset, message_id msg) const BOTAN_WARN_UNUSED_RESULT
size_t | peek (uint8_t &output, size_t offset, message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
size_t | peek_byte (uint8_t &out) const
| Pipe (Filter *=nullptr, Filter *=nullptr, Filter *=nullptr, Filter *=nullptr)
| Pipe (std::initializer_list< Filter * > filters)
| Pipe (const Pipe &)=delete
void | pop ()
void | prepend (Filter *filt)
void | prepend_filter (Filter *filt)
void | process_msg (const uint8_t in[], size_t length)
void | process_msg (const secure_vector< uint8_t > &in)
void | process_msg (const std::vector< uint8_t > &in)
void | process_msg (const std::string &in)
void | process_msg (DataSource &in)
size_t | read (uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
size_t | read (uint8_t output[], size_t length, message_id msg) BOTAN_WARN_UNUSED_RESULT
size_t | read (uint8_t &output, message_id msg=DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT
secure_vector< uint8_t > | read_all (message_id msg=DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT
std::string | read_all_as_string (message_id msg=DEFAULT_MESSAGE) BOTAN_WARN_UNUSED_RESULT
size_t | read_byte (uint8_t &out)
size_t | remaining (message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
void | reset ()
void | set_default_msg (message_id msg)
void | start_msg ()
void | write (const uint8_t in[], size_t length)
void | write (const secure_vector< uint8_t > &in)
void | write (const std::vector< uint8_t > &in)
void | write (const std::string &in)
void | write (DataSource &in)
void | write (uint8_t in)
| ~Pipe ()

## Static Public Attributes
static const message_id | DEFAULT_MESSAGE
static const message_id | LAST_MESSAGE

## Detailed Description

This class represents pipe objects. A set of filters can be placed into a pipe, and information flows through the pipe until it reaches the end, where the output is collected for retrieval. If you're familiar with the Unix shell environment, this design will sound quite familiar.

Definition at line 29 of file pipe.h.

## Member Typedef Documentation

typedef size_t Botan::Pipe::message_id

An opaque type that identifies a message in this Pipe

Definition at line 35 of file pipe.h.

## Constructor & Destructor Documentation

Botan::Pipe::Pipe | ( | Filter * | f1 = `nullptr`,
|  | Filter * | f2 = `nullptr`,
|  | Filter * | f3 = `nullptr`,
|  | Filter * | f4 = `nullptr`
| ) |  |

Construct a Pipe of up to four filters. The filters are set up in the same order as the arguments.

Definition at line 33 of file pipe.cpp.

33 :
34 Pipe({f1,f2,f3,f4})
35 {
36 }
Botan::Pipe::Pipe
Pipe(Filter *=nullptr, Filter *=nullptr, Filter *=nullptr, Filter *=nullptr)
Definition: pipe.cpp:33

Botan::Pipe::Pipe | ( | std::initializer_list< Filter * > | filters | ) |
| explicit

Construct a Pipe from a list of filters

Parameters

  filters | the set of filters to use

Definition at line 41 of file pipe.cpp.

42 {
43 m_outputs.reset(new Output_Buffers);
44 m_pipe = nullptr;
45 m_default_read = 0;
46 m_inside_msg = false;
47
48 for(auto i = args.begin(); i != args.end(); ++i)
49 do_append(*i);
50 }

Botan::Pipe::Pipe | ( | const Pipe & |  | ) |
| delete

Botan::Pipe::~Pipe | ( |  | ) |

Definition at line 55 of file pipe.cpp.

56 {
57 destruct(m_pipe);
58 }

## Member Function Documentation

void Botan::Pipe::append | ( | Filter * | filt | ) |

Insert a new filter at the back of the pipe Deprecated because runtime modification of Pipes is deprecated. You can instead use append_filter which only works before the first message is processed.

Parameters

  filt | the new filter to insert

Definition at line 204 of file pipe.cpp.

205 {
206 do_append(filter);
207 }

void Botan::Pipe::append_filter | ( | Filter * | filt | ) |

Append a new filter onto the filter sequence. This may only be called immediately after initial construction, before any calls to start_msg have been made.

This function (unlike append) is not deprecated, as it allows only modification of the pipe at initialization (before use) rather than after messages have been processed.

Definition at line 209 of file pipe.cpp.

210 {
211 if(m_outputs->message_count() != 0)
212 throw Invalid_State("Cannot call Pipe::append_filter after start_msg");
213
214 do_append(filter);
215 }

bool Botan::Pipe::check_available | ( | size_t | n | ) |
| override virtual

Implements Botan::DataSource.

Definition at line 171 of file pipe_rw.cpp.

References default_msg(), and remaining().

172 {
173 return (n <= remaining(default_msg()));
174 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:131
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:239

bool Botan::Pipe::check_available_msg | ( | size_t | n,
|  | message_id | msg
| ) |  |

Definition at line 176 of file pipe_rw.cpp.

References remaining().

177 {
178 return (n <= remaining(msg));
179 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:131

size_t Botan::Pipe::default_msg | ( |  | ) | const
| inline

Returns
  currently set default message

Definition at line 239 of file pipe.h.

Referenced by check_available(), get_bytes_read(), read_all(), and read_all_as_string().

239 { return m_default_read; }

size_t Botan::DataSource::discard_next | ( | size_t | N | ) |
| inherited

Discard the next N bytes of the data

Parameters

  N | the number of bytes to discard

Returns
  number of bytes actually discarded

Definition at line 39 of file data_src.cpp.

References Botan::DataSource::read().

40 {
41 uint8_t buf[64] = { 0 };
42 size_t discarded = 0;
43
44 while(n)
45 {
46 const size_t got = this->read(buf, std::min(n, sizeof(buf)));
47 discarded += got;
48 n -= got;
49
50 if(got == 0)
51 break;
52 }
53
54 return discarded;
55 }
Botan::DataSource::read
virtual size_t read(uint8_t out[], size_t length) BOTAN_WARN_UNUSED_RESULT=0

void Botan::Pipe::end_msg | ( |  | ) |

End the current message.

Definition at line 158 of file pipe.cpp.

Referenced by process_msg().

159 {
160 if(!m_inside_msg)
161 throw Invalid_State("Pipe::end_msg: Message was already ended");
162 m_pipe->finish_msg();
163 clear_endpoints(m_pipe);
164 if(dynamic_cast<Null_Filter*>(m_pipe))
165 {
166 delete m_pipe;
167 m_pipe = nullptr;
168 }
169 m_inside_msg = false;
170
171 m_outputs->retire();
172 }

bool Botan::Pipe::end_of_data | ( |  | ) | const
| override virtual

Test whether this pipe has any data that can be read from.

Returns
  true if there is more data to read, false otherwise

Implements Botan::DataSource.

Definition at line 85 of file pipe.cpp.

References remaining().

86 {
87 return (remaining() == 0);
88 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:131

size_t Botan::Pipe::get_bytes_read | ( |  | ) | const
| override virtual

Returns
  the number of bytes read from the default message.

Implements Botan::DataSource.

Definition at line 161 of file pipe_rw.cpp.

References default_msg().

162 {
163 return m_outputs->get_bytes_read(default_msg());
164 }
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:239

size_t Botan::Pipe::get_bytes_read | ( | message_id | msg | ) | const

Returns
  the number of bytes read from the specified message.

Definition at line 166 of file pipe_rw.cpp.

167 {
168 return m_outputs->get_bytes_read(msg);
169 }

virtual std::string Botan::DataSource::id | ( |  | ) | const
| inline virtual inherited

return the id of this data source

Returns
  std::string representing the id of this data source

Reimplemented in Botan::DataSource_Stream.

Definition at line 59 of file data_src.h.

59 { return ""; }

Pipe::message_id Botan::Pipe::message_count | ( |  | ) | const

Get the number of messages the are in this pipe.

Returns
  number of messages the are in this pipe

Definition at line 297 of file pipe.cpp.

Referenced by set_default_msg().

298 {
299 return m_outputs->message_count();
300 }

Pipe& Botan::Pipe::operator= | ( | const Pipe & |  | ) |
| delete

size_t Botan::Pipe::peek | ( | uint8_t | output[],
|  | size_t | length,
|  | size_t | offset
| ) |  | const
| override virtual

Read from the default message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.

Parameters

  output | the byte array to write the peeked message part to
  length | the length of the byte array output
  offset | the offset from the current position in message

Returns
  number of bytes actually peeked and written into output

Implements Botan::DataSource.

Definition at line 148 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

Referenced by peek().

149 {
150 return peek(output, length, offset, DEFAULT_MESSAGE);
151 }
Botan::Pipe::peek
size_t peek(uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:148
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:62

size_t Botan::Pipe::peek | ( | uint8_t | output[],
|  | size_t | length,
|  | size_t | offset,
|  | message_id | msg
| ) |  | const

Read from the specified message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.

Parameters

  output | the byte array to write the peeked message part to
  length | the length of the byte array output
  offset | the offset from the current position in message
  msg | the number identifying the message to peek from

Returns
  number of bytes actually peeked and written into output

Definition at line 139 of file pipe_rw.cpp.

141 {
142 return m_outputs->peek(output, length, offset, get_message_no("peek", msg));
143 }

size_t Botan::Pipe::peek | ( | uint8_t & | output,
|  | size_t | offset,
|  | message_id | msg = `DEFAULT_MESSAGE`
| ) |  | const

Read a single byte from the specified message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.

Parameters

  output | the byte to write the peeked message byte to
  offset | the offset from the current position in message
  msg | the number identifying the message to peek from

Returns
  number of bytes actually peeked and written into output

Definition at line 156 of file pipe_rw.cpp.

References peek().

157 {
158 return peek(&out, 1, offset, msg);
159 }
Botan::Pipe::peek
size_t peek(uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:148

size_t Botan::DataSource::peek_byte | ( | uint8_t & | out | ) | const
| inherited

Peek at one byte.

Parameters

  out | an output byte

Returns
  length in bytes that was actually read and put into out

Definition at line 31 of file data_src.cpp.

References Botan::DataSource::peek().

Referenced by Botan::ASN1::maybe_BER().

32 {
33 return peek(&out, 1, 0);
34 }
Botan::DataSource::peek
virtual size_t peek(uint8_t out[], size_t length, size_t peek_offset) const BOTAN_WARN_UNUSED_RESULT=0

void Botan::Pipe::pop | ( |  | ) |

Remove the first filter at the front of the pipe.

Definition at line 274 of file pipe.cpp.

275 {
276 if(m_inside_msg)
277 throw Invalid_State("Cannot pop off a Pipe while it is processing");
278
279 if(!m_pipe)
280 return;
281
282 if(m_pipe->total_ports() > 1)
283 throw Invalid_State("Cannot pop off a Filter with multiple ports");
284
285 size_t to_remove = m_pipe->owns() + 1;
286
287 while(to_remove--)
288 {
289 std::unique_ptr<Filter> to_destroy(m_pipe);
290 m_pipe = m_pipe->m_next[0];
291 }
292 }

void Botan::Pipe::prepend | ( | Filter * | filt | ) |

Insert a new filter at the front of the pipe Deprecated because runtime modification of Pipes is deprecated. You can instead use prepend_filter which only works before the first message is processed.

Parameters

  filt | the new filter to insert

Definition at line 217 of file pipe.cpp.

218 {
219 do_prepend(filter);
220 }

void Botan::Pipe::prepend_filter | ( | Filter * | filt | ) |

Prepend a new filter onto the filter sequence. This may only be called immediately after initial construction, before any calls to start_msg have been made.

This function (unlike prepend) is not deprecated, as it allows only modification of the pipe at initialization (before use) rather than after messages have been processed.

Definition at line 222 of file pipe.cpp.

223 {
224 if(m_outputs->message_count() != 0)
225 throw Invalid_State("Cannot call Pipe::prepend_filter after start_msg");
226
227 do_prepend(filter);
228 }

void Botan::Pipe::process_msg | ( | const uint8_t | in[],
|  | size_t | length
| ) |  |

Perform start_msg(), write() and end_msg() sequentially.

Parameters

  in | the byte array containing the data to write
  length | the length of the byte array to write

Definition at line 103 of file pipe.cpp.

References end_msg(), start_msg(), and write().

Referenced by Botan::aont_package(), Botan::aont_unpackage(), and process_msg().

104 {
105 start_msg();
106 write(input, length);
107 end_msg();
108 }
Botan::Pipe::start_msg
void start_msg()
Definition: pipe.cpp:144
Botan::Pipe::end_msg
void end_msg()
Definition: pipe.cpp:158
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

void Botan::Pipe::process_msg | ( | const secure_vector< uint8_t > & | in | ) |

Perform start_msg(), write() and end_msg() sequentially.

Parameters

  in | the secure_vector containing the data to write

Definition at line 113 of file pipe.cpp.

References process_msg().

114 {
115 process_msg(input.data(), input.size());
116 }
Botan::Pipe::process_msg
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:103

void Botan::Pipe::process_msg | ( | const std::vector< uint8_t > & | in | ) |

Perform start_msg(), write() and end_msg() sequentially.

Parameters

  in | the secure_vector containing the data to write

Definition at line 118 of file pipe.cpp.

References process_msg().

Referenced by process_msg().

119 {
120 process_msg(input.data(), input.size());
121 }
Botan::Pipe::process_msg
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:103

void Botan::Pipe::process_msg | ( | const std::string & | in | ) |

Perform start_msg(), write() and end_msg() sequentially.

Parameters

  in | the string containing the data to write

Definition at line 126 of file pipe.cpp.

References Botan::cast_char_ptr_to_uint8(), and process_msg().

127 {
128 process_msg(cast_char_ptr_to_uint8(input.data()), input.length());
129 }
Botan::cast_char_ptr_to_uint8
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:189
Botan::Pipe::process_msg
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:103

void Botan::Pipe::process_msg | ( | DataSource & | in | ) |

Perform start_msg(), write() and end_msg() sequentially.

Parameters

  in | the DataSource providing the data to write

Definition at line 134 of file pipe.cpp.

References end_msg(), start_msg(), and write().

135 {
136 start_msg();
137 write(input);
138 end_msg();
139 }
Botan::Pipe::start_msg
void start_msg()
Definition: pipe.cpp:144
Botan::Pipe::end_msg
void end_msg()
Definition: pipe.cpp:158
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

size_t Botan::Pipe::read | ( | uint8_t | output[],
|  | size_t | length
| ) |  |
| override virtual

Read the default message from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.

Parameters

  output | the byte array to write the read bytes to
  length | the length of the byte array output

Returns
  number of bytes actually read into output

Implements Botan::DataSource.

Definition at line 82 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::operator<<(), read(), read_all(), and read_all_as_string().

83 {
84 return read(output, length, DEFAULT_MESSAGE);
85 }
Botan::Pipe::read
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:82
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:62

size_t Botan::Pipe::read | ( | uint8_t | output[],
|  | size_t | length,
|  | message_id | msg
| ) |  |

Read a specified message from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.

Parameters

  output | the byte array to write the read bytes to
  length | the length of the byte array output
  msg | the number identifying the message to read from

Returns
  number of bytes actually read into output

Definition at line 74 of file pipe_rw.cpp.

75 {
76 return m_outputs->read(output, length, get_message_no("read", msg));
77 }

size_t Botan::Pipe::read | ( | uint8_t & | output,
|  | message_id | msg = `DEFAULT_MESSAGE`
| ) |  |

Read a single byte from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.

Parameters

  output | the byte to write the result to
  msg | the message to read from

Returns
  number of bytes actually read into output

Definition at line 90 of file pipe_rw.cpp.

References read().

91 {
92 return read(&out, 1, msg);
93 }
Botan::Pipe::read
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:82

secure_vector< uint8_t > Botan::Pipe::read_all | ( | message_id | msg = `DEFAULT_MESSAGE` | ) |

Read the full contents of the pipe.

Parameters

  msg | the number identifying the message to read from

Returns
  secure_vector holding the contents of the pipe

Definition at line 98 of file pipe_rw.cpp.

References DEFAULT_MESSAGE, default_msg(), read(), and remaining().

99 {
100 msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
101 secure_vector<uint8_t> buffer(remaining(msg));
102 size_t got = read(buffer.data(), buffer.size(), msg);
103 buffer.resize(got);
104 return buffer;
105 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:131
Botan::Pipe::read
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:82
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:62
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:239

std::string Botan::Pipe::read_all_as_string | ( | message_id | msg = `DEFAULT_MESSAGE` | ) |

Read the full contents of the pipe.

Parameters

  msg | the number identifying the message to read from

Returns
  string holding the contents of the pipe

Definition at line 110 of file pipe_rw.cpp.

References Botan::cast_uint8_ptr_to_char(), DEFAULT_MESSAGE, default_msg(), read(), and remaining().

111 {
112 msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
113 secure_vector<uint8_t> buffer(BOTAN_DEFAULT_BUFFER_SIZE);
114 std::string str;
115 str.reserve(remaining(msg));
116
117 while(true)
118 {
119 size_t got = read(buffer.data(), buffer.size(), msg);
120 if(got == 0)
121 break;
122 str.append(cast_uint8_ptr_to_char(buffer.data()), got);
123 }
124
125 return str;
126 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:131
Botan::Pipe::read
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:82
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:62
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:239
Botan::cast_uint8_ptr_to_char
const char * cast_uint8_ptr_to_char(const uint8_t *b)
Definition: mem_ops.h:194

size_t Botan::DataSource::read_byte | ( | uint8_t & | out | ) |
| inherited

Read one byte.

Parameters

  out | the byte to read to

Returns
  length in bytes that was actually read and put into out

Definition at line 23 of file data_src.cpp.

References Botan::DataSource::read().

Referenced by Botan::PEM_Code::decode(), Botan::BER_Decoder::discard_remaining(), and Botan::ASN1::maybe_BER().

24 {
25 return read(&out, 1);
26 }
Botan::DataSource::read
virtual size_t read(uint8_t out[], size_t length) BOTAN_WARN_UNUSED_RESULT=0

size_t Botan::Pipe::remaining | ( | message_id | msg = `DEFAULT_MESSAGE` | ) | const

Find out how many bytes are ready to read.

Parameters

  msg | the number identifying the message for which the information is desired

Returns
  number of bytes that can still be read

Definition at line 131 of file pipe_rw.cpp.

Referenced by Botan::aont_package(), Botan::aont_unpackage(), check_available(), check_available_msg(), end_of_data(), Botan::operator<<(), read_all(), and read_all_as_string().

132 {
133 return m_outputs->remaining(get_message_no("remaining", msg));
134 }

void Botan::Pipe::reset | ( |  | ) |

Reset this pipe to an empty pipe.

Definition at line 63 of file pipe.cpp.

64 {
65 destruct(m_pipe);
66 m_pipe = nullptr;
67 m_inside_msg = false;
68 }

void Botan::Pipe::set_default_msg | ( | message_id | msg | ) |

Set the default message

Parameters

  msg | the number identifying the message which is going to be the new default message

Definition at line 93 of file pipe.cpp.

References message_count().

94 {
95 if(msg >= message_count())
96 throw Invalid_Argument("Pipe::set_default_msg: msg number is too high");
97 m_default_read = msg;
98 }
Botan::Pipe::message_count
message_id message_count() const
Definition: pipe.cpp:297

void Botan::Pipe::start_msg | ( |  | ) |

Start a new message in the pipe. A potential other message in this pipe must be closed with end_msg() before this function may be called.

Definition at line 144 of file pipe.cpp.

Referenced by process_msg().

145 {
146 if(m_inside_msg)
147 throw Invalid_State("Pipe::start_msg: Message was already started");
148 if(m_pipe == nullptr)
149 m_pipe = new Null_Filter;
150 find_endpoints(m_pipe);
151 m_pipe->new_msg();
152 m_inside_msg = true;
153 }

void Botan::Pipe::write | ( | const uint8_t | in[],
|  | size_t | length
| ) |  |

Write input to the pipe, i.e. to its first filter.

Parameters

  in | the byte array to write
  length | the length of the byte array in

Definition at line 35 of file pipe_rw.cpp.

References Botan::Filter::write().

Referenced by Botan::operator>>(), process_msg(), and write().

36 {
37 if(!m_inside_msg)
38 throw Invalid_State("Cannot write to a Pipe while it is not processing");
39 m_pipe->write(input, length);
40 }
Botan::Filter::write
virtual void write(const uint8_t input[], size_t length)=0

void Botan::Pipe::write | ( | const secure_vector< uint8_t > & | in | ) |
| inline

Write input to the pipe, i.e. to its first filter.

Parameters

  in | the secure_vector containing the data to write

Definition at line 75 of file pipe.h.

76 { write(in.data(), in.size()); }
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

void Botan::Pipe::write | ( | const std::vector< uint8_t > & | in | ) |
| inline

Write input to the pipe, i.e. to its first filter.

Parameters

  in | the std::vector containing the data to write

Definition at line 82 of file pipe.h.

83 { write(in.data(), in.size()); }
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

void Botan::Pipe::write | ( | const std::string & | in | ) |

Write input to the pipe, i.e. to its first filter.

Parameters

  in | the string containing the data to write

Definition at line 45 of file pipe_rw.cpp.

References Botan::cast_char_ptr_to_uint8(), and write().

46 {
47 write(cast_char_ptr_to_uint8(str.data()), str.size());
48 }
Botan::cast_char_ptr_to_uint8
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:189
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

void Botan::Pipe::write | ( | DataSource & | in | ) |

Write input to the pipe, i.e. to its first filter.

Parameters

  in | the DataSource to read the data from

Definition at line 61 of file pipe_rw.cpp.

References Botan::DataSource::end_of_data(), Botan::DataSource::read(), and write().

62 {
63 secure_vector<uint8_t> buffer(BOTAN_DEFAULT_BUFFER_SIZE);
64 while(!source.end_of_data())
65 {
66 size_t got = source.read(buffer.data(), buffer.size());
67 write(buffer.data(), got);
68 }
69 }
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

void Botan::Pipe::write | ( | uint8_t | in | ) |

Write input to the pipe, i.e. to its first filter.

Parameters

  in | a single byte to be written

Definition at line 53 of file pipe_rw.cpp.

References write().

54 {
55 write(&input, 1);
56 }
Botan::Pipe::write
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:35

## Member Data Documentation

const Pipe::message_id Botan::Pipe::DEFAULT_MESSAGE
| static

Initial value:
=
static_cast<Pipe::message_id>(-1)

A meta-id for the default message (set with set_default_msg)

Definition at line 62 of file pipe.h.

Referenced by peek(), read(), read_all(), and read_all_as_string().

const Pipe::message_id Botan::Pipe::LAST_MESSAGE
| static

Initial value:
=
static_cast<Pipe::message_id>(-2)

A meta-id for whatever the last message is

Definition at line 57 of file pipe.h.

The documentation for this class was generated from the following files:

- src/lib/filters/pipe.h
- src/lib/filters/pipe.cpp
- src/lib/filters/pipe_rw.cpp