2017-11-01 20:14:23 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
/* MEMORY STREAMS *************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2017-11-01 22:07:41 +01:00
|
|
|
#ifndef _H_EBCL_MEMORYSTREAMS
|
|
|
|
#define _H_EBCL_MEMORYSTREAMS
|
|
|
|
#include <ebcl/Streams.hh>
|
|
|
|
namespace ebcl {
|
2017-11-01 20:14:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
class T_MemoryInputStream final : public A_InputStream
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint8_t const* buffer_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
T_MemoryInputStream( ) = delete;
|
|
|
|
T_MemoryInputStream( void const* buffer , size_t size );
|
|
|
|
|
|
|
|
T_MemoryInputStream( T_MemoryInputStream const& other ) noexcept;
|
|
|
|
friend void swap( T_MemoryInputStream& lhs , T_MemoryInputStream& rhs ) noexcept;
|
|
|
|
|
|
|
|
T_MemoryInputStream& operator= ( T_MemoryInputStream const& other ) noexcept;
|
|
|
|
|
|
|
|
template< int S , typename T >
|
|
|
|
explicit T_MemoryInputStream( T_FixedBuffer< S , T > const& buffer );
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
explicit T_MemoryInputStream( T_Buffer< T > const& buffer );
|
|
|
|
|
|
|
|
size_t read( void* data , size_t size ) override;
|
|
|
|
};
|
|
|
|
M_CLASS_POINTERS( MemoryInputStream );
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
class T_MemoryOutputStream final : public A_OutputStream
|
|
|
|
{
|
|
|
|
typedef std::function< uint8_t*( uint8_t* , size_t ) > F_Resizer;
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t* buffer_;
|
|
|
|
F_Resizer resizer_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
T_MemoryOutputStream( ) = delete;
|
|
|
|
|
|
|
|
T_MemoryOutputStream( void* buffer , size_t size , F_Resizer resizer = nullptr );
|
2020-03-08 13:12:43 +01:00
|
|
|
T_MemoryOutputStream( T_MemoryOutputStream&& source ) noexcept;
|
2017-11-01 20:14:23 +01:00
|
|
|
|
|
|
|
template< int S , typename T >
|
|
|
|
explicit T_MemoryOutputStream( T_FixedBuffer< S , T >& buffer );
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
explicit T_MemoryOutputStream( T_Buffer< T >& buffer );
|
|
|
|
|
|
|
|
size_t write( void const* data , size_t size ) override;
|
|
|
|
};
|
|
|
|
M_CLASS_POINTERS( MemoryOutputStream );
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2017-11-01 22:07:41 +01:00
|
|
|
#include <ebcl/inline/MemoryStreams.hh>
|
|
|
|
#endif // _H_EBCL_MEMORYSTREAMS
|