-
Notifications
You must be signed in to change notification settings - Fork 112
/
InputObjectOstream.h
44 lines (33 loc) · 927 Bytes
/
InputObjectOstream.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_INPUTOBJECTOFSTREAM_H
#define WHITEBOX_CRYPTO_AES_INPUTOBJECTOFSTREAM_H
#include "InputObject.h"
#include <iostream>
#include <fstream>
#include <stdexcept>
template<typename T>
class InputObjectOstream : public InputObject<T>{
public:
explicit InputObjectOstream(std::ostream *os) : os(os) {}
ssize_t write(const T *buffer, size_t maxSize) override {
os->write((const char*)buffer, maxSize);
return maxSize;
}
ssize_t read(T *buffer, size_t maxSize) override {
throw std::invalid_argument("Ostream does not support read");
}
bool isGood() override {
return os->good();
}
bool eof() override {
return os->eof();
}
bool isFull() override {
return !os->good();
}
protected:
std::ostream * os;
};
#endif //WHITEBOX_CRYPTO_AES_INPUTOBJECTOFSTREAM_H