Botan  2.1.0
Crypto and TLS for C++11
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:
Botan::DataSource

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) 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
 
Pipeoperator= (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 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=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 27 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 33 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 34 of file pipe.cpp.

References append().

35  {
36  init();
37  append(f1);
38  append(f2);
39  append(f3);
40  append(f4);
41  }
void append(Filter *filt)
Definition: pipe.cpp:221
Botan::Pipe::Pipe ( std::initializer_list< Filter * >  filters)
explicit

Construct a Pipe from a list of filters

Parameters
filtersthe set of filters to use

Definition at line 46 of file pipe.cpp.

References append().

47  {
48  init();
49 
50  for(auto i = args.begin(); i != args.end(); ++i)
51  append(*i);
52  }
void append(Filter *filt)
Definition: pipe.cpp:221
Botan::Pipe::Pipe ( const Pipe )
delete
Botan::Pipe::~Pipe ( )

Definition at line 57 of file pipe.cpp.

58  {
59  destruct(m_pipe);
60  delete m_outputs;
61  }

Member Function Documentation

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

Insert a new filter at the back of the pipe

Parameters
filtthe new filter to insert

Definition at line 221 of file pipe.cpp.

Referenced by Pipe().

222  {
223  if(m_inside_msg)
224  throw Invalid_State("Cannot append to a Pipe while it is processing");
225  if(!filter)
226  return;
227  if(dynamic_cast<SecureQueue*>(filter))
228  throw Invalid_Argument("Pipe::append: SecureQueue cannot be used");
229  if(filter->m_owned)
230  throw Invalid_Argument("Filters cannot be shared among multiple Pipes");
231 
232  filter->m_owned = true;
233 
234  if(!m_pipe) m_pipe = filter;
235  else m_pipe->attach(filter);
236  }
bool Botan::Pipe::check_available ( size_t  n)
overridevirtual

Implements Botan::DataSource.

Definition at line 170 of file pipe_rw.cpp.

References default_msg(), and remaining().

171  {
172  return (n <= remaining(default_msg()));
173  }
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:130
size_t default_msg() const
Definition: pipe.h:236
bool Botan::Pipe::check_available_msg ( size_t  n,
message_id  msg 
)

Definition at line 175 of file pipe_rw.cpp.

References remaining().

176  {
177  return (n <= remaining(msg));
178  }
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:130
size_t Botan::Pipe::default_msg ( ) const
inline
Returns
currently set default message

Definition at line 236 of file pipe.h.

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

236 { return m_default_read; }
size_t Botan::DataSource::discard_next ( size_t  N)
inherited

Discard the next N bytes of the data

Parameters
Nthe number of bytes to discard
Returns
number of bytes actually discarded

Definition at line 38 of file data_src.cpp.

References Botan::CT::min(), and Botan::DataSource::read().

39  {
40  uint8_t buf[64] = { 0 };
41  size_t discarded = 0;
42 
43  while(n)
44  {
45  const size_t got = this->read(buf, std::min(n, sizeof(buf)));
46  discarded += got;
47  n -= got;
48 
49  if(got == 0)
50  break;
51  }
52 
53  return discarded;
54  }
virtual size_t read(uint8_t out[], size_t length) BOTAN_WARN_UNUSED_RESULT=0
T min(T a, T b)
Definition: ct_utils.h:180
void Botan::Pipe::end_msg ( )

End the current message.

Definition at line 172 of file pipe.cpp.

References Botan::Output_Buffers::retire().

Referenced by process_msg().

173  {
174  if(!m_inside_msg)
175  throw Invalid_State("Pipe::end_msg: Message was already ended");
176  m_pipe->finish_msg();
177  clear_endpoints(m_pipe);
178  if(dynamic_cast<Null_Filter*>(m_pipe))
179  {
180  delete m_pipe;
181  m_pipe = nullptr;
182  }
183  m_inside_msg = false;
184 
185  m_outputs->retire();
186  }
bool Botan::Pipe::end_of_data ( ) const
overridevirtual

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

References remaining().

100  {
101  return (remaining() == 0);
102  }
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:130
size_t Botan::Pipe::get_bytes_read ( ) const
overridevirtual
Returns
the number of bytes read from the default message.

Implements Botan::DataSource.

Definition at line 160 of file pipe_rw.cpp.

References default_msg(), and Botan::Output_Buffers::get_bytes_read().

161  {
162  return m_outputs->get_bytes_read(default_msg());
163  }
size_t get_bytes_read(Pipe::message_id) const
Definition: out_buf.cpp:53
size_t default_msg() const
Definition: pipe.h:236
size_t Botan::Pipe::get_bytes_read ( message_id  msg) const
Returns
the number of bytes read from the specified message.

Definition at line 165 of file pipe_rw.cpp.

References Botan::Output_Buffers::get_bytes_read().

166  {
167  return m_outputs->get_bytes_read(msg);
168  }
size_t get_bytes_read(Pipe::message_id) const
Definition: out_buf.cpp:53
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.

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

References Botan::Output_Buffers::message_count().

Referenced by set_default_msg().

289  {
290  return m_outputs->message_count();
291  }
Pipe::message_id message_count() const
Definition: out_buf.cpp:109
Pipe& Botan::Pipe::operator= ( const Pipe )
delete
size_t Botan::Pipe::peek ( uint8_t  output[],
size_t  length,
size_t  offset 
) const
overridevirtual

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
outputthe byte array to write the peeked message part to
lengththe length of the byte array output
offsetthe offset from the current position in message
Returns
number of bytes actually peeked and written into output

Implements Botan::DataSource.

Definition at line 147 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

Referenced by peek().

148  {
149  return peek(output, length, offset, DEFAULT_MESSAGE);
150  }
size_t peek(uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:147
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:59
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
outputthe byte array to write the peeked message part to
lengththe length of the byte array output
offsetthe offset from the current position in message
msgthe number identifying the message to peek from
Returns
number of bytes actually peeked and written into output

Definition at line 138 of file pipe_rw.cpp.

References Botan::Output_Buffers::peek().

140  {
141  return m_outputs->peek(output, length, offset, get_message_no("peek", msg));
142  }
size_t peek(uint8_t[], size_t, size_t, Pipe::message_id) const
Definition: out_buf.cpp:29
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
outputthe byte to write the peeked message byte to
offsetthe offset from the current position in message
msgthe number identifying the message to peek from
Returns
number of bytes actually peeked and written into output

Definition at line 155 of file pipe_rw.cpp.

References peek().

156  {
157  return peek(&out, 1, offset, msg);
158  }
size_t peek(uint8_t output[], size_t length, size_t offset) const override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:147
size_t Botan::DataSource::peek_byte ( uint8_t &  out) const
inherited

Peek at one byte.

Parameters
outan output byte
Returns
length in bytes that was actually read and put into out

Definition at line 30 of file data_src.cpp.

References Botan::DataSource::peek().

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

31  {
32  return peek(&out, 1, 0);
33  }
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 261 of file pipe.cpp.

262  {
263  if(m_inside_msg)
264  throw Invalid_State("Cannot pop off a Pipe while it is processing");
265 
266  if(!m_pipe)
267  return;
268 
269  if(m_pipe->total_ports() > 1)
270  throw Invalid_State("Cannot pop off a Filter with multiple ports");
271 
272  Filter* f = m_pipe;
273  size_t owns = f->owns();
274  m_pipe = m_pipe->m_next[0];
275  delete f;
276 
277  while(owns--)
278  {
279  f = m_pipe;
280  m_pipe = m_pipe->m_next[0];
281  delete f;
282  }
283  }
void Botan::Pipe::prepend ( Filter filt)

Insert a new filter at the front of the pipe

Parameters
filtthe new filter to insert

Definition at line 241 of file pipe.cpp.

242  {
243  if(m_inside_msg)
244  throw Invalid_State("Cannot prepend to a Pipe while it is processing");
245  if(!filter)
246  return;
247  if(dynamic_cast<SecureQueue*>(filter))
248  throw Invalid_Argument("Pipe::prepend: SecureQueue cannot be used");
249  if(filter->m_owned)
250  throw Invalid_Argument("Filters cannot be shared among multiple Pipes");
251 
252  filter->m_owned = true;
253 
254  if(m_pipe) filter->attach(m_pipe);
255  m_pipe = filter;
256  }
void Botan::Pipe::process_msg ( const uint8_t  in[],
size_t  length 
)

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

Parameters
inthe byte array containing the data to write
lengththe length of the byte array to write

Definition at line 117 of file pipe.cpp.

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

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

118  {
119  start_msg();
120  write(input, length);
121  end_msg();
122  }
void start_msg()
Definition: pipe.cpp:158
void end_msg()
Definition: pipe.cpp:172
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:34
void Botan::Pipe::process_msg ( const secure_vector< uint8_t > &  in)

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

Parameters
inthe secure_vector containing the data to write

Definition at line 127 of file pipe.cpp.

References process_msg().

128  {
129  process_msg(input.data(), input.size());
130  }
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:117
void Botan::Pipe::process_msg ( const std::vector< uint8_t > &  in)

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

Parameters
inthe secure_vector containing the data to write

Definition at line 132 of file pipe.cpp.

References process_msg().

133  {
134  process_msg(input.data(), input.size());
135  }
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:117
void Botan::Pipe::process_msg ( const std::string &  in)

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

Parameters
inthe string containing the data to write

Definition at line 140 of file pipe.cpp.

References process_msg().

141  {
142  process_msg(reinterpret_cast<const uint8_t*>(input.data()), input.length());
143  }
void process_msg(const uint8_t in[], size_t length)
Definition: pipe.cpp:117
void Botan::Pipe::process_msg ( DataSource in)

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

Parameters
inthe DataSource providing the data to write

Definition at line 148 of file pipe.cpp.

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

149  {
150  start_msg();
151  write(input);
152  end_msg();
153  }
void start_msg()
Definition: pipe.cpp:158
void end_msg()
Definition: pipe.cpp:172
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:34
size_t Botan::Pipe::read ( uint8_t  output[],
size_t  length 
)
overridevirtual

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
outputthe byte array to write the read bytes to
lengththe length of the byte array output
Returns
number of bytes actually read into output

Implements Botan::DataSource.

Definition at line 81 of file pipe_rw.cpp.

References DEFAULT_MESSAGE.

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

82  {
83  return read(output, length, DEFAULT_MESSAGE);
84  }
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:81
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:59
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
outputthe byte array to write the read bytes to
lengththe length of the byte array output
msgthe number identifying the message to read from
Returns
number of bytes actually read into output

Definition at line 73 of file pipe_rw.cpp.

References Botan::Output_Buffers::read().

74  {
75  return m_outputs->read(output, length, get_message_no("read", msg));
76  }
size_t read(uint8_t[], size_t, Pipe::message_id)
Definition: out_buf.cpp:17
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
outputthe byte to write the result to
msgthe message to read from
Returns
number of bytes actually read into output

Definition at line 89 of file pipe_rw.cpp.

References read().

90  {
91  return read(&out, 1, msg);
92  }
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:81
secure_vector< uint8_t > Botan::Pipe::read_all ( message_id  msg = DEFAULT_MESSAGE)

Read the full contents of the pipe.

Parameters
msgthe number identifying the message to read from
Returns
secure_vector holding the contents of the pipe

Definition at line 97 of file pipe_rw.cpp.

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

98  {
99  msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
100  secure_vector<uint8_t> buffer(remaining(msg));
101  size_t got = read(buffer.data(), buffer.size(), msg);
102  buffer.resize(got);
103  return buffer;
104  }
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:130
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:81
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:59
size_t default_msg() const
Definition: pipe.h:236
std::string Botan::Pipe::read_all_as_string ( message_id  msg = DEFAULT_MESSAGE)

Read the full contents of the pipe.

Parameters
msgthe number identifying the message to read from
Returns
string holding the contents of the pipe

Definition at line 109 of file pipe_rw.cpp.

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

Referenced by Botan::CryptoBox::decrypt().

110  {
111  msg = ((msg != DEFAULT_MESSAGE) ? msg : default_msg());
112  secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE);
113  std::string str;
114  str.reserve(remaining(msg));
115 
116  while(true)
117  {
118  size_t got = read(buffer.data(), buffer.size(), msg);
119  if(got == 0)
120  break;
121  str.append(reinterpret_cast<const char*>(buffer.data()), got);
122  }
123 
124  return str;
125  }
size_t remaining(message_id msg=DEFAULT_MESSAGE) const BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:130
size_t read(uint8_t output[], size_t length) override BOTAN_WARN_UNUSED_RESULT
Definition: pipe_rw.cpp:81
static const message_id DEFAULT_MESSAGE
Definition: pipe.h:59
size_t default_msg() const
Definition: pipe.h:236
size_t Botan::DataSource::read_byte ( uint8_t &  out)
inherited

Read one byte.

Parameters
outthe byte to read to
Returns
length in bytes that was actually read and put into out

Definition at line 22 of file data_src.cpp.

References Botan::DataSource::read().

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

23  {
24  return read(&out, 1);
25  }
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
msgthe number identifying the message for which the information is desired
Returns
number of bytes that can still be read

Definition at line 130 of file pipe_rw.cpp.

References Botan::Output_Buffers::remaining().

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

131  {
132  return m_outputs->remaining(get_message_no("remaining", msg));
133  }
size_t remaining(Pipe::message_id) const
Definition: out_buf.cpp:42
void Botan::Pipe::reset ( )

Reset this pipe to an empty pipe.

Definition at line 77 of file pipe.cpp.

78  {
79  destruct(m_pipe);
80  m_pipe = nullptr;
81  m_inside_msg = false;
82  }
void Botan::Pipe::set_default_msg ( message_id  msg)

Set the default message

Parameters
msgthe number identifying the message which is going to be the new default message

Definition at line 107 of file pipe.cpp.

References message_count().

108  {
109  if(msg >= message_count())
110  throw Invalid_Argument("Pipe::set_default_msg: msg number is too high");
111  m_default_read = msg;
112  }
message_id message_count() const
Definition: pipe.cpp:288
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 158 of file pipe.cpp.

Referenced by process_msg().

159  {
160  if(m_inside_msg)
161  throw Invalid_State("Pipe::start_msg: Message was already started");
162  if(m_pipe == nullptr)
163  m_pipe = new Null_Filter;
164  find_endpoints(m_pipe);
165  m_pipe->new_msg();
166  m_inside_msg = true;
167  }
void Botan::Pipe::write ( const uint8_t  in[],
size_t  length 
)

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

Parameters
inthe byte array to write
lengththe length of the byte array in

Definition at line 34 of file pipe_rw.cpp.

References Botan::Filter::write().

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

35  {
36  if(!m_inside_msg)
37  throw Invalid_State("Cannot write to a Pipe while it is not processing");
38  m_pipe->write(input, length);
39  }
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
inthe secure_vector containing the data to write

Definition at line 72 of file pipe.h.

73  { write(in.data(), in.size()); }
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:34
void Botan::Pipe::write ( const std::vector< uint8_t > &  in)
inline

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

Parameters
inthe std::vector containing the data to write

Definition at line 79 of file pipe.h.

80  { write(in.data(), in.size()); }
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:34
void Botan::Pipe::write ( const std::string &  in)

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

Parameters
inthe string containing the data to write

Definition at line 44 of file pipe_rw.cpp.

References write().

45  {
46  write(reinterpret_cast<const uint8_t*>(str.data()), str.size());
47  }
void write(const uint8_t in[], size_t length)
Definition: pipe_rw.cpp:34
void Botan::Pipe::write ( DataSource in)

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

Parameters
inthe DataSource to read the data from

Definition at line 60 of file pipe_rw.cpp.

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

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

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

Parameters
ina single byte to be written

Definition at line 52 of file pipe_rw.cpp.

References write().

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

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


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