/*** *Iostream_init::Iostream_init() - initialize predefined streams * *Purpose: * Initializes predefined streams: cin, cout, cerr, clog; *Entry: * pstrm = cin, cout, cerr, or clog * sflg = 1 if cerr (unit buffered) * sflg = -1 if cout * *Exit: * *Exceptions: * *******************************************************************************/ Iostream_init::Iostream_init(ios& pstrm, int sflg) { #if ((!defined(_WINDOWS)) || defined(_QWIN)) pstrm.delbuf(1); if (sflg>=0) // make sure not cout pstrm.tie(&cout); if (sflg>0) pstrm.setf(ios::unitbuf); #endif }
void JSetState ( ios& stream, const int flag ) { #ifdef __SUNPRO_CC stream.clear(stream.rdstate() | flag); #elif __GNUG__ >= 3 stream.setstate((ios_base::iostate) flag); #else stream.setstate(flag); #endif }
void postSomething() { while(m_active) { m_io.post([]{std::cout<<"something...\n";}); sleep(1000); } }
iostream::iostream( ios const &strm ) { /*************************************/ // Public constructor, making an iostream with a streambuf attached. // Associate the streambuf found in "strm" with the ios. // Takes an ios so that it can be used with istream and ostream. streambuf *sb; __lock_it( strm.__i_lock ); sb = strm.rdbuf(); ios::init( sb ); }
void update() { m_io.poll(); //do other stuff }
~A() { m_active.reset(); m_io.run(); // to completion }
static void beGood(const ios& i) { if(!i.good()) { printf("File I/O error.\n"); exit(1); } }
void beGood(ios& i) { if(!i.good()) { printf("File I/O error in '%s'\n", (char*)i.pword(IOS_NAME_INDEX)); exit(1); } }
void setName(ios& i, const char* name) { i.pword(IOS_NAME_INDEX) = (void*)name; }