GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-fstrm.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_oct_fstrm_h)
24 #define octave_oct_fstrm_h 1
25 
26 #include <fstream>
27 #include <string>
28 
29 #include "oct-stream.h"
30 
31 class
33 {
34 public:
35 
36  octave_fstream (const std::string& nm_arg,
37  std::ios::openmode arg_md = std::ios::in|std::ios::out,
40 
41  static octave_stream
42  create (const std::string& nm_arg,
43  std::ios::openmode arg_md = std::ios::in|std::ios::out,
46 
47  // Position a stream at OFFSET relative to ORIGIN.
48 
49  int seek (off_t offset, int origin);
50 
51  // Return current stream position.
52 
53  off_t tell (void);
54 
55  // Return non-zero if EOF has been reached on this stream.
56 
57  bool eof (void) const;
58 
59  void do_close (void);
60 
61  // The name of the file.
62 
63  std::string name (void) const { return nm; }
64 
65  std::istream *input_stream (void);
66 
67  std::ostream *output_stream (void);
68 
69 protected:
70 
71  ~octave_fstream (void) { }
72 
73 private:
74 
75  std::string nm;
76 
77  std::fstream fs;
78 
79  // No copying!
80 
82 
83  octave_fstream& operator = (const octave_fstream&);
84 };
85 
86 #endif