annotate libinterp/corefcn/oct-stream.h @ 31363:af38813e5b89

build: Silence unused private field compilation warning in oct-stream.h (bug #63210) * oct-stream.h (class base_stream): Add FIXME note about compilation warning. Comment out private field declaration for "m_converter".
author Rik <rik@octave.org>
date Sat, 29 Oct 2022 18:07:10 -0700
parents 0826c503f294
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30429
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20465
diff changeset
26 #if ! defined (octave_oct_stream_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17787
diff changeset
27 #define octave_oct_stream_h 1
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
30
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
31 #include <ios>
8950
d865363208d6 include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
32 #include <iosfwd>
21475
4f3e63d75f33 use std::deque instead of Array to hold scanf and printf format elements
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
33 #include <list>
4f3e63d75f33 use std::deque instead of Array to hold scanf and printf format elements
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
34 #include <map>
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
35 #include <memory>
2877
5c1b9e545dd1 [project @ 1997-04-24 09:07:39 by jwe]
jwe
parents: 2847
diff changeset
36 #include <string>
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
37
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
38 #include "oct-string.h"
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
39
21477
4fc04d04dd9c make printf and scanf format element and list objects private
John W. Eaton <jwe@octave.org>
parents: 21475
diff changeset
40 // These only appear as reference arguments or return values.
4fc04d04dd9c make printf and scanf format element and list objects private
John W. Eaton <jwe@octave.org>
parents: 21475
diff changeset
41
21503
20bf0ec536e2 integrate textscan more completely with octave_stream class
John W. Eaton <jwe@octave.org>
parents: 21502
diff changeset
42 class Cell;
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
43 class octave_value;
21502
7a19c5678f91 move textscan class to oct-stream.cc and textscan function to file-io.cc
John W. Eaton <jwe@octave.org>
parents: 21477
diff changeset
44 class octave_value_list;
21477
4fc04d04dd9c make printf and scanf format element and list objects private
John W. Eaton <jwe@octave.org>
parents: 21475
diff changeset
45 class string_vector;
4fc04d04dd9c make printf and scanf format element and list objects private
John W. Eaton <jwe@octave.org>
parents: 21475
diff changeset
46
30429
e38202d3628d provide header file for forward declaration of Array<T> template
John W. Eaton <jwe@octave.org>
parents: 29655
diff changeset
47 #include "Array-fwd.h"
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2225
diff changeset
48 #include "data-conv.h"
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 2225
diff changeset
49 #include "mach-info.h"
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
50
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
51 namespace octave
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
52 {
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
53 class interpreter;
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
54
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
55 // These are only needed as arguments to private functions, so they
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
56 // are also treated as private.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
57
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
58 class scanf_format_elt;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
59 class scanf_format_list;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
60
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
61 class printf_format_elt;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
62 class printf_format_list;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
63
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
64 // Provide an interface for Octave streams.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
65
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
66 class
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
67 OCTINTERP_API
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
68 base_stream
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
69 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
70 friend class stream;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
71
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
72 public:
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
73
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
74 base_stream (std::ios::openmode arg_md = std::ios::in | std::ios::out,
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
75 mach_info::float_format ff = mach_info::native_float_format (),
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
76 const std::string& encoding = "utf-8")
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
77 : m_mode (arg_md), m_flt_fmt (ff), m_encoding (encoding),
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
78 m_conv_ostream (nullptr), m_fail (false), m_open_state (true),
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
79 m_errmsg ()
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
80 { }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
81
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
82 // No copying!
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
83
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
84 base_stream (const base_stream&) = delete;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
85
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
86 base_stream& operator = (const base_stream&) = delete;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
87
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
88 virtual ~base_stream (void) = default;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
89
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
90 // The remaining functions are not specific to input or output only,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
91 // and must be provided by the derived classes.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
92
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
93 // Position a stream at OFFSET relative to ORIGIN.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
94
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
95 virtual int seek (off_t offset, int origin) = 0;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
96
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
97 // Return current stream position.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
98
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
99 virtual off_t tell (void) = 0;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
100
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
101 // Return TRUE if EOF has been reached on this stream.
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
102
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
103 virtual bool eof (void) const = 0;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
104
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
105 // The name of the file.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
106
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
107 virtual std::string name (void) const = 0;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
108
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
109 // If the derived class provides this function and it returns a
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
110 // pointer to a valid istream, scanf(), read(), getl(), and gets()
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
111 // will automatically work for this stream.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
112
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23738
diff changeset
113 virtual std::istream * input_stream (void) { return nullptr; }
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
114
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
115 // If the derived class provides this function and it returns a
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
116 // pointer to a valid ostream, flush(), write(), and printf() will
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
117 // automatically work for this stream.
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
118
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23738
diff changeset
119 virtual std::ostream * output_stream (void) { return nullptr; }
3652
25e84fcef38a [project @ 2000-03-31 08:50:48 by jwe]
jwe
parents: 3642
diff changeset
120
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
121 // Return either the original output stream or one wrapped with the
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
122 // encoding facet.
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
123
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
124 std::ostream * preferred_output_stream (void)
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
125 {
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
126 if (! m_encoding.compare ("utf-8"))
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
127 return output_stream ();
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
128
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
129 if (m_conv_ostream)
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
130 return m_conv_ostream;
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
131
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
132 // wrap the output stream with encoding conversion facet
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
133 std::ostream *os = output_stream ();
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
134 if (os && *os)
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
135 {
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
136 convfacet_u8 *facet = new convfacet_u8 (m_encoding);
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
137 std::wbuffer_convert<convfacet_u8, char> *converter
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
138 = new std::wbuffer_convert<convfacet_u8, char> (os->rdbuf (),
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
139 facet);
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
140 m_conv_ostream = new std::ostream (converter);
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
141 }
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
142
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
143 return (m_conv_ostream ? m_conv_ostream : output_stream ());
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
144 }
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
145
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
146 // Return TRUE if this stream is open.
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
147
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
148 bool is_open (void) const { return m_open_state; }
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
149
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
150 virtual void do_close (void) { }
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
151
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
152 void close (void)
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
153 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
154 if (is_open ())
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
155 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
156 m_open_state = false;
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
157 do_close ();
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
158 }
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
159 }
11007
ffe58182db89 src/oct-stream.h (octave_base_stream::file_number): return 0, 1, and 2 for stdin, stdout, and stderr, -1 otherwise
John W. Eaton <jwe@octave.org>
parents: 11004
diff changeset
160
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
161 virtual int file_number (void) const
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
162 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
163 // Kluge alert!
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 2926
diff changeset
164
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
165 if (name () == "stdin")
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
166 return 0;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
167 else if (name () == "stdout")
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
168 return 1;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
169 else if (name () == "stderr")
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
170 return 2;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
171 else
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
172 return -1;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
173 }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
174
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
175 bool ok (void) const { return ! m_fail; }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
176
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
177 // Return current error message for this stream.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
178
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
179 std::string error (bool clear, int& err_num);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
180
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
181 protected:
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
182
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
183 int mode (void) const { return m_mode; }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
184
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
185 mach_info::float_format float_format (void) const { return m_flt_fmt; }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
186
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
187 std::string encoding (void) const { return m_encoding; }
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
188
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
189 // Set current error state and set fail to TRUE.
4889
658aad1c1b05 [project @ 2004-04-30 22:38:30 by jwe]
jwe
parents: 4799
diff changeset
190
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
191 OCTINTERP_API void error (const std::string& msg);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
192 OCTINTERP_API void error (const std::string& who, const std::string& msg);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
193
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
194 // Clear any error message and set fail to FALSE.
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
195
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
196 OCTINTERP_API void clear (void);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
197
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
198 // Clear stream state.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
199
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
200 OCTINTERP_API void clearerr (void);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
201
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
202 private:
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
203
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
204 // The permission bits for the file. Should be some combination of
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
205 // std::ios::open_mode bits.
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
206 int m_mode;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
207
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
208 // Data format.
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
209 mach_info::float_format m_flt_fmt;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
210
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
211 // Code page
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
212 std::string m_encoding;
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
213
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
214 // encoding conversion facet
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
215 typedef string::deletable_facet<string::codecvt_u8> convfacet_u8;
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
216
31363
af38813e5b89 build: Silence unused private field compilation warning in oct-stream.h (bug #63210)
Rik <rik@octave.org>
parents: 30822
diff changeset
217 // FIXME: Identified by compiler as unused private field.
af38813e5b89 build: Silence unused private field compilation warning in oct-stream.h (bug #63210)
Rik <rik@octave.org>
parents: 30822
diff changeset
218 // Commented out 10/29/2022.
af38813e5b89 build: Silence unused private field compilation warning in oct-stream.h (bug #63210)
Rik <rik@octave.org>
parents: 30822
diff changeset
219 // If there are no repercussions, delete entirely.
af38813e5b89 build: Silence unused private field compilation warning in oct-stream.h (bug #63210)
Rik <rik@octave.org>
parents: 30822
diff changeset
220 // std::wbuffer_convert<convfacet_u8, char> *m_converter;
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
221
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
222 // wrappers for encoding conversion
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
223 // std::istream *m_conv_istream;
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
224
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
225 std::ostream *m_conv_ostream;
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
226
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
227 // TRUE if an error has occurred.
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
228 bool m_fail;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
229
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
230 // TRUE if this stream is open.
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
231 bool m_open_state;
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
232
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
233 // Should contain error message if fail is TRUE.
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
234 std::string m_errmsg;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
235
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
236 // Functions that are defined for all input streams (input streams
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
237 // are those that define is).
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
238
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
239 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
240 do_gets (octave_idx_type max_len, bool& err, bool strip_newline,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
241 const std::string& who /* = "gets" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
242
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
243 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
244 getl (octave_idx_type max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
245 const std::string& who /* = "getl" */);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
246 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
247 gets (octave_idx_type max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
248 const std::string& who /* = "gets" */);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
249 OCTINTERP_API off_t
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
250 skipl (off_t count, bool& err, const std::string& who /* = "skipl" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
251
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
252 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
253 do_scanf (scanf_format_list& fmt_list, octave_idx_type nr,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
254 octave_idx_type nc, bool one_elt_size_spec,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
255 octave_idx_type& count, const std::string& who /* = "scanf" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
256
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
257 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
258 scanf (const std::string& fmt, const Array<double>& size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
259 octave_idx_type& count, const std::string& who /* = "scanf" */);
2215
ab0e1fd337f5 [project @ 1996-05-16 15:56:40 by jwe]
jwe
parents: 2148
diff changeset
260
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
261 OCTINTERP_API bool
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
262 do_oscanf (const scanf_format_elt *elt, octave_value&,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
263 const std::string& who /* = "scanf" */);
21503
20bf0ec536e2 integrate textscan more completely with octave_stream class
John W. Eaton <jwe@octave.org>
parents: 21502
diff changeset
264
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
265 OCTINTERP_API octave_value_list
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
266 oscanf (const std::string& fmt, const std::string& who /* = "scanf" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
267
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
268 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
269 do_textscan (const std::string& fmt, octave_idx_type ntimes,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
270 const octave_value_list& options,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
271 const std::string& who, octave_idx_type& count);
18650
491b0adfec95 compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents: 17822
diff changeset
272
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
273 // Functions that are defined for all output streams (output streams
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
274 // are those that define os).
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
275
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
276 OCTINTERP_API int flush (void);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
277
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
278 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
279 do_numeric_printf_conv (std::ostream& os, const printf_format_elt *elt,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
280 int nsa, int sa_1, int sa_2,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
281 const octave_value& val,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
282 const std::string& who);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
283
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
284 OCTINTERP_API void field_width_error (const std::string& who) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
285
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
286 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
287 do_printf (printf_format_list& fmt_list, const octave_value_list& args,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
288 const std::string& who /* = "printf" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
289
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
290 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
291 printf (const std::string& fmt, const octave_value_list& args,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
292 const std::string& who /* = "printf" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
293
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
294 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
295 puts (const std::string& s, const std::string& who /* = "puts" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
296
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
297 // We can always do this in terms of seek(), so the derived class
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
298 // only has to provide that.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
299
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
300 OCTINTERP_API void
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
301 invalid_operation (const std::string& who, const char *rw);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
302 };
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
303
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
304 class
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
305 OCTINTERP_API
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
306 stream
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
307 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
308 public:
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
309
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
310 // BS must be allocated with new or nullptr.
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
311 stream (base_stream *bs = nullptr) : m_rep (bs) { }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
312
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
313 stream (const stream&) = default;
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
314
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
315 stream& operator = (const stream&) = default;
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
316
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
317 ~stream (void) = default;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
318
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
319 OCTINTERP_API int flush (void);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
320
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
321 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
322 getl (octave_idx_type max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
323 const std::string& who /* = "getl" */);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
324
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
325 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
326 getl (const octave_value& max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
327 const std::string& who /* = "getl" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
328
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
329 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
330 gets (octave_idx_type max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
331 const std::string& who /* = "gets" */);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
332
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
333 OCTINTERP_API std::string
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
334 gets (const octave_value& max_len, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
335 const std::string& who /* = "gets" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
336
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
337 OCTINTERP_API off_t
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
338 skipl (off_t count, bool& err, const std::string& who /* = "skipl" */);
9701
531280b07625 implement fskipl
Jaroslav Hajek <highegg@gmail.com>
parents: 8950
diff changeset
339
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
340 OCTINTERP_API off_t
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
341 skipl (const octave_value& count, bool& err,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
342 const std::string& who /* = "skipl" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
343
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
344 OCTINTERP_API int seek (off_t offset, int origin);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
345
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
346 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
347 seek (const octave_value& offset, const octave_value& origin);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
348
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
349 OCTINTERP_API off_t tell (void);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
350
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
351 OCTINTERP_API int rewind (void);
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
352
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
353 OCTINTERP_API bool is_open (void) const;
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
354
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
355 OCTINTERP_API void close (void);
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
356
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
357 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
358 read (const Array<double>& size, octave_idx_type block_size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
359 oct_data_conv::data_type input_type,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
360 oct_data_conv::data_type output_type,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
361 octave_idx_type skip, mach_info::float_format flt_fmt,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
362 octave_idx_type& count);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
363
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
364 OCTINTERP_API octave_idx_type
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
365 write (const octave_value& data, octave_idx_type block_size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
366 oct_data_conv::data_type output_type,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
367 octave_idx_type skip, mach_info::float_format flt_fmt);
17416
6690dba6078a improve efficiency of fwrite
John W. Eaton <jwe@octave.org>
parents: 16892
diff changeset
368
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
369 OCTINTERP_API bool write_bytes (const void *data, std::size_t n_elts);
17416
6690dba6078a improve efficiency of fwrite
John W. Eaton <jwe@octave.org>
parents: 16892
diff changeset
370
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
371 OCTINTERP_API bool skip_bytes (std::size_t n_elts);
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4889
diff changeset
372
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
373 template <typename T>
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
374 OCTINTERP_API octave_idx_type
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
375 write (const Array<T>& data, octave_idx_type block_size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
376 oct_data_conv::data_type output_type,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
377 octave_idx_type skip, mach_info::float_format flt_fmt);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
378
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
379 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
380 scanf (const std::string& fmt, const Array<double>& size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
381 octave_idx_type& count, const std::string& who /* = "scanf" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
382
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
383 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
384 scanf (const octave_value& fmt, const Array<double>& size,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
385 octave_idx_type& count, const std::string& who /* = "scanf" */);
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
386
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
387 OCTINTERP_API octave_value_list
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
388 oscanf (const std::string& fmt, const std::string& who /* = "scanf" */);
2215
ab0e1fd337f5 [project @ 1996-05-16 15:56:40 by jwe]
jwe
parents: 2148
diff changeset
389
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
390 OCTINTERP_API octave_value_list
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
391 oscanf (const octave_value& fmt, const std::string& who /* = "scanf" */);
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
392
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
393 OCTINTERP_API octave_value
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
394 textscan (const std::string& fmt, octave_idx_type ntimes,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
395 const octave_value_list& options,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
396 const std::string& who, octave_idx_type& count);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
397
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
398 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
399 printf (const std::string& fmt, const octave_value_list& args,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
400 const std::string& who /* = "printf" */);
21503
20bf0ec536e2 integrate textscan more completely with octave_stream class
John W. Eaton <jwe@octave.org>
parents: 21502
diff changeset
401
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
402 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
403 printf (const octave_value& fmt, const octave_value_list& args,
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
404 const std::string& who /* = "printf" */);
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
405
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
406 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
407 puts (const std::string& s, const std::string& who /* = "puts" */);
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
408 OCTINTERP_API int
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
409 puts (const octave_value& s, const std::string& who /* = "puts" */);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
410
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
411 OCTINTERP_API bool eof (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
412
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
413 OCTINTERP_API std::string error (bool clear, int& err_num);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
414
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
415 std::string error (bool clear = false)
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
416 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
417 int err_num;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
418 return error (clear, err_num);
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
419 }
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
420
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
421 // Set the error message and state.
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
422
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
423 void error (const std::string& msg)
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
424 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
425 if (m_rep)
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
426 m_rep->error (msg);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
427 }
4799
e2d7d1ef5e55 [project @ 2004-02-24 19:47:18 by jwe]
jwe
parents: 4797
diff changeset
428
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
429 void error (const char *msg) { error (std::string (msg)); }
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
430
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
431 int file_number (void) { return m_rep ? m_rep->file_number () : -1; }
4799
e2d7d1ef5e55 [project @ 2004-02-24 19:47:18 by jwe]
jwe
parents: 4797
diff changeset
432
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
433 bool is_valid (void) const { return bool (m_rep); }
4799
e2d7d1ef5e55 [project @ 2004-02-24 19:47:18 by jwe]
jwe
parents: 4797
diff changeset
434
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
435 bool ok (void) const { return m_rep && m_rep->ok (); }
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 2926
diff changeset
436
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
437 operator bool () const { return ok (); }
3340
585a8809fd9b [project @ 1999-11-05 07:02:30 by jwe]
jwe
parents: 3268
diff changeset
438
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
439 OCTINTERP_API std::string name (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
440
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
441 OCTINTERP_API int mode (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
442
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
443 OCTINTERP_API mach_info::float_format float_format (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
444
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
445 OCTINTERP_API static std::string mode_as_string (int mode);
26995
ab5bfee22d18 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 26703
diff changeset
446
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
447 std::string encoding (void)
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
448 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
449 return m_rep ? m_rep->encoding () : std::string ();
26703
29ea2369971d Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26377
diff changeset
450 }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
451
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
452 std::istream * input_stream (void)
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
453 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
454 return m_rep ? m_rep->input_stream () : nullptr;
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
455 }
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
456
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
457 std::ostream * output_stream (void)
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
458 {
30822
0826c503f294 Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30565
diff changeset
459 return (m_rep ? m_rep->preferred_output_stream () : nullptr);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
460 }
2902
c5b7a019b9ed [project @ 1997-04-30 03:46:53 by jwe]
jwe
parents: 2877
diff changeset
461
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
462 void clearerr (void) { if (m_rep) m_rep->clearerr (); }
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
463
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
464 private:
16099
4b6c44096862 Backout changeset 238e499c5fea (locale support in scanf)
Rik <rik@octave.org>
parents: 16011
diff changeset
465
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
466 // The actual representation of this stream.
27735
8600f5ea1ec1 use std::shared_ptr to manage stream rep
John W. Eaton <jwe@octave.org>
parents: 27447
diff changeset
467 std::shared_ptr<base_stream> m_rep;
4889
658aad1c1b05 [project @ 2004-04-30 22:38:30 by jwe]
jwe
parents: 4799
diff changeset
468
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
469 bool stream_ok (bool clear = true) const
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
470 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
471 bool retval = true;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
472
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
473 if (m_rep)
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
474 {
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
475 if (clear)
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
476 m_rep->clear ();
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
477 }
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
478 else
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
479 retval = false;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
480
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
481 return retval;
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
482 }
5659
960f4b9a26af [project @ 2006-03-10 15:35:20 by jwe]
jwe
parents: 5649
diff changeset
483
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
484 void invalid_operation (const std::string& who, const char *rw)
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
485 {
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
486 if (m_rep)
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
487 m_rep->invalid_operation (who, rw);
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
488 }
5659
960f4b9a26af [project @ 2006-03-10 15:35:20 by jwe]
jwe
parents: 5649
diff changeset
489
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
490 OCTINTERP_API octave_value
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
491 finalize_read (std::list<void *>& input_buf_list,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
492 octave_idx_type input_buf_elts,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
493 octave_idx_type elts_read,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
494 octave_idx_type nr, octave_idx_type nc,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
495 oct_data_conv::data_type input_type,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
496 oct_data_conv::data_type output_type,
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
497 mach_info::float_format ffmt);
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
498 };
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4889
diff changeset
499
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
500 class
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
501 OCTINTERP_API
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
502 stream_list
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
503 {
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
504 public:
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
505
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
506 OCTINTERP_API stream_list (interpreter& interp);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
507
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
508 stream_list (const stream_list&) = delete;
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
509 stream_list& operator = (const stream_list&) = delete;
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
510
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
511 OCTINTERP_API ~stream_list (void);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
512
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
513 OCTINTERP_API int insert (stream& os);
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
514
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
515 OCTINTERP_API stream lookup (int fid, const std::string& who = "") const;
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
516 OCTINTERP_API stream
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
517 lookup (const octave_value& fid, const std::string& who = "") const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
518
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
519 OCTINTERP_API int remove (int fid, const std::string& who = "");
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29655
diff changeset
520 OCTINTERP_API int remove (const octave_value& fid,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29655
diff changeset
521 const std::string& who = "");
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
522
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
523 OCTINTERP_API void clear (bool flush = true);
4468
efb6301dae80 [project @ 2003-07-15 19:18:20 by jwe]
jwe
parents: 4051
diff changeset
524
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
525 OCTINTERP_API string_vector get_info (int fid) const;
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
526 OCTINTERP_API string_vector get_info (const octave_value& fid) const;
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
527
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
528 OCTINTERP_API std::string list_open_files (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
529
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
530 OCTINTERP_API octave_value open_file_numbers (void) const;
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
531
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
532 OCTINTERP_API int get_file_number (const octave_value& fid) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
533
29233
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
534 OCTINTERP_API octave_value stdin_file (void) const;
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
535 OCTINTERP_API octave_value stdout_file (void) const;
665c9ed14c97 Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
536 OCTINTERP_API octave_value stderr_file (void) const;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
537
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
538 private:
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
539
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
540 typedef std::map<int, stream> ostrl_map;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
541
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
542 ostrl_map m_list;
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
543
27172
b0abae0bd94b style fixes
John W. Eaton <jwe@octave.org>
parents: 26995
diff changeset
544 mutable ostrl_map::const_iterator m_lookup_cache;
2609
12bc9d0a50b5 [project @ 1997-01-18 00:17:36 by jwe]
jwe
parents: 2435
diff changeset
545
23738
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
546 int m_stdin_file;
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
547 int m_stdout_file;
8acd390d16c9 don't use singleton for stream_list object
John W. Eaton <jwe@octave.org>
parents: 23615
diff changeset
548 int m_stderr_file;
23059
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
549 };
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
550 }
b98ebcd7f11c move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
551
2117
b240b2fce8ed [project @ 1996-05-10 07:20:36 by jwe]
jwe
parents:
diff changeset
552 #endif