1 // -*- C++ -*-
2 /**
3 * @brief The class Ostream is an helper for pretty printing of Objects
4 *
5 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6 *
7 * This library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 #include "openturns/OTprivate.hxx"
23 #include "openturns/OStream.hxx"
24
25 BEGIN_NAMESPACE_OPENTURNS
26
27
28 // This operator writes Object derived objects to OStream
29
operator <<(OStream & OS,const Object & obj)30 OStream & operator << (OStream & OS, const Object & obj)
31 {
32 OS.getStream() << obj.__repr__();
33 return OS;
34 }
35
36
operator <<(OStream & OS,const String & st)37 OStream & operator << (OStream & OS, const String & st)
38 {
39 OS.getStream() << st;
40 return OS;
41 }
42
43
operator <<(OStream & OS,const char * ch)44 OStream & operator << (OStream & OS, const char * ch)
45 {
46 OS.getStream() << ch;
47 return OS;
48 }
49
50
operator <<(OStream & OS,int val)51 OStream & operator << (OStream & OS, int val)
52 {
53 OS.getStream() << val;
54 return OS;
55 }
56
57
operator <<(OStream & OS,long val)58 OStream & operator << (OStream & OS, long val)
59 {
60 OS.getStream() << val;
61 return OS;
62 }
63
64
65 #ifndef OPENTURNS_UNSIGNEDLONG_SAME_AS_UINT64
operator <<(OStream & OS,int64_t val)66 OStream & operator << (OStream & OS, int64_t val)
67 {
68 OS.getStream() << val;
69 return OS;
70 }
71 #endif
72
73
operator <<(OStream & OS,short val)74 OStream & operator << (OStream & OS, short val)
75 {
76 OS.getStream() << val;
77 return OS;
78 }
79
80
operator <<(OStream & OS,unsigned int val)81 OStream & operator << (OStream & OS, unsigned int val)
82 {
83 OS.getStream() << val;
84 return OS;
85 }
86
87
operator <<(OStream & OS,unsigned long val)88 OStream & operator << (OStream & OS, unsigned long val)
89 {
90 OS.getStream() << val;
91 return OS;
92 }
93
94
95 #ifndef OPENTURNS_UNSIGNEDLONG_SAME_AS_UINT64
operator <<(OStream & OS,uint64_t val)96 OStream & operator << (OStream & OS, uint64_t val)
97 {
98 OS.getStream() << val;
99 return OS;
100 }
101 #endif
102
103
operator <<(OStream & OS,unsigned short val)104 OStream & operator << (OStream & OS, unsigned short val)
105 {
106 OS.getStream() << val;
107 return OS;
108 }
109
110
operator <<(OStream & OS,char val)111 OStream & operator << (OStream & OS, char val)
112 {
113 OS.getStream() << val;
114 return OS;
115 }
116
117
operator <<(OStream & OS,bool val)118 OStream & operator << (OStream & OS, bool val)
119 {
120 OS.getStream() << (val ? "true" : "false");
121 return OS;
122 }
123
124
operator <<(OStream & OS,float val)125 OStream & operator << (OStream & OS, float val)
126 {
127 OS.getStream() << val;
128 return OS;
129 }
130
131
operator <<(OStream & OS,double val)132 OStream & operator << (OStream & OS, double val)
133 {
134 OS.getStream() << val;
135 return OS;
136 }
137
138
operator <<(OStream & OS,long double val)139 OStream & operator << (OStream & OS, long double val)
140 {
141 OS.getStream() << val;
142 return OS;
143 }
144
145
operator <<(OStream & OS,const Complex & c)146 OStream & operator << (OStream & OS, const Complex & c)
147 {
148 OS.getStream() << c;
149 return OS;
150 }
151
152
operator <<(OStream & OS,const void * ptr)153 OStream & operator << (OStream & OS, const void * ptr)
154 {
155 OS.getStream() << ptr;
156 return OS;
157 }
158
159
operator <<(OStream & OS,std::ostream & (* manip)(std::ostream &))160 OStream & operator << (OStream & OS, std::ostream & (*manip)(std::ostream &))
161 {
162 OS.getStream() << manip;
163 return OS;
164 }
165
166
operator <<(OStream & OS,std::ios_base & (* manip)(std::ios_base &))167 OStream & operator << (OStream & OS, std::ios_base & (*manip)(std::ios_base &))
168 {
169 OS.getStream() << manip;
170 return OS;
171 }
172
173 #if defined(__GNUC__) && !defined(_LIBCPP_VERSION)
174
operator <<(OStream & OS,std::_Setw manip)175 OStream & operator << (OStream & OS, std::_Setw manip)
176 {
177 OS.getStream() << manip;
178 return OS;
179 }
180
181
operator <<(OStream & OS,std::_Setprecision manip)182 OStream & operator << (OStream & OS, std::_Setprecision manip)
183 {
184 OS.getStream() << manip;
185 return OS;
186 }
187
188
operator <<(OStream & OS,std::_Setbase manip)189 OStream & operator << (OStream & OS, std::_Setbase manip)
190 {
191 OS.getStream() << manip;
192 return OS;
193 }
194
195
196
operator <<(OStream & OS,std::_Resetiosflags manip)197 OStream & operator << (OStream & OS, std::_Resetiosflags manip)
198 {
199 OS.getStream() << manip;
200 return OS;
201 }
202
203
operator <<(OStream & OS,std::_Setiosflags manip)204 OStream & operator << (OStream & OS, std::_Setiosflags manip)
205 {
206 OS.getStream() << manip;
207 return OS;
208 }
209
210
operator <<(OStream & OS,std::_Setfill<char> manip)211 OStream & operator << (OStream & OS, std::_Setfill<char> manip)
212 {
213 OS.getStream() << manip;
214 return OS;
215 }
216
217 #endif
218
219 END_NAMESPACE_OPENTURNS
220
221