1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/complex_io.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,161 @@
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 +#if !(defined (_STLP_MSVC) && _STLP_MSVC < 1200)
1.30 +
1.31 +// Specializations for narrow characters; lets us avoid the nuisance of
1.32 +// widening.
1.33 +_STLP_OPERATOR_SPEC
1.34 +basic_ostream<char, char_traits<char> >& _STLP_CALL
1.35 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<float>& __z)
1.36 +{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; }
1.37 +
1.38 +_STLP_OPERATOR_SPEC
1.39 +basic_ostream<char, char_traits<char> >& _STLP_CALL
1.40 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<double>& __z)
1.41 +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
1.42 +
1.43 +# ifndef _STLP_NO_LONG_DOUBLE
1.44 +_STLP_OPERATOR_SPEC
1.45 +basic_ostream<char, char_traits<char> >& _STLP_CALL
1.46 +operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<long double>& __z)
1.47 +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
1.48 +# endif
1.49 +
1.50 +// Specialization for narrow characters; lets us avoid widen.
1.51 +_STLP_OPERATOR_SPEC
1.52 +basic_istream<char, char_traits<char> >& _STLP_CALL
1.53 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z) {
1.54 + float __re = 0;
1.55 + float __im = 0;
1.56 +
1.57 + char __c;
1.58 +
1.59 + __is >> __c;
1.60 + if (__c == '(') {
1.61 + __is >> __re >> __c;
1.62 + if (__c == ',')
1.63 + __is >> __im >> __c;
1.64 + if (__c != ')')
1.65 + __is.setstate(ios_base::failbit);
1.66 + }
1.67 + else {
1.68 + __is.putback(__c);
1.69 + __is >> __re;
1.70 + }
1.71 +
1.72 + if (__is)
1.73 + __z = complex<float>(__re, __im);
1.74 + return __is;
1.75 +}
1.76 +
1.77 +_STLP_OPERATOR_SPEC
1.78 +basic_istream<char, char_traits<char> >& _STLP_CALL
1.79 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z) {
1.80 + double __re = 0;
1.81 + double __im = 0;
1.82 +
1.83 + char __c;
1.84 +
1.85 + __is >> __c;
1.86 + if (__c == '(') {
1.87 + __is >> __re >> __c;
1.88 + if (__c == ',')
1.89 + __is >> __im >> __c;
1.90 + if (__c != ')')
1.91 + __is.setstate(ios_base::failbit);
1.92 + }
1.93 + else {
1.94 + __is.putback(__c);
1.95 + __is >> __re;
1.96 + }
1.97 +
1.98 + if (__is)
1.99 + __z = complex<double>(__re, __im);
1.100 + return __is;
1.101 +}
1.102 +
1.103 +# ifndef _STLP_NO_LONG_DOUBLE
1.104 +_STLP_OPERATOR_SPEC
1.105 +basic_istream<char, char_traits<char> >& _STLP_CALL
1.106 +operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z) {
1.107 + long double __re = 0;
1.108 + long double __im = 0;
1.109 +
1.110 + char __c;
1.111 +
1.112 + __is >> __c;
1.113 + if (__c == '(') {
1.114 + __is >> __re >> __c;
1.115 + if (__c == ',')
1.116 + __is >> __im >> __c;
1.117 + if (__c != ')')
1.118 + __is.setstate(ios_base::failbit);
1.119 + }
1.120 + else {
1.121 + __is.putback(__c);
1.122 + __is >> __re;
1.123 + }
1.124 +
1.125 + if (__is)
1.126 + __z = complex<long double>(__re, __im);
1.127 + return __is;
1.128 +}
1.129 +# endif
1.130 +
1.131 +#endif /* MSVC */
1.132 +
1.133 +// Force instantiation of complex I/O functions
1.134 +#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T))
1.135 +
1.136 +_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.137 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
1.138 +
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<double>&);
1.141 +
1.142 +#ifndef _STLP_NO_LONG_DOUBLE
1.143 +_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.144 +operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
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<long double>&);
1.148 +#endif
1.149 +
1.150 +_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.151 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
1.152 +
1.153 +_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
1.154 +operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
1.155 +
1.156 +#endif /* _STLP_NO_WCHAR_T */
1.157 +
1.158 +_STLP_END_NAMESPACE
1.159 +
1.160 +
1.161 +// Local Variables:
1.162 +// mode:C++
1.163 +// End:
1.164 +