fstreambase - Member Functions and Data by Group

Constructors & Destructor

Objects of the fstreambase class can be constructed and destructed by objects that derive from it. These constructors and destructors should not be used directly.

~fstreambase
public:~fstreambase()

This is supported on AIX OS/400 z/OS

Destructs an fstreambase object.

fstreambase

Constructs an object of this class.

Overload 1
public:fstreambase(int fd, char* p, int l)

This is supported on AIX OS/400 z/OS

This constructor does the following:

  • constructs an fstreambase object
  • initializes the filebuf object to the file descriptor passed in
  • initializes the streambuf object and sets the get and put pointers based on the pointer p and the length l
  • initializes the ios object.

If the file is already open, it clears the ios state. Otherwise, it sets the ios::failbit in the format state of the object.

AIX and z/OS Considerations

This function is available for 32-bit applications. The third argument is an int value.

Overload 2
public:fstreambase( const char* name,
             const char* attr,
             int mode,
             int prot = filebuf::openprot )

This is supported on z/OS

Constructs an fstreambase object, initializes the ios object, and opens the specified file with the specified mode, attributes and protection.

You can use the attr parameter to specify additional file attributes such as lrecl or recfm. All the parameters documented for the fopen() functions are supported, with the exception of type=record.

z/OS Considerations

The prot parameter is ignored.

Overload 3
public:fstreambase(int fd)

This is supported on AIX OS/400 z/OS

This constructor does the following:

  • constructs an fstreambase object
  • initializes the filebuf object to the file descriptor passed in
  • initializes the ios object.

If the file is already open, it clears the ios state. Otherwise, it sets the ios::failbit in the format state of the object.

Overload 4
public:fstreambase(int fd, char* p, long l)

This is supported on AIX z/OS

This constructor does the following:

  • constructs an fstreambase object
  • initializes the filebuf object to the file descriptor passed in
  • initializes the streambuf object and sets the get and put pointers based on the pointer p and the length l
  • initializes the ios object.

If the file is already open, it clears the ios state. Otherwise, it sets the ios::failbit in the format state of the object.

This function is available for 64-bit applications. The third argument is a long value.

Overload 5
public:fstreambase( const char* name,
             int mode,
             int prot = filebuf::openprot,
             _CCSID_T ccsid = _CCSID_T ( 0 ) )

This is supported on OS/400

Constructs an fstreambase object, initializes the ios object, and opens the specified file with the specified mode, protection, and ccsid.

If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.

Overload 6
public:fstreambase(const char* name, int mode, _CCSID_T ccsid)

This is supported on OS/400

Constructs an fstreambase object, initializes the ios object, and opens the specified file with the specified mode and ccsid.

If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.

Overload 7
public:fstreambase( const char* name,
             int mode,
             int prot = filebuf::openprot )

This is supported on AIX z/OS

Constructs an fstreambase object, initializes the ios object, and opens the specified file with the specified mode and protection.

z/OS Considerations

The prot parameter is ignored.

Overload 8
public:fstreambase()

This is supported on AIX OS/400 z/OS

Default constructor. Constructs an fstreambase object and initializes the ios object.

Filebuf Functions

Use these functions to work with the underlying filebuf object.

attach

Attaches the fstream, ifstream or ofstream object to the file descriptor or file pointer.

Overload 1
public:void attach(FILE* fp)

This is supported on z/OS

Attaches the fstream, ifstream or ofstream object to the file pointer fp. If the object is already attached to a file pointer, an error occurs and ios::failbit is set in the format state of the object.

Overload 2
public:void attach(int fd)

This is supported on AIX OS/400 z/OS

Attaches the fstream, ifstream or ofstream object to the file descriptor fd. If the object is already attached to a file descriptor, an error occurs and ios::failbit is set in the format state of the object.

close
public:void close()

This is supported on AIX OS/400 z/OS

Closes the filebuf object, breaking the connection between the fstream, ifstream or ofstream object and the file descriptor. close() calls filebuf->close(). If this call fails, the error state of the fstream, ifstream or ofstream object is not cleared.

detach
public:int detach()

This is supported on AIX OS/400 z/OS

Detaches the filebuf object, breaking the connection between the fstream, ifstream or ofstream object and the file descriptor. detach() calls filebuf->detach().

rdbuf
public:filebuf* rdbuf()

This is supported on AIX OS/400 z/OS

Returns a pointer to the filebuf object that is attached to the fstream, ifstream or ofstream object.

Miscellaneous Functions

verify
protected:void verify(int)

This is supported on AIX OS/400 z/OS

Clears the format state of the object or sets the ios::failbit in the format state of the object depending on the value of the argument. If the argument value is 1, the format state is cleared, otherwise the ios::failbit is set.

Open Functions

open

Opens the specified file.

Overload 1
public:void
  open( const char* name,
        const char* attr,
        int mode,
        int prot = filebuf::openprot )

This is supported on z/OS

Opens the file with the name and attaches it to the fstream object. If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.

You can use the attr parameter to specify additional file attributes, such as lrecl or recfm. All the parameters documented for the fopen() function are supported, with the exception of type=record.

The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.

Overload 2
public:void open(const char* name, int mode, _CCSID_T ccsid)

This is supported on OS/400

Opens the file with the specified name, mode and coded character set id and attaches it to the fstream object.

If the file with the name, name does not already exist, open() tries to create it unless ios::nocreate is set.

The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.

If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.

Overload 3
public:void
  open( const char* name,
        int mode,
        int prot = filebuf::openprot,
        _CCSID_T ccsid = _CCSID_T ( 0 ) )

This is supported on OS/400

Opens the file with the specified name, mode, protection and coded character set id and attaches it to the fstream object.

If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.

The default value for prot is filebuf::openprot. If the fstream object is already attached to a file or if the call to fstream.rdbuf()->open() fails, ios::failbit is set in the error state for the fstream object.

The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.

If the ccsid parameter is non-zero then it is treated as a CCSID (coded character set identifier) and will correspond to the CCSID of data written to and from the file. If the parameter value is zero then the CCSID of the job will be used.

Overload 4
public:void
  open( const char* name,
        int mode,
        int prot = filebuf::openprot )

This is supported on AIX z/OS

Opens the file with the name and attaches it to the fstream object. If the file with the name, name does not already exist, open() tries to create it with protection mode equal to prot, unless ios::nocreate is set.

The default value for prot is filebuf::openprot. If the fstream object is already attached to a file of if the call to fstream.rdbuf()->open() fails, ios::failbit is set in the error state for the fstream object.

The members of the ios::open_mode enumeration are bits that can be ORed together. The value of mode is the result of such an OR operation. This result is an int value, and for this reason, mode has type int rather than open_mode.

Stream Buffer Functions

Use these functions to work with the underlying streambuf object.

setbuf
Overload 1
public:void setbuf(char* p, long l)

This is supported on AIX z/OS

Sets up a stream buffer with length in bytes equal to l beginning at the position pointed to by p. If p is equal to 0 or l is nonpositive, the fstream, ifstream or ofstream object (fb) will be unbuffered. If fb is open, or the call to fb->setbuf() fails, setbuf() sets ios::failbit in the object's state.

This function is available for 64-bit applications. The second argument is a long value.

Overload 2
public:void setbuf(char* p, int l)

This is supported on AIX OS/400 z/OS

Sets up a stream buffer with length in bytes equal to l beginning at the position pointed to by p. If p is equal to 0 or l is nonpositive, the fstream, ifstream or ofstream object (fb) will be unbuffered. If fb is open, or the call to fb->setbuf() fails, setbuf() sets ios::failbit in the object's state.

AIX and z/OS Considerations

This function is available for 32-bit applications. The second argument is an int value.