00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1999, 2001, 2002, 2005, 2006, 2008 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef LIBAEGIS_OUTPUT_FILE_H 00021 #define LIBAEGIS_OUTPUT_FILE_H 00022 00023 #include <common/nstring.h> 00024 #include <libaegis/output.h> 00025 00026 struct nstring; // forward 00027 00032 class output_file: 00033 public output 00034 { 00035 public: 00039 virtual ~output_file(); 00040 00041 private: 00052 output_file(const nstring &file_name, bool binary = false); 00053 00054 public: 00064 static output::pointer open(const nstring &fn, bool binary = false); 00065 00073 static inline output::pointer 00074 text_open(string_ty *fn) 00075 { 00076 return open(nstring(fn), false); 00077 } 00078 00086 static inline output::pointer 00087 text_open(const nstring &fn) 00088 { 00089 return open(fn, false); 00090 } 00091 00099 inline static output::pointer 00100 binary_open(string_ty *fn) 00101 { 00102 return open(nstring(fn), true); 00103 } 00104 00112 inline static output::pointer 00113 binary_open(const nstring &fn) 00114 { 00115 return open(fn, true); 00116 } 00117 00118 protected: 00119 // See base class for documentation. 00120 nstring filename() const; 00121 00122 // See base class for documentation. 00123 const char *type_name() const; 00124 00125 // See base class for documentation. 00126 long ftell_inner() const; 00127 00128 // See base class for documentation. 00129 void write_inner(const void *data, size_t length); 00130 00131 // See base class for documentation. 00132 void end_of_line_inner(); 00133 00134 // See base class for documentation. 00135 int page_width() const; 00136 00137 // See base class for documentation. 00138 int page_length() const; 00139 00140 private: 00145 nstring file_name; 00146 00151 int fd; 00152 00157 bool bol; 00158 00163 size_t pos; 00164 00168 output_file(); 00169 00173 output_file(const output_file &); 00174 00178 output_file &operator=(const output_file &); 00179 }; 00180 00181 #endif // LIBAEGIS_OUTPUT_FILE_H