27 #ifndef CDPL_MATH_IO_HPP
28 #define CDPL_MATH_IO_HPP
61 template <
typename C,
typename T,
typename E>
64 typename std::basic_ostream<C, T>::sentry se(os);
65 std::ios_base::iostate state(std::ios_base::goodbit);
69 std::basic_ostringstream<C, T, std::allocator<C> > oss;
71 oss.flags(os.flags());
72 oss.imbue(os.getloc());
73 oss.precision(os.precision());
75 typedef typename E::SizeType SizeType;
77 SizeType size = e().getSize();
79 oss <<
'[' << size <<
"](";
84 for (SizeType i = 1; i < size; i++)
90 state |= std::ios_base::failbit;
92 os << oss.str().c_str();
95 os.setstate(std::ios_base::failbit);
100 if (state != std::ios_base::goodbit)
122 template <
typename C,
typename T,
typename E>
125 typename std::basic_ostream<C, T>::sentry se(os);
126 std::ios_base::iostate state(std::ios_base::goodbit);
130 std::basic_ostringstream<C, T, std::allocator<C> > oss;
132 oss.flags(os.flags());
133 oss.imbue(os.getloc());
134 oss.precision(os.precision());
136 typedef typename E::SizeType SizeType;
138 SizeType size1 = e().getSize1();
139 SizeType size2 = e().getSize2();
141 oss <<
'[' << size1 <<
',' << size2 <<
"](";
143 if (size1 > 0 && size2 > 0) {
144 for (SizeType i = 0; i < size1; i++) {
150 for (SizeType j = 0; j < size2; j++) {
164 state |= std::ios_base::failbit;
166 os << oss.str().c_str();
169 os.setstate(std::ios_base::failbit);
174 if (state != std::ios_base::goodbit)
192 template <
typename C,
typename T,
typename E>
195 typename std::basic_ostream<C, T>::sentry se(os);
196 std::ios_base::iostate state(std::ios_base::goodbit);
200 std::basic_ostringstream<C, T, std::allocator<C> > oss;
202 oss.flags(os.flags());
203 oss.imbue(os.getloc());
204 oss.precision(os.precision());
206 oss <<
'(' << e().getC1() <<
',' << e().getC2() <<
',' << e().getC3() <<
',' << e().getC4() <<
')';
209 state |= std::ios_base::failbit;
211 os << oss.str().c_str();
214 os.setstate(std::ios_base::failbit);
219 if (state != std::ios_base::goodbit)
242 template <
typename C,
typename T,
typename E>
245 typename std::basic_ostream<C, T>::sentry se(os);
246 std::ios_base::iostate state(std::ios_base::goodbit);
250 std::basic_ostringstream<C, T, std::allocator<C> > oss;
252 oss.flags(os.flags());
253 oss.imbue(os.getloc());
254 oss.precision(os.precision());
256 typedef typename E::SizeType SizeType;
258 SizeType size1 = e().getSize1();
259 SizeType size2 = e().getSize2();
260 SizeType size3 = e().getSize3();
262 oss <<
'[' << size1 <<
',' << size2 <<
',' << size3 <<
"](";
264 if (size1 > 0 && size2 > 0 && size3 > 0) {
265 for (SizeType i = 0; i < size1; i++) {
271 for (SizeType j = 0; j < size2; j++) {
277 for (SizeType k = 0; k < size3; k++) {
294 state |= std::ios_base::failbit;
296 os << oss.str().c_str();
299 os.setstate(std::ios_base::failbit);
304 if (state != std::ios_base::goodbit)
CRTP base class for all grid expression types.
Definition: Expression.hpp:180
CRTP base class for all matrix expression types.
Definition: Expression.hpp:104
CRTP base class for all quaternion expression types.
Definition: Expression.hpp:142
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
std::basic_ostream< C, T > & operator<<(std::basic_ostream< C, T > &os, const VectorExpression< E > &e)
Writes a textual representation of the vector expression e to os.
Definition: IO.hpp:62
The namespace of the Chemical Data Processing Library.