sl@0: /* sl@0: * Copyright (c) 1999 sl@0: * Silicon Graphics Computer Systems, Inc. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Boris Fomitchev sl@0: * sl@0: * This material is provided "as is", with absolutely no warranty expressed sl@0: * or implied. Any use is at your own risk. sl@0: * sl@0: * Permission to use or copy this software for any purpose is hereby granted sl@0: * without fee, provided the above notices are retained on all copies. sl@0: * Permission to modify the code and to distribute modified code is granted, sl@0: * provided the above notices are retained, and a notice that the code was sl@0: * modified is included with the above copyright notice. sl@0: * sl@0: */ sl@0: sl@0: # include "stlport_prefix.h" sl@0: // #include sl@0: #include "complex_impl.h" sl@0: #include sl@0: sl@0: _STLP_BEGIN_NAMESPACE sl@0: sl@0: # if ! (defined (_STLP_MSVC) && _STLP_MSVC < 1200) sl@0: sl@0: // Specializations for narrow characters; lets us avoid the nuisance of sl@0: // widening. sl@0: _STLP_OPERATOR_SPEC sl@0: basic_ostream >& _STLP_CALL sl@0: operator<< (basic_ostream >& __os, const complex& __z) sl@0: { sl@0: return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; sl@0: } sl@0: sl@0: _STLP_OPERATOR_SPEC sl@0: basic_ostream >& _STLP_CALL sl@0: operator<< (basic_ostream >& __os, const complex& __z) sl@0: { sl@0: return __os << '(' << __z.real() << ',' << __z.imag() << ')'; sl@0: } sl@0: sl@0: #ifndef _STLP_NO_LONG_DOUBLE sl@0: _STLP_OPERATOR_SPEC sl@0: basic_ostream >& _STLP_CALL sl@0: operator<< (basic_ostream >& __os, const complex& __z) sl@0: { sl@0: return __os << '(' << __z.real() << ',' << __z.imag() << ')'; sl@0: } sl@0: #endif sl@0: sl@0: // Specialization for narrow characters; lets us avoid widen. sl@0: _STLP_OPERATOR_SPEC sl@0: basic_istream >& _STLP_CALL sl@0: operator>>(basic_istream >& __is, complex& __z) sl@0: { sl@0: float __re = 0; sl@0: float __im = 0; sl@0: sl@0: char __c; sl@0: sl@0: __is >> __c; sl@0: if (__c == '(') { sl@0: __is >> __re >> __c; sl@0: if (__c == ',') sl@0: __is >> __im >> __c; sl@0: if (__c != ')') sl@0: __is.setstate(ios_base::failbit); sl@0: } sl@0: else { sl@0: __is.putback(__c); sl@0: __is >> __re; sl@0: } sl@0: sl@0: if (__is) sl@0: __z = complex(__re, __im); sl@0: return __is; sl@0: } sl@0: sl@0: _STLP_OPERATOR_SPEC sl@0: basic_istream >& _STLP_CALL sl@0: operator>>(basic_istream >& __is, complex& __z) sl@0: { sl@0: double __re = 0; sl@0: double __im = 0; sl@0: sl@0: char __c; sl@0: sl@0: __is >> __c; sl@0: if (__c == '(') { sl@0: __is >> __re >> __c; sl@0: if (__c == ',') sl@0: __is >> __im >> __c; sl@0: if (__c != ')') sl@0: __is.setstate(ios_base::failbit); sl@0: } sl@0: else { sl@0: __is.putback(__c); sl@0: __is >> __re; sl@0: } sl@0: sl@0: if (__is) sl@0: __z = complex(__re, __im); sl@0: return __is; sl@0: } sl@0: sl@0: # ifndef _STLP_NO_LONG_DOUBLE sl@0: _STLP_OPERATOR_SPEC sl@0: basic_istream >& _STLP_CALL sl@0: operator>>(basic_istream >& __is, complex& __z) { sl@0: long double __re = 0; sl@0: long double __im = 0; sl@0: sl@0: char __c; sl@0: sl@0: __is >> __c; sl@0: if (__c == '(') { sl@0: __is >> __re >> __c; sl@0: if (__c == ',') sl@0: __is >> __im >> __c; sl@0: if (__c != ')') sl@0: __is.setstate(ios_base::failbit); sl@0: } sl@0: else { sl@0: __is.putback(__c); sl@0: __is >> __re; sl@0: } sl@0: sl@0: if (__is) sl@0: __z = complex(__re, __im); sl@0: return __is; sl@0: } sl@0: # endif sl@0: sl@0: # endif /* MSVC */ sl@0: sl@0: _STLP_END_NAMESPACE sl@0: sl@0: sl@0: // Local Variables: sl@0: // mode:C++ sl@0: // End: sl@0: