tuchulcha  0.10.1
Graphical Workflow Configuration Editor
Qtiostream.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2009 Jens-Malte Gottfried
2 
3  This file is part of Tuchulcha.
4 
5  Tuchulcha is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Tuchulcha is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
17 */
24 #include "Qtiostream.h"
25 #include <QDebug>
26 
27 std::ostream& operator<<(std::ostream& os, const QPointF& point) {
28  os << point.x() << "," << point.y();
29  return os;
30 }
31 
32 std::ostream& operator<<(std::ostream& os, const QRectF& rect) {
33  os << rect.topLeft() << "," << rect.bottomRight();
34  return os;
35 }
36 
37 std::istream& operator>>(std::istream& is, QPointF& point) {
38  double x, y;
39  char ch;
40  is >> x; // get x value
41  is.get(ch);
42  Q_ASSERT(ch == ','); // check separator
43  is >> y; // get y value
44 
45  point = QPointF(x, y);
46  return is;
47 }
48 
49 std::istream& operator>>(std::istream& is, QRectF& rect) {
50  QPointF tl, br;
51  char ch;
52  is >> tl; // get top left point
53  is.get(ch);
54  Q_ASSERT(ch == ','); // check separator
55  is >> br; // get bottom right point
56 
57  rect = QRectF(tl, br);
58  return is;
59 }
Useful Qt I/O functions.
std::ostream & operator<<(std::ostream &os, const QPointF &point)
Output of QPointF to std::ostream.
Definition: Qtiostream.cpp:27
std::istream & operator>>(std::istream &is, QPointF &point)
Read a QPointF from a std::istream.
Definition: Qtiostream.cpp:37