Botan

DataSource

License
Botan is released under the Simplified BSD License (see LICENSE.md)

interface  DataSourceImpl;

This class represents an abstract data source object.


abstract size_t  read(ubyte* output, size_t length);

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

Parameters
ubyte* output the ubyte array to write the result to
size_t length the length of the ubyte array out
Returns
length in bytes that was actually  read and put into out

abstract const size_t  peek(ubyte* output, size_t length, size_t peek_offset);

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
ubyte* output the ubyte array to write the output to
size_t length the length of the ubyte array out
size_t peek_offset the offset into the stream to read at
Returns
length in bytes that was actually read and put into out

abstract const bool  endOfData();

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

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

abstract const string  id();

return the  id of this data source

Returns
string representing the  id of this data source

final size_t  readByte(ref ubyte output);

Read one ubyte.

Parameters
ubyte output the ubyte to read to
Returns
length in bytes that was actually read and put into out

final const size_t  peekByte(ref ubyte output);

Peek at one ubyte.

Parameters
ubyte output an output ubyte
Returns
length in bytes that was actually read and put into out

final size_t  discardNext(size_t n);

Discard the next N bytes of the data

Parameters
size_t n the number of bytes to discard
Returns
number of bytes actually discarded

abstract const size_t  getBytesRead();

Returns
number of bytes read so far.

class  DataSourceMemoryImpl: botan.filters.data_src.DataSourceImpl;

This class represents a Memory-Based DataSource


this(in string input);

Construct a memory source that reads from a string

Parameters
string input the string to read from

this(const(ubyte)* input, size_t length);

Construct a memory source that reads from a ubyte array

Parameters
const(ubyte)* input the ubyte array to read from
size_t length the length of the ubyte array

this(T, ALLOC)(auto ref const RefCounted!(Vector!(T, ALLOC), ALLOC) input);

Construct a memory source that reads from a referenced vector

Parameters
RefCounted!(Vector!(T, ALLOC), ALLOC) input the MemoryRegion to read from

this(T, ALLOC)(auto ref const Vector!(T, ALLOC) input);

Construct a memory source that reads from a vector

Parameters
Vector!(T, ALLOC) input the MemoryRegion to read from

this(T, ALLOC)(const Vector!(T, ALLOC)* input);

Construct a memory source that reads from a vector*

Parameters
Vector!(T, ALLOC)* input the MemoryRegion to read from

class  DataSourceStreamImpl: botan.filters.data_src.DataSourceImpl;

This class represents a Stream-Based DataSource.


this(in string path, bool use_binary = false);

Construct a Stream-Based DataSource from file

Parameters
string path the name of the file
bool use_binary whether to treat the file as binary or not