mirror of https://github.com/OpenMW/openmw.git
Add generic StreamWithBuffer owning the underlying buffer
parent
9d6d0c6ffb
commit
c94d8be7bf
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef OPENMW_COMPONENTS_FILES_STREAMWITHBUFFER_H
|
||||||
|
#define OPENMW_COMPONENTS_FILES_STREAMWITHBUFFER_H
|
||||||
|
|
||||||
|
#include <istream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Files
|
||||||
|
{
|
||||||
|
template <class Buffer>
|
||||||
|
class StreamWithBuffer final : public std::istream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit StreamWithBuffer(std::unique_ptr<Buffer>&& buffer)
|
||||||
|
: std::istream(buffer.get())
|
||||||
|
, mBuffer(std::move(buffer))
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<Buffer> mBuffer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue