41 lines
No EOL
716 B
C++
41 lines
No EOL
716 B
C++
#pragma once
|
|
|
|
#include "Vector.h"
|
|
#include "Stream.h"
|
|
|
|
template<typename T>
|
|
class InputStream : public Stream
|
|
{
|
|
public:
|
|
virtual bool get(T& item) = 0;
|
|
|
|
virtual int get(Vector<T>& items)
|
|
{
|
|
size_t count = 0;
|
|
T item;
|
|
while(good() && count < items.size())
|
|
{
|
|
if (const auto ok = get(item); !ok)
|
|
{
|
|
break;
|
|
}
|
|
items[count] = item;
|
|
count++;
|
|
}
|
|
if (has_error())
|
|
{
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
return count;
|
|
}
|
|
}
|
|
};
|
|
|
|
template<typename T>
|
|
class OutputStream : public Stream
|
|
{
|
|
public:
|
|
virtual int write(T* data, size_t size) = 0;
|
|
}; |