Class RandomAccessSerializer

Inheritance Relationships

Base Types

Class Documentation

class RandomAccessSerializer : public gpa::serialization::MemoryBackedSerializer, public gpa::serialization::StorageListener

Implement MemoryBackedSerializer in terms of Storage (specifically, in terms of the RandomAccessStorage subclass)

Public Functions

RandomAccessSerializer(stream::RandomAccessStorage *storage)

RandomAccessSerializer (ctor)

Parameters

storage -- Pointer to Storage representing a valid RandomAccessStorage instance. This property is not checked internally (other than by assert that is only active in Debug builds) and if the Storage provided is not of type RandomAccessStorage, the behavior is undefined.

~RandomAccessSerializer()
virtual size_t WriteRawData(void const *src, size_t size) override

Writes the given raw data to the underlying data stream.

virtual size_t ReadRawData(void *dst, size_t size) override

Reads raw data from the current position in the underlying data stream into the given destination.

virtual bool EnsureWriteCapacity(size_t const size) override

Ensures that there is enough space available for writing to the underlying data stream.

Returns

false if no space of the given size could be made available

virtual bool CheckAvailableData(size_t const size) const override

Checks if data is available for reading in the underlying data stream.

Returns

true if data of the given size is available, false otherwise.

virtual void Clear() override

Resets the underlying memory stream such that it behaves as an empty one.

virtual bool Seek(int64_t offset, SeekOrigin origin = SeekOrigin::kBegin) override

Seeks to the offset in the buffer in bytes.

The offset is based on the given seek origin. A positive number is forward, a negative is backward. If the requested offset is out-of-bounds, the current position is unchanged.

Returns

true on success and the current position is changed. TODO : allow Seek to resize buffer if outside buffer range

virtual size_t GetPosition() const override

Returns the offset the current read/write cursor is at.

virtual uint64_t GetAbsolutePosition() const override

Access the offset of the current read/write cursor relative to the beginning of the underlying storage.

virtual void *Get(uint64_t offset) const override

Return a pointer to the address referenced by offset, relative to the start of the underlying storage.

Parameters

offset -- Offset of memory address relative to start of storage

Returns

If the offset refers to memory within the bounds of the storage as visible to the process, then the method returns a pointer to that memory; nullptr otherwise.

stream::SizeType GetAbsoluteOffset() const

Access the absolute offset of the current pointer into the underlying storage.

Returns

Number of bytes of current pointer offset into underlying storage

stream::SizeType GetAbsoluteWriteOffset() const

Access the absolute offset of the write pointer into the underlying storage.

Returns

Number of bytes of write pointer offset into underlying storage

virtual void OnClose() override

See also

StorageListener::Close