ReactOS  0.4.13-dev-73-gcfe54aa
complex_io.cpp
Go to the documentation of this file.
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  */
18 
19 #include "stlport_prefix.h"
20 
21 #include <complex>
22 #include <istream>
23 
25 
26 // Specializations for narrow characters; lets us avoid the nuisance of
27 // widening.
28 _STLP_OPERATOR_SPEC
31 { return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; }
32 
33 _STLP_OPERATOR_SPEC
36 { return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
37 
38 #ifndef _STLP_NO_LONG_DOUBLE
39 _STLP_OPERATOR_SPEC
42 { return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
43 #endif
44 
45 // Specialization for narrow characters; lets us avoid widen.
46 _STLP_OPERATOR_SPEC
49  float __re = 0;
50  float __im = 0;
51 
52  char __c;
53 
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  }
66 
67  if (__is)
68  __z = complex<float>(__re, __im);
69  return __is;
70 }
71 
72 _STLP_OPERATOR_SPEC
75  double __re = 0;
76  double __im = 0;
77 
78  char __c;
79 
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  }
92 
93  if (__is)
94  __z = complex<double>(__re, __im);
95  return __is;
96 }
97 
98 #ifndef _STLP_NO_LONG_DOUBLE
99 _STLP_OPERATOR_SPEC
102  long double __re = 0;
103  long double __im = 0;
104 
105  char __c;
106 
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  }
119 
120  if (__is)
121  __z = complex<long double>(__re, __im);
122  return __is;
123 }
124 #endif
125 
126 // Force instantiation of complex I/O functions
127 #if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T))
128 
131 
134 
135 #ifndef _STLP_NO_LONG_DOUBLE
138 
141 #endif
142 
145 
148 
149 #endif /* _STLP_NO_WCHAR_T */
150 
152 
153 
154 // Local Variables:
155 // mode:C++
156 // End:
157 
value_type imag() const
Definition: _complex.h:473
#define __c
Definition: schilyio.h:209
value_type imag() const
Definition: _complex.h:335
_STLP_BEGIN_NAMESPACE _STLP_OPERATOR_SPEC basic_ostream< char, char_traits< char > > &_STLP_CALL operator<<(basic_ostream< char, char_traits< char > > &__os, const complex< float > &__z)
Definition: complex_io.cpp:30
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
value_type real() const
Definition: _complex.h:472
value_type real() const
Definition: _complex.h:334
value_type imag() const
Definition: _complex.h:196
#define _STLP_END_NAMESPACE
Definition: features.h:503
value_type real() const
Definition: _complex.h:195
_STLP_OPERATOR_SPEC basic_istream< char, char_traits< char > > &_STLP_CALL operator>>(basic_istream< char, char_traits< char > > &__is, complex< float > &__z)
Definition: complex_io.cpp:48
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_CALL
Definition: _bc.h:131