ios - Member Functions and Data by Group

Constructors & Destructor

Objects of the ios class can be constructed and destructed.

~ios
public:virtual ~ios()

This is supported on AIX OS/400 z/OS

Destructs an ios object.

ios

Creates an ios object.

Overload 1
public:ios(streambuf*)

This is supported on AIX OS/400 z/OS

The streambuf object is associated with the constructed ios object. If this argument is equal to 0, the result is undefined.

Overload 2
protected:ios()

This is supported on AIX OS/400 z/OS

This version of the ios constructor takes no arguments and is declared as protected. The ios class is used as a virtual base class for iostream, and therefore the ios class must have a constructor that takes no arguments. If you use this constructor in a derived class, you must use the init() function to associated the constructed ios object with the streambuf object.

Data members

adjustfield
public:static const long adjustfield

This is supported on AIX OS/400 z/OS

Data member for the ios class.

basefield
public:static const long basefield

This is supported on AIX OS/400 z/OS

Data member for the ios class.

floatfield
public:static const long floatfield

This is supported on AIX OS/400 z/OS

Data member for the ios class.

assign_private
protected:int assign_private

This is supported on AIX OS/400 z/OS

Data member for the ios class.

bp
protected:streambuf* bp

This is supported on AIX OS/400 z/OS

Data member for the ios class. Pointer to the streambuf object.

delbuf
protected:int delbuf

This is supported on AIX OS/400 z/OS

Data member for the ios class.

isfx_special
protected:int isfx_special

This is supported on AIX OS/400 z/OS

Data member for the ios class.

ispecial
protected:int ispecial

This is supported on AIX OS/400 z/OS

Data member for the ios class.

osfx_special
protected:int osfx_special

This is supported on AIX OS/400 z/OS

Data member for the ios class.

ospecial
protected:int ospecial

This is supported on AIX OS/400 z/OS

Data member for the ios class.

state
protected:int state

This is supported on AIX OS/400 z/OS

Data member for the ios class.

x_flags
protected:long x_flags

This is supported on AIX OS/400 z/OS

Data member for the ios class.

x_tie
protected:ostream* x_tie

This is supported on AIX OS/400 z/OS

Data member for the ios class.

Error State Functions

bad
public:int bad() const

This is supported on AIX OS/400 z/OS

Returns a nonzero value is ios::badbit is set in the error state of the ios object. Otherwise, it returns 0.

ios::badbit is usually set when some operation on the streambuf object that is associated with the ios object has failed. It will probably not be possible to continue input and output operations on the ios object.

clear
public:void clear(int i = 0)

This is supported on AIX OS/400 z/OS

Changes the error state of the ios object to the specified value. If the argument equals 0 (its default), all of the bits in the error state are cleared. If you want to set one of the bits without clearing or setting the other bits in the error state, you can perform a bitwise OR between the bit you want to set and the current error state. For example, the following statement sets ios::badbit in the ios object and leaves all the other error state bits unchanged:

   iosobj.clear(ios::badbit | iosobj.rdstate());
eof
public:int eof() const

This is supported on AIX OS/400 z/OS

Returns a nonzero value if ios::eofbit is set in the error state of the ios object. Otherwise, it returns 0.

ios::eofbit is usually set when an EOF has been encountered during an extraction operation.

fail
public:int fail() const

This is supported on AIX OS/400 z/OS

Returns a nonzero value if either ios::badbit or ios::failbit is set in the error state. Otherwise, it returns 0.

good
public:int good() const

This is supported on AIX OS/400 z/OS

Returns a nonzero value if no bits are set in the error state of the ios object. Otherwise, it returns 0.

rdstate
public:int rdstate() const

This is supported on AIX OS/400 z/OS

Returns the current value of the error state of the ios object.

setstate
protected:void setstate(int b)

This is supported on AIX OS/400 z/OS

Format State Functions

fill
Overload 1
public:char fill() const

This is supported on AIX OS/400 z/OS

Returns the value of ios::x_fill of the ios object.

ios::x_fill is the character used as padding if the field is wider than the representation of a value. The default value for ios::x_fill is a space. The ios::left, ios::right and ios::internal flags determine the position of the fill character.

You can also use the parameterized manipulator setfill to set the value of ios::x_fill.

Overload 2
public:char fill(char)

This is supported on AIX OS/400 z/OS

Sets the value of ios::x_fill of the ios object to the specified character.

ios::x_fill is the character used as padding if the field is wider than the representation of a value. The default value for ios::x_fill is a space. The ios::left, ios::right and ios::internal flags determine the position of the fill character.

You can also use the parameterized manipulator setfill to set the value of ios::x_fill.

flags
Overload 1
public:long flags() const

This is supported on AIX OS/400 z/OS

Returns the value of the flags that make up the current format state.

Overload 2
public:long flags(long f)

This is supported on AIX OS/400 z/OS

Sets the flags in the format state to the settings specified in the argument and returns the value of the previous settings of the format flags.

precision
Overload 1
public:int precision() const

This is supported on AIX OS/400 z/OS

Returns the value of ios::x_precision.

ios::x_precision controls the number of significant digits when floating-point values are inserted.

The format state in effect when precision() is called affects the behavior of precision(). If neither ios::scientific nor ios::fixed is set, ios::x_precision specifies the number of significant digits in the floating-point value that is being inserted. If, in addition, ios::showpoint is not set, all trailing zeros are removed and a decimal point only appears if it is followed by digits.

If either ios::scientific or ios::fixed is set, ios::x_precision specifies the number of digits following the decimal point.

Overload 2
public:int precision(int)

This is supported on AIX OS/400 z/OS

Sets the value of ios::x_precision to the specified value and returns the previous value. The value must be greater than 0. If the value is negative, the value of ios::x_precision is set to the default value, 6.

You can also use the parameterized manipulator setprecision to set ios::x_precision.

The format state in effect when precision() is called affects the behavior of precision(). If neither ios::scientific nor ios::fixed is set, ios::x_precision specifies the number of significant digits in the floating-point value that is being inserted. If, in addition, ios::showpoint is not set, all trailing zeros are removed and a decimal point only appears if it is followed by digits.

If either ios::scientific or ios::fixed is set, ios::x_precision specifies the number of digits following the decimal point.

setf
Overload 1
public:long setf(long setbits, long field)

This is supported on AIX OS/400 z/OS

This function clears the format flags specified in field, sets the format flags specified in setbits, and returns the previous value of the format state.

For example, to change the conversion base in the format state to ios::hex, you could use a statement like this:

   s.setf(ios::hex, ios::basefield);

In this statement, ios::basefield specifies the conversion base as the format flag that is going to be changed and ios::hex specifies the new value for the conversion base. If setbits equals 0, all of the format flags specified in field are cleared.

You can also use the parameterized manipulator resetiosflags to clear format flags.

Note: If you set conflicting flags the results are unpredictable.

Overload 2
public:long setf(long)

This is supported on AIX OS/400 z/OS

This function is accumulative. It sets the format flags that are specified in the argument, without affecting format flags that are not marked in the argument, and returns the previous value of the format state.

You can also use the parameterized manipulator setiosflags to set the format flags to a specific setting.

skip
public:int skip(int i)

This is supported on AIX OS/400 z/OS

Sets the format flag ios::skipws if the value of the argument i does not equal 0. If i does equal 0, ios::skipws is cleared.

skip() returns a value of 1 if ios::skipws was set prior to the call to skip(), and returns 0 otherwise.

unsetf
public:long unsetf(long)

This is supported on AIX OS/400 z/OS

Turns off the format flags specified in the argument and returns the previous format state.

width
Overload 1
public:int width() const

This is supported on AIX OS/400 z/OS

Returns the value of the current setting of the format state field width variable, ios::x_width.

If the value of ios::x_width is smaller than the space needed for the representation of the value, the full value is still inserted.

Overload 2
public:int width(int w)

This is supported on AIX OS/400 z/OS

Sets ios::x_width to the value w and returns the previous value.

The default field width is 0. When the value of ios::x_width is 0, the operations that insert values only insert the characters needed to represent a value.

If the value of ios::x_width is greater than 0, the characters needed to represent the value are inserted. Then fill characters are inserted, if necessary, so that the representation of the value takes up the entire field. ios::x_width only specifies a minimum width, not a maximum width. If the number of characters needed to represent a value is greater than the field width, none of the characters is truncated. After every insertion of a value of a numeric or string type (including char*, unsigned char *, signed char*, and wchar_t*, but excluding char, unsigned char, signed char, and wchar_t), the value of ios::x_width is reset to 0. After every extraction of a value of type char*, unsigned char*, signed char*, or wchar_t*, the value of ios::x_width is reset to 0.

You can also use the parameterized manipulator setw to set the field width.

Format State Variables

The format state is a collection of format flags and format variables that control the details of formatting for input and output operations.

x_fill
protected:char x_fill

This is supported on AIX OS/400 z/OS

Represents the character that is used to pad values that do not require the width of an entire field for their representation. Its default value is a space character.

x_precision
protected:short x_precision

This is supported on AIX OS/400 z/OS

Represents the number of significant digits in the representation of floating-point values. Its default value is 6.

x_width
protected:short x_width

This is supported on AIX OS/400 z/OS

Represents the minimum width of a field. Its default value is 0.

Initialization Functions

init
protected:void init(streambuf*)

This is supported on AIX OS/400 z/OS

Locking functions

ios_resource
public:IRTLResource& ios_resource() const

This is supported on z/OS

Miscellaneous Functions

bitalloc
public:static long bitalloc()

This is supported on AIX OS/400 z/OS

A static function that returns a long value with a previously unallocated bit set. You can use this long value as an additional flag, and pass it as an argument to the format state member functions. When all the bits are exhausted, bitalloc() returns 0.

iword
public:long& iword(int)

This is supported on AIX OS/400 z/OS

Returns a reference to the indexed user-defined flag, where the index used in the argument to this function is returned by xalloc().

iword() allocates space for the user-defined flag. If the allocation fails, iword() sets ios::failbit. You should check ios::failbit after calling iword().

operator !
public:int operator !() const

This is supported on AIX OS/400 z/OS

The ! operator returns a nonzero value if ios::failbit or ios::badbit is set in the error state of the ios object.

For example, you could write:

   if (!cin)
      cout << "either ios::failbit or ios::badbit is set"  << endl;
   else
      cout << "neither ios::failbit nor ios::badbit is set" << endl;
operator const void *
public:operator const void *() const

This is supported on AIX OS/400 z/OS

operator void *
public:operator void *()

This is supported on AIX OS/400 z/OS

pword
public:void *& pword(int)

This is supported on AIX OS/400 z/OS

Returns a reference to a pointer to the indexed user-defined flag where the index used in the argument to this function is returned by xalloc().

pword() allocates space for the user-defined flag. If the allocation fails, pword() sets ios::failbit. You should check ios::failbit after calling pword().

On platforms where long and pointer types are the same size, pword() is the same as iword(), except that the two functions return different types.

rdbuf
public:streambuf* rdbuf()

This is supported on AIX OS/400 z/OS

Returns a pointer to the streambuf object that is associated with the ios object. This is the streambuf object that was passed as an argument to the ios constructor.

sync_with_stdio
public:static void sync_with_stdio()

This is supported on AIX OS/400 z/OS

sync_with_stdio() is a static function that solves the problems that occur when you call functions declared in stdio.h and I/O Stream Library functions in the same program. The first time that you call sync_with_stdio(), it attaches stdiobuf objects to the predefined streams cin, cout and cerr. After that, input and output using these predefined streams can be mixed with input and output using the corresponding FILE objects (stdin, stdout, and stderr). This input and output are correctly synchronized.

If you switch between the I/O Stream Library formatted extraction functions and stdio.h functions, you may find that a byte is "lost". The reason is that the formatted extraction functions for integers and floating-point values keep extracting characters until a nondigit character is encountered. This nondigit character acts as a delimiter for the value that preceded it. Because it is not part of the value, putback() is called to return it to the stream buffer. If a C stdio library function, such as getchar(), performs the next input operation, it will begin input at the character after this nondigit character. Thus, this nondigit character is not part of the value extracted by the formatted extraction function, and it is not the character extracted by the C stdio library function. It is "lost". Therefore, you should avoid switching between the I/O Stream Library formatted extraction functions and C stdio library functions whenever possible.

sync_with_stdio() makes cout and clog unit buffered. After you call sync_with_stdio(), the performance of your program could diminish. The performance of your program depends on the length of strings, with performance diminishing most when the strings are shortest.

tie
Overload 1
public:ostream* tie()

This is supported on AIX OS/400 z/OS

Returns the value of ios::x_tie.

ios::x_tie is the tie variable that points to the ostream object that is tied to the ios object.

You can use ios::x_tie to automatically flush the stream buffer attached to an ios object. If ios::x_tie for an ios object is not equal to 0 and the ios object needs more characters or has characters to be consumed, the ostream object pointed to by ios::x_tie is flushed.

By default, the tie variables of the predefined streams cin, cerr and clog all point to the predefined stream cout.

Overload 2
public:ostream* tie(ostream* s)

This is supported on AIX OS/400 z/OS

Sets the tie variable, ios::x_tie, equal to the specified ostream and returns the previous value.

You can use ios::x_tie to automatically flush the stream buffer attached to an ios object. If ios::x_tie for an ios object is not equal to 0 and the ios object needs more characters or has characters to be consumed, the ostream object pointed to by ios::x_tie is flushed.

By default, the tie variables of the predefined streams cin, cerr and clog all point to the predefined stream cout.

xalloc

A static function that returns an unused index into an array of words available for use as format state variables by classes derived from ios.

xalloc() simply returns a new index; it does not do any allocation. iword() and pword() do the allocation, and if the allocation fails, they set ios::failbit. You should check ios::failbit after calling iword() or pword().

Overload 1
public:static int xalloc()

This is supported on AIX OS/400 z/OS

AIX and z/OS Considerations

The value returned is an int for 32-bit applications. This function is not available for 64-bit applications.

Overload 2
public:static long xalloc()

This is supported on AIX z/OS

The value returned is a long for 64-bit applications. This function is not available for 32-bit applications.

( * stdioflush ) ( )
protected:static void ( * stdioflush ) ( )

This is supported on AIX OS/400 z/OS