build/stlport/src/complex_io.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial