39 lines
934 B
C++
39 lines
934 B
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: IStreamReader.hpp
|
|
Date: 2021-6-10
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::IO
|
|
{
|
|
class IStreamReader
|
|
{
|
|
public:
|
|
virtual EStreamError Open() = 0;
|
|
virtual EStreamError Read(void *buffer, AuUInt32 &len) = 0;
|
|
virtual void Close() = 0;
|
|
|
|
EStreamError ReadAll(AuList<AuUInt8> &buffer)
|
|
{
|
|
static const int kBufferSize = 2048;
|
|
AuUInt8 temp[kBufferSize];
|
|
|
|
AuUInt32 len = kBufferSize;
|
|
EStreamError ret = EStreamError::eErrorEndOfStream;
|
|
|
|
while ((ret = Read(temp, len)) == EStreamError::eErrorNone)
|
|
{
|
|
if (len == 0) break;
|
|
|
|
buffer.insert(buffer.end(), temp, temp + len);
|
|
|
|
if (len != kBufferSize) break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
};
|
|
} |