Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- istream ----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_ISTREAM |
| 12 | #define _LIBCPP_ISTREAM |
| 13 | |
| 14 | /* |
| 15 | istream synopsis |
| 16 | |
| 17 | template <class charT, class traits = char_traits<charT> > |
| 18 | class basic_istream |
| 19 | : virtual public basic_ios<charT,traits> |
| 20 | { |
| 21 | public: |
| 22 | // types (inherited from basic_ios (27.5.4)): |
| 23 | typedef charT char_type; |
| 24 | typedef traits traits_type; |
| 25 | typedef typename traits_type::int_type int_type; |
| 26 | typedef typename traits_type::pos_type pos_type; |
| 27 | typedef typename traits_type::off_type off_type; |
| 28 | |
| 29 | // 27.7.1.1.1 Constructor/destructor: |
| 30 | explicit basic_istream(basic_streambuf<char_type, traits_type>* sb); |
| 31 | basic_istream(basic_istream&& rhs); |
| 32 | virtual ~basic_istream(); |
| 33 | |
| 34 | // 27.7.1.1.2 Assign/swap: |
| 35 | basic_istream& operator=(basic_istream&& rhs); |
| 36 | void swap(basic_istream& rhs); |
| 37 | |
| 38 | // 27.7.1.1.3 Prefix/suffix: |
| 39 | class sentry; |
| 40 | |
| 41 | // 27.7.1.2 Formatted input: |
| 42 | basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); |
| 43 | basic_istream& operator>>(basic_ios<char_type, traits_type>& |
| 44 | (*pf)(basic_ios<char_type, traits_type>&)); |
| 45 | basic_istream& operator>>(ios_base& (*pf)(ios_base&)); |
| 46 | basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb); |
| 47 | basic_istream& operator>>(bool& n); |
| 48 | basic_istream& operator>>(short& n); |
| 49 | basic_istream& operator>>(unsigned short& n); |
| 50 | basic_istream& operator>>(int& n); |
| 51 | basic_istream& operator>>(unsigned int& n); |
| 52 | basic_istream& operator>>(long& n); |
| 53 | basic_istream& operator>>(unsigned long& n); |
| 54 | basic_istream& operator>>(long long& n); |
| 55 | basic_istream& operator>>(unsigned long long& n); |
| 56 | basic_istream& operator>>(float& f); |
| 57 | basic_istream& operator>>(double& f); |
| 58 | basic_istream& operator>>(long double& f); |
| 59 | basic_istream& operator>>(void*& p); |
| 60 | |
| 61 | // 27.7.1.3 Unformatted input: |
| 62 | streamsize gcount() const; |
| 63 | int_type get(); |
| 64 | basic_istream& get(char_type& c); |
| 65 | basic_istream& get(char_type* s, streamsize n); |
| 66 | basic_istream& get(char_type* s, streamsize n, char_type delim); |
| 67 | basic_istream& get(basic_streambuf<char_type,traits_type>& sb); |
| 68 | basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim); |
| 69 | |
| 70 | basic_istream& getline(char_type* s, streamsize n); |
| 71 | basic_istream& getline(char_type* s, streamsize n, char_type delim); |
| 72 | |
| 73 | basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); |
| 74 | int_type peek(); |
| 75 | basic_istream& read (char_type* s, streamsize n); |
| 76 | streamsize readsome(char_type* s, streamsize n); |
| 77 | |
| 78 | basic_istream& putback(char_type c); |
| 79 | basic_istream& unget(); |
| 80 | int sync(); |
| 81 | |
| 82 | pos_type tellg(); |
| 83 | basic_istream& seekg(pos_type); |
| 84 | basic_istream& seekg(off_type, ios_base::seekdir); |
Marshall Clow | 546eca8 | 2014-09-16 15:27:01 +0000 | [diff] [blame^] | 85 | protected: |
| 86 | basic_istream(const basic_istream& rhs) = delete; |
| 87 | basic_istream(basic_istream&& rhs); |
| 88 | // 27.7.2.1.2 Assign/swap: |
| 89 | basic_istream& operator=(const basic_istream& rhs) = delete; |
| 90 | basic_istream& operator=(basic_istream&& rhs); |
| 91 | void swap(basic_istream& rhs); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | // 27.7.1.2.3 character extraction templates: |
| 95 | template<class charT, class traits> |
| 96 | basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&); |
| 97 | |
| 98 | template<class traits> |
| 99 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&); |
| 100 | |
| 101 | template<class traits> |
| 102 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&); |
| 103 | |
| 104 | template<class charT, class traits> |
| 105 | basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*); |
| 106 | |
| 107 | template<class traits> |
| 108 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*); |
| 109 | |
| 110 | template<class traits> |
| 111 | basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*); |
| 112 | |
| 113 | template <class charT, class traits> |
| 114 | void |
| 115 | swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y); |
| 116 | |
| 117 | typedef basic_istream<char> istream; |
| 118 | typedef basic_istream<wchar_t> wistream; |
| 119 | |
| 120 | template <class charT, class traits = char_traits<charT> > |
| 121 | class basic_iostream : |
| 122 | public basic_istream<charT,traits>, |
| 123 | public basic_ostream<charT,traits> |
| 124 | { |
| 125 | public: |
| 126 | // types: |
| 127 | typedef charT char_type; |
| 128 | typedef traits traits_type; |
| 129 | typedef typename traits_type::int_type int_type; |
| 130 | typedef typename traits_type::pos_type pos_type; |
| 131 | typedef typename traits_type::off_type off_type; |
| 132 | |
| 133 | // constructor/destructor |
| 134 | explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb); |
| 135 | basic_iostream(basic_iostream&& rhs); |
| 136 | virtual ~basic_iostream(); |
| 137 | |
| 138 | // assign/swap |
| 139 | basic_iostream& operator=(basic_iostream&& rhs); |
| 140 | void swap(basic_iostream& rhs); |
| 141 | }; |
| 142 | |
| 143 | template <class charT, class traits> |
| 144 | void |
| 145 | swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y); |
| 146 | |
| 147 | typedef basic_iostream<char> iostream; |
| 148 | typedef basic_iostream<wchar_t> wiostream; |
| 149 | |
| 150 | template <class charT, class traits> |
| 151 | basic_istream<charT,traits>& |
| 152 | ws(basic_istream<charT,traits>& is); |
| 153 | |
| 154 | template <class charT, class traits, class T> |
| 155 | basic_istream<charT, traits>& |
| 156 | operator>>(basic_istream<charT, traits>&& is, T& x); |
| 157 | |
| 158 | } // std |
| 159 | |
| 160 | */ |
| 161 | |
| 162 | #include <__config> |
| 163 | #include <ostream> |
| 164 | |
Howard Hinnant | 66c6f97 | 2011-11-29 16:45:27 +0000 | [diff] [blame] | 165 | #include <__undef_min_max> |
| 166 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 167 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 168 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 169 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 170 | |
| 171 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 172 | |
| 173 | template <class _CharT, class _Traits> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 174 | class _LIBCPP_TYPE_VIS_ONLY basic_istream |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | : virtual public basic_ios<_CharT, _Traits> |
| 176 | { |
| 177 | streamsize __gc_; |
| 178 | public: |
| 179 | // types (inherited from basic_ios (27.5.4)): |
| 180 | typedef _CharT char_type; |
| 181 | typedef _Traits traits_type; |
| 182 | typedef typename traits_type::int_type int_type; |
| 183 | typedef typename traits_type::pos_type pos_type; |
| 184 | typedef typename traits_type::off_type off_type; |
| 185 | |
| 186 | // 27.7.1.1.1 Constructor/destructor: |
| 187 | explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb); |
| 188 | virtual ~basic_istream(); |
| 189 | protected: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 190 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ac6de54 | 2011-07-07 21:03:52 +0000 | [diff] [blame] | 191 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 192 | basic_istream(basic_istream&& __rhs); |
| 193 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 194 | // 27.7.1.1.2 Assign/swap: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 195 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ac6de54 | 2011-07-07 21:03:52 +0000 | [diff] [blame] | 196 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 197 | basic_istream& operator=(basic_istream&& __rhs); |
| 198 | #endif |
| 199 | void swap(basic_istream& __rhs); |
Marshall Clow | 546eca8 | 2014-09-16 15:27:01 +0000 | [diff] [blame^] | 200 | |
| 201 | #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS |
| 202 | basic_istream (basic_istream& __rhs) = delete; |
| 203 | basic_istream& operator=(basic_istream& __rhs) = delete; |
| 204 | #else |
| 205 | private: |
| 206 | basic_istream (basic_istream& __rhs); |
| 207 | basic_istream& operator=(basic_istream& __rhs); |
| 208 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 209 | public: |
| 210 | |
| 211 | // 27.7.1.1.3 Prefix/suffix: |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 212 | class _LIBCPP_TYPE_VIS_ONLY sentry; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 213 | |
| 214 | // 27.7.1.2 Formatted input: |
| 215 | basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); |
| 216 | basic_istream& operator>>(basic_ios<char_type, traits_type>& |
| 217 | (*__pf)(basic_ios<char_type, traits_type>&)); |
| 218 | basic_istream& operator>>(ios_base& (*__pf)(ios_base&)); |
| 219 | basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb); |
| 220 | basic_istream& operator>>(bool& __n); |
| 221 | basic_istream& operator>>(short& __n); |
| 222 | basic_istream& operator>>(unsigned short& __n); |
| 223 | basic_istream& operator>>(int& __n); |
| 224 | basic_istream& operator>>(unsigned int& __n); |
| 225 | basic_istream& operator>>(long& __n); |
| 226 | basic_istream& operator>>(unsigned long& __n); |
| 227 | basic_istream& operator>>(long long& __n); |
| 228 | basic_istream& operator>>(unsigned long long& __n); |
| 229 | basic_istream& operator>>(float& __f); |
| 230 | basic_istream& operator>>(double& __f); |
| 231 | basic_istream& operator>>(long double& __f); |
| 232 | basic_istream& operator>>(void*& __p); |
| 233 | |
| 234 | // 27.7.1.3 Unformatted input: |
Howard Hinnant | 68a8e90 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 235 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 236 | streamsize gcount() const {return __gc_;} |
| 237 | int_type get(); |
| 238 | basic_istream& get(char_type& __c); |
| 239 | basic_istream& get(char_type* __s, streamsize __n); |
| 240 | basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); |
| 241 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb); |
| 242 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); |
| 243 | |
| 244 | basic_istream& getline(char_type* __s, streamsize __n); |
| 245 | basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); |
| 246 | |
| 247 | basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); |
| 248 | int_type peek(); |
| 249 | basic_istream& read (char_type* __s, streamsize __n); |
| 250 | streamsize readsome(char_type* __s, streamsize __n); |
| 251 | |
| 252 | basic_istream& putback(char_type __c); |
| 253 | basic_istream& unget(); |
| 254 | int sync(); |
| 255 | |
| 256 | pos_type tellg(); |
| 257 | basic_istream& seekg(pos_type __pos); |
| 258 | basic_istream& seekg(off_type __off, ios_base::seekdir __dir); |
| 259 | }; |
| 260 | |
| 261 | template <class _CharT, class _Traits> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 262 | class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 263 | { |
| 264 | bool __ok_; |
| 265 | |
| 266 | sentry(const sentry&); // = delete; |
| 267 | sentry& operator=(const sentry&); // = delete; |
| 268 | |
| 269 | public: |
| 270 | explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); |
| 271 | // ~sentry() = default; |
| 272 | |
Howard Hinnant | 68a8e90 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 273 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 7786188 | 2012-02-21 21:46:43 +0000 | [diff] [blame] | 274 | _LIBCPP_EXPLICIT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 275 | operator bool() const {return __ok_;} |
| 276 | }; |
| 277 | |
| 278 | template <class _CharT, class _Traits> |
| 279 | basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, |
| 280 | bool __noskipws) |
| 281 | : __ok_(false) |
| 282 | { |
| 283 | if (__is.good()) |
| 284 | { |
| 285 | if (__is.tie()) |
| 286 | __is.tie()->flush(); |
| 287 | if (!__noskipws && (__is.flags() & ios_base::skipws)) |
| 288 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 289 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 290 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 291 | _Ip __i(__is); |
| 292 | _Ip __eof; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 293 | for (; __i != __eof; ++__i) |
| 294 | if (!__ct.is(__ct.space, *__i)) |
| 295 | break; |
| 296 | if (__i == __eof) |
| 297 | __is.setstate(ios_base::failbit | ios_base::eofbit); |
| 298 | } |
| 299 | __ok_ = __is.good(); |
| 300 | } |
| 301 | else |
| 302 | __is.setstate(ios_base::failbit); |
| 303 | } |
| 304 | |
| 305 | template <class _CharT, class _Traits> |
| 306 | inline _LIBCPP_INLINE_VISIBILITY |
| 307 | basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb) |
| 308 | : __gc_(0) |
| 309 | { |
| 310 | this->init(__sb); |
| 311 | } |
| 312 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 313 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 314 | |
| 315 | template <class _CharT, class _Traits> |
| 316 | inline _LIBCPP_INLINE_VISIBILITY |
| 317 | basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) |
| 318 | : __gc_(__rhs.__gc_) |
| 319 | { |
| 320 | __rhs.__gc_ = 0; |
| 321 | this->move(__rhs); |
| 322 | } |
| 323 | |
| 324 | template <class _CharT, class _Traits> |
| 325 | inline _LIBCPP_INLINE_VISIBILITY |
| 326 | basic_istream<_CharT, _Traits>& |
| 327 | basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) |
| 328 | { |
| 329 | swap(__rhs); |
| 330 | return *this; |
| 331 | } |
| 332 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 333 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 334 | |
| 335 | template <class _CharT, class _Traits> |
| 336 | basic_istream<_CharT, _Traits>::~basic_istream() |
| 337 | { |
| 338 | } |
| 339 | |
| 340 | template <class _CharT, class _Traits> |
| 341 | inline _LIBCPP_INLINE_VISIBILITY |
| 342 | void |
| 343 | basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) |
| 344 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 345 | _VSTD::swap(__gc_, __rhs.__gc_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 346 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 347 | } |
| 348 | |
| 349 | template <class _CharT, class _Traits> |
| 350 | basic_istream<_CharT, _Traits>& |
| 351 | basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) |
| 352 | { |
| 353 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 354 | try |
| 355 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 356 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 357 | sentry __s(*this); |
| 358 | if (__s) |
| 359 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 360 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 361 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 362 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 363 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 364 | this->setstate(__err); |
| 365 | } |
| 366 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 367 | } |
| 368 | catch (...) |
| 369 | { |
| 370 | this->__set_badbit_and_consider_rethrow(); |
| 371 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 372 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 373 | return *this; |
| 374 | } |
| 375 | |
| 376 | template <class _CharT, class _Traits> |
| 377 | basic_istream<_CharT, _Traits>& |
| 378 | basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n) |
| 379 | { |
| 380 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 381 | try |
| 382 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 383 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | sentry __s(*this); |
| 385 | if (__s) |
| 386 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 387 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 388 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 389 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 390 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 391 | this->setstate(__err); |
| 392 | } |
| 393 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 394 | } |
| 395 | catch (...) |
| 396 | { |
| 397 | this->__set_badbit_and_consider_rethrow(); |
| 398 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 399 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 400 | return *this; |
| 401 | } |
| 402 | |
| 403 | template <class _CharT, class _Traits> |
| 404 | basic_istream<_CharT, _Traits>& |
| 405 | basic_istream<_CharT, _Traits>::operator>>(long& __n) |
| 406 | { |
| 407 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 408 | try |
| 409 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 410 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 411 | sentry __s(*this); |
| 412 | if (__s) |
| 413 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 414 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 415 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 416 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 417 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 418 | this->setstate(__err); |
| 419 | } |
| 420 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 421 | } |
| 422 | catch (...) |
| 423 | { |
| 424 | this->__set_badbit_and_consider_rethrow(); |
| 425 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 426 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 427 | return *this; |
| 428 | } |
| 429 | |
| 430 | template <class _CharT, class _Traits> |
| 431 | basic_istream<_CharT, _Traits>& |
| 432 | basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n) |
| 433 | { |
| 434 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 435 | try |
| 436 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 437 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 438 | sentry __s(*this); |
| 439 | if (__s) |
| 440 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 441 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 442 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 443 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 444 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | this->setstate(__err); |
| 446 | } |
| 447 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 448 | } |
| 449 | catch (...) |
| 450 | { |
| 451 | this->__set_badbit_and_consider_rethrow(); |
| 452 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 453 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 454 | return *this; |
| 455 | } |
| 456 | |
| 457 | template <class _CharT, class _Traits> |
| 458 | basic_istream<_CharT, _Traits>& |
| 459 | basic_istream<_CharT, _Traits>::operator>>(long long& __n) |
| 460 | { |
| 461 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 462 | try |
| 463 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 464 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 465 | sentry __s(*this); |
| 466 | if (__s) |
| 467 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 468 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 469 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 470 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 471 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 472 | this->setstate(__err); |
| 473 | } |
| 474 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 475 | } |
| 476 | catch (...) |
| 477 | { |
| 478 | this->__set_badbit_and_consider_rethrow(); |
| 479 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 480 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 481 | return *this; |
| 482 | } |
| 483 | |
| 484 | template <class _CharT, class _Traits> |
| 485 | basic_istream<_CharT, _Traits>& |
| 486 | basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n) |
| 487 | { |
| 488 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 489 | try |
| 490 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 491 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 492 | sentry __s(*this); |
| 493 | if (__s) |
| 494 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 495 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 496 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 497 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 498 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 499 | this->setstate(__err); |
| 500 | } |
| 501 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 502 | } |
| 503 | catch (...) |
| 504 | { |
| 505 | this->__set_badbit_and_consider_rethrow(); |
| 506 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 507 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 508 | return *this; |
| 509 | } |
| 510 | |
| 511 | template <class _CharT, class _Traits> |
| 512 | basic_istream<_CharT, _Traits>& |
| 513 | basic_istream<_CharT, _Traits>::operator>>(float& __n) |
| 514 | { |
| 515 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 516 | try |
| 517 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 518 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 519 | sentry __s(*this); |
| 520 | if (__s) |
| 521 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 522 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 523 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 524 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 525 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 526 | this->setstate(__err); |
| 527 | } |
| 528 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 529 | } |
| 530 | catch (...) |
| 531 | { |
| 532 | this->__set_badbit_and_consider_rethrow(); |
| 533 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 534 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 535 | return *this; |
| 536 | } |
| 537 | |
| 538 | template <class _CharT, class _Traits> |
| 539 | basic_istream<_CharT, _Traits>& |
| 540 | basic_istream<_CharT, _Traits>::operator>>(double& __n) |
| 541 | { |
| 542 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 543 | try |
| 544 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 545 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 546 | sentry __s(*this); |
| 547 | if (__s) |
| 548 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 549 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 550 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 551 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 552 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 553 | this->setstate(__err); |
| 554 | } |
| 555 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 556 | } |
| 557 | catch (...) |
| 558 | { |
| 559 | this->__set_badbit_and_consider_rethrow(); |
| 560 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 561 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 562 | return *this; |
| 563 | } |
| 564 | |
| 565 | template <class _CharT, class _Traits> |
| 566 | basic_istream<_CharT, _Traits>& |
| 567 | basic_istream<_CharT, _Traits>::operator>>(long double& __n) |
| 568 | { |
| 569 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 570 | try |
| 571 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 572 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 573 | sentry __s(*this); |
| 574 | if (__s) |
| 575 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 576 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 577 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 578 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 579 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 580 | this->setstate(__err); |
| 581 | } |
| 582 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 583 | } |
| 584 | catch (...) |
| 585 | { |
| 586 | this->__set_badbit_and_consider_rethrow(); |
| 587 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 588 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | return *this; |
| 590 | } |
| 591 | |
| 592 | template <class _CharT, class _Traits> |
| 593 | basic_istream<_CharT, _Traits>& |
| 594 | basic_istream<_CharT, _Traits>::operator>>(bool& __n) |
| 595 | { |
| 596 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 597 | try |
| 598 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 599 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 600 | sentry __s(*this); |
| 601 | if (__s) |
| 602 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 603 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 604 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 606 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 607 | this->setstate(__err); |
| 608 | } |
| 609 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 610 | } |
| 611 | catch (...) |
| 612 | { |
| 613 | this->__set_badbit_and_consider_rethrow(); |
| 614 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 615 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 616 | return *this; |
| 617 | } |
| 618 | |
| 619 | template <class _CharT, class _Traits> |
| 620 | basic_istream<_CharT, _Traits>& |
| 621 | basic_istream<_CharT, _Traits>::operator>>(void*& __n) |
| 622 | { |
| 623 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 624 | try |
| 625 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 626 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 627 | sentry __s(*this); |
| 628 | if (__s) |
| 629 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 630 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 631 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 632 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 633 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 634 | this->setstate(__err); |
| 635 | } |
| 636 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 637 | } |
| 638 | catch (...) |
| 639 | { |
| 640 | this->__set_badbit_and_consider_rethrow(); |
| 641 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 642 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 643 | return *this; |
| 644 | } |
| 645 | |
| 646 | template <class _CharT, class _Traits> |
| 647 | basic_istream<_CharT, _Traits>& |
| 648 | basic_istream<_CharT, _Traits>::operator>>(short& __n) |
| 649 | { |
| 650 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 651 | try |
| 652 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 653 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 654 | sentry __s(*this); |
| 655 | if (__s) |
| 656 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 657 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 658 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 659 | ios_base::iostate __err = ios_base::goodbit; |
| 660 | long __temp; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 661 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | if (__temp < numeric_limits<short>::min()) |
| 663 | { |
| 664 | __err |= ios_base::failbit; |
| 665 | __n = numeric_limits<short>::min(); |
| 666 | } |
| 667 | else if (__temp > numeric_limits<short>::max()) |
| 668 | { |
| 669 | __err |= ios_base::failbit; |
| 670 | __n = numeric_limits<short>::max(); |
| 671 | } |
| 672 | else |
| 673 | __n = static_cast<short>(__temp); |
| 674 | this->setstate(__err); |
| 675 | } |
| 676 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 677 | } |
| 678 | catch (...) |
| 679 | { |
| 680 | this->__set_badbit_and_consider_rethrow(); |
| 681 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 682 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 683 | return *this; |
| 684 | } |
| 685 | |
| 686 | template <class _CharT, class _Traits> |
| 687 | basic_istream<_CharT, _Traits>& |
| 688 | basic_istream<_CharT, _Traits>::operator>>(int& __n) |
| 689 | { |
| 690 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 691 | try |
| 692 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 693 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 694 | sentry __s(*this); |
| 695 | if (__s) |
| 696 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 697 | typedef istreambuf_iterator<char_type, traits_type> _Ip; |
| 698 | typedef num_get<char_type, _Ip> _Fp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 699 | ios_base::iostate __err = ios_base::goodbit; |
| 700 | long __temp; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 701 | use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | if (__temp < numeric_limits<int>::min()) |
| 703 | { |
| 704 | __err |= ios_base::failbit; |
| 705 | __n = numeric_limits<int>::min(); |
| 706 | } |
| 707 | else if (__temp > numeric_limits<int>::max()) |
| 708 | { |
| 709 | __err |= ios_base::failbit; |
| 710 | __n = numeric_limits<int>::max(); |
| 711 | } |
| 712 | else |
| 713 | __n = static_cast<int>(__temp); |
| 714 | this->setstate(__err); |
| 715 | } |
| 716 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 717 | } |
| 718 | catch (...) |
| 719 | { |
| 720 | this->__set_badbit_and_consider_rethrow(); |
| 721 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 722 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 723 | return *this; |
| 724 | } |
| 725 | |
| 726 | template <class _CharT, class _Traits> |
| 727 | inline _LIBCPP_INLINE_VISIBILITY |
| 728 | basic_istream<_CharT, _Traits>& |
| 729 | basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) |
| 730 | { |
| 731 | return __pf(*this); |
| 732 | } |
| 733 | |
| 734 | template <class _CharT, class _Traits> |
| 735 | inline _LIBCPP_INLINE_VISIBILITY |
| 736 | basic_istream<_CharT, _Traits>& |
| 737 | basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>& |
| 738 | (*__pf)(basic_ios<char_type, traits_type>&)) |
| 739 | { |
| 740 | __pf(*this); |
| 741 | return *this; |
| 742 | } |
| 743 | |
| 744 | template <class _CharT, class _Traits> |
| 745 | inline _LIBCPP_INLINE_VISIBILITY |
| 746 | basic_istream<_CharT, _Traits>& |
| 747 | basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) |
| 748 | { |
| 749 | __pf(*this); |
| 750 | return *this; |
| 751 | } |
| 752 | |
| 753 | template<class _CharT, class _Traits> |
| 754 | basic_istream<_CharT, _Traits>& |
| 755 | operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) |
| 756 | { |
| 757 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 758 | try |
| 759 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 760 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 761 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 762 | if (__sen) |
| 763 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 764 | streamsize __n = __is.width(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 765 | if (__n <= 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 766 | __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1; |
| 767 | streamsize __c = 0; |
| 768 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 769 | ios_base::iostate __err = ios_base::goodbit; |
| 770 | while (__c < __n-1) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 771 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 772 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| 773 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 774 | { |
| 775 | __err |= ios_base::eofbit; |
| 776 | break; |
| 777 | } |
| 778 | _CharT __ch = _Traits::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 779 | if (__ct.is(__ct.space, __ch)) |
| 780 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 781 | *__s++ = __ch; |
| 782 | ++__c; |
| 783 | __is.rdbuf()->sbumpc(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 784 | } |
| 785 | *__s = _CharT(); |
| 786 | __is.width(0); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 787 | if (__c == 0) |
| 788 | __err |= ios_base::failbit; |
| 789 | __is.setstate(__err); |
| 790 | } |
| 791 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 792 | } |
| 793 | catch (...) |
| 794 | { |
| 795 | __is.__set_badbit_and_consider_rethrow(); |
| 796 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 797 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 798 | return __is; |
| 799 | } |
| 800 | |
| 801 | template<class _Traits> |
| 802 | inline _LIBCPP_INLINE_VISIBILITY |
| 803 | basic_istream<char, _Traits>& |
| 804 | operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s) |
| 805 | { |
| 806 | return __is >> (char*)__s; |
| 807 | } |
| 808 | |
| 809 | template<class _Traits> |
| 810 | inline _LIBCPP_INLINE_VISIBILITY |
| 811 | basic_istream<char, _Traits>& |
| 812 | operator>>(basic_istream<char, _Traits>& __is, signed char* __s) |
| 813 | { |
| 814 | return __is >> (char*)__s; |
| 815 | } |
| 816 | |
| 817 | template<class _CharT, class _Traits> |
| 818 | basic_istream<_CharT, _Traits>& |
| 819 | operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) |
| 820 | { |
| 821 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 822 | try |
| 823 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 824 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 825 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 826 | if (__sen) |
| 827 | { |
Howard Hinnant | df85e57 | 2011-02-27 18:02:02 +0000 | [diff] [blame] | 828 | typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); |
| 829 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 830 | __is.setstate(ios_base::eofbit | ios_base::failbit); |
| 831 | else |
| 832 | __c = _Traits::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 833 | } |
| 834 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 835 | } |
| 836 | catch (...) |
| 837 | { |
| 838 | __is.__set_badbit_and_consider_rethrow(); |
| 839 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 840 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 841 | return __is; |
| 842 | } |
| 843 | |
| 844 | template<class _Traits> |
| 845 | inline _LIBCPP_INLINE_VISIBILITY |
| 846 | basic_istream<char, _Traits>& |
| 847 | operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c) |
| 848 | { |
| 849 | return __is >> (char&)__c; |
| 850 | } |
| 851 | |
| 852 | template<class _Traits> |
| 853 | inline _LIBCPP_INLINE_VISIBILITY |
| 854 | basic_istream<char, _Traits>& |
| 855 | operator>>(basic_istream<char, _Traits>& __is, signed char& __c) |
| 856 | { |
| 857 | return __is >> (char&)__c; |
| 858 | } |
| 859 | |
| 860 | template<class _CharT, class _Traits> |
| 861 | basic_istream<_CharT, _Traits>& |
| 862 | basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb) |
| 863 | { |
| 864 | __gc_ = 0; |
| 865 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 866 | try |
| 867 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 868 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 869 | sentry __s(*this, true); |
| 870 | if (__s) |
| 871 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 872 | if (__sb) |
| 873 | { |
| 874 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 875 | try |
| 876 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 877 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 878 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 879 | while (true) |
| 880 | { |
| 881 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 882 | if (traits_type::eq_int_type(__i, _Traits::eof())) |
| 883 | { |
| 884 | __err |= ios_base::eofbit; |
| 885 | break; |
| 886 | } |
| 887 | if (traits_type::eq_int_type( |
| 888 | __sb->sputc(traits_type::to_char_type(__i)), |
| 889 | traits_type::eof())) |
| 890 | break; |
| 891 | ++__gc_; |
| 892 | this->rdbuf()->sbumpc(); |
| 893 | } |
| 894 | if (__gc_ == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 895 | __err |= ios_base::failbit; |
| 896 | this->setstate(__err); |
| 897 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 898 | } |
| 899 | catch (...) |
| 900 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 901 | if (__gc_ == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | this->__set_failbit_and_consider_rethrow(); |
| 903 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 904 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | } |
| 906 | else |
| 907 | this->setstate(ios_base::failbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 908 | } |
| 909 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 910 | } |
| 911 | catch (...) |
| 912 | { |
| 913 | this->__set_badbit_and_consider_rethrow(); |
| 914 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 915 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 916 | return *this; |
| 917 | } |
| 918 | |
| 919 | template<class _CharT, class _Traits> |
| 920 | typename basic_istream<_CharT, _Traits>::int_type |
| 921 | basic_istream<_CharT, _Traits>::get() |
| 922 | { |
| 923 | __gc_ = 0; |
| 924 | int_type __r = traits_type::eof(); |
| 925 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 926 | try |
| 927 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 928 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 929 | sentry __s(*this, true); |
| 930 | if (__s) |
| 931 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 932 | __r = this->rdbuf()->sbumpc(); |
| 933 | if (traits_type::eq_int_type(__r, traits_type::eof())) |
| 934 | this->setstate(ios_base::failbit | ios_base::eofbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 935 | else |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 936 | __gc_ = 1; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 937 | } |
| 938 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 939 | } |
| 940 | catch (...) |
| 941 | { |
| 942 | this->__set_badbit_and_consider_rethrow(); |
| 943 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 944 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 945 | return __r; |
| 946 | } |
| 947 | |
| 948 | template<class _CharT, class _Traits> |
| 949 | inline _LIBCPP_INLINE_VISIBILITY |
| 950 | basic_istream<_CharT, _Traits>& |
| 951 | basic_istream<_CharT, _Traits>::get(char_type& __c) |
| 952 | { |
| 953 | int_type __ch = get(); |
| 954 | if (__ch != traits_type::eof()) |
| 955 | __c = traits_type::to_char_type(__ch); |
| 956 | return *this; |
| 957 | } |
| 958 | |
| 959 | template<class _CharT, class _Traits> |
| 960 | basic_istream<_CharT, _Traits>& |
| 961 | basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) |
| 962 | { |
| 963 | __gc_ = 0; |
| 964 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 965 | try |
| 966 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 967 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 968 | sentry __sen(*this, true); |
| 969 | if (__sen) |
| 970 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 971 | if (__n > 0) |
| 972 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 973 | ios_base::iostate __err = ios_base::goodbit; |
| 974 | while (__gc_ < __n-1) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 975 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 976 | int_type __i = this->rdbuf()->sgetc(); |
| 977 | if (traits_type::eq_int_type(__i, traits_type::eof())) |
| 978 | { |
| 979 | __err |= ios_base::eofbit; |
| 980 | break; |
| 981 | } |
| 982 | char_type __ch = traits_type::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 983 | if (traits_type::eq(__ch, __dlm)) |
| 984 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 985 | *__s++ = __ch; |
| 986 | ++__gc_; |
| 987 | this->rdbuf()->sbumpc(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 988 | } |
| 989 | *__s = char_type(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 990 | if (__gc_ == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 991 | __err |= ios_base::failbit; |
| 992 | this->setstate(__err); |
| 993 | } |
| 994 | else |
| 995 | this->setstate(ios_base::failbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 996 | } |
| 997 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 998 | } |
| 999 | catch (...) |
| 1000 | { |
| 1001 | this->__set_badbit_and_consider_rethrow(); |
| 1002 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1003 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1004 | return *this; |
| 1005 | } |
| 1006 | |
| 1007 | template<class _CharT, class _Traits> |
| 1008 | inline _LIBCPP_INLINE_VISIBILITY |
| 1009 | basic_istream<_CharT, _Traits>& |
| 1010 | basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) |
| 1011 | { |
| 1012 | return get(__s, __n, this->widen('\n')); |
| 1013 | } |
| 1014 | |
| 1015 | template<class _CharT, class _Traits> |
| 1016 | basic_istream<_CharT, _Traits>& |
| 1017 | basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb, |
| 1018 | char_type __dlm) |
| 1019 | { |
| 1020 | __gc_ = 0; |
| 1021 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1022 | try |
| 1023 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1024 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1025 | sentry __sen(*this, true); |
| 1026 | if (__sen) |
| 1027 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1028 | ios_base::iostate __err = ios_base::goodbit; |
| 1029 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1030 | try |
| 1031 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1032 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1033 | while (true) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1034 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1035 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 1036 | if (traits_type::eq_int_type(__i, traits_type::eof())) |
| 1037 | { |
| 1038 | __err |= ios_base::eofbit; |
| 1039 | break; |
| 1040 | } |
| 1041 | char_type __ch = traits_type::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1042 | if (traits_type::eq(__ch, __dlm)) |
| 1043 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1044 | if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof())) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1045 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1046 | ++__gc_; |
| 1047 | this->rdbuf()->sbumpc(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1048 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1049 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1050 | } |
| 1051 | catch (...) |
| 1052 | { |
| 1053 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1054 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1055 | if (__gc_ == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1056 | __err |= ios_base::failbit; |
| 1057 | this->setstate(__err); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1058 | } |
| 1059 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1060 | } |
| 1061 | catch (...) |
| 1062 | { |
| 1063 | this->__set_badbit_and_consider_rethrow(); |
| 1064 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1065 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1066 | return *this; |
| 1067 | } |
| 1068 | |
| 1069 | template<class _CharT, class _Traits> |
| 1070 | inline _LIBCPP_INLINE_VISIBILITY |
| 1071 | basic_istream<_CharT, _Traits>& |
| 1072 | basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb) |
| 1073 | { |
| 1074 | return get(__sb, this->widen('\n')); |
| 1075 | } |
| 1076 | |
| 1077 | template<class _CharT, class _Traits> |
| 1078 | basic_istream<_CharT, _Traits>& |
| 1079 | basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) |
| 1080 | { |
| 1081 | __gc_ = 0; |
| 1082 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1083 | try |
| 1084 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1085 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1086 | sentry __sen(*this, true); |
| 1087 | if (__sen) |
| 1088 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1089 | ios_base::iostate __err = ios_base::goodbit; |
| 1090 | while (true) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1091 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1092 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 1093 | if (traits_type::eq_int_type(__i, traits_type::eof())) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1094 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1095 | __err |= ios_base::eofbit; |
| 1096 | break; |
| 1097 | } |
| 1098 | char_type __ch = traits_type::to_char_type(__i); |
| 1099 | if (traits_type::eq(__ch, __dlm)) |
| 1100 | { |
| 1101 | this->rdbuf()->sbumpc(); |
| 1102 | ++__gc_; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1103 | break; |
| 1104 | } |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1105 | if (__gc_ >= __n-1) |
| 1106 | { |
| 1107 | __err |= ios_base::failbit; |
| 1108 | break; |
| 1109 | } |
| 1110 | *__s++ = __ch; |
| 1111 | this->rdbuf()->sbumpc(); |
| 1112 | ++__gc_; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1113 | } |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1114 | if (__n > 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1115 | *__s = char_type(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1116 | if (__gc_ == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1117 | __err |= ios_base::failbit; |
| 1118 | this->setstate(__err); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1119 | } |
| 1120 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1121 | } |
| 1122 | catch (...) |
| 1123 | { |
| 1124 | this->__set_badbit_and_consider_rethrow(); |
| 1125 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1126 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1127 | return *this; |
| 1128 | } |
| 1129 | |
| 1130 | template<class _CharT, class _Traits> |
| 1131 | inline _LIBCPP_INLINE_VISIBILITY |
| 1132 | basic_istream<_CharT, _Traits>& |
| 1133 | basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) |
| 1134 | { |
| 1135 | return getline(__s, __n, this->widen('\n')); |
| 1136 | } |
| 1137 | |
| 1138 | template<class _CharT, class _Traits> |
| 1139 | basic_istream<_CharT, _Traits>& |
| 1140 | basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) |
| 1141 | { |
| 1142 | __gc_ = 0; |
| 1143 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1144 | try |
| 1145 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1146 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1147 | sentry __sen(*this, true); |
| 1148 | if (__sen) |
| 1149 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1150 | ios_base::iostate __err = ios_base::goodbit; |
| 1151 | if (__n == numeric_limits<streamsize>::max()) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1152 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1153 | while (true) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1154 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1155 | typename traits_type::int_type __i = this->rdbuf()->sbumpc(); |
| 1156 | if (traits_type::eq_int_type(__i, traits_type::eof())) |
| 1157 | { |
| 1158 | __err |= ios_base::eofbit; |
| 1159 | break; |
| 1160 | } |
| 1161 | ++__gc_; |
Howard Hinnant | 11b8718 | 2013-07-01 00:37:50 +0000 | [diff] [blame] | 1162 | if (traits_type::eq_int_type(__i, __dlm)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1163 | break; |
| 1164 | } |
| 1165 | } |
| 1166 | else |
| 1167 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1168 | while (__gc_ < __n) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1169 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1170 | typename traits_type::int_type __i = this->rdbuf()->sbumpc(); |
| 1171 | if (traits_type::eq_int_type(__i, traits_type::eof())) |
| 1172 | { |
| 1173 | __err |= ios_base::eofbit; |
| 1174 | break; |
| 1175 | } |
| 1176 | ++__gc_; |
Howard Hinnant | 11b8718 | 2013-07-01 00:37:50 +0000 | [diff] [blame] | 1177 | if (traits_type::eq_int_type(__i, __dlm)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1178 | break; |
| 1179 | } |
| 1180 | } |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1181 | this->setstate(__err); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1182 | } |
| 1183 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1184 | } |
| 1185 | catch (...) |
| 1186 | { |
| 1187 | this->__set_badbit_and_consider_rethrow(); |
| 1188 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1189 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1190 | return *this; |
| 1191 | } |
| 1192 | |
| 1193 | template<class _CharT, class _Traits> |
| 1194 | typename basic_istream<_CharT, _Traits>::int_type |
| 1195 | basic_istream<_CharT, _Traits>::peek() |
| 1196 | { |
| 1197 | __gc_ = 0; |
| 1198 | int_type __r = traits_type::eof(); |
| 1199 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1200 | try |
| 1201 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1202 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1203 | sentry __sen(*this, true); |
| 1204 | if (__sen) |
Howard Hinnant | 73c85c7 | 2012-11-01 17:32:07 +0000 | [diff] [blame] | 1205 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1206 | __r = this->rdbuf()->sgetc(); |
Howard Hinnant | 73c85c7 | 2012-11-01 17:32:07 +0000 | [diff] [blame] | 1207 | if (traits_type::eq_int_type(__r, traits_type::eof())) |
| 1208 | this->setstate(ios_base::eofbit); |
| 1209 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1210 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1211 | } |
| 1212 | catch (...) |
| 1213 | { |
| 1214 | this->__set_badbit_and_consider_rethrow(); |
| 1215 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1216 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1217 | return __r; |
| 1218 | } |
| 1219 | |
| 1220 | template<class _CharT, class _Traits> |
| 1221 | basic_istream<_CharT, _Traits>& |
| 1222 | basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) |
| 1223 | { |
| 1224 | __gc_ = 0; |
| 1225 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1226 | try |
| 1227 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1228 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1229 | sentry __sen(*this, true); |
| 1230 | if (__sen) |
| 1231 | { |
Howard Hinnant | cc7bdae | 2013-03-06 19:27:56 +0000 | [diff] [blame] | 1232 | __gc_ = this->rdbuf()->sgetn(__s, __n); |
| 1233 | if (__gc_ != __n) |
| 1234 | this->setstate(ios_base::failbit | ios_base::eofbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1235 | } |
| 1236 | else |
| 1237 | this->setstate(ios_base::failbit); |
| 1238 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1239 | } |
| 1240 | catch (...) |
| 1241 | { |
| 1242 | this->__set_badbit_and_consider_rethrow(); |
| 1243 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1244 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1245 | return *this; |
| 1246 | } |
| 1247 | |
| 1248 | template<class _CharT, class _Traits> |
| 1249 | streamsize |
| 1250 | basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) |
| 1251 | { |
Howard Hinnant | ee717d8 | 2012-12-20 15:40:28 +0000 | [diff] [blame] | 1252 | __gc_ = 0; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1253 | streamsize __c = this->rdbuf()->in_avail(); |
| 1254 | switch (__c) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1255 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1256 | case -1: |
| 1257 | this->setstate(ios_base::eofbit); |
| 1258 | break; |
| 1259 | case 0: |
| 1260 | break; |
| 1261 | default: |
| 1262 | read(__s, _VSTD::min(__c, __n)); |
| 1263 | break; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1264 | } |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1265 | return __gc_; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | template<class _CharT, class _Traits> |
| 1269 | basic_istream<_CharT, _Traits>& |
| 1270 | basic_istream<_CharT, _Traits>::putback(char_type __c) |
| 1271 | { |
| 1272 | __gc_ = 0; |
| 1273 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1274 | try |
| 1275 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1276 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 37bdf0e | 2012-08-24 22:03:03 +0000 | [diff] [blame] | 1277 | this->clear(this->rdstate() & ~ios_base::eofbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1278 | sentry __sen(*this, true); |
| 1279 | if (__sen) |
| 1280 | { |
| 1281 | if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof()) |
| 1282 | this->setstate(ios_base::badbit); |
| 1283 | } |
| 1284 | else |
| 1285 | this->setstate(ios_base::failbit); |
| 1286 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1287 | } |
| 1288 | catch (...) |
| 1289 | { |
| 1290 | this->__set_badbit_and_consider_rethrow(); |
| 1291 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1292 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1293 | return *this; |
| 1294 | } |
| 1295 | |
| 1296 | template<class _CharT, class _Traits> |
| 1297 | basic_istream<_CharT, _Traits>& |
| 1298 | basic_istream<_CharT, _Traits>::unget() |
| 1299 | { |
| 1300 | __gc_ = 0; |
| 1301 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1302 | try |
| 1303 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1304 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 37bdf0e | 2012-08-24 22:03:03 +0000 | [diff] [blame] | 1305 | this->clear(this->rdstate() & ~ios_base::eofbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1306 | sentry __sen(*this, true); |
| 1307 | if (__sen) |
| 1308 | { |
| 1309 | if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof()) |
| 1310 | this->setstate(ios_base::badbit); |
| 1311 | } |
| 1312 | else |
| 1313 | this->setstate(ios_base::failbit); |
| 1314 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1315 | } |
| 1316 | catch (...) |
| 1317 | { |
| 1318 | this->__set_badbit_and_consider_rethrow(); |
| 1319 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1320 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1321 | return *this; |
| 1322 | } |
| 1323 | |
| 1324 | template<class _CharT, class _Traits> |
| 1325 | int |
| 1326 | basic_istream<_CharT, _Traits>::sync() |
| 1327 | { |
| 1328 | int __r = 0; |
| 1329 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1330 | try |
| 1331 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1332 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1333 | sentry __sen(*this, true); |
| 1334 | if (__sen) |
| 1335 | { |
| 1336 | if (this->rdbuf() == 0) |
| 1337 | return -1; |
| 1338 | if (this->rdbuf()->pubsync() == -1) |
| 1339 | { |
| 1340 | this->setstate(ios_base::badbit); |
| 1341 | return -1; |
| 1342 | } |
| 1343 | } |
| 1344 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1345 | } |
| 1346 | catch (...) |
| 1347 | { |
| 1348 | this->__set_badbit_and_consider_rethrow(); |
| 1349 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1350 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1351 | return __r; |
| 1352 | } |
| 1353 | |
| 1354 | template<class _CharT, class _Traits> |
| 1355 | typename basic_istream<_CharT, _Traits>::pos_type |
| 1356 | basic_istream<_CharT, _Traits>::tellg() |
| 1357 | { |
| 1358 | pos_type __r(-1); |
| 1359 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1360 | try |
| 1361 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1362 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1363 | sentry __sen(*this, true); |
| 1364 | if (__sen) |
| 1365 | __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); |
| 1366 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1367 | } |
| 1368 | catch (...) |
| 1369 | { |
| 1370 | this->__set_badbit_and_consider_rethrow(); |
| 1371 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1372 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1373 | return __r; |
| 1374 | } |
| 1375 | |
| 1376 | template<class _CharT, class _Traits> |
| 1377 | basic_istream<_CharT, _Traits>& |
| 1378 | basic_istream<_CharT, _Traits>::seekg(pos_type __pos) |
| 1379 | { |
| 1380 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1381 | try |
| 1382 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1383 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | 37bdf0e | 2012-08-24 22:03:03 +0000 | [diff] [blame] | 1384 | this->clear(this->rdstate() & ~ios_base::eofbit); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1385 | sentry __sen(*this, true); |
| 1386 | if (__sen) |
Marshall Clow | 76a8670 | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 1387 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1388 | if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) |
| 1389 | this->setstate(ios_base::failbit); |
Marshall Clow | 76a8670 | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 1390 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1391 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1392 | } |
| 1393 | catch (...) |
| 1394 | { |
| 1395 | this->__set_badbit_and_consider_rethrow(); |
| 1396 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1397 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1398 | return *this; |
| 1399 | } |
| 1400 | |
| 1401 | template<class _CharT, class _Traits> |
| 1402 | basic_istream<_CharT, _Traits>& |
| 1403 | basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) |
| 1404 | { |
| 1405 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1406 | try |
| 1407 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1408 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1409 | sentry __sen(*this, true); |
| 1410 | if (__sen) |
Marshall Clow | 76a8670 | 2013-10-31 22:20:45 +0000 | [diff] [blame] | 1411 | { |
| 1412 | if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) |
| 1413 | this->setstate(ios_base::failbit); |
| 1414 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1415 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1416 | } |
| 1417 | catch (...) |
| 1418 | { |
| 1419 | this->__set_badbit_and_consider_rethrow(); |
| 1420 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1421 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1422 | return *this; |
| 1423 | } |
| 1424 | |
| 1425 | template <class _CharT, class _Traits> |
| 1426 | basic_istream<_CharT, _Traits>& |
| 1427 | ws(basic_istream<_CharT, _Traits>& __is) |
| 1428 | { |
| 1429 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1430 | try |
| 1431 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1432 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1433 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1434 | if (__sen) |
| 1435 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1436 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1437 | while (true) |
| 1438 | { |
| 1439 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| 1440 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 1441 | { |
| 1442 | __is.setstate(ios_base::eofbit); |
| 1443 | break; |
| 1444 | } |
| 1445 | if (!__ct.is(__ct.space, _Traits::to_char_type(__i))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1446 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1447 | __is.rdbuf()->sbumpc(); |
| 1448 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1449 | } |
| 1450 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1451 | } |
| 1452 | catch (...) |
| 1453 | { |
| 1454 | __is.__set_badbit_and_consider_rethrow(); |
| 1455 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1456 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1457 | return __is; |
| 1458 | } |
| 1459 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1460 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1461 | |
| 1462 | template <class _CharT, class _Traits, class _Tp> |
| 1463 | inline _LIBCPP_INLINE_VISIBILITY |
| 1464 | basic_istream<_CharT, _Traits>& |
| 1465 | operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) |
| 1466 | { |
| 1467 | __is >> __x; |
| 1468 | return __is; |
| 1469 | } |
| 1470 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1471 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1472 | |
| 1473 | template <class _CharT, class _Traits> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1474 | class _LIBCPP_TYPE_VIS_ONLY basic_iostream |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1475 | : public basic_istream<_CharT, _Traits>, |
| 1476 | public basic_ostream<_CharT, _Traits> |
| 1477 | { |
| 1478 | public: |
| 1479 | // types: |
| 1480 | typedef _CharT char_type; |
| 1481 | typedef _Traits traits_type; |
| 1482 | typedef typename traits_type::int_type int_type; |
| 1483 | typedef typename traits_type::pos_type pos_type; |
| 1484 | typedef typename traits_type::off_type off_type; |
| 1485 | |
| 1486 | // constructor/destructor |
| 1487 | explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb); |
| 1488 | virtual ~basic_iostream(); |
| 1489 | protected: |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1490 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ac6de54 | 2011-07-07 21:03:52 +0000 | [diff] [blame] | 1491 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1492 | basic_iostream(basic_iostream&& __rhs); |
| 1493 | #endif |
| 1494 | |
| 1495 | // assign/swap |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1496 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ac6de54 | 2011-07-07 21:03:52 +0000 | [diff] [blame] | 1497 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1498 | basic_iostream& operator=(basic_iostream&& __rhs); |
| 1499 | #endif |
| 1500 | void swap(basic_iostream& __rhs); |
| 1501 | public: |
| 1502 | }; |
| 1503 | |
| 1504 | template <class _CharT, class _Traits> |
| 1505 | inline _LIBCPP_INLINE_VISIBILITY |
| 1506 | basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb) |
| 1507 | : basic_istream<_CharT, _Traits>(__sb) |
| 1508 | { |
| 1509 | } |
| 1510 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1511 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1512 | |
| 1513 | template <class _CharT, class _Traits> |
| 1514 | inline _LIBCPP_INLINE_VISIBILITY |
| 1515 | basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1516 | : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1517 | { |
| 1518 | } |
| 1519 | |
| 1520 | template <class _CharT, class _Traits> |
| 1521 | inline _LIBCPP_INLINE_VISIBILITY |
| 1522 | basic_iostream<_CharT, _Traits>& |
| 1523 | basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) |
| 1524 | { |
| 1525 | swap(__rhs); |
| 1526 | return *this; |
| 1527 | } |
| 1528 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1529 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1530 | |
| 1531 | template <class _CharT, class _Traits> |
| 1532 | basic_iostream<_CharT, _Traits>::~basic_iostream() |
| 1533 | { |
| 1534 | } |
| 1535 | |
| 1536 | template <class _CharT, class _Traits> |
| 1537 | inline _LIBCPP_INLINE_VISIBILITY |
| 1538 | void |
| 1539 | basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) |
| 1540 | { |
| 1541 | basic_istream<char_type, traits_type>::swap(__rhs); |
| 1542 | } |
| 1543 | |
| 1544 | template<class _CharT, class _Traits, class _Allocator> |
| 1545 | basic_istream<_CharT, _Traits>& |
| 1546 | operator>>(basic_istream<_CharT, _Traits>& __is, |
| 1547 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1548 | { |
| 1549 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1550 | try |
| 1551 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1552 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1553 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1554 | if (__sen) |
| 1555 | { |
| 1556 | __str.clear(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1557 | streamsize __n = __is.width(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1558 | if (__n <= 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1559 | __n = __str.max_size(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1560 | if (__n <= 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1561 | __n = numeric_limits<streamsize>::max(); |
| 1562 | streamsize __c = 0; |
| 1563 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1564 | ios_base::iostate __err = ios_base::goodbit; |
| 1565 | while (__c < __n) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1566 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1567 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| 1568 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 1569 | { |
| 1570 | __err |= ios_base::eofbit; |
| 1571 | break; |
| 1572 | } |
| 1573 | _CharT __ch = _Traits::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1574 | if (__ct.is(__ct.space, __ch)) |
| 1575 | break; |
| 1576 | __str.push_back(__ch); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1577 | ++__c; |
| 1578 | __is.rdbuf()->sbumpc(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1579 | } |
| 1580 | __is.width(0); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1581 | if (__c == 0) |
| 1582 | __err |= ios_base::failbit; |
| 1583 | __is.setstate(__err); |
| 1584 | } |
| 1585 | else |
| 1586 | __is.setstate(ios_base::failbit); |
| 1587 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1588 | } |
| 1589 | catch (...) |
| 1590 | { |
| 1591 | __is.__set_badbit_and_consider_rethrow(); |
| 1592 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1593 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1594 | return __is; |
| 1595 | } |
| 1596 | |
| 1597 | template<class _CharT, class _Traits, class _Allocator> |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1598 | basic_istream<_CharT, _Traits>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1599 | getline(basic_istream<_CharT, _Traits>& __is, |
| 1600 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) |
| 1601 | { |
| 1602 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1603 | try |
| 1604 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1605 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1606 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1607 | if (__sen) |
| 1608 | { |
| 1609 | __str.clear(); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1610 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | b97de44 | 2011-10-09 15:20:46 +0000 | [diff] [blame] | 1611 | streamsize __extr = 0; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1612 | while (true) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1613 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1614 | typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); |
| 1615 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 1616 | { |
| 1617 | __err |= ios_base::eofbit; |
| 1618 | break; |
| 1619 | } |
Howard Hinnant | b97de44 | 2011-10-09 15:20:46 +0000 | [diff] [blame] | 1620 | ++__extr; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1621 | _CharT __ch = _Traits::to_char_type(__i); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1622 | if (_Traits::eq(__ch, __dlm)) |
| 1623 | break; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1624 | __str.push_back(__ch); |
| 1625 | if (__str.size() == __str.max_size()) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1626 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1627 | __err |= ios_base::failbit; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1628 | break; |
| 1629 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1630 | } |
Howard Hinnant | b97de44 | 2011-10-09 15:20:46 +0000 | [diff] [blame] | 1631 | if (__extr == 0) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1632 | __err |= ios_base::failbit; |
| 1633 | __is.setstate(__err); |
| 1634 | } |
| 1635 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1636 | } |
| 1637 | catch (...) |
| 1638 | { |
| 1639 | __is.__set_badbit_and_consider_rethrow(); |
| 1640 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1641 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1642 | return __is; |
| 1643 | } |
| 1644 | |
| 1645 | template<class _CharT, class _Traits, class _Allocator> |
Howard Hinnant | 68a8e90 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 1646 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1647 | basic_istream<_CharT, _Traits>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1648 | getline(basic_istream<_CharT, _Traits>& __is, |
| 1649 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1650 | { |
| 1651 | return getline(__is, __str, __is.widen('\n')); |
| 1652 | } |
| 1653 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1654 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1655 | |
| 1656 | template<class _CharT, class _Traits, class _Allocator> |
Howard Hinnant | 68a8e90 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 1657 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1658 | basic_istream<_CharT, _Traits>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1659 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 1660 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) |
| 1661 | { |
| 1662 | return getline(__is, __str, __dlm); |
| 1663 | } |
| 1664 | |
| 1665 | template<class _CharT, class _Traits, class _Allocator> |
Howard Hinnant | 68a8e90 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 1666 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1667 | basic_istream<_CharT, _Traits>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1668 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 1669 | basic_string<_CharT, _Traits, _Allocator>& __str) |
| 1670 | { |
| 1671 | return getline(__is, __str, __is.widen('\n')); |
| 1672 | } |
| 1673 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1674 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1675 | |
| 1676 | template <class _CharT, class _Traits, size_t _Size> |
| 1677 | basic_istream<_CharT, _Traits>& |
| 1678 | operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) |
| 1679 | { |
| 1680 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1681 | try |
| 1682 | { |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1683 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1684 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1685 | if (__sen) |
| 1686 | { |
| 1687 | basic_string<_CharT, _Traits> __str; |
| 1688 | const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1689 | streamsize __c = 0; |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1690 | ios_base::iostate __err = ios_base::goodbit; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1691 | _CharT __zero = __ct.widen('0'); |
| 1692 | _CharT __one = __ct.widen('1'); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1693 | while (__c < _Size) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1694 | { |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1695 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| 1696 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 1697 | { |
| 1698 | __err |= ios_base::eofbit; |
| 1699 | break; |
| 1700 | } |
| 1701 | _CharT __ch = _Traits::to_char_type(__i); |
| 1702 | if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1703 | break; |
| 1704 | __str.push_back(__ch); |
Howard Hinnant | 92a836c | 2011-09-01 21:02:45 +0000 | [diff] [blame] | 1705 | ++__c; |
| 1706 | __is.rdbuf()->sbumpc(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1707 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1708 | __x = bitset<_Size>(__str); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1709 | if (__c == 0) |
| 1710 | __err |= ios_base::failbit; |
| 1711 | __is.setstate(__err); |
| 1712 | } |
| 1713 | else |
| 1714 | __is.setstate(ios_base::failbit); |
| 1715 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1716 | } |
| 1717 | catch (...) |
| 1718 | { |
| 1719 | __is.__set_badbit_and_consider_rethrow(); |
| 1720 | } |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1721 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1722 | return __is; |
| 1723 | } |
| 1724 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1725 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>) |
| 1726 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>) |
| 1727 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1728 | |
| 1729 | _LIBCPP_END_NAMESPACE_STD |
| 1730 | |
| 1731 | #endif // _LIBCPP_ISTREAM |