GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
oct-fstrm.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 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
38class fstream : public base_stream
39{
40public:
41
42 fstream (const std::string& nm_arg,
43 std::ios::openmode arg_md = std::ios::in | std::ios::out,
44 mach_info::float_format flt_fmt = mach_info::native_float_format ());
45
46 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (fstream)
47
48 static stream
49 create (const std::string& nm_arg,
50 std::ios::openmode arg_md = std::ios::in | std::ios::out,
51 mach_info::float_format flt_fmt = mach_info::native_float_format ());
52
53 // Position a stream at OFFSET relative to ORIGIN.
54
55 int seek (off_t offset, int origin);
56
57 // Return current stream position.
58
59 off_t tell ();
60
61 // Return nonzero if EOF has been reached on this stream.
62
63 bool eof () const;
64
65 void do_close ();
66
67 // The name of the file.
68
69 std::string name () const { return m_name; }
70
71 std::istream * input_stream ();
72
73 std::ostream * output_stream ();
74
75protected:
76
77 ~fstream () = default;
78
79private:
80
81 std::string m_name;
82
83 std::fstream m_fstream;
84};
85
86OCTAVE_END_NAMESPACE(octave)
87
88#endif
std::string name() const
Definition oct-fstrm.h:69
~fstream()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn