[an error occurred while processing this directive]

HP OpenVMS Systems

C++ Programming Language
Content starts here

Parameterized_manipulators

Each of these manipulators takes a single argument, operates on it as described, and returns it.

Additional Information on:

  • lock(Mutex &)
  • resetiosflags(long)
  • setfill(int)
  • setiosflags(long)
  • setprecision(int)
  • setw(int w)
  • unlock(Mutex &)

  • filebuf

    This class specializes the streambuf class to use a file as a repository of characters. Writing to the file consumes characters; reading from the file produces characters. Files that allow searches are said to be seekable. When a file is readable and writable, the filebuf object permits character insertion and extraction.

    Header:

    #include <fstream.hxx>


    fstream

    This class specializes the class iostream to files using a filebuf object to do the input and output. Your program can perform common operations, such as opening and closing files, without explicitly mentioning filebuf objects.

    Header:

    #include <fstream.hxx>


    ifstream

    This class specializes the class istream to files using a filebuf object to do the input. Your program can perform common operations, such as opening and closing files, without explicitly mentioning filebuf objects.

    Header:

    #include <fstream.hxx>


    ios

    Classes derived from the ios class provide an interface for transferring formatted and unformatted information into and out of streambuf objects.

    Header:

    #include <iostream.hxx>

    Additional Information on:

  • Deriving_a_user_class

  • iostream

    This class combines the classes istream and ostream. You use it to carry out bidirectional operations (inserting into and extracting from a single sequence of characters).

    Header:

    #include <iostream.hxx>


    iostream_withassign

    This class adds an assignment operator and a constructor with no operands to the iostream class.

    Header:

    #include <iostream.hxx>


    istream

    This class provides facilities for formatted and unformatted extraction from streambuf objects.

    Header:

    #include <iostream.hxx>


    istream_withassign

    This class adds an assignment operator and a constructor with no operands to the istream class.

    Header:

    #include <iostream.hxx>


    istrstream

    This class specializes the istream class to perform extractions from arrays of bytes in memory.

    Header:

    #include <strstream.hxx>


    ofstream

    This class specializes the class ostream to files using a filebuf object to do the output. Your program can perform common operations, such as opening and closing files, without explicitly mentioning filebuf objects.

    Header:

    #include <fstream.hxx>


    ostream

    Objects of this class perform formatted and unformatted insertions into streambuf objects.

    Header:

    #include <iostream.hxx>


    ostream_withassign

    This class adds an assignment operator and a constructor with no operands to the ostream class.

    Header:

    #include <iostream.hxx>


    ostrstream

    This class specializes the ostream class to perform insertions into arrays of bytes in memory.

    Header:

    #include <strstream.hxx>


    stdiobuf

    This class specializes the streambuf class for stdio FILEs. It uses unbuffered mode, which causes all operations to be reflected immediately in the FILE.

    Header:

    #include <stdiostream.hxx>


    stdiostream

    This class specializes the ios class for stdio FILEs; it also specializes the ios class to use stdiobuf as its associated streambuf.

    Header:

    #include <stdiostream.hxx>


    streambuf

    This class supports buffers into which you can insert (put) or extract (get) characters. It contains only the basic members for manipulating the characters. To implement the functions of this class, use a class derived from the streambuf class.

    The protected members of this class present an interface to the derived classes organized around the get, put, and reserve areas (arrays of bytes), which are managed cooperatively by the base and derived classes.

    The reserve area is a sequence of characters with an associated get pointer, put pointer, or both. This area serves mainly as a resource in which to allocate space for the put and get areas. As characters enter and exit the reserve area, the put and get areas change but the reserve area remains fixed. A collection of character pointer values defines the three areas. These pointers infer a boundary condition; therefore, it may be helpful to consider such pointers as pointing just before the byte but they actually point right at it.

    Classes derived from streambuf vary in their handling of the get and put pointers. The simplest are unidirectional buffers that permit only get and put operations. Such classes serve as producers and consumers of characters. Queue-like buffers (such as strstream and strstreambuf) have a put and a get pointer that move independently of each other. In such buffers, stored characters are queued until later fetched. File-like buffers (such as filebuf) allow both get and put operations but have their get and put pointers linked together, so that when one pointer moves so does the other.

    To manage the collections of characters in the get and put areas, you can call virtual functions. Services supplied by virtual functions include fetching more characters from an ultimate producer and flushing a collection of characters to an ultimate consumer.

    Header:

    #include <iostream.hxx>


    strstream

    This class specializes iostream for storing in and fetching from arrays of bytes. It handles all predefined data types, and provides an extensive set of options for performing input and output on these data types.

    Header:

    #include <strstream.hxx>


    strstreambuf

    Objects of this class let you use an array of bytes (a string of characters) in memory as a streambuf for stream input/output operations on various kinds of data. Mapping between abstract get and put pointers and char* pointers is direct in the sense that a char* is interpreted as pointing immediately ahead of the char it points to. Moving the pointers corresponds to incrementing and decrementing the char* values.

    To accommodate the need for strings of arbitrary length, this class supports a dynamic mode. When a strstreambuf object is in dynamic mode, space for the character is allocated as needed. When the sequence is extended too far, it is copied to a new array.

    Header:

    #include <strstream.hxx>


    Manipulators

    Manipulators are supplied to let executing programs insert values into or extract values from a stream to cause some special effect as follows:

    ios &dec(ios &s) Sets the conversion base format to decimal. ios &hex(ios &s) Sets the conversion base format to hexadecimal. ios &oct(ios &s) Sets the conversion base format to octal. ios &lock(ios &s) Locks a predefined object ios &unlock(ios &s) Unlcks a predefined object istream &ws(istream &i) Extracts (skips) white-space characters. ostream &endl(ostream &o) Ends a line by inserting a new-line character and flushing. ostream &ends(ostream &o) Ends a string by inserting a null (0) character. ostream &flush(ostream &o) Flushes ostreams.


    IMANIP(TYPE)

    This class supplies predefined parameterized manipulators and provides macros for user-defined parameterized manipulators for istream objects.

    Header:

    #include <iomanip.hxx>


    IOMANIP(TYPE)

    This class supplies predefined parameterized manipulators and provides macros for user-defined parameterized manipulators for iostream objects.

    Header:

    #include <iomanip.hxx>


    OMANIP(TYPE)

    This class supplies predefined parameterized manipulators and provides macros for user-defined parameterized manipulators for ostream objects.

    Header:

    #include <iomanip.hxx>


    SMANIP(TYPE)

    This class supplies predefined parameterized manipulators and provides macros for user-defined parameterized manipulators for ios objects.

    Header:

    #include <iomanip.hxx>


    Predefined_stream_objects_synchronization

    Two unparameterized locking and unlocking manipulators, lock and unlock, are available for use in synchronizing access to the predefined stream objects: cerr, cin, clog, and cout. If your application needs to lock two or more of these objects at the same time, the application must adhere to this locking order:

    cin, cerr, clog, cout

    The unlocking order is not important.

    When your application calls a member function for a predefined stream object, the member function will typically lock the object for the duration of the call. Therefore, if your application has locked one of the stream objects and then uses another, this use must also adhere to the predefined locking order. For example, your application should not send output to cerr while cout is locked.

    The locking order necessarily matches the default 'ties' between the stream objects as follows:

    cin is tied to cout cerr is tied to cout clog is tied to cout cout has no ties

    Any input/output operation on a stream object causes the iostream Package to flush the object to which it is tied. Thus, an output to cerr flushes cout.


    User-defined_stream_objects_synchronization

    Two parameterized locking and unlocking manipulators, lock and unlock, are available for use in synchronizing access to user-defined stream objects. To use these manipulators, you must first define a Mutex object which you then pass to the manipulator. The association of a Mutex object with a stream object is not enforced by the iostream package. This association is enforced only by a program developer. For more information, see help on the Mutex_package.