GNU Octave  9.1.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-2024 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 
37 
38 class
39 fstream : public base_stream
40 {
41 public:
42 
43  fstream (const std::string& nm_arg,
44  std::ios::openmode arg_md = std::ios::in | std::ios::out,
46 
47  OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (fstream)
48 
49  static stream
50  create (const std::string& nm_arg,
51  std::ios::openmode arg_md = std::ios::in | std::ios::out,
53 
54  // Position a stream at OFFSET relative to ORIGIN.
55 
56  int seek (off_t offset, int origin);
57 
58  // Return current stream position.
59 
60  off_t tell ();
61 
62  // Return nonzero if EOF has been reached on this stream.
63 
64  bool eof () const;
65 
66  void do_close ();
67 
68  // The name of the file.
69 
70  std::string name () const { return m_name; }
71 
72  std::istream * input_stream ();
73 
74  std::ostream * output_stream ();
75 
76 protected:
77 
78  ~fstream () = default;
79 
80 private:
81 
82  std::string m_name;
83 
84  std::fstream m_fstream;
85 };
86 
87 OCTAVE_END_NAMESPACE(octave)
88 
89 #endif
std::string name() const
Definition: oct-fstrm.h:70
~fstream()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::fstream fstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:607
float_format native_float_format()
Definition: mach-info.cc:67
float_format
Definition: mach-info.h:38