VMS Help
CXXLSTD, IOStreams, istrstream

 *Conan The Librarian

 			   Standard C++	Library
 		 Copyright 1996, Rogue Wave Software, Inc.

 NAME

   istrstream

 SYNOPSIS

   #include <strstream>
   class	istrstream
   : public basic_istream<char>

 DESCRIPTION

   The class istrstream provides	functionality to read characters from
   an array	in memory. It uses a private strstreambuf object to
   control the	associated array object. It inherits from
   basic_istream<char> and	therefore can use all the formatted
   and unformatted	input functions.

 INTERFACE

   class	istrstream : public basic_istream<char>	{

   public:

    typedef char_traits<char>		 traits;

    typedef char				char_type;
    typedef typename traits::int_type	int_type;
    typedef typename traits::pos_type	pos_type;
    typedef typename traits::off_type	off_type;

    explicit istrstream(const char *s);
    istrstream(const char *s, streamsize	n);
    explicit istrstream(char *s);
    istrstream(char *s, streamsize n);

    virtual ~istrstream();

    strstreambuf	*rdbuf() const;

    char	*str();

   };

 TYPES

   char_type
      The type char_type	is a synonym of	type char.

   int_type
      The type int_type is a synonym of type traits::in_type.

   off_type
      The type off_type is a synonym of type traits::off_type.

   pos_type
      The type pos_type is a synonym of type traits::pos_type.

   traits
      The type traits is	a synonym of type char_traits<char>.

 CONSTRUCTORS

   explicit istrstream(const char* s);
   explicit istrstream(char* s);
      Constructs	an object of class istrstream, initializing the	base
      class basic_istream<char> with the associated strstreambuf
      object. The strstreambuf object is initialized	by calling
      strstreambuf(s,0), where s shall designate the first element of
      an NTBS.

   explicit istrstream(const char* s, streamsize	n);
   explicit istrstream(char* s, streamsize n);
      Constructs	an object of class istrstream, initializing the	base
      class basic_istream<char> with the associated strstreambuf
      object. The strstreambuf object is initialized	by calling
      strstreambuf(s,n), where s shall designate the first element of
      an array whose length	is n elements, and	n shall	be
      greater than	zero.

 DESTRUCTORS

   virtual ~istrstream();
      Destroys an object	of class istrstream.

 MEMBER FUNCTIONS

   char*
   str();
      Returns a pointer to the underlying array object which may
      be null.

   strstreambuf*
   rdbuf() const;
      Returns a pointer to the private strstreambuf object associated
      with the stream.

 EXAMPLES

   //
   // stdlib/examples/manual/istrstream.cpp
   //
   #include<iostream>
   #include<strstream>

   void main ( )
   {
    using namespace std;

    const char* p="C'est	pas l'homme qui	prend la mer, ";
    char* s="c'est la mer qui prend l'homme";

     // create an istrstream object and initialize
     // the underlying strstreambuf with	p
    istrstream in_first(p);

     // create an istrstream object and initialize
     // the underlying strstreambuf with	s
    istrstream in_next(s);

     // create an ostrstream object
    ostrstream out;

     // output the content of in_first and
     // in_next to out
    out << in_first.rdbuf() << in_next.str();

     // output the content of out to stdout
    cout	<< endl	<< out.rdbuf() << endl;

     // output the content of in_first to stdout
    cout	<< endl	<< in_first.str();

     // output the content of in_next to	stdout
    cout	<< endl	<< in_next.rdbuf() << endl;

   }

 SEE ALSO

   char_traits,	ios_base, basic_ios,
   strstreambuf, ostrstream, strstream(3c++)

   Working Paper	for Draft Proposed International Standard for
   Information Systems--Programming Language	C++, Annex D
   Compatibility features Section D.6.2

 STANDARDS CONFORMANCE
   ANSI X3J16/ISO WG21 Joint C++	Committee
  Close     Help