corelib/include/ebcl/inline/Streams.hh

106 lines
2.6 KiB
C++
Raw Normal View History

/******************************************************************************/
/* STREAMS - INLINE CODE ******************************************************/
/******************************************************************************/
#ifndef _H_EBCL_INLINE_STREAMS
#define _H_EBCL_INLINE_STREAMS
#include <ebcl/Streams.hh>
namespace ebcl {
/*= X_StreamError ============================================================*/
inline X_StreamError::X_StreamError(
const E_StreamError e ,
T_Optional< T_FSPath > p ) noexcept
: std::exception( ) , error_( e ) , sysError_( -1 ) ,
path_{ std::move( p ) }
{ }
inline X_StreamError::X_StreamError( const int error ,
T_Optional< T_FSPath > p ) noexcept
: std::exception( ) , error_( E_StreamError::SYSTEM_ERROR ) ,
sysError_( error ) , path_{ std::move( p ) }
{ }
/*----------------------------------------------------------------------------*/
inline E_StreamError X_StreamError::code( ) const noexcept
{
return error_;
}
inline int X_StreamError::systemError( ) const noexcept
{
return sysError_;
}
/*= A_Stream =================================================================*/
inline A_Stream::A_Stream( bool isInput , size_t position ) noexcept
: isInput_( isInput ) , knownSize_( false ) , position_( position )
{ }
inline A_Stream::A_Stream( bool isInput , size_t position , size_t size ) noexcept
: isInput_( isInput ) , knownSize_( true ) , size_( size ) ,
position_( position )
{ }
/*----------------------------------------------------------------------------*/
inline A_Stream::~A_Stream( )
{ }
/*----------------------------------------------------------------------------*/
inline bool A_Stream::isInput( ) const
{
return isInput_;
}
inline bool A_Stream::isSizeKnown( ) const
{
return knownSize_;
}
inline size_t A_Stream::position( ) const
{
return position_;
}
inline size_t A_Stream::size( ) const
{
if ( knownSize_ ) {
return size_;
} else {
throw X_StreamError( E_StreamError::NOT_SUPPORTED );
}
}
/*= A_InputStream ============================================================*/
inline A_InputStream::A_InputStream( size_t position ) noexcept
: A_Stream( true , position )
{ }
inline A_InputStream::A_InputStream( size_t position , size_t size ) noexcept
: A_Stream( true , position , size )
{ }
/*= A_OutputStream ===========================================================*/
inline A_OutputStream::A_OutputStream( size_t position ) noexcept
: A_Stream( false , position )
{ }
inline A_OutputStream::A_OutputStream( size_t position , size_t size ) noexcept
: A_Stream( false , position , size )
{ }
} // namespace
#endif // _H_EBCL_INLINE_STREAMS