Ramfile

class Ramfile

An in-memory buffer specifically designed for downloading files to memory.

Inheritance diagram

Inheritance diagram of Ramfile

Ramfile(void)
Ramfile(Ramfile const&) = default
void clear(void)

Empties the current buffer contents.

PyObject *get_data(void) const

Returns the entire buffer contents as a string, regardless of the current data pointer.

std::size_t get_data_size(void) const

Returns the size of the entire buffer contents.

PyObject *read(std::size_t length)

Extracts and returns the indicated number of characters from the current data pointer, and advances the data pointer. If the data pointer exceeds the end of the buffer, returns empty string.

The interface here is intentionally designed to be similar to that for Python’s file.read() function.

PyObject *readline(void)

Assumes the stream represents a text file, and extracts one line up to and including the trailing newline character. Returns empty string when the end of file is reached.

The interface here is intentionally designed to be similar to that for Python’s file.readline() function.

PyObject *readlines(void)
void seek(std::size_t pos)

Moves the data pointer to the indicated byte position. It is not an error to move the pointer past the end of data.

std::size_t tell(void) const

Returns the current data pointer position as a byte offset from the beginning of the stream.