Skip to content. Skip to navigation

ICTP Portal

Sections
You are here: Home Manuals on-line PGI Compiler pgC_lib istrstream
Personal tools
Document Actions

istrstream



Click on the banner to return to the class reference home page.

istrstream


istrstreambasic_istreambasic_iosios_base

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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(3C++), ios_base(3C++), basic_ios(3C++), strstreambuf(3C++), ostrstream(3C++), 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


©Copyright 1996, Rogue Wave Software, Inc.

Weather
No information available
 

Powered by Plone This site conforms to the following standards: