annotate src/c-file-ptr-stream.h @ 3644:9add655e8b8c

[project @ 2000-03-24 11:58:50 by jwe]
author jwe
date Fri, 24 Mar 2000 11:58:50 +0000
parents 168c4d71dc63
children 25e84fcef38a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
1 /*
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
2
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 2000 John W. Eaton
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
4
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
6
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
10 later version.
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
11
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
15 for more details.
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
16
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
20
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
21 */
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
22
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_c_file_ptr_stream_h)
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
24 #define octave_c_file_ptr_stream_h 1
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
25
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
26 #ifdef __GNUG__
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
27 #pragma interface
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
28 #endif
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
29
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
30 #include <iostream>
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
31 #include <stdio.h>
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
32
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
33 class
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
34 c_file_ptr_buf : public std::streambuf
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
35 {
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
36 public:
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
37
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
38 FILE* stdiofile (void) const { return f; }
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
39
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
40 c_file_ptr_buf (FILE *f_arg) : std::streambuf (), f (f_arg) { }
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
41
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
42 ~c_file_ptr_buf (void);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
43
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
44 int overflow (int);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
45
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
46 int underflow (void);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
47
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
48 int uflow (void);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
49
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
50 int pbackfail (int);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
51
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
52 std::streamsize xsputn (const char*, std::streamsize);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
53
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
54 std::streamsize xsgetn (char *, std::streamsize);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
55
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
56 std::streampos seekoff (std::streamoff, std::ios::seekdir,
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
57 std::ios::openmode = std::ios::in | std::ios::out);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
58
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
59 std::streampos seekpos (std::streampos,
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
60 std::ios::openmode = std::ios::in | std::ios::out);
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
61
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
62 int sync (void);
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
63
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
64 protected:
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
65
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
66 FILE *f;
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
67 };
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
68
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
69 class
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
70 i_c_file_ptr_stream : public std::istream
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
71 {
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
72 public:
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
73
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
74 i_c_file_ptr_stream (FILE* f)
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
75 : std::istream (), buf (new c_file_ptr_buf (f)) { init (buf); }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
76
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
77 ~i_c_file_ptr_stream (void) { delete buf; buf = 0; }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
78
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
79 c_file_ptr_buf *rdbuf (void) { return buf; }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
80
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
81 private:
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
82
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
83 c_file_ptr_buf *buf;
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
84 };
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
85
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
86 class
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
87 o_c_file_ptr_stream : public std::ostream
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
88 {
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
89 public:
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
90
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
91 o_c_file_ptr_stream (FILE* f)
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
92 : std::ostream (), buf (new c_file_ptr_buf (f)) { init (buf); }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
93
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
94 ~o_c_file_ptr_stream (void) { delete buf; buf = 0; }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
95
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
96 c_file_ptr_buf *rdbuf (void) { return buf; }
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
97
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
98 private:
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
99
3644
9add655e8b8c [project @ 2000-03-24 11:58:50 by jwe]
jwe
parents: 3628
diff changeset
100 c_file_ptr_buf *buf;
3628
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
101 };
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
102
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
103 #endif
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
104
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
105 /*
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
106 ;;; Local Variables: ***
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
107 ;;; mode: C++ ***
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
108 ;;; End: ***
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
109 */
168c4d71dc63 [project @ 2000-03-23 07:34:54 by jwe]
jwe
parents:
diff changeset
110