2017-11-01 20:14:23 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
/* MEMORY STREAMS - INLINE CODE ***********************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2017-11-01 22:07:41 +01:00
|
|
|
#ifndef _H_EBCL_INLINE_MEMORYSTREAMS
|
|
|
|
#define _H_EBCL_INLINE_MEMORYSTREAMS
|
|
|
|
#include <ebcl/MemoryStreams.hh>
|
|
|
|
namespace ebcl {
|
2017-11-01 20:14:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*= T_MemoryInputStream ======================================================*/
|
|
|
|
|
2020-09-27 11:04:00 +02:00
|
|
|
template< size_t S , typename T >
|
2017-11-01 20:14:23 +01:00
|
|
|
inline T_MemoryInputStream::T_MemoryInputStream( T_FixedBuffer< S , T > const& buffer )
|
|
|
|
: T_MemoryInputStream( buffer.data( ) , buffer.bytes( ) )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
inline T_MemoryInputStream::T_MemoryInputStream( T_Buffer< T > const& buffer )
|
|
|
|
: T_MemoryInputStream( buffer.data( ) , buffer.bytes( ) )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
/*= T_MemoryOutputStream =====================================================*/
|
|
|
|
|
2020-09-27 11:04:00 +02:00
|
|
|
template< size_t S , typename T >
|
2017-11-01 20:14:23 +01:00
|
|
|
inline T_MemoryOutputStream::T_MemoryOutputStream( T_FixedBuffer< S , T >& buffer )
|
|
|
|
: T_MemoryOutputStream( buffer.data( ) , buffer.bytes( ) )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
inline T_MemoryOutputStream::T_MemoryOutputStream( T_Buffer< T >& buffer )
|
|
|
|
: T_MemoryOutputStream( buffer.data( ) , buffer.bytes( ) ,
|
|
|
|
[&buffer] ( uint8_t* , size_t reqSize ) -> uint8_t*
|
|
|
|
{
|
|
|
|
const size_t mod( reqSize % sizeof( T ) );
|
|
|
|
const size_t nItems( reqSize / sizeof( T ) + ( mod ? 1 : 0 ) );
|
|
|
|
buffer.resize( nItems );
|
|
|
|
return buffer.data( );
|
|
|
|
} )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2017-11-01 22:07:41 +01:00
|
|
|
#endif // _H_EBCL_INLINE_MEMORYSTREAMS
|