? piostreams.diff ? config/depcomp ? config/texinfo.tex ? demo/pio ? doc/commoncpp2.info ? doc/commoncpp2.info-1 ? doc/commoncpp2.info-2 ? doc/commoncpp2.info-3 ? include/stamp-h1 ? include/cc++/pfstream ? ssl/Makefile ? ssl/Makefile.in ? win32/CCXX2.rc Index: include/cc++/postream =================================================================== RCS file: /cvsroot/commoncpp/commoncpp2/include/cc++/postream,v retrieving revision 1.1 diff -u -3 -p -r1.1 postream --- include/cc++/postream 21 Sep 2002 18:26:57 -0000 1.1 +++ include/cc++/postream 7 Oct 2002 05:17:23 -0000 @@ -71,14 +71,15 @@ public: typedef Traits traits_type; // Non-standard Types: - typedef basic_streambuf streambuf_type; - //typedef basic_pstreambuf pstreambuf_type; - typedef basic_ios ios_type; - typedef basic_ostream ostream_type; - typedef basic_postream postream_type; - typedef ostreambuf_iterator ostreambuf_iter; - typedef num_put numput_type; - typedef ctype ctype_type; + typedef basic_streambuf streambuf_type; + typedef basic_ios ios_type; + typedef basic_ostream ostream_type; + typedef basic_postream postream_type; + typedef ostreambuf_iterator ostreambuf_iter; + typedef num_put numput_type; + typedef ctype ctype_type; + + typedef typename basic_postream::iostate iostate_type; // Constructor/destructor: explicit @@ -98,22 +99,19 @@ public: postream_type& operator<<(postream_type& (*pf)(postream_type&)); - //postream_type& - //operator<<(ostream_type& (*pf)(ostream_type&)); - postream_type& operator<<(ios_type& (*pf)(ios_type&)); - + postream_type& operator<<(ios_base& (*pf)(ios_base&)); // Arithmetic Inserters postream_type& operator<<(long n); - + postream_type& operator<<(unsigned long n); - + postream_type& operator<<(bool n); @@ -187,6 +185,7 @@ public: postream_type& seekp(pos_type); + postream_type& seekp(off_type, ios_base::seekdir); @@ -197,96 +196,212 @@ public: flags() const { MutexLock mlock(lock); - basic_ostream::flags(); + return ostream_type::flags(); } inline ios_base::fmtflags flags(ios_base::fmtflags fmtfl) { MutexLock mlock(lock); - basic_ostream::flags(fmtfl); + return ostream_type::flags(fmtfl); } inline ios_base::fmtflags setf(ios_base::fmtflags fmtfl) { MutexLock mlock(lock); - basic_ostream::setf(fmtfl); + return ostream_type::setf(fmtfl); } inline ios_base::fmtflags setf(ios_base::fmtflags fmtfl, ios_base::fmtflags mask) { MutexLock mlock(lock); - basic_ostream::setf(fmtfl, mask); + return ostream_type::setf(fmtfl, mask); } inline void unsetf(ios_base::fmtflags mask) { MutexLock mlock(lock); - basic_ostream::unsetf(mask); + ostream_type::unsetf(mask); } inline streamsize precision() const { MutexLock mlock(lock); - basic_ostream::precision(); + return ostream_type::precision(); } inline streamsize precision(streamsize prec) { MutexLock mlock(lock); - basic_ostream::precision(prec); + return ostream_type::precision(prec); } inline streamsize width() const { MutexLock mlock(lock); - basic_ostream::width(); + return ostream_type::width(); } inline streamsize width(streamsize wide) { MutexLock mlock(lock); - basic_ostream::width(wide); + return ostream_type::width(wide); } - static bool - sync_with_stdio(bool sync = true); - - // Locales: - locale - imbue(const locale& loc); + //static bool + //sync_with_stdio(bool sync = true); inline locale getloc() const { MutexLock mlock(lock); - basic_ostream::getloc(); + return ostream_type::getloc(); } // Storage: - static int - xalloc() throw(); + //static int + //xalloc() throw(); inline long& iword(int ix) { MutexLock mlock(lock); - basic_ostream::iword(ix); + return ostream_type::iword(ix); } inline void*& pword(int ix) { MutexLock mlock(lock); - basic_ostream::pword(ix); + return ostream_type::pword(ix); + } + + // std::basic_ios methods + + //operator void*() const + //{ return this->fail() ? 0 : const_cast(this); } + + //bool + //operator!() const + //{ return this->fail(); } + + iostate_type + rdstate() const + { + MutexLock mlock(lock); + return ostream_type::rdstate(); + } + + void + clear(iostate_type state = goodbit); + + void + setstate(iostate_type state) + { + MutexLock mlock(lock); + ostream_type::setstate(state); + } + + bool + good() const + { + MutexLock mlock(lock); + return ostream_type::good(); + } + + bool + eof() const + { + MutexLock mlock(lock); + return ostream_type::eof(); + } + + bool + fail() const + { + MutexLock mlock(lock); + return ostream_type::fail(); + } + + bool + bad() const + { + MutexLock mlock(lock); + return ostream_type::bad(); } + + iostate_type + exceptions() const + { + MutexLock mlock(lock); + return ostream_type::exceptions(); + } + + void + exceptions(iostate_type except) + { + MutexLock mlock(lock); + ostream_type::exceptions(except); + } + + // Members: + basic_postream* + tie() const + { + MutexLock mlock(lock); + return ostream_type::tie(); + } + + basic_ostream* + tie(basic_ostream* tiestr) + { + MutexLock mlock(lock); + return ostream_type::tie(tiestr); + } + + basic_streambuf* + rdbuf() const + { + MutexLock mlock(lock); + return ostream_type::rdbuf(); + } + + basic_streambuf* + rdbuf(basic_streambuf* sb); + + //std::basic_ios& + //copyfmt(const basic_ios& rhs); + + char_type + fill() const + { + MutexLock mlock(lock); + return ostream_type::fill(); + } + + char_type + fill(char_type ch) + { + MutexLock mlock(lock); + return ostream_type::fill(ch); + } + + // Locales: + locale + imbue(const locale& locb); + + char + narrow(char_type c, char dfault) const; + + char_type + widen(char c) const; Thread* currth; int pid; Index: include/cc++/postream.tcc =================================================================== RCS file: /cvsroot/commoncpp/commoncpp2/include/cc++/postream.tcc,v retrieving revision 1.1 diff -u -3 -p -r1.1 postream.tcc --- include/cc++/postream.tcc 21 Sep 2002 18:26:57 -0000 1.1 +++ include/cc++/postream.tcc 7 Oct 2002 05:17:23 -0000 @@ -144,38 +144,25 @@ operator<<(ios_base& (*pf)(ios_base&)) template basic_postream& -basic_postream::operator<<(streambuf_type* sbin) +basic_postream::operator<<(long n) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); - ostream_type::operator<<(sbin); - - return *this; -} - -template -basic_postream& -basic_postream::operator<<(bool n) -{ - // Create a psentry object (may set error bits or throw failure) - typedef basic_postream postream_type; - typename postream_type::psentry opfx(*this); - ostream_type::operator<<(n); - + return *this; } template basic_postream& -basic_postream::operator<<(long n) +basic_postream::operator<<(unsigned long n) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); - + ostream_type::operator<<(n); return *this; @@ -183,14 +170,14 @@ basic_postream::operator< template basic_postream& -basic_postream::operator<<(unsigned long n) +basic_postream::operator<<(bool n) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); ostream_type::operator<<(n); - + return *this; } @@ -223,44 +210,57 @@ basic_postream::operator< template basic_postream& -basic_postream::operator<<(double n) +basic_postream::operator<<(double f) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); - ostream_type::operator<<(n); + ostream_type::operator<<(f); return *this; } template basic_postream& -basic_postream::operator<<(long double n) +basic_postream::operator<<(long double f) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); - ostream_type::operator<<(n); + ostream_type::operator<<(f); return *this; } template basic_postream& -basic_postream::operator<<(const void* n) +basic_postream::operator<<(const void* p) { // Create a psentry object (may set error bits or throw failure) typedef basic_postream postream_type; typename postream_type::psentry opfx(*this); - ostream_type::operator<<(n); + ostream_type::operator<<(p); return *this; } template +basic_postream& +basic_postream::operator<<(streambuf_type* sbin) +{ + // Create a psentry object (may set error bits or throw failure) + typedef basic_postream postream_type; + typename postream_type::psentry opfx(*this); + + ostream_type::operator<<(sbin); + + return *this; +} + +template basic_postream& basic_postream::put(char_type c) { @@ -303,7 +303,7 @@ template::pos_type basic_postream::tellp() { - // TODO: make this operation thread-safe? + MutexLock mlock(lock); ostream_type::tellp(); return *this; @@ -313,10 +313,10 @@ template& basic_postream::seekp(pos_type pos) { - // TODO: make this operation thread-safe? + MutexLock mlock(lock); ostream_type::seekp(pos); - return this; + return *this; } template @@ -324,61 +324,40 @@ basic_postream& basic_postream:: seekp(off_type off, ios_base::seekdir d) { - // TODO: make this operation thread-safe? + MutexLock mlock(lock); ostream_type::seekp(d); return *this; } -template -void -basic_postream::lockStream() -{ - if(!owned) - { - currth = ost::getThread(); - owned = true; - pid = getpid(); - tid = currth->getThreadID(); - if(!header) - { - outputHeader(); - header = true; - } - } - lock.enterMutex(); - lockcnt++; -} -template -void -basic_postream::unlockStream() -{ - mtx.enterMutex(); - if(owned) - { - currth = NULL; - owned = false; - pid = 0; - tid = 0; - header = false; - } - while(lockcnt != 0) - { - lock.leaveMutex(); - lockcnt--; - } - mtx.leaveMutex(); - printf("fully unlocked\n"); -} +// TODO: May have to move this to pios.cpp? +//int +//postream::xalloc() throw() +//{ + //MutexLock mlock(lock); +// return ostream_type::xalloc(); +//} template -void -basic_postream::outputHeader() +basic_streambuf* +basic_postream:: +rdbuf(basic_streambuf* sb) { - *this << "PID: " << pid << ", TID: " << tid << "> "; + MutexLock mlock(lock); + return ostream_type::rdbuf(); } +//template +//basic_ios& +//basic_postream:: +//copyfmt(const basic_ios& rhs) +//{ +// MutexLock mlock(lock); +// return ostream_type::copyfmt(rhs); +//} + + // Character inserters. template basic_postream& @@ -393,6 +372,36 @@ operator<<(basic_postream //~psentry } + +// Locales: +template +locale +basic_postream:: +imbue(const locale& locb) +{ + MutexLock mlock(lock); + return ostream_type::imbue(locb); +} + +template +char +basic_postream:: +narrow(char_type c, char dfault) const +{ + MutexLock mlock(lock); + return ostream_type::narrow(c, dfault); +} + +template +//char_type +//char +charT +basic_postream::widen(char c) const +{ + MutexLock mlock(lock); + return ostream_type::widen(c); +} + // Specializations template basic_postream& @@ -401,7 +410,7 @@ operator<<(basic_postream& typedef basic_postream postream_type; typename postream_type::psentry opfx(out); - std::operator<<(out, c); + std::operator<<(out, c); return out; //~psentry