ostream.mh
来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 236 行
MH
236 行
///////////////////////////////////////////////////////////////////////////
// FILE: ostream/ostream.h (ostream class)
//
:keep CPP_HDR
:include crwat.sp
//
// Description: This header is part of the C++ standard library. It
// defines the output stream class and associated
// parameterless manipulators.
///////////////////////////////////////////////////////////////////////////
:segment !CNAME
#ifndef _OSTREAM_H_INCLUDED
#define _OSTREAM_H_INCLUDED
:include readonly.sp
#ifndef _OSTREAM_INCLUDED
#include <ostream>
#endif
using std::ostream;
using std::endl;
using std::ends;
using std::flush;
// All included names should also be in the global namespace.
#ifndef _IOS_H_INCLUDED
#include <ios.h>
#endif
#endif
:elsesegment
#ifndef _OSTREAM_INCLUDED
#define _OSTREAM_INCLUDED
:include readonly.sp
#ifndef __cplusplus
#error The header ostream requires C++
#endif
#ifndef _COMDEF_H_INCLUDED
#include <_comdef.h>
#endif
#ifndef _IOS_INCLUDED
#include <ios>
#endif
namespace std {
// **************************** OSTREAM ************************************
:include pshpackl.sp
class _WPRTLINK ostream : virtual public ios {
public:
ostream( streambuf *__sb );
ostream( ostream const &__ostrm );
virtual ~ostream();
ostream &operator = ( streambuf *__sb );
ostream &operator = ( ostream const &__ostrm );
ostream &operator << ( char __c );
ostream &operator << ( signed char __c );
ostream &operator << ( unsigned char __c );
ostream &operator << ( signed short __s );
ostream &operator << ( unsigned short __s );
ostream &operator << ( signed int __i );
ostream &operator << ( unsigned int __i );
ostream &operator << ( signed long __l );
ostream &operator << ( unsigned long __l );
ostream &operator << ( signed __int64 __l );
ostream &operator << ( unsigned __int64 __l );
ostream &operator << ( float __f );
ostream &operator << ( double __f );
ostream &operator << ( long double __f );
ostream &operator << ( void *__p );
ostream &operator << ( streambuf *__sb );
ostream &operator << ( char const *__buf );
ostream &operator << ( signed char const *__buf );
ostream &operator << ( unsigned char const *__buf );
ostream &operator << ( _WPRTLINK ostream &(*__f)( ostream & ) );
ostream &operator << ( _WPRTLINK ios &(*__f)( ios & ) );
int opfx();
void osfx();
ostream &put( char __c );
ostream &put( signed char __c );
ostream &put( unsigned char __c );
ostream &write( char const *__buf, int __len );
ostream &write( signed char const *__buf, int __len );
ostream &write( unsigned char const *__buf, int __len );
ostream &flush();
ostream &seekp( streampos __position );
ostream &seekp( streamoff __offset, ios::seekdir __direction );
streampos tellp();
protected:
ostream();
ostream &__outfloat( long double const & );
ostream &do_lshift( char __c);
int do_opfx();
};
:include poppack.sp
#ifdef __BIG_INLINE__
inline ostream &ostream::operator << ( char __c ) {
__lock_it( __i_lock );
if( opfx() ) {
if( width() == 0 ) {
if( rdbuf()->sputc( __c ) == EOF ) {
setstate( ios::failbit );
}
} else {
do_lshift( __c );
}
osfx();
}
return( *this );
}
#endif
inline ostream &ostream::operator << ( signed char __c ) {
return( *this << (char) __c );
}
inline ostream &ostream::operator << ( unsigned char __c ) {
return( *this << (char) __c );
}
inline ostream &ostream::operator << ( signed short __s ) {
return( *this << (signed long) __s );
}
inline ostream &ostream::operator << ( unsigned short __s ) {
return( *this << (unsigned long) __s );
}
inline ostream &ostream::operator << ( signed int __i ) {
return( *this << (signed long) __i );
}
inline ostream &ostream::operator << ( unsigned int __i ) {
return( *this << (unsigned long) __i );
}
inline ostream &ostream::operator << ( float __f ) {
return( __outfloat( (long double)__f ) );
}
inline ostream &ostream::operator << ( double __f ) {
return( __outfloat( (long double)__f ) );
}
inline ostream &ostream::operator << ( long double __f ) {
return( __outfloat( __f ) );
}
inline ostream &ostream::operator << ( signed char const *__buf ) {
return( *this << (char const *) __buf );
}
inline ostream &ostream::operator << ( unsigned char const *__buf ) {
return( *this << (char const *) __buf );
}
#ifdef __BIG_INLINE__
inline ostream &ostream::put( char __c ) {
__lock_it( __i_lock );
if( opfx() ) {
if( rdbuf()->sputc( __c ) == EOF ) {
setstate( ios::failbit );
}
osfx();
}
return( *this );
}
#endif
inline ostream &ostream::put( signed char __c ) {
return( put( (char) __c ) );
}
inline ostream &ostream::put( unsigned char __c ) {
return( put( (char) __c ) );
}
#ifdef __BIG_INLINE__
inline ostream &ostream::write( char const *__buf, int __len ) {
__lock_it( __i_lock );
if( opfx() ) {
if( __len ) {
if( rdbuf()->sputn( __buf, __len ) != __len ) {
setstate( ios::failbit );
}
}
osfx();
}
return( *this );
}
#endif
inline ostream &ostream::write( signed char const *__buf, int __len ) {
return( write( (char const *) __buf, __len ) );
}
inline ostream &ostream::write( unsigned char const *__buf, int __len ) {
return( write( (char const *) __buf, __len ) );
}
inline int ostream::opfx() {
__lock_it( __i_lock );
if( !good() ) {
return 0;
} else if( tie() || ( flags() & ios::stdio ) ) {
return do_opfx();
} else {
return 1;
}
}
inline void ostream::osfx() {
__lock_it( __i_lock );
if( flags() & ios::unitbuf ) {
flush();
}
}
// **************************** MANIPULATORS *******************************
_WPRTLINK extern ostream & endl( ostream & );
_WPRTLINK extern ostream & ends( ostream & );
_WPRTLINK extern ostream &flush( ostream & );
} // namespace std
#endif
:endsegment
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?