Panda3D
Public Member Functions | List of all members
DatagramInputFile Class Reference

This class can be used to read a binary file that consists of an arbitrary header followed by a number of datagrams. More...

Inheritance diagram for DatagramInputFile:
DatagramGenerator

Public Member Functions

 __init__ ()
 
 close ()
 Closes the file. This is also implicitly done when the DatagramInputFile destructs. More...
 
Istream getStream ()
 Returns the istream represented by the input file. More...
 
bool open (const FileReference file)
 Opens the indicated filename for reading. Returns true on success, false on failure. More...
 
bool open (const Filename filename)
 Opens the indicated filename for reading. Returns true on success, false on failure. More...
 
bool open (Istream in, const Filename filename)
 Starts reading from the indicated stream. Returns true on success, false on failure. The DatagramInputFile does not take ownership of the stream; you are responsible for closing or deleting it when you are done. More...
 
bool readHeader (String header, size_t num_bytes)
 Reads a sequence of bytes from the beginning of the datagram file. This may be called any number of times after the file has been opened and before the first datagram is read. It may not be called once the first datagram has been read. More...
 
- Public Member Functions inherited from DatagramGenerator
bool getDatagram (Datagram data)
 
const FileReference getFile ()
 Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a file on disk. More...
 
const Filename getFilename ()
 Returns the filename that provides the source for these datagrams, if any, or empty string if the datagrams do not originate from a file on disk. More...
 
Streampos getFilePos ()
 Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined. More...
 
time_t getTimestamp ()
 Returns the on-disk timestamp of the file that was read, at the time it was opened, if that is available, or 0 if it is not. More...
 
VirtualFile getVfile ()
 Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a VirtualFile. More...
 
bool isEof ()
 
bool isError ()
 
bool saveDatagram (SubfileInfo info)
 Skips over the next datagram without extracting it, but saves the relevant file information in the SubfileInfo object so that its data may be read later. For non-file-based datagram generators, this may mean creating a temporary file and copying the contents of the datagram to disk. More...
 

Detailed Description

This class can be used to read a binary file that consists of an arbitrary header followed by a number of datagrams.

Member Function Documentation

◆ __init__()

__init__ ( )

◆ close()

close ( )

Closes the file. This is also implicitly done when the DatagramInputFile destructs.

◆ getStream()

Istream getStream ( )

Returns the istream represented by the input file.

◆ open() [1/3]

bool open ( const FileReference  file)

Opens the indicated filename for reading. Returns true on success, false on failure.

◆ open() [2/3]

bool open ( const Filename  filename)

Opens the indicated filename for reading. Returns true on success, false on failure.

◆ open() [3/3]

bool open ( Istream  in,
const Filename  filename 
)

Starts reading from the indicated stream. Returns true on success, false on failure. The DatagramInputFile does not take ownership of the stream; you are responsible for closing or deleting it when you are done.

◆ readHeader()

bool readHeader ( String  header,
size_t  num_bytes 
)

Reads a sequence of bytes from the beginning of the datagram file. This may be called any number of times after the file has been opened and before the first datagram is read. It may not be called once the first datagram has been read.