2081
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2081
|
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 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "oct-strstrm.h" |
|
28 |
|
29 // Position a stream at OFFSET relative to ORIGIN. |
|
30 |
|
31 int |
3775
|
32 octave_base_strstream::seek (std::streamoff offset, std::ios::seekdir origin) |
2081
|
33 { |
|
34 int retval = -1; |
|
35 |
|
36 if (! bad ()) |
|
37 { |
3523
|
38 std::streambuf *sb = rdbuf (); |
2081
|
39 |
|
40 if (sb) |
|
41 { |
|
42 clear (); |
|
43 |
3558
|
44 sb->pubseekoff (offset, origin); |
2081
|
45 retval = bad () ? -1 : 0; |
|
46 } |
|
47 } |
|
48 |
|
49 return retval; |
|
50 } |
|
51 |
|
52 // Return current stream position. |
|
53 |
|
54 long |
|
55 octave_base_strstream::tell (void) const |
|
56 { |
|
57 long retval = -1; |
|
58 |
|
59 if (! bad ()) |
|
60 { |
|
61 // XXX FIXME XXX -- shouldn't have to do this! |
|
62 |
3523
|
63 std::streambuf *sb = (const_cast<octave_base_strstream *>(this))->rdbuf (); |
2081
|
64 |
|
65 if (sb) |
|
66 { |
3558
|
67 retval = static_cast<long> (sb->pubseekoff (0, std::ios::cur)); |
2081
|
68 |
|
69 if (bad ()) |
|
70 retval = -1; |
|
71 } |
|
72 } |
|
73 |
|
74 return retval; |
|
75 } |
|
76 |
3340
|
77 octave_stream |
3544
|
78 octave_istrstream::create (const char *data, std::ios::openmode arg_md, |
3340
|
79 oct_mach_info::float_format flt_fmt) |
|
80 { |
|
81 return octave_stream (new octave_istrstream (data, arg_md, flt_fmt)); |
|
82 } |
|
83 |
|
84 octave_stream |
3544
|
85 octave_istrstream::create (const std::string& data, std::ios::openmode arg_md, |
3340
|
86 oct_mach_info::float_format flt_fmt) |
|
87 { |
|
88 return octave_stream (new octave_istrstream (data, arg_md, flt_fmt)); |
|
89 } |
|
90 |
|
91 octave_stream |
3544
|
92 octave_ostrstream::create (std::ios::openmode arg_md, |
3340
|
93 oct_mach_info::float_format flt_fmt) |
|
94 { |
|
95 return octave_stream (new octave_ostrstream (arg_md, flt_fmt)); |
|
96 } |
|
97 |
2081
|
98 /* |
|
99 ;;; Local Variables: *** |
|
100 ;;; mode: C++ *** |
|
101 ;;; End: *** |
|
102 */ |