1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/stlport/src/complex_io.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,157 @@ 1.4 +/* 1.5 + * Copyright (c) 1999 1.6 + * Silicon Graphics Computer Systems, Inc. 1.7 + * 1.8 + * Copyright (c) 1999 1.9 + * Boris Fomitchev 1.10 + * 1.11 + * This material is provided "as is", with absolutely no warranty expressed 1.12 + * or implied. Any use is at your own risk. 1.13 + * 1.14 + * Permission to use or copy this software for any purpose is hereby granted 1.15 + * without fee, provided the above notices are retained on all copies. 1.16 + * Permission to modify the code and to distribute modified code is granted, 1.17 + * provided the above notices are retained, and a notice that the code was 1.18 + * modified is included with the above copyright notice. 1.19 + * 1.20 + */ 1.21 + 1.22 +#include "stlport_prefix.h" 1.23 + 1.24 +#include <complex> 1.25 +#include <istream> 1.26 + 1.27 +_STLP_BEGIN_NAMESPACE 1.28 + 1.29 +// Specializations for narrow characters; lets us avoid the nuisance of 1.30 +// widening. 1.31 +_STLP_OPERATOR_SPEC 1.32 +basic_ostream<char, char_traits<char> >& _STLP_CALL 1.33 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<float>& __z) 1.34 +{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; } 1.35 + 1.36 +_STLP_OPERATOR_SPEC 1.37 +basic_ostream<char, char_traits<char> >& _STLP_CALL 1.38 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<double>& __z) 1.39 +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } 1.40 + 1.41 +#ifndef _STLP_NO_LONG_DOUBLE 1.42 +_STLP_OPERATOR_SPEC 1.43 +basic_ostream<char, char_traits<char> >& _STLP_CALL 1.44 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<long double>& __z) 1.45 +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } 1.46 +#endif 1.47 + 1.48 +// Specialization for narrow characters; lets us avoid widen. 1.49 +_STLP_OPERATOR_SPEC 1.50 +basic_istream<char, char_traits<char> >& _STLP_CALL 1.51 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z) { 1.52 + float __re = 0; 1.53 + float __im = 0; 1.54 + 1.55 + char __c; 1.56 + 1.57 + __is >> __c; 1.58 + if (__c == '(') { 1.59 + __is >> __re >> __c; 1.60 + if (__c == ',') 1.61 + __is >> __im >> __c; 1.62 + if (__c != ')') 1.63 + __is.setstate(ios_base::failbit); 1.64 + } 1.65 + else { 1.66 + __is.putback(__c); 1.67 + __is >> __re; 1.68 + } 1.69 + 1.70 + if (__is) 1.71 + __z = complex<float>(__re, __im); 1.72 + return __is; 1.73 +} 1.74 + 1.75 +_STLP_OPERATOR_SPEC 1.76 +basic_istream<char, char_traits<char> >& _STLP_CALL 1.77 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z) { 1.78 + double __re = 0; 1.79 + double __im = 0; 1.80 + 1.81 + char __c; 1.82 + 1.83 + __is >> __c; 1.84 + if (__c == '(') { 1.85 + __is >> __re >> __c; 1.86 + if (__c == ',') 1.87 + __is >> __im >> __c; 1.88 + if (__c != ')') 1.89 + __is.setstate(ios_base::failbit); 1.90 + } 1.91 + else { 1.92 + __is.putback(__c); 1.93 + __is >> __re; 1.94 + } 1.95 + 1.96 + if (__is) 1.97 + __z = complex<double>(__re, __im); 1.98 + return __is; 1.99 +} 1.100 + 1.101 +#ifndef _STLP_NO_LONG_DOUBLE 1.102 +_STLP_OPERATOR_SPEC 1.103 +basic_istream<char, char_traits<char> >& _STLP_CALL 1.104 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z) { 1.105 + long double __re = 0; 1.106 + long double __im = 0; 1.107 + 1.108 + char __c; 1.109 + 1.110 + __is >> __c; 1.111 + if (__c == '(') { 1.112 + __is >> __re >> __c; 1.113 + if (__c == ',') 1.114 + __is >> __im >> __c; 1.115 + if (__c != ')') 1.116 + __is.setstate(ios_base::failbit); 1.117 + } 1.118 + else { 1.119 + __is.putback(__c); 1.120 + __is >> __re; 1.121 + } 1.122 + 1.123 + if (__is) 1.124 + __z = complex<long double>(__re, __im); 1.125 + return __is; 1.126 +} 1.127 +#endif 1.128 + 1.129 +// Force instantiation of complex I/O functions 1.130 +#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T)) 1.131 + 1.132 +_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.133 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&); 1.134 + 1.135 +_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.136 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&); 1.137 + 1.138 +#ifndef _STLP_NO_LONG_DOUBLE 1.139 +_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.140 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&); 1.141 + 1.142 +_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.143 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&); 1.144 +#endif 1.145 + 1.146 +_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.147 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&); 1.148 + 1.149 +_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL 1.150 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&); 1.151 + 1.152 +#endif /* _STLP_NO_WCHAR_T */ 1.153 + 1.154 +_STLP_END_NAMESPACE 1.155 + 1.156 + 1.157 +// Local Variables: 1.158 +// mode:C++ 1.159 +// End: 1.160 +