00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef WITHOUTPUTFILE_H
00016 #define WITHOUTPUTFILE_H
00017
00018 #include "pandatoolbase.h"
00019
00020 #include "programBase.h"
00021 #include "filename.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class WithOutputFile {
00034 public:
00035 WithOutputFile(bool allow_last_param, bool allow_stdout,
00036 bool binary_output);
00037 virtual ~WithOutputFile();
00038
00039 ostream &get_output();
00040 void close_output();
00041 bool has_output_filename() const;
00042 Filename get_output_filename() const;
00043
00044 protected:
00045 INLINE void set_binary_output(bool binary_output);
00046
00047 bool check_last_arg(ProgramBase::Args &args, int minimum_args);
00048 bool verify_output_file_safe() const;
00049
00050 protected:
00051 bool _allow_last_param;
00052 bool _allow_stdout;
00053 bool _binary_output;
00054 string _preferred_extension;
00055 bool _got_output_filename;
00056 Filename _output_filename;
00057
00058 private:
00059 ofstream _output_stream;
00060 ostream *_output_ptr;
00061 bool _owns_output_ptr;
00062 };
00063
00064 #include "withOutputFile.I"
00065
00066 #endif
00067
00068