-
Notifications
You must be signed in to change notification settings - Fork 112
/
InputObjectIstream.h
44 lines (33 loc) · 968 Bytes
/
InputObjectIstream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Created by Dusan Klinec on 02.01.18.
//
#ifndef WHITEBOX_CRYPTO_AES_INPUTOBJECTIFSTREAM_H
#define WHITEBOX_CRYPTO_AES_INPUTOBJECTIFSTREAM_H
#include "InputObject.h"
#include <fstream>
#include <iostream>
#include <stdexcept>
template<typename T>
class InputObjectIstream : public InputObject<T>{
public:
explicit InputObjectIstream(std::istream *is) : is(is) {}
ssize_t write(const T *buffer, size_t maxSize) override {
throw std::invalid_argument("Istream does not support write");
}
ssize_t read(T *buffer, size_t maxSize) override {
is->read((char*)buffer, maxSize);
return is->gcount();
}
bool eof() override {
return is->eof();
}
bool isFull() override {
throw std::invalid_argument("Istream does not support write");
}
bool isGood() override {
return is->good();
}
protected:
std::istream * is;
};
#endif //WHITEBOX_CRYPTO_AES_INPUTOBJECTIFSTREAM_H