9 #include <botan/data_src.h>
10 #include <botan/exceptn.h>
29 return peek(&out, 1, 0);
39 for(
size_t j = 0; j !=
n; ++j)
49 size_t got = std::min<size_t>(source.
size() - offset, length);
59 size_t peek_offset)
const
61 const size_t bytes_left = source.
size() - offset;
62 if(peek_offset >= bytes_left)
return 0;
64 size_t got = std::min(bytes_left - peek_offset, length);
65 copy_mem(out, &source[offset + peek_offset], got);
74 return (offset == source.
size());
99 source(reinterpret_cast<const
byte*>(in.data()), in.length())
109 source.read(reinterpret_cast<char*>(out), length);
113 size_t got = source.gcount();
124 throw Invalid_State(
"DataSource_Stream: Cannot peek when out of data");
131 source.read(reinterpret_cast<char*>(&buf[0]), buf.
size());
134 got = source.gcount();
139 source.read(reinterpret_cast<char*>(out), length);
142 got = source.gcount();
147 source.seekg(total_read, std::ios::beg);
157 return (!source.good());
174 source_p(new
std::ifstream(
176 use_binary ?
std::ios::binary :
std::ios::in)),
191 const std::string& name) :
size_t peek(byte[], size_t, size_t) const
virtual size_t read(byte out[], size_t length)=0
size_t peek_byte(byte &out) const
size_t discard_next(size_t N)
virtual size_t peek(byte out[], size_t length, size_t peek_offset) const =0
DataSource_Stream(std::istream &, const std::string &id="<std::istream>")
size_t peek(byte[], size_t, size_t) const
size_t read_byte(byte &out)
void copy_mem(T *out, const T *in, size_t n)
size_t read(byte[], size_t)
DataSource_Memory(const std::string &in)
size_t read(byte[], size_t)