diff -r 000000000000 -r bde4ae8d615e os/ossrv/genericopenlibs/cppstdlib/stl/src/complex_io.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/complex_io.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,161 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "stlport_prefix.h" + +#include +#include + +_STLP_BEGIN_NAMESPACE + +#if !(defined (_STLP_MSVC) && _STLP_MSVC < 1200) + +// Specializations for narrow characters; lets us avoid the nuisance of +// widening. +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; } + +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } + +# ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC +basic_ostream >& _STLP_CALL +operator<< (basic_ostream >& __os, const complex& __z) +{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; } +# endif + +// Specialization for narrow characters; lets us avoid widen. +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + float __re = 0; + float __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} + +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + double __re = 0; + double __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} + +# ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC +basic_istream >& _STLP_CALL +operator>>(basic_istream >& __is, complex& __z) { + long double __re = 0; + long double __im = 0; + + char __c; + + __is >> __c; + if (__c == '(') { + __is >> __re >> __c; + if (__c == ',') + __is >> __im >> __c; + if (__c != ')') + __is.setstate(ios_base::failbit); + } + else { + __is.putback(__c); + __is >> __re; + } + + if (__is) + __z = complex(__re, __im); + return __is; +} +# endif + +#endif /* MSVC */ + +// Force instantiation of complex I/O functions +#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T)) + +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +#ifndef _STLP_NO_LONG_DOUBLE +_STLP_OPERATOR_SPEC basic_istream >& _STLP_CALL +operator>>(basic_istream >&, complex&); + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); +#endif + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); + +_STLP_OPERATOR_SPEC basic_ostream >& _STLP_CALL +operator<<(basic_ostream >&, const complex&); + +#endif /* _STLP_NO_WCHAR_T */ + +_STLP_END_NAMESPACE + + +// Local Variables: +// mode:C++ +// End: +