corelib/include/ebcl/inline/MemoryStreams.hh

45 lines
1.5 KiB
C++

/******************************************************************************/
/* MEMORY STREAMS - INLINE CODE ***********************************************/
/******************************************************************************/
#ifndef _H_EBCL_INLINE_MEMORYSTREAMS
#define _H_EBCL_INLINE_MEMORYSTREAMS
#include <ebcl/MemoryStreams.hh>
namespace ebcl {
/*= T_MemoryInputStream ======================================================*/
template< int S , typename T >
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 =====================================================*/
template< int S , typename T >
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
#endif // _H_EBCL_INLINE_MEMORYSTREAMS