home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / octave-2.1.23 / src / oct-prcstrm.cc < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  96 lines

  1. /*
  2.  
  3. Copyright (C) 1996, 1997 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 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 <cstdio>
  28.  
  29. #include "oct-prcstrm.h"
  30.  
  31. octave_stream
  32. octave_iprocstream::create (const string& n, ios::openmode arg_md,
  33.                 oct_mach_info::float_format flt_fmt)
  34. {
  35.   return octave_stream (new octave_iprocstream (n, arg_md, flt_fmt));
  36. }
  37.  
  38. octave_iprocstream::octave_iprocstream (const string& n,
  39.                     ios::openmode arg_md,
  40.                     oct_mach_info::float_format flt_fmt)
  41.   : octave_istdiostream (n, 0, arg_md, flt_fmt)
  42. {
  43.   fp = popen (n.c_str (), "r");
  44.  
  45.   if (fp)
  46.     {
  47.       delete is;
  48.       is = new istdiostream (fp);
  49.     }
  50. }
  51.  
  52. octave_iprocstream::~octave_iprocstream (void)
  53. {
  54.   if (fp)
  55.     {
  56.       pclose (fp);
  57.       fp = 0;
  58.     }
  59. }
  60.  
  61. octave_stream
  62. octave_oprocstream::create (const string& n, ios::openmode arg_md,
  63.                 oct_mach_info::float_format flt_fmt)
  64. {
  65.   return octave_stream (new octave_oprocstream (n, arg_md, flt_fmt));
  66. }
  67.  
  68. octave_oprocstream::octave_oprocstream (const string& n,
  69.                     ios::openmode arg_md,
  70.                     oct_mach_info::float_format flt_fmt)
  71.   : octave_ostdiostream (n, 0, arg_md, flt_fmt)
  72. {
  73.   fp = popen (n.c_str (), "w");
  74.  
  75.   if (fp)
  76.     {
  77.       delete os;
  78.       os = new ostdiostream (fp);
  79.     }
  80. }
  81.  
  82. octave_oprocstream::~octave_oprocstream (void)
  83. {
  84.   if (fp)
  85.     {
  86.       pclose (fp);
  87.       fp = 0;
  88.     }
  89. }
  90.  
  91. /*
  92. ;;; Local Variables: ***
  93. ;;; mode: C++ ***
  94. ;;; End: ***
  95. */
  96.