ios_base::register_callback
void register_callback ( event_callback fn, int index ); | ios_base |
cplusplus.com |
Register event callback function.
Registers function fn
such that when an event occurs it is called. index is passed as a parameter
when fn is called.
If more than one, registered functions are called in opposite order of registration.
Functions are called by an expression equivalent to:
(*fn)(ev,*this,index)
where ev is an object of member type event with one of
the following values:
The registered function is called on all the cases above.
copyfmt_event on a call to copyfmt (just when all format flags have been copied, but before exception mask). erase_event on a call to the class destructor (also called by copyfmt at beginning). imbue_event on a call to imbue (just before function returns).
Parameters.
Return Value.
none
Example.
// stream callbacks
#include <iostream>
#include <fstream>
using namespace std;
void testfn (ios_base::event ev, ios_base& iosobj, int index)
{
switch (ev)
{
case ios_base::copyfmt_event:
cout << "copyfmt_event\n"; break;
case ios_base::imbue_event:
cout << "imbue_event\n"; break;
case ios_base::erase_event:
cout << "erase_event\n"; break;
}
}
int main () {
ofstream filestr;
filestr.register_callback (testfn,0);
filestr.imbue (cout.getloc());
return 0;
}
The execution of this example shall display something similar to:
imbue_event erase_event
See also.
imbue,
ios::copyfmt,
event type,
ios_base class