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())
106 return (n <= (source.
size() - offset));
114 source.read(reinterpret_cast<char*>(out), length);
118 size_t got = source.gcount();
125 const std::streampos orig_pos = source.tellg();
126 source.seekg(0, std::ios::end);
127 const size_t avail = source.tellg() - orig_pos;
128 source.seekg(orig_pos);
138 throw Invalid_State(
"DataSource_Stream: Cannot peek when out of data");
145 source.read(reinterpret_cast<char*>(&buf[0]), buf.
size());
148 got = source.gcount();
153 source.read(reinterpret_cast<char*>(out), length);
156 got = source.gcount();
161 source.seekg(total_read, std::ios::beg);
171 return (!source.good());
188 source_p(new
std::ifstream(
190 use_binary ?
std::ios::binary :
std::ios::in)),
205 const std::string& name) :
bool check_available(size_t n)
virtual size_t read(byte out[], size_t length)=0
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 read_byte(byte &out)
size_t peek_byte(byte &out) const
void copy_mem(T *out, const T *in, size_t n)
size_t peek(byte[], size_t, size_t) const
size_t peek(byte[], size_t, size_t) const
size_t read(byte[], size_t)
bool check_available(size_t n)
DataSource_Memory(const std::string &in)
size_t read(byte[], size_t)