Man Page stdiobuf.3




NAME

     stdiobuf - buffer and stream classes for use with C stdio


SYNOPSIS

     #include <stdiostream.h> // includes <iostream.h> and <stdio.h>
     class stdiobuf : public streambuf {
     public:
          stdiobuf(FILE*);
          FILE*     stdiofile();
     };
     class stdiostream : public ios {
     public:
          stdiostream(FILE*);
          stdiobuf* rdbuf();
     };


DESCRIPTION

     The stdiobuf class is a specialization of streambufs using a
     C  stdio  FILE as an intermediary to an actual file which is
     the source or destination of characters.  The basic  stream-
     buf  operations  are  as  described  in  sbufprot(3CC4)  and
     sbufpub(3CC4).   Input,  output,  and  seek  operations  are
     reflected in changes to the associated FILE.  The seek func-
     tions are implemented in terms of fseek(), for example.

     The stdiostream provides a C++ interface to a C stdio  FILE.
     It has a stdiobuf as its buffer.  It is not a full implemen-
     tation of iostreams; it has only the buffer-class  and  ios-
     class  functionality.   C++  I/O  is  done via per-character
     calls to the C stdio getc() and putc() functions.  There  is
     no  normal buffering, since that would break synchronization
     of the C and C++ accesses.

     The only reason to use either of these classes is to provide
     a  way to mix C stdio code and C++ iostream-like code on the
     same file.  Prefer to use filebuf and fstream, which are far
     more efficient, for new code.

  stdiobuf functions
     stdiobuf(fp)
          Constructs a stdiobuf attached to  the  FILE  structure
          pointed to by fp.

     FILE* fp = siobuf.stdiofile()
          Returns a pointer to the FILE structure associated with
          siobuf.

  stdiostream functions
     stdiostream(fp)
          Constructs a stdiostream attached to the FILE structure
          pointed to by fp.

     stdiobuf* sbp = siostr.rdbuf()
          Returns a  pointer  to  the  stdiobuf  associated  with
          siostr.   This is the same as ios::rdbuf(), except that
          the return type is specifically a stdiobuf.


SEE ALSO

     ios.intro(3CC4), ios(3CC4), sbufprot(3CC4), sbufpub(3CC4),
     stdio(3C), C++ Library Reference, Chapter 3, "The Classic
     iostream Library"