corelib/include/ebcl/inline/Files.hh

100 lines
2.1 KiB
C++
Raw Normal View History

/******************************************************************************/
/* FILES - INLINE CODE ********************************************************/
/******************************************************************************/
2017-11-01 22:07:41 +01:00
#ifndef _H_EBCL_INLINE_FILES
#define _H_EBCL_INLINE_FILES
#include <ebcl/Files.hh>
namespace ebcl {
/*= T_File ===================================================================*/
inline T_File::~T_File( )
{
close( );
}
/*---------------------------------------------------------------------------*/
inline void swap( T_File& lhs , T_File& rhs ) noexcept
{
using std::swap;
swap( lhs.path_ , rhs.path_ );
swap( lhs.mode_ , rhs.mode_ );
swap( lhs.file_ , rhs.file_ );
swap( lhs.size_ , rhs.size_ );
swap( lhs.pos_ , rhs.pos_ );
}
/*---------------------------------------------------------------------------*/
inline T_String const& T_File::path( ) const noexcept
{
return path_;
}
inline E_FileMode T_File::mode( ) const noexcept
{
return mode_;
}
inline bool T_File::isOpen( ) const noexcept
{
return file_ != nullptr;
}
inline size_t T_File::size( ) const noexcept
{
return isOpen( ) ? size_ : 0;
}
inline size_t T_File::position( ) const noexcept
{
return isOpen( ) ? pos_ : 0;
}
/*= T_FileInputStream ========================================================*/
inline void swap( T_FileInputStream& lhs , T_FileInputStream& rhs ) noexcept
{
lhs.swap( rhs );
}
/*---------------------------------------------------------------------------*/
inline T_File& T_FileInputStream::file( ) const noexcept
{
return fileRaw_ ? *fileRaw_ : *fileOwned_;
}
inline size_t T_FileInputStream::offset( ) const noexcept
{
return start_;
}
/*= T_FileOutputStream =======================================================*/
inline void swap( T_FileOutputStream& lhs , T_FileOutputStream& rhs ) noexcept
{
lhs.swap( rhs );
}
/*---------------------------------------------------------------------------*/
inline T_File& T_FileOutputStream::file( ) const noexcept
{
return fileRaw_ ? *fileRaw_ : *fileOwned_;
}
inline size_t T_FileOutputStream::offset( ) const noexcept
{
return start_;
}
} // namespace
2017-11-01 22:07:41 +01:00
#endif // _H_EBCL_INLINE_FILES