Class StreamSerializer

Inheritance Relationships

Base Type

Class Documentation

class StreamSerializer : public gpa::serialization::MemoryBackedSerializer

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

Public Functions

StreamSerializer(Storage *storage)

StreamSerializer (ctor)

Parameters

storage -- Pointer to Storage representing a valid SequentialStorage instance. This property is not checked internally and if the Storage provided is not of type SequentialStorage, the behavior is undefined.

~StreamSerializer()
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.