Botan: Botan::Pipe Class Reference

Botan 1.10.17

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

`#include <pipe.h>`

Inheritance diagram for Botan::Pipe:

## Classes
struct | Invalid_Message_Number

## Public Types
typedef size_t | message_id

## Public Member Functions
void | append (Filter *filt)
bool | check_available (size_t n)
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
virtual std::string | id () const
message_id | message_count () const
size_t | peek (byte output[], size_t length, size_t offset) const
size_t | peek (byte output[], size_t length, size_t offset, message_id msg) const
size_t | peek (byte &output, size_t offset, message_id msg=DEFAULT_MESSAGE) const
size_t | peek_byte (byte &out) const
| Pipe (Filter *=0, Filter *=0, Filter *=0, Filter *=0)
| Pipe (Filter *filters[], size_t count)
void | pop ()
void | prepend (Filter *filt)
void | process_msg (const byte in[], size_t length)
void | process_msg (const MemoryRegion< byte > &in)
void | process_msg (const std::string &in)
void | process_msg (DataSource &in)
size_t | read (byte output[], size_t length)
size_t | read (byte output[], size_t length, message_id msg)
size_t | read (byte &output, message_id msg=DEFAULT_MESSAGE)
SecureVector< byte > | read_all (message_id msg=DEFAULT_MESSAGE)
std::string | read_all_as_string (message_id=DEFAULT_MESSAGE)
size_t | read_byte (byte &out)
size_t | remaining (message_id msg=DEFAULT_MESSAGE) const
void | reset ()
void | set_default_msg (message_id msg)
void | start_msg ()
void | write (const byte in[], size_t length)
void | write (const MemoryRegion< byte > &in)
void | write (const std::string &in)
void | write (DataSource &in)
void | write (byte 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 25 of file pipe.h.

## Member Typedef Documentation

## ◆ message_id

typedef size_t Botan::Pipe::message_id

An opaque type that identifies a message in this Pipe

Definition at line 31 of file pipe.h.

## Constructor & Destructor Documentation

## ◆ Pipe() [1/2]

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

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

Definition at line 34 of file pipe.cpp.

References append().

35 {
36 init();
37 append(f1);
38 append(f2);
39 append(f3);
40 append(f4);
41 }
Botan::Pipe::append
void append(Filter *filt)
Definition: pipe.cpp:215

## ◆ Pipe() [2/2]

Botan::Pipe::Pipe | ( | Filter * | filters[],
|  | size_t | count
| ) |  |

Construct a Pipe from range of filters passed as an array

Parameters

  filters | the set of filters to use
  count | the number of elements in filters

Definition at line 46 of file pipe.cpp.

References append().

47 {
48 init();
49 for(size_t j = 0; j != count; ++j)
50 append(filter_array[j]);
51 }
Botan::Pipe::append
void append(Filter *filt)
Definition: pipe.cpp:215

## ◆ ~Pipe()

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

Definition at line 56 of file pipe.cpp.

57 {
58 destruct(pipe);
59 delete outputs;
60 }

## Member Function Documentation

## ◆ append()

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

Insert a new filter at the back of the pipe

Parameters

  filt | the new filter to insert

Definition at line 215 of file pipe.cpp.

Referenced by Pipe(), Botan::Record_Writer::set_keys(), Botan::Record_Reader::set_keys(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().

216 {
217 if(inside_msg)
218 throw Invalid_State("Cannot append to a Pipe while it is processing");
219 if(!filter)
220 return;
221 if(dynamic_cast<SecureQueue*>(filter))
222 throw Invalid_Argument("Pipe::append: SecureQueue cannot be used");
223 if(filter->owned)
224 throw Invalid_Argument("Filters cannot be shared among multiple Pipes");
225
226 filter->owned = true;
227
228 if(!pipe) pipe = filter;
229 else pipe->attach(filter);
230 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

## ◆ check_available()

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

Implements Botan::DataSource.

Definition at line 143 of file pipe_rw.cpp.

144 {
145 return (n <= remaining(DEFAULT_MESSAGE));
146 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
Definition: pipe_rw.cpp:138
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:57

## ◆ check_available_msg()

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

Definition at line 148 of file pipe_rw.cpp.

149 {
150 return (n <= remaining(msg));
151 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
Definition: pipe_rw.cpp:138

## ◆ default_msg()

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

Returns
  currently set default message

Definition at line 209 of file pipe.h.

Referenced by read_all(), read_all_as_string(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().

209 { return default_read; }

## ◆ discard_next()

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 35 of file data_src.cpp.

36 {
37 size_t discarded = 0;
38 byte dummy;
39 for(size_t j = 0; j != n; ++j)
40 discarded += read_byte(dummy);
41 return discarded;
42 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::DataSource::read_byte
size_t read_byte(byte &out)
Definition: data_src.cpp:19

## ◆ end_msg()

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

End the current message.

Definition at line 166 of file pipe.cpp.

References Botan::Output_Buffers::retire().

Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), and process_msg().

167 {
168 if(!inside_msg)
169 throw Invalid_State("Pipe::end_msg: Message was already ended");
170 pipe->finish_msg();
171 clear_endpoints(pipe);
172 if(dynamic_cast<Null_Filter*>(pipe))
173 {
174 delete pipe;
175 pipe = 0;
176 }
177 inside_msg = false;
178
179 outputs->retire();
180 }
Botan::Output_Buffers::retire
void retire()
Definition: out_buf.cpp:66

## ◆ end_of_data()

bool Botan::Pipe::end_of_data | ( |  | ) | const
| 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 98 of file pipe.cpp.

References remaining().

99 {
100 return (remaining() == 0);
101 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
Definition: pipe_rw.cpp:138

## ◆ id()

virtual std::string Botan::DataSource::id | ( |  | ) | const
| inlinevirtualinherited

return the id of this data source

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

Reimplemented in Botan::DataSource_Stream, and Botan::DataSource_Command.

Definition at line 57 of file data_src.h.

57 { return ""; }

## ◆ message_count()

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 282 of file pipe.cpp.

References Botan::Output_Buffers::message_count().

Referenced by set_default_msg(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().

283 {
284 return outputs->message_count();
285 }
Botan::Output_Buffers::message_count
Pipe::message_id message_count() const
Definition: out_buf.cpp:99

## ◆ peek() [1/3]

size_t Botan::Pipe::peek | ( | byte | output[],
|  | size_t | length,
|  | size_t | offset
| ) |  | const
| 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 165 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

Referenced by peek().

166 {
167 return peek(output, length, offset, DEFAULT_MESSAGE);
168 }
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:57
Botan::Pipe::peek
size_t peek(byte output[], size_t length, size_t offset) const
Definition: pipe_rw.cpp:165

## ◆ peek() [2/3]

size_t Botan::Pipe::peek | ( | byte | 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 156 of file pipe_rw.cpp.

References Botan::Output_Buffers::peek().

158 {
159 return outputs->peek(output, length, offset, get_message_no("peek", msg));
160 }
Botan::Output_Buffers::peek
size_t peek(byte[], size_t, size_t, Pipe::message_id) const
Definition: out_buf.cpp:29

## ◆ peek() [3/3]

size_t Botan::Pipe::peek | ( | byte & | 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 173 of file pipe_rw.cpp.

References peek().

174 {
175 return peek(&out, 1, offset, msg);
176 }
Botan::Pipe::peek
size_t peek(byte output[], size_t length, size_t offset) const
Definition: pipe_rw.cpp:165

## ◆ peek_byte()

size_t Botan::DataSource::peek_byte | ( | byte & | 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 27 of file data_src.cpp.

References Botan::DataSource::peek().

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

28 {
29 return peek(&out, 1, 0);
30 }
Botan::DataSource::peek
virtual size_t peek(byte out[], size_t length, size_t peek_offset) const =0

## ◆ pop()

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

Remove the first filter at the front of the pipe.

Definition at line 255 of file pipe.cpp.

256 {
257 if(inside_msg)
258 throw Invalid_State("Cannot pop off a Pipe while it is processing");
259
260 if(!pipe)
261 return;
262
263 if(pipe->total_ports() > 1)
264 throw Invalid_State("Cannot pop off a Filter with multiple ports");
265
266 Filter* f = pipe;
267 size_t owns = f->owns();
268 pipe = pipe->next[0];
269 delete f;
270
271 while(owns--)
272 {
273 f = pipe;
274 pipe = pipe->next[0];
275 delete f;
276 }
277 }

## ◆ prepend()

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

Insert a new filter at the front of the pipe

Parameters

  filt | the new filter to insert

Definition at line 235 of file pipe.cpp.

236 {
237 if(inside_msg)
238 throw Invalid_State("Cannot prepend to a Pipe while it is processing");
239 if(!filter)
240 return;
241 if(dynamic_cast<SecureQueue*>(filter))
242 throw Invalid_Argument("Pipe::prepend: SecureQueue cannot be used");
243 if(filter->owned)
244 throw Invalid_Argument("Filters cannot be shared among multiple Pipes");
245
246 filter->owned = true;
247
248 if(pipe) filter->attach(pipe);
249 pipe = filter;
250 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

## ◆ process_msg() [1/4]

void Botan::Pipe::process_msg | ( | const byte | 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 116 of file pipe.cpp.

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

Referenced by Botan::aont_unpackage(), Botan::CMS_Encoder::compress(), Botan::CryptoBox::decrypt(), Botan::PEM_Code::encode(), Botan::Record_Reader::get_record(), Botan::PGP_encode(), and process_msg().

117 {
118 start_msg();
119 write(input, length);
120 end_msg();
121 }
Botan::Pipe::start_msg
void start_msg()
Definition: pipe.cpp:152
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34
Botan::Pipe::end_msg
void end_msg()
Definition: pipe.cpp:166

## ◆ process_msg() [2/4]

void Botan::Pipe::process_msg | ( | const MemoryRegion< byte > & | in | ) |

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

Parameters

  in | the MemoryRegion containing the data to write

Definition at line 126 of file pipe.cpp.

References process_msg(), and Botan::MemoryRegion< T >::size().

127 {
128 process_msg(&input[0], input.size());
129 }
Botan::Pipe::process_msg
void process_msg(const byte in[], size_t length)
Definition: pipe.cpp:116

## ◆ process_msg() [3/4]

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 134 of file pipe.cpp.

References process_msg().

135 {
136 process_msg(reinterpret_cast<const byte*>(input.data()), input.length());
137 }
Botan::Pipe::process_msg
void process_msg(const byte in[], size_t length)
Definition: pipe.cpp:116

## ◆ process_msg() [4/4]

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 142 of file pipe.cpp.

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

143 {
144 start_msg();
145 write(input);
146 end_msg();
147 }
Botan::Pipe::start_msg
void start_msg()
Definition: pipe.cpp:152
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34
Botan::Pipe::end_msg
void end_msg()
Definition: pipe.cpp:166

## ◆ read() [1/3]

size_t Botan::Pipe::read | ( | byte | output[],
|  | size_t | length
| ) |  |
| 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 89 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

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

90 {
91 return read(output, length, DEFAULT_MESSAGE);
92 }
Botan::Pipe::read
size_t read(byte output[], size_t length)
Definition: pipe_rw.cpp:89
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:57

## ◆ read() [2/3]

size_t Botan::Pipe::read | ( | byte | 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 81 of file pipe_rw.cpp.

References Botan::Output_Buffers::read().

82 {
83 return outputs->read(output, length, get_message_no("read", msg));
84 }
Botan::Output_Buffers::read
size_t read(byte[], size_t, Pipe::message_id)
Definition: out_buf.cpp:17

## ◆ read() [3/3]

size_t Botan::Pipe::read | ( | byte & | 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 97 of file pipe_rw.cpp.

References read().

98 {
99 return read(&out, 1, msg);
100 }
Botan::Pipe::read
size_t read(byte output[], size_t length)
Definition: pipe_rw.cpp:89

## ◆ read_all()

SecureVector< byte > 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
  SecureVector holding the contents of the pipe

Definition at line 105 of file pipe_rw.cpp.

References DEFAULT_MESSAGE, default_msg(), read(), remaining(), Botan::MemoryRegion< T >::resize(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::CMS_Encoder::compress(), Botan::PEM_Code::decode(), Botan::Record_Reader::get_record(), and Botan::PGP_decode().

106 {
107 msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
108 SecureVector<byte> buffer(remaining(msg));
109 size_t got = read(&buffer[0], buffer.size(), msg);
110 buffer.resize(got);
111 return buffer;
112 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
Definition: pipe_rw.cpp:138
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:209
Botan::Pipe::read
size_t read(byte output[], size_t length)
Definition: pipe_rw.cpp:89
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:57

## ◆ read_all_as_string()

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 117 of file pipe_rw.cpp.

References DEFAULT_MESSAGE, default_msg(), read(), remaining(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::CryptoBox::decrypt(), Botan::PEM_Code::encode(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), and Botan::PGP_encode().

118 {
119 msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
120 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
121 std::string str;
122 str.reserve(remaining(msg));
123
124 while(true)
125 {
126 size_t got = read(&buffer[0], buffer.size(), msg);
127 if(got == 0)
128 break;
129 str.append(reinterpret_cast<const char*>(&buffer[0]), got);
130 }
131
132 return str;
133 }
Botan::Pipe::remaining
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
Definition: pipe_rw.cpp:138
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:209
Botan::Pipe::read
size_t read(byte output[], size_t length)
Definition: pipe_rw.cpp:89
Botan::Pipe::DEFAULT_MESSAGE
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:57

## ◆ read_byte()

size_t Botan::DataSource::read_byte | ( | byte & | 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 19 of file data_src.cpp.

References Botan::DataSource::read().

Referenced by Botan::PEM_Code::decode(), Botan::BER_Decoder::discard_remaining(), Botan::PGP_decode(), and Botan::BER_Decoder::raw_bytes().

20 {
21 return read(&out, 1);
22 }
Botan::DataSource::read
virtual size_t read(byte out[], size_t length)=0

## ◆ remaining()

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 138 of file pipe_rw.cpp.

References Botan::Output_Buffers::remaining().

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

139 {
140 return outputs->remaining(get_message_no("remaining", msg));
141 }
Botan::Output_Buffers::remaining
size_t remaining(Pipe::message_id) const
Definition: out_buf.cpp:42

## ◆ reset()

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

Reset this pipe to an empty pipe.

Definition at line 76 of file pipe.cpp.

Referenced by Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::Record_Writer::reset(), Botan::Record_Reader::reset(), Botan::Record_Writer::set_keys(), and Botan::Record_Reader::set_keys().

77 {
78 destruct(pipe);
79 pipe = 0;
80 inside_msg = false;
81 }

## ◆ set_default_msg()

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 106 of file pipe.cpp.

References message_count().

Referenced by Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().

107 {
108 if(msg >= message_count())
109 throw Invalid_Argument("Pipe::set_default_msg: msg number is too high");
110 default_read = msg;
111 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::Pipe::message_count
message_id message_count() const
Definition: pipe.cpp:282

## ◆ start_msg()

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 152 of file pipe.cpp.

Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), process_msg(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().

153 {
154 if(inside_msg)
155 throw Invalid_State("Pipe::start_msg: Message was already started");
156 if(pipe == 0)
157 pipe = new Null_Filter;
158 find_endpoints(pipe);
159 pipe->new_msg();
160 inside_msg = true;
161 }

## ◆ write() [1/5]

void Botan::Pipe::write | ( | const byte | 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 34 of file pipe_rw.cpp.

References Botan::Filter::write().

Referenced by Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::EAC1_1_gen_CVC< EAC1_1_Req >::encode(), Botan::EAC1_1_ADO::encode(), Botan::X509_Object::encode(), Botan::operator>>(), Botan::PGP_decode(), process_msg(), Botan::PBE_PKCS5v15::write(), Botan::PBE_PKCS5v20::write(), and write().

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

## ◆ write() [2/5]

void Botan::Pipe::write | ( | const MemoryRegion< byte > & | in | ) |

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

Parameters

  in | the MemoryRegion containing the data to write

Definition at line 44 of file pipe_rw.cpp.

References Botan::MemoryRegion< T >::size(), and write().

45 {
46 write(&input[0], input.size());
47 }
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

## ◆ write() [3/5]

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 52 of file pipe_rw.cpp.

References write().

53 {
54 write(reinterpret_cast<const byte*>(str.data()), str.size());
55 }
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

## ◆ write() [4/5]

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 68 of file pipe_rw.cpp.

References Botan::DataSource::end_of_data(), Botan::DataSource::read(), Botan::MemoryRegion< T >::size(), and write().

69 {
70 SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
71 while(!source.end_of_data())
72 {
73 size_t got = source.read(&buffer[0], buffer.size());
74 write(&buffer[0], got);
75 }
76 }
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

## ◆ write() [5/5]

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

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

Parameters

  in | a single byte to be written

Definition at line 60 of file pipe_rw.cpp.

References write().

61 {
62 write(&input, 1);
63 }
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

## Member Data Documentation

## ◆ DEFAULT_MESSAGE

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 57 of file pipe.h.

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

## ◆ LAST_MESSAGE

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 52 of file pipe.h.

Referenced by Botan::Record_Reader::get_record().

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

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