Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
22 #ifndef _STLP_INTERNAL_OSTREAM_H
23 #define _STLP_INTERNAL_OSTREAM_H
25 #ifndef _STLP_INTERNAL_IOS_H
26 # include <stl/_ios.h> // For basic_ios<>. Includes <iosfwd>.
29 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
30 # include <stl/_ostreambuf_iterator.h>
35 template <class _CharT, class _Traits, class _Number>
36 basic_ostream<_CharT, _Traits>& _STLP_CALL
37 _M_put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x);
39 # if defined (_STLP_USE_TEMPLATE_EXPORT)
40 template <class _CharT, class _Traits>
44 template <class _CharT, class _Traits>
46 _M_init(basic_ostream<_CharT, _Traits>& __str);
48 //----------------------------------------------------------------------
49 // class basic_ostream<>
51 template <class _CharT, class _Traits>
52 class basic_ostream : virtual public basic_ios<_CharT, _Traits>
54 typedef basic_ostream<_CharT, _Traits> _Self;
57 typedef _CharT char_type;
58 typedef typename _Traits::int_type int_type;
59 typedef typename _Traits::pos_type pos_type;
60 typedef typename _Traits::off_type off_type;
61 typedef _Traits traits_type;
62 typedef basic_ios<_CharT, _Traits> _Basic_ios;
64 public: // Constructor and destructor.
65 _STLP_DECLSPEC explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf);
66 _STLP_DECLSPEC ~basic_ostream();
68 public: // Hooks for manipulators.
69 typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
70 typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&);
71 typedef _Self& (_STLP_CALL *__ostream_fn)(_Self&);
72 _Self& operator<< (__ostream_fn __f) { return __f(*this); }
73 _Self & operator<< (__ios_base_fn __f) { __f(*this); return *this; }
74 _Self& operator<< (__ios_fn __ff) { __ff(*this); return *this; }
77 bool _M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from,
78 basic_streambuf<_CharT, _Traits>* __to);
79 bool _M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from,
80 basic_streambuf<_CharT, _Traits>* __to);
83 void _M_put_char(_CharT __c);
85 void _M_put_nowiden(const _CharT* __s);
86 void _M_put_widen(const char* __s);
87 bool _M_put_widen_aux(const char* __s, streamsize __n);
89 public: // Unformatted output.
90 _Self& put(char_type __c);
91 _Self& write(const char_type* __s, streamsize __n);
93 public: // Formatted output.
94 // Formatted output from a streambuf.
95 _Self& operator<<(basic_streambuf<_CharT, _Traits>* __buf);
96 # ifndef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER
97 // this is needed for compiling with option char = unsigned
98 _Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; }
101 _Self& operator<<(short __x)
103 ios_base::fmtflags __fmtf =
104 ios_base::flags() & ios_base::basefield;
105 long __ly = (__fmtf == ios_base::oct || __fmtf == ios_base::hex) ?
106 (long)(unsigned short)(__x) : (long)__x;
107 return _M_put_num(*this, __ly);
109 _Self& operator<<(int __x)
111 ios_base::fmtflags __fmtf =
112 ios_base::flags() & ios_base::basefield;
113 long __ly = (__fmtf == ios_base::oct || __fmtf == ios_base::hex) ?
114 (long)(unsigned int)(__x) : (long)__x;
115 return _M_put_num(*this, __ly);
118 _Self& operator<<(short __x) { return _M_put_num(*this, __x); }
119 _Self& operator<<(int __x) { return _M_put_num(*this, __x); }
121 _Self& operator<<(unsigned int __x) { return _M_put_num(*this, __STATIC_CAST(unsigned long,__x)); }
122 _Self& operator<<(unsigned short __x) { return _M_put_num(*this, __STATIC_CAST(unsigned long,__x)); }
123 _Self& operator<<(long __x) { return _M_put_num(*this, __x); }
124 _Self& operator<<(unsigned long __x) { return _M_put_num(*this, __x); }
125 #ifdef _STLP_LONG_LONG
126 _Self& operator<< (_STLP_LONG_LONG __x) { return _M_put_num(*this, __x); }
127 _Self& operator<< (unsigned _STLP_LONG_LONG __x) { return _M_put_num(*this, __x); }
129 _Self& operator<<(float __x)
130 { return _M_put_num(*this, __STATIC_CAST(double,__x)); }
131 _Self& operator<<(double __x) { return _M_put_num(*this, __x); }
132 # ifndef _STLP_NO_LONG_DOUBLE
133 _Self& operator<<(long double __x) { return _M_put_num(*this, __x); }
135 _Self& operator<<(const void* __x) { return _M_put_num(*this, __x); }
136 # ifndef _STLP_NO_BOOL
137 _Self& operator<<(bool __x) { return _M_put_num(*this, __x); }
140 public: // Buffer positioning and manipulation.
143 if (this->rdbuf()->pubsync() == -1)
144 this->setstate(ios_base::badbit);
149 return this->rdbuf() && !this->fail()
150 ? this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out)
154 _Self& seekp(pos_type __pos) {
155 if (this->rdbuf() && !this->fail())
156 if( pos_type(off_type(-1)) == this->rdbuf()->pubseekpos(__pos, ios_base::out))
157 this->setstate(ios_base::failbit);
161 _Self& seekp(off_type __off, ios_base::seekdir __dir) {
162 if (this->rdbuf() && !this->fail())
163 if( pos_type(off_type(-1)) == this->rdbuf()->pubseekoff(__off, __dir, ios_base::out))
164 this->setstate(ios_base::failbit);
168 #if defined (_STLP_USE_TEMPLATE_EXPORT)
169 // If we are using DLL specs, we have not to use inner classes
170 // end class declaration here
171 typedef _Osentry<_CharT, _Traits> sentry;
173 # define sentry _Osentry
174 template <class _CharT, class _Traits>
176 typedef _Osentry<_CharT, _Traits> _Self;
179 typedef sentry _Self;
182 basic_ostream<_CharT, _Traits>& _M_str;
183 // basic_streambuf<_CharT, _Traits>* _M_buf;
186 explicit sentry(basic_ostream<_CharT, _Traits>& __str)
187 : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_M_init(__str))
192 if (_M_str.flags() & ios_base::unitbuf)
193 # ifndef _STLP_INCOMPLETE_EXCEPTION_HEADER
194 if (!_STLP_VENDOR_EXCEPT_STD::uncaught_exception())
199 operator bool() const { return _M_ok; }
200 private: // Disable assignment and copy constructor.
201 sentry(const _Self& __s) : _M_str (__s._M_str) {};
202 void operator=(const _Self&) {};
204 # if defined (_STLP_USE_TEMPLATE_EXPORT)
207 // close basic_ostream class definition here
211 # if defined (_STLP_USE_TEMPLATE_EXPORT)
212 _STLP_EXPORT_TEMPLATE_CLASS basic_ostream<char, char_traits<char> >;
213 _STLP_EXPORT_TEMPLATE_CLASS _Osentry<char, char_traits<char> >;
214 # if !defined (_STLP_NO_WCHAR_T)
215 _STLP_EXPORT_TEMPLATE_CLASS basic_ostream<wchar_t, char_traits<wchar_t> >;
216 _STLP_EXPORT_TEMPLATE_CLASS _Osentry<wchar_t, char_traits<wchar_t> >;
218 # endif /* _STLP_USE_TEMPLATE_EXPORT */
220 template <class _CharT, class _Traits>
221 inline basic_streambuf<_CharT, _Traits>* _STLP_CALL
222 _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& __St)
227 // Non-member functions.
229 template <class _CharT, class _Traits>
230 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
231 operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
232 __os._M_put_char(__c);
236 template <class _CharT, class _Traits>
237 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
238 operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) {
240 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
242 __os._M_put_nowiden(__s);
247 # ifdef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER
248 // some specializations
250 inline basic_ostream<char, char_traits<char> >& _STLP_CALL
251 operator<<(basic_ostream<char, char_traits<char> >& __os, char __c) {
252 __os._M_put_char(__c);
256 inline basic_ostream<char, char_traits<char> >& _STLP_CALL
257 operator<<(basic_ostream<char, char_traits<char> >& __os, signed char __c) {
258 __os._M_put_char(__c);
262 inline basic_ostream<char, char_traits<char> >& _STLP_CALL
263 operator<<(basic_ostream<char, char_traits<char> >& __os, unsigned char __c) {
264 __os._M_put_char(__c);
268 inline basic_ostream<char, char_traits<char> >& _STLP_CALL
269 operator<<(basic_ostream<char, char_traits<char> >& __os, const char* __s) {
271 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
273 __os._M_put_nowiden(__s);
278 inline basic_ostream<char, char_traits<char> >& _STLP_CALL
279 operator<<(basic_ostream<char, char_traits<char> >& __os, const signed char* __s) {
281 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
283 __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
288 inline basic_ostream<char, char_traits<char> >&
289 operator<<(basic_ostream<char, char_traits<char> >& __os, const unsigned char* __s) {
291 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
293 __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
300 // also for compilers who might use that
301 template <class _CharT, class _Traits>
302 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
303 operator<<(basic_ostream<_CharT, _Traits>& __os, char __c) {
304 __os._M_put_char(__os.widen(__c));
308 template <class _Traits>
309 inline basic_ostream<char, _Traits>& _STLP_CALL
310 operator<<(basic_ostream<char, _Traits>& __os, char __c) {
311 __os._M_put_char(__c);
315 template <class _Traits>
316 inline basic_ostream<char, _Traits>& _STLP_CALL
317 operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
318 __os._M_put_char(__c);
322 template <class _Traits>
323 inline basic_ostream<char, _Traits>& _STLP_CALL
324 operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
325 __os._M_put_char(__c);
329 template <class _CharT, class _Traits>
330 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
331 operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) {
333 !__s ? __os.setstate(ios_base::badbit):__os._M_put_widen(__s);
335 __os._M_put_widen(__s);
340 template <class _Traits>
341 inline basic_ostream<char, _Traits>& _STLP_CALL
342 operator<<(basic_ostream<char, _Traits>& __os, const char* __s) {
344 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
346 __os._M_put_nowiden(__s);
351 template <class _Traits>
352 inline basic_ostream<char, _Traits>& _STLP_CALL
353 operator<<(basic_ostream<char, _Traits>& __os, const signed char* __s) {
355 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
357 __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
362 template <class _Traits>
363 inline basic_ostream<char, _Traits>&
364 operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __s) {
366 !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
368 __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
372 # endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */
374 //----------------------------------------------------------------------
375 // basic_ostream manipulators.
377 template <class _CharT, class _Traits>
378 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
379 endl(basic_ostream<_CharT, _Traits>& __os) {
380 __os.put(__os.widen('\n'));
385 template <class _CharT, class _Traits>
386 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
387 ends(basic_ostream<_CharT, _Traits>& __os) {
388 __os.put(_STLP_DEFAULT_CONSTRUCTED(_CharT));
392 template <class _CharT, class _Traits>
393 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
394 flush(basic_ostream<_CharT, _Traits>& __os) {
401 # undef _STLP_MANIP_INLINE
403 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
404 # include <stl/_ostream.c>
407 #endif /* _STLP_INTERNAL_OSTREAM_H */