Core/Stream: Add MemoryMapped stream options (allowing for direct memory access)
This commit is contained in:
@@ -42,13 +42,26 @@ namespace Nz
|
||||
*/
|
||||
|
||||
MemoryView::MemoryView(const void* ptr, UInt64 size) :
|
||||
Stream(StreamOption::None, OpenMode::ReadOnly),
|
||||
Stream(StreamOption::MemoryMapped, OpenMode::ReadOnly),
|
||||
m_ptr(static_cast<UInt8*>(const_cast<void*>(ptr))), //< Okay, right, const_cast is bad, but this pointer is still read-only
|
||||
m_pos(0),
|
||||
m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Flushes the stream
|
||||
*/
|
||||
void MemoryView::FlushStream()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void* MemoryView::GetMemoryMappedPointer() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the size of the raw memory
|
||||
* \return Size of the memory
|
||||
@@ -59,15 +72,6 @@ namespace Nz
|
||||
return m_size;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Flushes the stream
|
||||
*/
|
||||
|
||||
void MemoryView::FlushStream()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Reads blocks
|
||||
* \return Number of blocks read
|
||||
@@ -100,15 +104,6 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the position of the cursor
|
||||
* \return Position of the cursor
|
||||
*/
|
||||
UInt64 MemoryView::TellStreamCursor() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the stream reached the end of the stream
|
||||
* \return true if cursor is at the end of the stream
|
||||
@@ -118,6 +113,15 @@ namespace Nz
|
||||
return m_pos >= m_size;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the position of the cursor
|
||||
* \return Position of the cursor
|
||||
*/
|
||||
UInt64 MemoryView::TellStreamCursor() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Writes blocks
|
||||
* \return Number of blocks written
|
||||
|
||||
Reference in New Issue
Block a user