GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-iostrm.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 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 (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <istream>
31 #include <ostream>
32 
33 #include "error.h"
34 #include "oct-iostrm.h"
35 
37 
38 // Position a stream at OFFSET relative to ORIGIN.
39 
40 int
41 base_iostream::seek (off_t, int)
42 {
44  return -1;
45 }
46 
47 // Return current stream position.
48 
49 off_t
51 {
53  return -1;
54 }
55 
56 // Return nonzero if EOF has been reached on this stream.
57 
58 bool
59 base_iostream::eof (void) const
60 {
62  return false;
63 }
64 
65 void
67 {
68  // Note: use ::error to get error from error.h which halts operation.
69  ::error ("%s: invalid operation", stream_type ());
70 }
71 
72 // Return nonzero if EOF has been reached on this stream.
73 
74 bool
75 istream::eof (void) const
76 {
77  return m_istream && m_istream->eof ();
78 }
79 
80 octave::stream
81 istream::create (std::istream *arg, const std::string& n)
82 {
83  return octave::stream (new istream (arg, n));
84 }
85 
86 // Return nonzero if EOF has been reached on this stream.
87 
88 bool
89 ostream::eof (void) const
90 {
91  return m_ostream && m_ostream->eof ();
92 }
93 
94 octave::stream
95 ostream::create (std::ostream *arg, const std::string& n)
96 {
97  return octave::stream (new ostream (arg, n));
98 }
99 
OCTAVE_END_NAMESPACE(octave)
off_t tell(void)
Definition: oct-iostrm.cc:50
int seek(off_t offset, int origin)
Definition: oct-iostrm.cc:41
bool eof(void) const
Definition: oct-iostrm.cc:59
void invalid_operation(void) const
Definition: oct-iostrm.cc:66
virtual const char * stream_type(void) const =0
std::string error(bool clear, int &err_num)
Definition: oct-stream.cc:6115
bool eof(void) const
Definition: oct-iostrm.cc:75
std::istream * m_istream
Definition: oct-iostrm.h:113
static stream create(std::istream *arg=nullptr, const std::string &n="")
Definition: oct-iostrm.cc:81
static stream create(std::ostream *arg, const std::string &n="")
Definition: oct-iostrm.cc:95
bool eof(void) const
Definition: oct-iostrm.cc:89
std::ostream * m_ostream
Definition: oct-iostrm.h:151
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave_idx_type n
Definition: mx-inlines.cc:753