Panda3D
withOutputFile.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file withOutputFile.h
10  * @author drose
11  * @date 2001-04-11
12  */
13 
14 #ifndef WITHOUTPUTFILE_H
15 #define WITHOUTPUTFILE_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "programBase.h"
20 #include "filename.h"
21 
22 /**
23  * This is the bare functionality (intended to be inherited from along with
24  * ProgramBase or some derivative) for a program that might generate an output
25  * file.
26  *
27  * This provides the has_output_filename() and get_output_filename() methods.
28  */
30 public:
31  WithOutputFile(bool allow_last_param, bool allow_stdout,
32  bool binary_output);
33  virtual ~WithOutputFile();
34 
35  std::ostream &get_output();
36  void close_output();
37  bool has_output_filename() const;
39 
40 protected:
41  INLINE void set_binary_output(bool binary_output);
42 
43  bool check_last_arg(ProgramBase::Args &args, int minimum_args);
44  bool verify_output_file_safe() const;
45 
46 protected:
47  bool _allow_last_param;
48  bool _allow_stdout;
49  bool _binary_output;
50  std::string _preferred_extension;
51  bool _got_output_filename;
52  Filename _output_filename;
53 
54 private:
55  std::ofstream _output_stream;
56  std::ostream *_output_ptr;
57  bool _owns_output_ptr;
58 };
59 
60 #include "withOutputFile.I"
61 
62 #endif
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This is the bare functionality (intended to be inherited from along with ProgramBase or some derivati...
Filename get_output_filename() const
If has_output_filename() returns true, this is the filename that the user specified.
void close_output()
Closes the output stream previously opened by get_output().
bool has_output_filename() const
Returns true if the user specified an output filename, false otherwise (e.g.
std::ostream & get_output()
Returns an output stream that corresponds to the user's intended egg file output–either stdout,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.