ios - Enumerations

White Space and Padding

The following values are set by default:

skipws

If ios::skipws is set, white space will be skipped on input. If it is not set, white space is not skipped. If ios::skipws is not set, the arithmetic extractors will signal an error if you attempt to read an integer or floating-point value that is preceded by white space. ios::failbit is set, and extraction ceases until it is cleared. This is done to avoid looping problems. If the following program is run with an input file that contains integer values separated by spaces, ios::failbit is set after the first integer value is read, and the program halts. If the program did not fail() at the beginning of the while loop to test if ios::failbit is set, it would loop indefinitely.

   #include < fstream.h >
   int main()
   {
      fstream f("spadina.dat", ios::in);
      f.unsetf(ios::skipws);
      int i;
      while (!f.eof() && !f.fail()) {
         f >> i;
         cout << i;
      }
   }

left

If ios::left is set, the value is left-justified. Fill characters are added after the value.

right

If ios::right is set, the value is right-justified. Fill characters are added before the value.

internal

If ios::internal is set, the fill characters are added after any leading sign or base notation, but before the value itself.

Base Conversion

The manipulators ios::dec, ios::oct, and ios::hex have the same effect as the flags ios::dec, ios::oct, and ios::hex respectively. dec is set by default.

dec

If ios::dec is set, the conversion base is 10.

oct

If ios::oct is set, the conversion base is 8.

hex

If ios::hex is set, the conversion base is 16.

showbase

If ios::showbase is set, the operation that inserts values converts them to an external form that can be read according to the C++ lexical conventions for integral constants. By default, ios::showbase is unset.

Integral Formatting

The following manipulator affects integral formatting:

showpos

If ios::showpos is set, the operation that inserts values places a positive sign "+" into decimal conversions of positive integral values. By default, showpos is not set.

Floating-Point Formatting

The following format flags control the formatting of floating-point values:

showpoint

If ios:showpoint is set, trailing zeros and a decimal point appear in the result of a floating-point conversion. This flag has no effect if either ios::scientific or ios::fixed is set.

scientific

If ios::scientific is set, the value is converted using scientific notation. In scientific notation, there is one digit before the decimal point and the number of digits following the decimal point depends on the value of ios::x_precision. The default value for ios::x_precision is 6. If ios::uppercase is set, an uppercase "E" precedes the exponent. Otherwise, a lowercase "e" precedes the exponent.

fixed

If ios::fixed is set, floating point values are converted to fixed notation with the number of digits after the decimal point equal to the value of ios::x_precision (or 6 by default).

If neither ios::fixed nor ios::scientific is set, the representation of floating-point values depends on their values and the number of significant digits in the representation equals ios::x_precision. Floating-point values are converted to scientific notation if the exponent resulting from a conversion to scientific notation is less an -4 or greater than or equal to the value of ios::x_precision. Otherwise, floating-point values are converted to fixed notation. If ios::showpoint is not set, trailing zeros are removed from the result and a decimal point appears only if it is followed by a digit. ios::scientific and ios::fixed are collectively identified by the static member ios::floatfield.

Uppercase and Lowercase

uppercase

If ios::uppercase is set, the operation that inserts values uses an uppercase "E" for floating point values in scientific notation. In addition, the operation that inserts values stores hexadecimal digits "A" to "F" in uppercase and places an uppercase "X" before hexadecimal values when ios::showbase is set. If ios::uppercase is not set, a lowercase "e" introduces the exponent in floating-point values, hexadecimal digits "a" to "f" are stored in lowercase, and a lowercase "x" is inserted before hexadecimal values when ios::showbase is set.

Buffer Flushing

unitbuf

If ios::unitbuf is set, ostream::osfx() performs a flush after each insertion. The attached stream buffer is unit buffered.

stdio

This flag is used internally by sync_with_stdio(). You should not use ios::stdio directly.

Variation 1
enum  { skipws=01,
        left=02,
        right=04,
        internal=010,
        dec=020,
        oct=040,
        hex=0100,
        showbase=0200,
        showpoint=0400,
        uppercase=01000,
        showpos=02000,
        scientific=04000,
        fixed=010000,
        unitbuf=020000,
        stdio=040000 }

This is supported on AIX OS/400 z/OS

Variation 2
enum  { skipping=01000,
        tied=02000 }

This is supported on AIX OS/400 z/OS

io_state

The error state state is an enumeration that records the errors that take place in the processing of ios objects.

Note: hardfail is a flag used internally by the I/O Stream Library. Do not use it.

open_mode

The elements of the open_mode enumeration have the following meanings:

Variation 1
enum open_mode { in=1,
                 out=2,
                 ate=4,
                 app=010,
                 trunc=020,
                 nocreate=040,
                 noreplace=0100,
                 bin=0200,
                 binary=bin }

This is supported on AIX z/OS

Variation 2
enum open_mode { in=1,
                 out=2,
                 ate=4,
                 app=010,
                 trunc=020,
                 nocreate=040,
                 noreplace=0100,
                 bin=0200,
                 binary=bin,
                 text=0400 }

This is supported on OS/400

seek_dir

The elements of the seek_dir enumeration have the following meanings: