GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-iostrm.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_oct_iostrm_h)
24 #define octave_oct_iostrm_h 1
25 
26 #include "octave-config.h"
27 
28 #include <iosfwd>
29 
30 #include "oct-stream.h"
31 
32 class
34 {
35 public:
36 
38  std::ios::openmode m = std::ios::in | std::ios::out,
41  : octave_base_stream (m, ff), nm (n) { }
42 
43  // Position a stream at OFFSET relative to ORIGIN.
44 
45  int seek (off_t offset, int origin);
46 
47  // Return current stream position.
48 
49  off_t tell (void);
50 
51  // Return nonzero if EOF has been reached on this stream.
52 
53  bool eof (void) const;
54 
55  // The name of the file.
56 
57  std::string name (void) const { return nm; }
58 
59 protected:
60 
62 
63  void invalid_operation (void) const;
64 
65 private:
66 
68 
69  virtual const char *stream_type (void) const = 0;
70 
71  // No copying!
72 
74 
75  octave_base_iostream& operator = (const octave_base_iostream&);
76 };
77 
78 class
80 {
81 public:
82 
83  octave_istream (std::istream *arg = 0, const std::string& n = "")
84  : octave_base_iostream (n, std::ios::in,
85  octave::mach_info::native_float_format ()),
86  is (arg)
87  { }
88 
89  static octave_stream
90  create (std::istream *arg = 0, const std::string& n = "");
91 
92  // Return nonzero if EOF has been reached on this stream.
93 
94  bool eof (void) const;
95 
96  std::istream *input_stream (void) { return is; }
97 
98  std::ostream *output_stream (void) { return 0; }
99 
100 protected:
101 
102  ~octave_istream (void) { }
103 
104 private:
105 
106  std::istream *is;
107 
108  const char *stream_type (void) const { return "octave_istream"; }
109 
110  // No copying!
111 
113 
114  octave_istream& operator = (const octave_istream&);
115 };
116 
117 class
119 {
120 public:
121 
122  octave_ostream (std::ostream *arg, const std::string& n = "")
123  : octave_base_iostream (n, std::ios::out,
124  octave::mach_info::native_float_format ()),
125  os (arg)
126  { }
127 
128  static octave_stream
129  create (std::ostream *arg, const std::string& n = "");
130 
131  // Return nonzero if EOF has been reached on this stream.
132 
133  bool eof (void) const;
134 
135  std::istream *input_stream (void) { return 0; }
136 
137  std::ostream *output_stream (void) { return os; }
138 
139 protected:
140 
141  ~octave_ostream (void) { }
142 
143 private:
144 
145  std::ostream *os;
146 
147  const char *stream_type (void) const { return "octave_ostream"; }
148 
149  // No copying!
150 
152 
153  octave_ostream& operator = (const octave_ostream&);
154 };
155 
156 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
std::istream * is
Definition: oct-iostrm.h:106
std::ostream * output_stream(void)
Definition: oct-iostrm.h:137
STL namespace.
~octave_ostream(void)
Definition: oct-iostrm.h:141
~octave_base_iostream(void)
Definition: oct-iostrm.h:61
octave_value arg
Definition: pr-output.cc:3440
const char * stream_type(void) const
Definition: oct-iostrm.h:108
std::string nm
Definition: oct-iostrm.h:67
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
std::istream * input_stream(void)
Definition: oct-iostrm.h:96
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
std::ostream * output_stream(void)
Definition: oct-iostrm.h:98
~octave_istream(void)
Definition: oct-iostrm.h:102
std::istream * input_stream(void)
Definition: oct-iostrm.h:135
static float_format native_float_format(void)
Definition: mach-info.cc:162
octave_ostream(std::ostream *arg, const std::string &n="")
Definition: oct-iostrm.h:122
octave_istream(std::istream *arg=0, const std::string &n="")
Definition: oct-iostrm.h:83
std::string name(void) const
Definition: oct-iostrm.h:57
write the output to stdout if nargout is
Definition: load-save.cc:1576
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
octave_base_iostream(const std::string &n="", std::ios::openmode m=std::ios::in|std::ios::out, octave::mach_info::float_format ff=octave::mach_info::native_float_format())
Definition: oct-iostrm.h:37
std::ostream * os
Definition: oct-iostrm.h:145
const char * stream_type(void) const
Definition: oct-iostrm.h:147