oct-fstrm.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_octave_fstream_h)
00024 #define octave_octave_fstream_h 1
00025 
00026 #include <fstream>
00027 #include <string>
00028 
00029 #include "oct-stream.h"
00030 
00031 class
00032 octave_fstream : public octave_base_stream
00033 {
00034 public:
00035 
00036   octave_fstream (const std::string& nm_arg,
00037                   std::ios::openmode arg_md = std::ios::in|std::ios::out,
00038                   oct_mach_info::float_format flt_fmt
00039                     = oct_mach_info::native_float_format ());
00040 
00041   static octave_stream
00042   create (const std::string& nm_arg,
00043           std::ios::openmode arg_md = std::ios::in|std::ios::out,
00044           oct_mach_info::float_format flt_fmt
00045             = oct_mach_info::native_float_format ());
00046 
00047   // Position a stream at OFFSET relative to ORIGIN.
00048 
00049   int seek (long offset, int origin);
00050 
00051   // Return current stream position.
00052 
00053   long tell (void);
00054 
00055   // Return non-zero if EOF has been reached on this stream.
00056 
00057   bool eof (void) const;
00058 
00059   void do_close (void);
00060 
00061   // The name of the file.
00062 
00063   std::string name (void) const { return nm; }
00064 
00065   std::istream *input_stream (void);
00066 
00067   std::ostream *output_stream (void);
00068 
00069 protected:
00070 
00071   ~octave_fstream (void) { }
00072 
00073 private:
00074 
00075   std::string nm;
00076 
00077   std::fstream fs;
00078 
00079   // No copying!
00080 
00081   octave_fstream (const octave_fstream&);
00082 
00083   octave_fstream& operator = (const octave_fstream&);
00084 };
00085 
00086 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines