# HG changeset patch # User jwe # Date 830402256 0 # Node ID e9ec222a53e1964812b1a0ef83e1183467ffe999 # Parent 452f63bfa60c8fa2a28801130a779c9e79c8e9af [project @ 1996-04-25 03:17:36 by jwe] Initial revision diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-fstrm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-fstrm.cc Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,128 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "error.h" +#include "oct-fstrm.h" + +octave_fstream::octave_fstream (const string& nm_arg, + ios::openmode md = ios::in|ios::out, + octave_base_stream::arch_type at = native) + : octave_base_stream (md, at), nm (nm_arg) +{ + // Override default protection of 0664 so that umask will appear to + // do the right thing. + + fs.open (nm.c_str (), md, 0666); + + if (! fs) + error (strerror (errno)); +} + +// Position a stream at OFFSET relative to ORIGIN. + +int +octave_fstream::seek (streamoff offset, ios::seek_dir origin) +{ + int retval = -1; + + if (! fs.bad ()) + { + fs.clear (); + + filebuf *fb = fs.rdbuf (); + + if (fb) + { + fb->seekoff (offset, origin); + retval = fs.bad () ? -1 : 0; + } + } + + return retval; +} + +// Return current stream position. + +long +octave_fstream::tell (void) const +{ + long retval = -1; + + if (fs) + { + filebuf *fb = fs.rdbuf (); + retval = (long) fb->seekoff (0, ios::cur); + } + + return retval; +} + +// Return non-zero if EOF has been reached on this stream. + +bool +octave_fstream::eof (void) const +{ + return fs.eof (); +} + +// The name of the file. + +string +octave_fstream::name (void) +{ + return nm; +} + +istream * +octave_fstream::input_stream (void) +{ + istream *retval = 0; + + if (mode () & ios::in) + retval = &fs; + + return retval; +} + +ostream * +octave_fstream::output_stream (void) +{ + ostream *retval = 0; + + if (mode () & ios::out) + retval = &fs; + + return retval; +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-fstrm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-fstrm.h Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,80 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_octave_fstream_h) +#define octave_octave_fstream_h 1 + +#include + +#include "oct-stream.h" + +class +octave_fstream : public octave_base_stream +{ +public: + + octave_fstream (const string& nm_arg, + ios::openmode md = ios::in|ios::out, + octave_base_stream::arch_type at = native); + + ~octave_fstream (void) { } + + // Position a stream at OFFSET relative to ORIGIN. + + int seek (streampos offset, ios::seek_dir origin); + + // Return current stream position. + + long tell (void) const; + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const; + + // The name of the file. + + string name (void); + + istream *input_stream (void); + + ostream *output_stream (void); + +private: + + string nm; + + fstream fs; + + // No copying! + + octave_fstream (const octave_fstream&); + + octave_fstream& operator = (const octave_fstream&); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-iostrm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-iostrm.cc Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,75 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "error.h" +#include "oct-iostrm.h" + +// Position a stream at OFFSET relative to ORIGIN. + +int +octave_base_iostream::seek (streamoff, ios::seek_dir) +{ + invalid_operation (); + return -1; +} + +// Return current stream position. + +long +octave_base_iostream::tell (void) const +{ + invalid_operation (); + return -1; +} + +// Return non-zero if EOF has been reached on this stream. + +bool +octave_base_iostream::eof (void) const +{ + invalid_operation (); + return false; +} + +// The name of the file. + +string +octave_base_iostream::name (void) +{ + return nm; +} + +void +octave_base_iostream::invalid_operation (void) const +{ + ::error ("%s: invalid operation", stream_type ()); +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-iostrm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-iostrm.h Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,138 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_octave_iostream_h) +#define octave_octave_iostream_h 1 + +#include "oct-stream.h" + +class istream; +class ostream; + +class +octave_base_iostream : public octave_base_stream +{ +public: + + octave_base_iostream (const string& n = string (), + ios::openmode md = ios::in|ios::out, + octave_base_stream::arch_type at = native) + : octave_base_stream (md, at), nm (n) { } + + ~octave_base_iostream (void) { } + + // Position a stream at OFFSET relative to ORIGIN. + + int seek (streampos offset, ios::seek_dir origin); + + // Return current stream position. + + long tell (void) const; + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const; + + // The name of the file. + + string name (void); + +protected: + + void invalid_operation (void) const; + +private: + + string nm; + + virtual const char *stream_type (void) const = 0; + + // No copying! + + octave_base_iostream (const octave_base_iostream&); + + octave_base_iostream& operator = (const octave_base_iostream&); +}; + +class +octave_istream : public octave_base_iostream +{ +public: + + octave_istream (istream *arg = 0, const string& nm = string ()) + : octave_base_iostream (nm, ios::in, octave_base_stream::native), + is (arg) { } + + ~octave_istream (void) { } + + istream *input_stream (void) { return is; } + + ostream *output_stream (void) { return 0; } + +private: + + istream *is; + + const char *stream_type (void) const { return "octave_istream"; } + + // No copying! + + octave_istream (const octave_istream&); + + octave_istream& operator = (const octave_istream&); +}; + +class +octave_ostream : public octave_base_iostream +{ +public: + + octave_ostream (ostream *arg, const string& nm = string ()) + : octave_base_iostream (nm, ios::out, octave_base_stream::native), + os (arg) { } + + ~octave_ostream (void) { } + + istream *input_stream (void) { return 0; } + + ostream *output_stream (void) { return os; } + +private: + + ostream *os; + + const char *stream_type (void) const { return "octave_ostream"; } + + // No copying! + + octave_ostream (const octave_ostream&); + + octave_ostream& operator = (const octave_ostream&); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-prcstrm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-prcstrm.cc Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,81 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "oct-prcstrm.h" + +octave_iprocstream::octave_iprocstream (const string& n, + ios::openmode arg_md, + arch_type arg_at) + : octave_istdiostream (n, 0, arg_md, arg_at) +{ + fp = popen (n.c_str (), "r"); + + if (fp) + { + delete is; + is = new istdiostream (fp); + } +} + +octave_iprocstream::~octave_iprocstream (void) +{ + if (fp) + { + pclose (fp); + fp = 0; + } +} + +octave_oprocstream::octave_oprocstream (const string& n, + ios::openmode arg_md, + arch_type arg_at) + : octave_ostdiostream (n, 0, arg_md, arg_at) +{ + fp = popen (n.c_str (), "w"); + + if (fp) + { + delete os; + os = new ostdiostream (fp); + } +} + +octave_oprocstream::~octave_oprocstream (void) +{ + if (fp) + { + pclose (fp); + fp = 0; + } +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-prcstrm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-prcstrm.h Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,74 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_octave_procstream_h) +#define octave_octave_procstream_h 1 + +#include "oct-stdstrm.h" + +class +octave_iprocstream : public octave_istdiostream +{ +public: + + octave_iprocstream (const string& n, + ios::openmode arg_md = ios::in, + arch_type arg_at = native); + + ~octave_iprocstream (void); + +private: + + // No copying! + + octave_iprocstream (const octave_iprocstream&); + + octave_iprocstream& operator = (const octave_iprocstream&); +}; + +class +octave_oprocstream : public octave_ostdiostream +{ +public: + + octave_oprocstream (const string& n, + ios::openmode arg_md = ios::out, + arch_type arg_at = native); + + ~octave_oprocstream (void); + +private: + + // No copying! + + octave_oprocstream (const octave_oprocstream&); + + octave_oprocstream& operator = (const octave_oprocstream&); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-stdstrm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-stdstrm.cc Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,118 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "oct-stdstrm.h" + +octave_base_stdiostream::~octave_base_stdiostream (void) +{ + if (fp) + { + fclose (fp); + fp = 0; + } +} + +// Position a stream at OFFSET relative to ORIGIN. + +int +octave_base_stdiostream::seek (streampos offset, ios::seek_dir origin) +{ + int retval = -1; + + if (! bad ()) + { + stdiobuf *sb = rdbuf (); + + if (sb) + { + clear (); + + sb->seekoff (offset, origin); + retval = bad () ? -1 : 0; + } + } + + return retval; +} + +// Return current stream position. + +long +octave_base_stdiostream::tell (void) const +{ + long retval = -1; + + if (! bad ()) + { + stdiobuf *sb = rdbuf (); + + if (sb) + { + retval = (long) sb->seekoff (0, ios::cur); + + if (bad ()) + retval = -1; + } + } + + return retval; +} + +octave_istdiostream::octave_istdiostream (const string& n, FILE *f, + ios::openmode arg_md, + arch_type arg_at) + : octave_base_stdiostream (n, f, arg_md, arg_at), is (0) +{ + if (f) + is = new istdiostream (f); +} + +octave_istdiostream::~octave_istdiostream (void) +{ + delete is; +} + +octave_ostdiostream::octave_ostdiostream (const string& n, FILE *f, + ios::openmode arg_md, + arch_type arg_at) + : octave_base_stdiostream (n, f, arg_md, arg_at), os (0) +{ + if (f) + os = new ostdiostream (f); +} + +octave_ostdiostream::~octave_ostdiostream (void) +{ + delete os; +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-stdstrm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-stdstrm.h Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,167 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_octave_stdiostream_h) +#define octave_octave_stdiostream_h 1 + +#include + +#include "oct-stream.h" + +class +octave_base_stdiostream : public octave_base_stream +{ +public: + + octave_base_stdiostream (const string& n, FILE *f, + ios::openmode arg_md = ios::in|ios::out, + arch_type arg_at = native) + : octave_base_stream (arg_md, arg_at), nm (n), fp (f) { } + + ~octave_base_stdiostream (void); + + // Position a stream at OFFSET relative to ORIGIN. + + int seek (streampos offset, ios::seek_dir origin); + + // Return current stream position. + + long tell (void) const; + + // The name of the file. + + string name (void) { return nm; } + + virtual stdiobuf *rdbuf (void) const = 0; + + virtual bool bad (void) const = 0; + + virtual void clear (void) = 0; + +protected: + + string nm; + + FILE *fp; + + // No copying! + + octave_base_stdiostream (const octave_base_stdiostream&); + + octave_base_stdiostream& operator = (const octave_base_stdiostream&); +}; + +class +octave_istdiostream : public octave_base_stdiostream +{ +public: + + octave_istdiostream (const string& n, FILE *f = 0, + ios::openmode arg_md = ios::in, + arch_type arg_at = native); + + ~octave_istdiostream (void); + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const { return is ? is->eof () : true; } + + istream *input_stream (void) { return is; } + + ostream *output_stream (void) { return 0; } + + // XXX FIXME XXX -- should not have to cast away const here. + stdiobuf *rdbuf (void) const + { return is ? ((istdiostream *) is)->rdbuf () : 0; } + + bool bad (void) const { return is ? is->bad () : true; } + + void clear (void) + { + if (is) + is->clear (); + } + +protected: + + istdiostream *is; + +private: + + // No copying! + + octave_istdiostream (const octave_istdiostream&); + + octave_istdiostream& operator = (const octave_istdiostream&); +}; + +class +octave_ostdiostream : public octave_base_stdiostream +{ +public: + + octave_ostdiostream (const string& n, FILE *f = 0, + ios::openmode arg_md = ios::out, + arch_type arg_at = native); + + ~octave_ostdiostream (void); + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const { return os ? os->eof () : true; } + + istream *input_stream (void) { return 0; } + + ostream *output_stream (void) { return os; } + + // XXX FIXME XXX -- should not have to cast away const here. + stdiobuf *rdbuf (void) const + { return os ? ((ostdiostream *) os)->rdbuf () : 0; } + + bool bad (void) const { return os ? os->bad () : true; } + + void clear (void) + { + if (os) + os->clear (); + } + +protected: + + ostdiostream *os; + +private: + + // No copying! + + octave_ostdiostream (const octave_ostdiostream&); + + octave_ostdiostream& operator = (const octave_ostdiostream&); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-strstrm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-strstrm.cc Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,81 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "oct-strstrm.h" + +// Position a stream at OFFSET relative to ORIGIN. + +int +octave_base_strstream::seek (streampos offset, ios::seek_dir origin) +{ + int retval = -1; + + if (! bad ()) + { + streambuf *sb = rdbuf (); + + if (sb) + { + clear (); + + sb->seekoff (offset, origin); + retval = bad () ? -1 : 0; + } + } + + return retval; +} + +// Return current stream position. + +long +octave_base_strstream::tell (void) const +{ + long retval = -1; + + if (! bad ()) + { + // XXX FIXME XXX -- shouldn't have to do this! + + streambuf *sb = ((octave_base_strstream *)this)->rdbuf (); + + if (sb) + { + retval = (long) sb->seekoff (0, ios::cur); + + if (bad ()) + retval = -1; + } + } + + return retval; +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 452f63bfa60c -r e9ec222a53e1 src/oct-strstrm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/oct-strstrm.h Thu Apr 25 03:17:36 1996 +0000 @@ -0,0 +1,159 @@ +/* + +Copyright (C) 1996 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#if !defined (octave_octave_strstream_h) +#define octave_octave_strstream_h 1 + +#include +#include + +#include "oct-stream.h" + +class +octave_base_strstream : public octave_base_stream +{ +public: + + octave_base_strstream (ios::openmode arg_md = ios::out, + arch_type arg_at = native) + : octave_base_stream (arg_md, arg_at) { } + + ~octave_base_strstream (void) { } + + // Position a stream at OFFSET relative to ORIGIN. + + int seek (streampos offset, ios::seek_dir origin); + + // Return current stream position. + + long tell (void) const; + + // The name of the file. + + string name (void) { return string (); } + + virtual streambuf *rdbuf (void) = 0; + + virtual bool bad (void) const = 0; + + virtual void clear (void) = 0; + +private: + + // No copying! + + octave_base_strstream (const octave_base_strstream&); + + octave_base_strstream& operator = (const octave_base_strstream&); +}; + +class +octave_istrstream : public octave_base_strstream +{ +public: + + octave_istrstream (const char *data, + ios::openmode arg_md = ios::out, + arch_type arg_at = native) + : octave_base_strstream (arg_md, arg_at), is (data) { } + + octave_istrstream (const string& data, + ios::openmode arg_md = ios::out, + arch_type arg_at = native) + : octave_base_strstream (arg_md, arg_at), is (data.c_str ()) { } + + ~octave_istrstream (void) { } + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const { return is.eof (); } + + istream *input_stream (void) { return &is; } + + ostream *output_stream (void) { return 0; } + + streambuf *rdbuf (void) { return is ? is.rdbuf () : 0; } + + bool bad (void) const { return is.bad (); } + + void clear (void) { is.clear (); } + +private: + + istrstream is; + + // No copying! + + octave_istrstream (const octave_istrstream&); + + octave_istrstream& operator = (const octave_istrstream&); +}; + +class +octave_ostrstream : public octave_base_strstream +{ +public: + + octave_ostrstream (ios::openmode arg_md = ios::out, + arch_type arg_at = native) + : octave_base_strstream (arg_md, arg_at) { } + + ~octave_ostrstream (void) { } + + // Return non-zero if EOF has been reached on this stream. + + bool eof (void) const { return os.eof (); } + + istream *input_stream (void) { return 0; } + + ostream *output_stream (void) { return &os; } + + char *str (void) + { + os << ends; + return os.str (); + } + + streambuf *rdbuf (void) { return os ? os.rdbuf () : 0; } + + bool bad (void) const { return os.bad (); } + + void clear (void) { os.clear (); } + +private: + + ostrstream os; + + // No copying! + + octave_ostrstream (const octave_ostrstream&); + + octave_ostrstream& operator = (const octave_ostrstream&); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/