Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 1999 |
michael@0 | 3 | * Silicon Graphics Computer Systems, Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Copyright (c) 1999 |
michael@0 | 6 | * Boris Fomitchev |
michael@0 | 7 | * |
michael@0 | 8 | * This material is provided "as is", with absolutely no warranty expressed |
michael@0 | 9 | * or implied. Any use is at your own risk. |
michael@0 | 10 | * |
michael@0 | 11 | * Permission to use or copy this software for any purpose is hereby granted |
michael@0 | 12 | * without fee, provided the above notices are retained on all copies. |
michael@0 | 13 | * Permission to modify the code and to distribute modified code is granted, |
michael@0 | 14 | * provided the above notices are retained, and a notice that the code was |
michael@0 | 15 | * modified is included with the above copyright notice. |
michael@0 | 16 | * |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | #include "stlport_prefix.h" |
michael@0 | 20 | |
michael@0 | 21 | #include <complex> |
michael@0 | 22 | #include <istream> |
michael@0 | 23 | |
michael@0 | 24 | _STLP_BEGIN_NAMESPACE |
michael@0 | 25 | |
michael@0 | 26 | // Specializations for narrow characters; lets us avoid the nuisance of |
michael@0 | 27 | // widening. |
michael@0 | 28 | _STLP_OPERATOR_SPEC |
michael@0 | 29 | basic_ostream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 30 | operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<float>& __z) |
michael@0 | 31 | { return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; } |
michael@0 | 32 | |
michael@0 | 33 | _STLP_OPERATOR_SPEC |
michael@0 | 34 | basic_ostream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 35 | operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<double>& __z) |
michael@0 | 36 | { return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } |
michael@0 | 37 | |
michael@0 | 38 | #ifndef _STLP_NO_LONG_DOUBLE |
michael@0 | 39 | _STLP_OPERATOR_SPEC |
michael@0 | 40 | basic_ostream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 41 | operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<long double>& __z) |
michael@0 | 42 | { return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } |
michael@0 | 43 | #endif |
michael@0 | 44 | |
michael@0 | 45 | // Specialization for narrow characters; lets us avoid widen. |
michael@0 | 46 | _STLP_OPERATOR_SPEC |
michael@0 | 47 | basic_istream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 48 | operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z) { |
michael@0 | 49 | float __re = 0; |
michael@0 | 50 | float __im = 0; |
michael@0 | 51 | |
michael@0 | 52 | char __c; |
michael@0 | 53 | |
michael@0 | 54 | __is >> __c; |
michael@0 | 55 | if (__c == '(') { |
michael@0 | 56 | __is >> __re >> __c; |
michael@0 | 57 | if (__c == ',') |
michael@0 | 58 | __is >> __im >> __c; |
michael@0 | 59 | if (__c != ')') |
michael@0 | 60 | __is.setstate(ios_base::failbit); |
michael@0 | 61 | } |
michael@0 | 62 | else { |
michael@0 | 63 | __is.putback(__c); |
michael@0 | 64 | __is >> __re; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | if (__is) |
michael@0 | 68 | __z = complex<float>(__re, __im); |
michael@0 | 69 | return __is; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | _STLP_OPERATOR_SPEC |
michael@0 | 73 | basic_istream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 74 | operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z) { |
michael@0 | 75 | double __re = 0; |
michael@0 | 76 | double __im = 0; |
michael@0 | 77 | |
michael@0 | 78 | char __c; |
michael@0 | 79 | |
michael@0 | 80 | __is >> __c; |
michael@0 | 81 | if (__c == '(') { |
michael@0 | 82 | __is >> __re >> __c; |
michael@0 | 83 | if (__c == ',') |
michael@0 | 84 | __is >> __im >> __c; |
michael@0 | 85 | if (__c != ')') |
michael@0 | 86 | __is.setstate(ios_base::failbit); |
michael@0 | 87 | } |
michael@0 | 88 | else { |
michael@0 | 89 | __is.putback(__c); |
michael@0 | 90 | __is >> __re; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | if (__is) |
michael@0 | 94 | __z = complex<double>(__re, __im); |
michael@0 | 95 | return __is; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | #ifndef _STLP_NO_LONG_DOUBLE |
michael@0 | 99 | _STLP_OPERATOR_SPEC |
michael@0 | 100 | basic_istream<char, char_traits<char> >& _STLP_CALL |
michael@0 | 101 | operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z) { |
michael@0 | 102 | long double __re = 0; |
michael@0 | 103 | long double __im = 0; |
michael@0 | 104 | |
michael@0 | 105 | char __c; |
michael@0 | 106 | |
michael@0 | 107 | __is >> __c; |
michael@0 | 108 | if (__c == '(') { |
michael@0 | 109 | __is >> __re >> __c; |
michael@0 | 110 | if (__c == ',') |
michael@0 | 111 | __is >> __im >> __c; |
michael@0 | 112 | if (__c != ')') |
michael@0 | 113 | __is.setstate(ios_base::failbit); |
michael@0 | 114 | } |
michael@0 | 115 | else { |
michael@0 | 116 | __is.putback(__c); |
michael@0 | 117 | __is >> __re; |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | if (__is) |
michael@0 | 121 | __z = complex<long double>(__re, __im); |
michael@0 | 122 | return __is; |
michael@0 | 123 | } |
michael@0 | 124 | #endif |
michael@0 | 125 | |
michael@0 | 126 | // Force instantiation of complex I/O functions |
michael@0 | 127 | #if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T)) |
michael@0 | 128 | |
michael@0 | 129 | _STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 130 | operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&); |
michael@0 | 131 | |
michael@0 | 132 | _STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 133 | operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&); |
michael@0 | 134 | |
michael@0 | 135 | #ifndef _STLP_NO_LONG_DOUBLE |
michael@0 | 136 | _STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 137 | operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&); |
michael@0 | 138 | |
michael@0 | 139 | _STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 140 | operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&); |
michael@0 | 141 | #endif |
michael@0 | 142 | |
michael@0 | 143 | _STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 144 | operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&); |
michael@0 | 145 | |
michael@0 | 146 | _STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL |
michael@0 | 147 | operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&); |
michael@0 | 148 | |
michael@0 | 149 | #endif /* _STLP_NO_WCHAR_T */ |
michael@0 | 150 | |
michael@0 | 151 | _STLP_END_NAMESPACE |
michael@0 | 152 | |
michael@0 | 153 | |
michael@0 | 154 | // Local Variables: |
michael@0 | 155 | // mode:C++ |
michael@0 | 156 | // End: |
michael@0 | 157 |