Panda3D
Public Member Functions | Public Attributes
Ramfile Class Reference

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

#include "ramfile.h"

List of all members.

Public Member Functions

void clear ()
 Empties the current buffer contents.
const string & get_data () const
 Returns the entire buffer contents as a string, regardless of the current data pointer.
size_t get_data_size () const
 Returns the size of the entire buffer contents.
string read (size_t length)
 Extracts and returns the indicated number of characters from the current data pointer, and advances the data pointer.
string readline ()
 Assumes the stream represents a text file, and extracts one line up to and including the trailing newline character.
void seek (size_t pos)
 Moves the data pointer to the indicated byte position.
size_t tell () const
 Returns the current data pointer position as a byte offset from the beginning of the stream.

Public Attributes

string _data
size_t _pos

Detailed Description

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

Definition at line 27 of file ramfile.h.


Member Function Documentation

void Ramfile::clear ( ) [inline]

Empties the current buffer contents.

Definition at line 75 of file ramfile.I.

const string & Ramfile::get_data ( ) const [inline]

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

Definition at line 55 of file ramfile.I.

size_t Ramfile::get_data_size ( ) const [inline]

Returns the size of the entire buffer contents.

Definition at line 65 of file ramfile.I.

string Ramfile::read ( 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.

Definition at line 29 of file ramfile.cxx.

string Ramfile::readline ( )

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.

Definition at line 48 of file ramfile.cxx.

void Ramfile::seek ( size_t  pos) [inline]

Moves the data pointer to the indicated byte position.

It is not an error to move the pointer past the end of data.

Definition at line 33 of file ramfile.I.

size_t Ramfile::tell ( ) const [inline]

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

Definition at line 44 of file ramfile.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations