Panda3D
Public Member Functions | Public Attributes | List of all members
DatagramOutputFile Class Reference

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

Inheritance diagram for DatagramOutputFile:
DatagramSink

Public Member Functions

 __init__ ()
 
 close ()
 Closes the file. More...
 
bool open (const FileReference file)
 Opens the indicated filename for writing. More...
 
bool open (const Filename filename)
 Opens the indicated filename for writing. More...
 
bool open (Ostream out, const Filename filename)
 Starts writing to the indicated stream. More...
 
bool writeHeader (str header)
 Writes a sequence of bytes to the beginning of the datagram file. More...
 
- Public Member Functions inherited from DatagramSink
bool copyDatagram (SubfileInfo result, const Filename filename)
 Copies the file data from the entire indicated file (via the vfs) as the next datagram. More...
 
bool copyDatagram (SubfileInfo result, const SubfileInfo source)
 Copies the file data from the range of the indicated file (outside of the vfs) as the next datagram. More...
 
 flush ()
 
const FileReference getFile ()
 Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk. More...
 
const Filename getFilename ()
 Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk. More...
 
Streamoff 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...
 
bool isError ()
 
bool putDatagram (const Datagram data)
 

Public Attributes

Ostream stream
 Returns the ostream represented by the output file. More...
 
- Public Attributes inherited from DatagramSink
const FileReference file
 Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk. More...
 
Streamoff file_pos
 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...
 
const Filename filename
 Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk. More...
 

Detailed Description

This class can be used to write 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 DatagramOutputFile destructs.

◆ open() [1/3]

bool open ( const FileReference  file)

Opens the indicated filename for writing.

Returns true if successful, false on failure.

◆ open() [2/3]

bool open ( const Filename  filename)

Opens the indicated filename for writing.

Returns true on success, false on failure.

◆ open() [3/3]

bool open ( Ostream  out,
const Filename  filename 
)

Starts writing to the indicated stream.

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

◆ writeHeader()

bool writeHeader ( str  header)

Writes a sequence of bytes to 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 written. It may not be called once the first datagram is written.

Member Data Documentation

◆ stream

Ostream stream

Returns the ostream represented by the output file.