C++ Library - <ios_base>



Introduction

Base class for the entire hierarchy of stream classes in the standard input/output library, describing the most basic part of a stream which is common to all stream objects, independently of their character type.

It has no public constructors, and thus no objects of this class can be declared. Both ios_base and its derived class basic_ios define the components of streams that do not depend on whether the stream is an input or an output stream: ios_base describes the members that are independent of the template parameters (i.e. the character type and traits), while basic_ios describes the members that do depend on them.

More specifically, the ios_base class maintains the following information of a stream −

fieldmember functionsdescription
Formattingformat flags

flags

setf

unsetf

A set of internal flags that affect how certain input/output operations are interpreted or generated. See member type fmtflags.
field widthwidthWidth of the next formatted element to insert.
display precisionprecisionDecimal precision for the next floating-point value inserted.
locale

getloc

imbue

The locale object used by the function for formatted input/output operations affected by localization properties.
Othercallback stackregister_callbackStack of pointers to functions that are called when certain events occur.
extensible arrays

iword

pword

xalloc

Internal arrays to store objects of type long and void*.

Definition

Below is definition of ios_base as shown below −

class ios_base;

Member types

Sr.No.Member typesDefinition
1eventType to indicate event type
2event_callbackEvent callback function type
3fmtflagsType for stream format flags
4iostateType for stream state flags
5openmodeType for stream opening mode flags
6seekdirType for stream seeking direction flag

Public Member Functions

Sr.No.Member typesDefinition
1(constructor)Construct object (public member function )
2(destructor)Destruct object (public member function )

Formatting

Sr.No.Member typesDefinition
1flagsIt is used to get/set format flags
2setfIt is used to set specific format flags
3unsetfIt is used to clear specific format flags
4precisionIt is used to get/Set floating-point decimal precision
5widthIt is used to get/set field width

Locales

Sr.No.Member typesDefinition
1imbueImbue locale
2getlocGet current locale

Internal extensible array

Sr.No.Member typesDefinition
1xallocIt is used to get new index for extensible array [static]
2iwordIt is used to get integer element of extensible array
3pwordIt is used to get pointer element of extensible array

Others

Sr.No.Member typesDefinition
1register_callbackRegister event callback function
2sync_with_stdioToggle synchronization with cstdio streams [static]
ios.htm