Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

WithOutputFile Class Reference

This is the bare functionality (intended to be inherited from along with ProgramBase or some derivative) for a program that might generate an output file. More...

#include <withOutputFile.h>

Inheritance diagram for WithOutputFile:

EggWriter FltTrans ImageWriter EggFilter EggMakeFont EggTextureCards ImageFilter EggConverter EggCrop EggTrans ImageResize ImageTrans EggToSomething SomethingToEgg EggToBam EggToC EggToX BamToEgg FltToEgg LwoToEgg MayaToEgg XFileToEgg List of all members.

Public Member Functions

 WithOutputFile (bool allow_last_param, bool allow_stdout, bool binary_output)
virtual ~WithOutputFile ()
ostream & get_output ()
 Returns an output stream that corresponds to the user's intended egg file output--either stdout, or the named output file.

bool has_output_filename () const
 Returns true if the user specified an output filename, false otherwise (e.g.

Filename get_output_filename () const
 If has_output_filename() returns true, this is the filename that the user specified.


Protected Member Functions

bool check_last_arg (ProgramBase::Args &args, int minimum_args)
 Checks if the last filename on the argument list is a file with the expected extension (if _allow_last_param was set true), and removes it from the argument list if it is.

bool verify_output_file_safe () const
 This is called when the output file is given as the last parameter on the command line.


Protected Attributes

bool _allow_last_param
bool _allow_stdout
bool _binary_output
string _preferred_extension
bool _got_output_filename
Filename _output_filename

Private Attributes

ofstream _output_stream
ostream * _output_ptr

Detailed Description

This is the bare functionality (intended to be inherited from along with ProgramBase or some derivative) for a program that might generate an output file.

This provides the has_output_filename() and get_output_filename() methods.

Definition at line 49 of file withOutputFile.h.


Constructor & Destructor Documentation

WithOutputFile::WithOutputFile bool  allow_last_param,
bool  allow_stdout,
bool  binary_output
 

Definition at line 35 of file withOutputFile.cxx.

References NULL, and ostream.

WithOutputFile::~WithOutputFile  )  [virtual]
 

Definition at line 52 of file withOutputFile.cxx.

References _allow_stdout, _got_output_filename, _output_filename, _output_ptr, _output_stream, Filename::c_str(), Filename::make_dir(), nassertr, NULL, and ostream.


Member Function Documentation

bool WithOutputFile::check_last_arg ProgramBase::Args args,
int  minimum_args
[protected]
 

Checks if the last filename on the argument list is a file with the expected extension (if _allow_last_param was set true), and removes it from the argument list if it is.

Returns true if the arguments are good, false if something is invalid.

minimum_args is the number of arguments we know must be input parameters and therefore cannot be interpreted as output filenames.

Definition at line 159 of file withOutputFile.cxx.

References _got_output_filename, _output_filename, Filename::exists(), nassertr, and nout.

Referenced by EggWriter::post_process_egg_file(), and ImageWriter::write_image().

ostream & WithOutputFile::get_output  ) 
 

Returns an output stream that corresponds to the user's intended egg file output--either stdout, or the named output file.

Definition at line 68 of file withOutputFile.cxx.

References _output_filename, and Filename::set_binary().

Filename WithOutputFile::get_output_filename  )  const
 

If has_output_filename() returns true, this is the filename that the user specified.

Otherwise, it returns the empty string.

Definition at line 127 of file withOutputFile.cxx.

References _allow_last_param, _allow_stdout, _got_output_filename, _output_filename, _preferred_extension, Filename::from_os_specific(), Filename::get_extension(), nout, and verify_output_file_safe().

bool WithOutputFile::has_output_filename  )  const
 

Returns true if the user specified an output filename, false otherwise (e.g.

the output file is implicitly stdout).

Definition at line 110 of file withOutputFile.cxx.

bool WithOutputFile::verify_output_file_safe  )  const [protected]
 

This is called when the output file is given as the last parameter on the command line.

Since this is a fairly dangerous way to specify the output file (it's easy to accidentally overwrite an input file this way), the convention is to disallow this syntax if the output file already exists.

This function will test if the output file exists, and issue a warning message if it does, returning false. If all is well, it will return true.

Definition at line 217 of file withOutputFile.cxx.

Referenced by get_output_filename().


Member Data Documentation

bool WithOutputFile::_allow_last_param [protected]
 

Definition at line 64 of file withOutputFile.h.

Referenced by get_output_filename().

bool WithOutputFile::_allow_stdout [protected]
 

Definition at line 65 of file withOutputFile.h.

Referenced by get_output_filename(), and ~WithOutputFile().

bool WithOutputFile::_binary_output [protected]
 

Definition at line 66 of file withOutputFile.h.

bool WithOutputFile::_got_output_filename [protected]
 

Definition at line 68 of file withOutputFile.h.

Referenced by SomethingToEgg::apply_parameters(), check_last_arg(), FltTrans::FltTrans(), get_output_filename(), EggWriter::post_process_egg_file(), and ~WithOutputFile().

Filename WithOutputFile::_output_filename [protected]
 

Definition at line 69 of file withOutputFile.h.

Referenced by SomethingToEgg::apply_parameters(), check_last_arg(), FltTrans::FltTrans(), get_output(), get_output_filename(), EggWriter::post_process_egg_file(), and ~WithOutputFile().

ostream* WithOutputFile::_output_ptr [private]
 

Reimplemented in EggWriter.

Definition at line 73 of file withOutputFile.h.

Referenced by ~WithOutputFile().

ofstream WithOutputFile::_output_stream [private]
 

Reimplemented in EggWriter.

Definition at line 72 of file withOutputFile.h.

Referenced by ~WithOutputFile().

string WithOutputFile::_preferred_extension [protected]
 

Definition at line 67 of file withOutputFile.h.

Referenced by FltTrans::FltTrans(), and get_output_filename().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:28:08 2003 for Panda-Tool by doxygen1.3