Botan  1.10.9
Public Member Functions | List of all members
Botan::DataSource Class Referenceabstract

#include <data_src.h>

Inheritance diagram for Botan::DataSource:
Botan::DataSource_Command Botan::DataSource_Memory Botan::DataSource_Stream Botan::Pipe Botan::SecureQueue

Public Member Functions

 DataSource ()
 
size_t discard_next (size_t N)
 
virtual bool end_of_data () const =0
 
virtual std::string id () const
 
virtual size_t peek (byte out[], size_t length, size_t peek_offset) const =0
 
size_t peek_byte (byte &out) const
 
virtual size_t read (byte out[], size_t length)=0
 
size_t read_byte (byte &out)
 
virtual ~DataSource ()
 

Detailed Description

This class represents an abstract data source object.

Definition at line 20 of file data_src.h.

Constructor & Destructor Documentation

Botan::DataSource::DataSource ( )
inline

Definition at line 82 of file data_src.h.

82 {}
virtual Botan::DataSource::~DataSource ( )
inlinevirtual

Definition at line 83 of file data_src.h.

83 {}

Member Function Documentation

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

Discard the next N bytes of the data

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

Definition at line 35 of file data_src.cpp.

References n, and read_byte().

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  }
BigInt n
Definition: numthry.cpp:26
unsigned char byte
Definition: types.h:22
size_t read_byte(byte &out)
Definition: data_src.cpp:19
virtual bool Botan::DataSource::end_of_data ( ) const
pure virtual

Test whether the source still has data that can be read.

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

Implemented in Botan::Pipe, Botan::DataSource_Stream, Botan::DataSource_Memory, Botan::DataSource_Command, and Botan::SecureQueue.

Referenced by Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::more_items(), Botan::BER_Decoder::verify_end(), and Botan::Pipe::write().

virtual std::string Botan::DataSource::id ( ) const
inlinevirtual

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 ""; }
virtual size_t Botan::DataSource::peek ( byte  out[],
size_t  length,
size_t  peek_offset 
) const
pure virtual

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

Parameters
outthe byte array to write the output to
lengththe length of the byte array out
peek_offsetthe offset into the stream to read at
Returns
length in bytes that was actually read and put into out

Implemented in Botan::Pipe, Botan::DataSource_Stream, Botan::DataSource_Memory, Botan::DataSource_Command, and Botan::SecureQueue.

Referenced by Botan::PEM_Code::matches(), and peek_byte().

size_t Botan::DataSource::peek_byte ( byte out) const

Peek at one byte.

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

Definition at line 27 of file data_src.cpp.

References peek().

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

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

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

Parameters
outthe byte array to write the result to
lengththe length of the byte array out
Returns
length in bytes that was actually read and put into out

Implemented in Botan::Pipe, Botan::DataSource_Stream, Botan::DataSource_Memory, Botan::DataSource_Command, and Botan::SecureQueue.

Referenced by Botan::BER_Decoder::get_next_object(), read_byte(), and Botan::Pipe::write().

size_t Botan::DataSource::read_byte ( byte out)

Read one byte.

Parameters
outthe 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 read().

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

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

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