Panda3D
datagramOutputFile.I
1 // Filename: datagramOutputFile.I
2 // Created by: drose (27Oct00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: DatagramOutputFile::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE DatagramOutputFile::
22 DatagramOutputFile() {
23  _error = false;
24  _wrote_first_datagram = false;
25  _out = (ostream *)NULL;
26  _owns_out = false;
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: DatagramOutputFile::Destructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE DatagramOutputFile::
35 ~DatagramOutputFile() {
36  close();
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: DatagramOutputFile::open
41 // Access: Published
42 // Description: Opens the indicated filename for writing. Returns
43 // true on success, false on failure.
44 ////////////////////////////////////////////////////////////////////
45 INLINE bool DatagramOutputFile::
46 open(const Filename &filename) {
47  return open(new FileReference(filename));
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: DatagramOutputFile::get_stream
52 // Access: Published
53 // Description: Returns the ostream represented by the output file.
54 ////////////////////////////////////////////////////////////////////
55 INLINE ostream &DatagramOutputFile::
57  static ofstream null_stream;
58  nassertr(_out != NULL, null_stream);
59  return *_out;
60 }
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:29
bool open(const FileReference *file)
Opens the indicated filename for writing.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
ostream & get_stream()
Returns the ostream represented by the output file.
void close()
Closes the file.