GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-fstrm.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_oct_fstrm_h)
27 #define octave_oct_fstrm_h 1
28 
29 #include "octave-config.h"
30 
31 #include <fstream>
32 #include <string>
33 
34 #include "oct-stream.h"
35 
36 class
38 {
39 public:
40 
41  octave_fstream (const std::string& nm_arg,
42  std::ios::openmode arg_md = std::ios::in | std::ios::out,
45 
46  // No copying!
47 
48  octave_fstream (const octave_fstream&) = delete;
49 
50  octave_fstream& operator = (const octave_fstream&) = delete;
51 
52  static octave::stream
53  create (const std::string& nm_arg,
54  std::ios::openmode arg_md = std::ios::in | std::ios::out,
57 
58  // Position a stream at OFFSET relative to ORIGIN.
59 
60  int seek (off_t offset, int origin);
61 
62  // Return current stream position.
63 
64  off_t tell (void);
65 
66  // Return nonzero if EOF has been reached on this stream.
67 
68  bool eof (void) const;
69 
70  void do_close (void);
71 
72  // The name of the file.
73 
74  std::string name (void) const { return m_name; }
75 
76  std::istream * input_stream (void);
77 
78  std::ostream * output_stream (void);
79 
80 protected:
81 
82  ~octave_fstream (void) = default;
83 
84 private:
85 
86  std::string m_name;
87 
89 };
90 
91 #endif
octave_fstream(const octave_fstream &)=delete
std::string name(void) const
Definition: oct-fstrm.h:74
std::string m_name
Definition: oct-fstrm.h:86
~octave_fstream(void)=default
std::fstream m_fstream
Definition: oct-fstrm.h:88
float_format native_float_format(void)
Definition: mach-info.cc:65
std::fstream fstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:367