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

ios_base


Base Class

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

Synopsis

#include <ios>
class ios_base;

Description

The class ios_base defines several member types:

It maintains several kinds of data:

Interface

class ios_base {
  
 public:

   class failure : public exception {
      
      public:

          explicit failure(const string& msg);
          virtual ~failure() throw();
          virtual const char* what() const throw();
    };

   typedef int      iostate;

   enum io_state {
                   goodbit     = 0x00,   
                   badbit      = 0x01, 
                   eofbit      = 0x02,
                   failbit     = 0x04
                 };

   typedef int      openmode;

   enum open_mode {
                    app         = 0x01, 
                    binary      = 0x02, 
                    in          = 0x04, 
                    out         = 0x08, 
                    trunc       = 0x10,  
                    ate         = 0x20 
                  };

   typedef int      seekdir;

   enum seek_dir {
                     beg         = 0x0,  
                     cur         = 0x1, 
                     end         = 0x2    
                 };


   typedef int      fmtflags;

   enum fmt_flags {
                    boolalpha   = 0x0001,
                    dec         = 0x0002,
                    fixed       = 0x0004, 
                    hex         = 0x0008,
                    internal    = 0x0010,
                    left        = 0x0020,
                    oct         = 0x0040,
                    right       = 0x0080,
                    scientific  = 0x0100,
                    showbase    = 0x0200,
                    showpoint   = 0x0400, 
                    showpos     = 0x0800,
                    skipws      = 0x1000,
                    unitbuf     = 0x2000,
                    uppercase   = 0x4000,
                    adjustfield = left | right | internal,
                    basefield   = dec | oct | hex,
                    floatfield  = scientific | fixed
                  };
    
   enum event     {
                    erase_event   = 0x0001,
                    imbue_event   = 0x0002,   
                    copyfmt_event = 0x004
                  };

   typedef void (*event_callback) (event, ios_base&, int index);

   void register_callback(event_callback fn, int index);

   class Init;

   fmtflags flags() const;
   fmtflags flags(fmtflags fmtfl);
   fmtflags setf(fmtflags fmtfl);
   fmtflags setf(fmtflags fmtfl, fmtflags mask);

   void unsetf(fmtflags mask);

   ios_base& copyfmt(const ios_base& rhs);

   streamsize precision() const;
   streamsize precision(streamsize prec);

   streamsize width() const;
   streamsize width(streamsize wide);

   locale imbue(const locale& loc);
   locale getloc() const

   static int xalloc();

   long&  iword(int index);
   void*& pword(int index);

   bool synch_with_stdio(bool sync = true);
   bool is_synch();

  protected:

   ios_base();
   ~ios_base();

  private:

   union ios_user_union {
                           long  lword;
                           void* pword;
                        };

   union ios_user_union *userwords_;
};

 ios_base& boolalpha(ios_base&);
 ios_base& noboolalpha(ios_base&);
 ios_base& showbase(ios_base&);
 ios_base& noshowbase(ios_base&);
 ios_base& showpoint(ios_base&);
 ios_base& noshowpoint(ios_base&);
 ios_base& showpos(ios_base&);
 ios_base& noshowpos(ios_base&);
 ios_base& skipws(ios_base&);
 ios_base& noskipws(ios_base&);
 ios_base& uppercase(ios_base&);
 ios_base& nouppercase(ios_base&);
 ios_base& internal(ios_base&);
 ios_base& left(ios_base&);
 ios_base& right(ios_base&);
 ios_base& dec(ios_base&);
 ios_base& hex(ios_base&);
 ios_base& oct(ios_base&);
 ios_base& fixed(ios_base&);
 ios_base& scientific(ios_base&);
 ios_base& unitbuf(ios_base&);
 ios_base& nounitbuf(ios_base&);

Types

fmtflags
showpos
Generates a + sign in non-negative generated numeric output.
showbase
Generates a prefix indicating the numeric base of generated integer output.
uppercase
Replaces certain lowercase letters with their uppercase equivalents in generated output.
showpoint
Generates a decimal-point character unconditionally in generated floating-point output.
boolalpha
Inserts and extracts bool type in alphabetic format.
unitbuf
Flushes output after each output operation.
internal
Adds fill characters at a designated internal point in certain generated output, or identical to right if no such point is designated.
left
Adds fill characters on the right (final positions) of certain generated output.
right
Adds fill characters on the left (initial positions) of certain generated output.
dec
Converts integer input or generates integer output in decimal base.
hex
Converts integer input or generates integer output in hexadecimal base.
oct
Converts integer input or generates integer output in octal base.
fixed
Generates floating-point output in fixed-point notation.
scientific
Generates floating-point output in scientific notation.
Skipws
Skips leading white space before certain input operation.
iostate
badbit
Indicates a loss of integrity in an input or output sequence.
eofbit
Indicates that an input operation reached the end of an input sequence.
failbit
Indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters.
openmode
app
Seeks to the end before writing.
ate
Opens and seek to end immediately after opening.
binary
Performs input and output in binary mode.
in
Opens for input.
out
Opens for output.
trunc
Truncates an existing stream when opening.
seekdir
beg
Requests a seek relative to the beginning of the stream.
cur
Requests a seek relative to the current position within the sequence.
end
Requests a seek relative to the current end of the sequence.
event_callback

Public Constructor

ios_base();

Public Destructor

~ios_base();

Public Member Functions

ios_base& 
copyfmt(const ios_base& rhs);
fmtflags 
flags() const;
fmtflags 
flags(fmtflags fmtfl);
locale 
getloc() const;
locale 
imbue(const locale& loc);
bool 
is_sync();
long& 
iword(int idx);
streamsize 
precision() const;
streamsize 
precision(streamsize prec);
void*& 
pword(int idx);
void 
register_callback(event_callback fn, int index);
fmtflags 
setf(fmtflags fmtfl);
fmtflags 
setf(fmtflags fmtfl, fmtflags mask);
bool 
sync_with_stdio(bool sync = true);
void 
unsetf(fmtflags mask);
streamsize 
width() const;
streamsize 
width(streamsize wide);
static int 
xalloc();

The Class failure

The class failure defines the base class for the types of all objects thrown as exceptions, by functions in the iostreams library, to report errors detected during stream buffer operations.

explicit failure(const string& msg);
const char* 
what() const;

Class Init

The class Init describes an object whose construction ensures the construction of the eight objects declared in <iostream> that associate file stream buffers with the standard C streams.

Non-Member Functions

ios_base& 
boolalpha(ios_base& str);
ios_base& 
dec(ios_base& str);
ios_base& 
fixed(ios_base& str);
ios_base& 
hex(ios_base& str);
ios_base& 
internal(ios_base& str);
ios_base& 
left(ios_base& str);
ios_base& 
noboolalpha(ios_base& str);
ios_base& 
noshowbase(ios_base& str);
ios_base& 
noshowpoint(ios_base& str);
ios_base& 
noshowpos(ios_base& str);
ios_base& 
noskipws(ios_base& str);
ios_base& 
nounitbuf(ios_base& str);
ios_base& 
nouppercase(ios_base& str);
ios_base& 
oct(ios_base& str);
ios_base& 
right(ios_base& str);
ios_base& 
scientific(ios_base& str);
ios_base& 
showbase(ios_base& str);
ios_base& 
showpoint(ios_base& str);
ios_base& 
showpos(ios_base& str);
ios_base& 
skipws(ios_base& str);
ios_base& 
unitbuf(ios_base& str);
ios_base& 
uppercase(ios_base& str);

See Also

basic_ios(3C++), basic_istream(3C++), basic_ostream(3C++), char_traits(3C++)

Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.4.3

Standards Conformance

ANSI X3J16/ISO WG21 Joint C++ Committee


©Copyright 1996, Rogue Wave Software, Inc.