Class View

Class Documentation

class View

Represents a window into random-access storage. This window can be any size (including the encompassing the entire storage) and start at any offset in the storage (the end of the View will never run off the end of the storage, so a non-zero offset will imply a View that is less in size than the size of the Storage).

Public Functions

virtual ~View()
virtual bool Resize(size_t size, SizeType offset = (SizeType)-1) = 0

Move the mapping window, optionally changing its size.

Note

Reasons the resize could fail include, but not limited to:

  • size exceeds the limits of the storage or of the system (for example, in 32-bit applications, an attempt to set the window size at 2GiB or greater will fail)

  • offset outside the bounds of the storage

  • offset would place the requested size (considering defaults if none provided) outside the bounds of the underlying storage

Parameters
  • size -- Size of the mapping window in bytes.

  • offset -- Start the mapping window this number of bytes from the start of the open storage.

Returns

True if the resize operation succeeded, false otherwise.

virtual bool Valid() const = 0

Communicates the validity of the View; if this method ever returns false, the holder may as well call Unmap() with this View to dispose of it, as the View is no longer useful.

void *Base() const

Access the base address of this View mapping.

size_t Size() const

Access the size (in bytes) of the mapping.

SizeType Offset() const

Access the offset (in bytes) of the mapping from the beginning of the underlying storage.

void *OffsetToAddress(SizeType offset) const

Convenience method to convert an offset into the mapping into an address.

void *operator[](SizeType offset) const

Convenience indexing operator; see OffsetToAddress.

Protected Attributes

void *mBase
size_t mSize
SizeType mOffset