Botan: Botan::DataSource Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

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

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

`#include <data_src.h>`

Inheritance diagram for Botan::DataSource:

## Public Member Functions
virtual bool | check_available (size_t n)=0
| 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 84 of file data_src.h.

84 {}

virtual Botan::DataSource::~DataSource | ( |  | ) |
| inlinevirtual

Definition at line 85 of file data_src.h.

85 {}

## Member Function Documentation

virtual bool Botan::DataSource::check_available | ( | size_t | n | ) |
| pure virtual

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

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

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.

References 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 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::DataSource::read_byte
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::X509_Store::add_cert(), 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

  out | the byte array to write the output to
  length | the length of the byte array out
  peek_offset | the 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

  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 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

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

  out | the byte array to write the result to
  length | the 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 read_byte(), and Botan::Pipe::write().

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

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

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

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

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

- src/filters/data_src.h
- src/filters/data_src.cpp