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.
4 * Silicon Graphics Computer Systems, Inc.
9 * This material is provided "as is", with absolutely no warranty expressed
10 * or implied. Any use is at your own risk.
12 * Permission to use or copy this software for any purpose is hereby granted
13 * without fee, provided the above notices are retained on all copies.
14 * Permission to modify the code and to distribute modified code is granted,
15 * provided the above notices are retained, and a notice that the code was
16 * modified is included with the above copyright notice.
19 #ifndef _STLP_INTERNAL_ISTREAM_H
20 #define _STLP_INTERNAL_ISTREAM_H
22 // this block is included by _ostream.h, we include it here to lower #include level
23 # if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_CWCHAR_H)
24 # include <stl/_cwchar.h>
27 # ifndef _STLP_INTERNAL_IOS_H
28 # include <stl/_ios.h> // For basic_ios<>. Includes <iosfwd>.
31 #ifndef _STLP_INTERNAL_OSTREAM_H
32 # include <stl/_ostream.h> // Needed as a base class of basic_iostream.
35 #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
36 # include <stl/_istreambuf_iterator.h>
39 #include <stl/_ctraits_fns.h> // Helper functions that allow char traits
40 // to be used as function objects.
43 template <class _CharT, class _Traits, class _Number>
44 ios_base::iostate _STLP_CALL
45 _M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val);
47 #if defined (_STLP_USE_TEMPLATE_EXPORT)
48 template <class _CharT, class _Traits>
52 struct _No_Skip_WS {}; // Dummy class used by sentry.
54 template <class _CharT, class _Traits>
55 bool _M_init_skip(basic_istream<_CharT, _Traits>& __is);
56 template <class _CharT, class _Traits>
57 bool _M_init_noskip(basic_istream<_CharT, _Traits>& __is);
59 //----------------------------------------------------------------------
60 // Class basic_istream, a class that performs formatted input through
63 // The second template parameter, _Traits, defaults to char_traits<_CharT>.
64 // The default is declared in header <iosfwd>, and it isn't declared here
65 // because C++ language rules do not allow it to be declared twice.
67 template <class _CharT, class _Traits>
68 class basic_istream : virtual public basic_ios<_CharT, _Traits> {
71 typedef _CharT char_type;
72 typedef typename _Traits::int_type int_type;
73 typedef typename _Traits::pos_type pos_type;
74 typedef typename _Traits::off_type off_type;
75 typedef _Traits traits_type;
76 typedef basic_ios<_CharT, _Traits> _Basic_ios;
77 typedef basic_istream<_CharT, _Traits> _Self;
79 typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
80 typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&);
81 typedef _Self& (_STLP_CALL *__istream_fn)(_Self&);
83 public: // Constructor and destructor.
84 _STLP_DECLSPEC explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf);
85 _STLP_DECLSPEC ~basic_istream();
87 public: // Nested sentry class.
89 public: // Hooks for manipulators. The arguments are
91 _Self& operator>> (__istream_fn __f) { return __f(*this); }
92 _Self& operator>> (__ios_fn __f) { __f(*this); return *this; }
93 _Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; }
95 public: // Formatted input of numbers.
96 _Self& operator>> (short& __val) {
98 unsigned short __uval;
99 _M_get_num(*this, __lval);
100 __val = __STATIC_CAST(short, __lval);
102 // check if we lose digits
103 // if ((__val != __lval) && ((unsigned short)__val != __lval))
104 if ((__val != __lval) && ((long)__uval != __lval))
105 this->setstate(ios_base::failbit);
108 _Self& operator>> (int& __val) {
111 _M_get_num(*this, __lval);
114 // check if we lose digits
115 // if ((__val != __lval) && ((unsigned int)__val != __lval))
116 if ((__val != __lval) && ((long)__uval != __lval))
117 this->setstate(ios_base::failbit);
120 _Self& operator>> (unsigned short& __val) { _M_get_num(*this, __val); return *this; }
121 _Self& operator>> (unsigned int& __val) { _M_get_num(*this, __val); return *this; }
122 _Self& operator>> (long& __val) { _M_get_num(*this, __val); return *this; }
123 _Self& operator>> (unsigned long& __val) { _M_get_num(*this, __val); return *this; }
124 #ifdef _STLP_LONG_LONG
125 _Self& operator>> (_STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; }
126 _Self& operator>> (unsigned _STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; }
128 _Self& operator>> (float& __val) { _M_get_num(*this, __val); return *this; }
129 _Self& operator>> (double& __val) { _M_get_num(*this, __val); return *this; }
130 # ifndef _STLP_NO_LONG_DOUBLE
131 _Self& operator>> (long double& __val) { _M_get_num(*this, __val); return *this; }
133 # ifndef _STLP_NO_BOOL
134 _Self& operator>> (bool& __val) { _M_get_num(*this, __val); return *this; }
136 _Self& operator>> (void*& __val) { _M_get_num(*this, __val); return *this; }
138 public: // Copying characters into a streambuf.
139 _Self& operator>>(basic_streambuf<_CharT, _Traits>*);
141 public: // Unformatted input.
142 streamsize gcount() const { return _M_gcount; }
145 public: // get() for single characters
147 _Self& get(char_type& __c);
149 public: // get() for character arrays.
150 _Self& get(char_type* __s, streamsize __n, char_type __delim);
151 _Self& get(char_type* __s, streamsize __n)
152 { return get(__s, __n, this->widen('\n')); }
154 public: // get() for streambufs
155 _Self& get(basic_streambuf<_CharT, _Traits>& __buf,
157 _Self& get(basic_streambuf<_CharT, _Traits>& __buf)
158 { return get(__buf, this->widen('\n')); }
161 _Self& getline(char_type* __s, streamsize __n, char_type delim);
162 _Self& getline(char_type* __s, streamsize __n)
163 { return getline(__s, __n, this->widen('\n')); }
165 public: // read(), readsome(), ignore()
167 _Self& ignore(streamsize __n);
168 #if (defined (_STLP_MSVC) && _STLP_MSVC < 1200)
171 _Self& ignore(streamsize __n, int_type __delim);
173 _Self& read(char_type* __s, streamsize __n);
174 streamsize readsome(char_type* __s, streamsize __n);
177 _Self& putback(char_type __c);
180 public: // Positioning and buffer control.
184 _Self& seekg(pos_type __pos);
185 _Self& seekg(off_type, ios_base::seekdir);
187 public: // Helper functions for non-member extractors.
188 void _M_formatted_get(_CharT& __c);
189 void _M_formatted_get(_CharT* __s);
190 void _M_skip_whitespace(bool __set_failbit);
192 private: // Number of characters extracted by the
193 streamsize _M_gcount; // most recent unformatted input function.
197 #if defined (_STLP_USE_TEMPLATE_EXPORT)
198 // If we are using DLL specs, we have not to use inner classes
199 // end class declaration here
200 typedef _Isentry<_CharT, _Traits> sentry;
202 # define sentry _Isentry
203 template <class _CharT, class _Traits>
205 typedef _Isentry<_CharT, _Traits> _Self;
208 typedef sentry _Self;
213 // basic_streambuf<_CharT, _Traits>* _M_buf;
216 typedef _Traits traits_type;
218 explicit sentry(basic_istream<_CharT, _Traits>& __is,
219 bool __noskipws = false) :
220 _M_ok((__noskipws || !(__is.flags() & ios_base::skipws)) ? _M_init_noskip(__is) : _M_init_skip(__is) )
221 /* , _M_buf(__is.rdbuf()) */
224 // Calling this constructor is the same as calling the previous one with
225 // __noskipws = true, except that it doesn't require a runtime test.
226 sentry(basic_istream<_CharT, _Traits>& __is, _No_Skip_WS) : /* _M_buf(__is.rdbuf()), */
227 _M_ok(_M_init_noskip(__is)) {}
231 operator bool() const { return _M_ok; }
233 private: // Disable assignment and copy constructor.
234 sentry(const _Self&) : _M_ok(false) {}
235 void operator=(const _Self&) {}
238 # if defined (_STLP_USE_TEMPLATE_EXPORT)
241 // close basic_istream class definition here
245 # if defined (_STLP_USE_TEMPLATE_EXPORT)
246 _STLP_EXPORT_TEMPLATE_CLASS _Isentry<char, char_traits<char> >;
247 _STLP_EXPORT_TEMPLATE_CLASS basic_istream<char, char_traits<char> >;
248 # if ! defined (_STLP_NO_WCHAR_T)
249 _STLP_EXPORT_TEMPLATE_CLASS _Isentry<wchar_t, char_traits<wchar_t> >;
250 _STLP_EXPORT_TEMPLATE_CLASS basic_istream<wchar_t, char_traits<wchar_t> >;
252 # endif /* _STLP_USE_TEMPLATE_EXPORT */
254 // Non-member character and string extractor functions.
256 template <class _CharT, class _Traits>
257 inline basic_istream<_CharT, _Traits>& _STLP_CALL
258 operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT& __c) {
259 __stl_in._M_formatted_get(__c);
263 template <class _Traits>
264 inline basic_istream<char, _Traits>& _STLP_CALL
265 operator>>(basic_istream<char, _Traits>& __stl_in, unsigned char& __c) {
266 __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c));
270 template <class _Traits>
271 inline basic_istream<char, _Traits>& _STLP_CALL
272 operator>>(basic_istream<char, _Traits>& __stl_in, signed char& __c) {
273 __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c));
277 template <class _CharT, class _Traits>
278 inline basic_istream<_CharT, _Traits>& _STLP_CALL
279 operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT* __s) {
280 __stl_in._M_formatted_get(__s);
284 template <class _Traits>
285 inline basic_istream<char, _Traits>& _STLP_CALL
286 operator>>(basic_istream<char, _Traits>& __stl_in, unsigned char* __s) {
287 __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s));
291 template <class _Traits>
292 inline basic_istream<char, _Traits>& _STLP_CALL
293 operator>>(basic_istream<char, _Traits>& __stl_in, signed char* __s) {
294 __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s));
298 //----------------------------------------------------------------------
299 // istream manipulator.
300 template <class _CharT, class _Traits>
301 basic_istream<_CharT, _Traits>& _STLP_CALL
302 ws(basic_istream<_CharT, _Traits>& __is);
304 //----------------------------------------------------------------------
307 template <class _CharT, class _Traits>
309 : public basic_istream<_CharT, _Traits>,
310 public basic_ostream<_CharT, _Traits>
313 typedef basic_ios<_CharT, _Traits> _Basic_ios;
315 _STLP_DECLSPEC explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf);
316 _STLP_DECLSPEC virtual ~basic_iostream();
319 # if defined (_STLP_USE_TEMPLATE_EXPORT)
320 _STLP_EXPORT_TEMPLATE_CLASS basic_iostream<char, char_traits<char> >;
321 # if ! defined (_STLP_NO_WCHAR_T)
322 _STLP_EXPORT_TEMPLATE_CLASS basic_iostream<wchar_t, char_traits<wchar_t> >;
324 # endif /* _STLP_USE_TEMPLATE_EXPORT */
326 template <class _CharT, class _Traits>
327 basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __is)
334 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
335 # include <stl/_istream.c>
338 #endif /* _STLP_INTERNAL_ISTREAM_H */