io: add lval ref-qualifiers to mapped_file members

This commit is contained in:
Danny Robson 2016-06-28 14:23:42 +10:00
parent 642317f6a4
commit 0b128384eb
4 changed files with 55 additions and 52 deletions

View File

@ -79,7 +79,8 @@ mapped_file::empty (void) const
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
uint8_t* uint8_t*
mapped_file::data (void) { mapped_file::data (void) &
{
CHECK (m_size > 0); CHECK (m_size > 0);
CHECK (m_data != NULL); CHECK (m_data != NULL);
@ -89,7 +90,8 @@ mapped_file::data (void) {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::data (void) const { mapped_file::data (void) const &
{
CHECK (m_size > 0); CHECK (m_size > 0);
CHECK (m_data != NULL); CHECK (m_data != NULL);
@ -99,21 +101,23 @@ mapped_file::data (void) const {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
uint8_t* uint8_t*
mapped_file::begin (void) { mapped_file::begin (void) &
{
return data (); return data ();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
uint8_t* uint8_t*
mapped_file::end (void) { mapped_file::end (void) &
{
return data () + size (); return data () + size ();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::begin (void) const mapped_file::begin (void) const &
{ {
return data (); return data ();
} }
@ -121,7 +125,7 @@ mapped_file::begin (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::end (void) const mapped_file::end (void) const &
{ {
return data () + size (); return data () + size ();
} }
@ -129,14 +133,16 @@ mapped_file::end (void) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::cbegin (void) const { mapped_file::cbegin (void) const &
{
return data (); return data ();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::cend (void) const { mapped_file::cend (void) const &
{
return data () + size (); return data () + size ();
} }

View File

@ -35,20 +35,20 @@ namespace util {
~mapped_file (); ~mapped_file ();
const uint8_t* data (void) const;
uint8_t* data (void);
bool empty (void) const; bool empty (void) const;
size_t size (void) const; size_t size (void) const;
uint8_t* begin (void); const uint8_t* data (void) const &;
uint8_t* end (void); uint8_t* data (void) &;
const uint8_t* begin (void) const; uint8_t* begin (void) &;
const uint8_t* end (void) const; uint8_t* end (void) &;
const uint8_t* cbegin (void) const; const uint8_t* begin (void) const &;
const uint8_t* cend (void) const; const uint8_t* end (void) const &;
const uint8_t* cbegin (void) const &;
const uint8_t* cend (void) const &;
template <typename T> operator util::view<const T *restrict> () const &; template <typename T> operator util::view<const T *restrict> () const &;
template <typename T> operator util::view< T *restrict> () &; template <typename T> operator util::view< T *restrict> () &;

View File

@ -136,22 +136,6 @@ mapped_file::mapped_file (const boost::filesystem::path &path,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
const uint8_t*
mapped_file::data (void) const
{
return m_data.get ();
}
//-----------------------------------------------------------------------------
uint8_t*
mapped_file::data (void)
{
return m_data.get ();
}
//-----------------------------------------------------------------------------
size_t size_t
mapped_file::size (void) const mapped_file::size (void) const
{ {
@ -167,9 +151,25 @@ mapped_file::empty (void) const
} }
//-----------------------------------------------------------------------------
const uint8_t*
mapped_file::data (void) const &
{
return m_data.get ();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
uint8_t* uint8_t*
mapped_file::begin (void) mapped_file::data (void) &
{
return m_data.get ();
}
//-----------------------------------------------------------------------------
uint8_t*
mapped_file::begin (void) &
{ {
return data (); return data ();
} }
@ -177,7 +177,7 @@ mapped_file::begin (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
uint8_t* uint8_t*
mapped_file::end (void) mapped_file::end (void) &
{ {
return data () + size (); return data () + size ();
} }
@ -185,7 +185,7 @@ mapped_file::end (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::begin (void) const mapped_file::begin (void) const &
{ {
return cbegin (); return cbegin ();
} }
@ -193,7 +193,7 @@ mapped_file::begin (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::end (void) const mapped_file::end (void) const &
{ {
return cend (); return cend ();
} }
@ -201,7 +201,7 @@ mapped_file::end (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::cbegin (void) const mapped_file::cbegin (void) const &
{ {
return data (); return data ();
} }
@ -209,7 +209,7 @@ mapped_file::cbegin (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const uint8_t* const uint8_t*
mapped_file::cend (void) const mapped_file::cend (void) const &
{ {
return data () + size (); return data () + size ();
} }

View File

@ -45,26 +45,23 @@ namespace util {
mapped_file (const mapped_file&) = delete; mapped_file (const mapped_file&) = delete;
mapped_file& operator= (const mapped_file&) = delete; mapped_file& operator= (const mapped_file&) = delete;
const uint8_t* data (void) const;
uint8_t* data (void);
size_t size (void) const; size_t size (void) const;
bool empty (void) const; bool empty (void) const;
uint8_t* begin (void); const uint8_t* data (void) const &;
uint8_t* end (void); uint8_t* data (void) &;
const uint8_t* begin (void) const; uint8_t* begin (void) &;
const uint8_t* end (void) const; uint8_t* end (void) &;
const uint8_t* cbegin (void) const; const uint8_t* begin (void) const &;
const uint8_t* cend (void) const; const uint8_t* end (void) const &;
template <typename T> const uint8_t* cbegin (void) const &;
operator util::view<const T *restrict> () const &; const uint8_t* cend (void) const &;
template <typename T> template <typename T> operator util::view<const T *restrict> () const &;
operator util::view<T *restrict> () &; template <typename T> operator util::view< T *restrict> () &;
private: private:
::util::win32::handle m_file; ::util::win32::handle m_file;