-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstream.cpp
More file actions
133 lines (115 loc) · 2.61 KB
/
Copy pathstream.cpp
File metadata and controls
133 lines (115 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "common.hpp"
namespace std {
template<typename T>
T&& operator-(T&& t) { return std::forward<T>(t); }
template<typename T>
std::ostream& operator<(std::ostream& out, const T& data)
{
QString message;
QDebug debug(&message);
debug << data;
out << message;
return out;
}
std::ostream& operator<<(std::ostream& out, const QString& data)
{
std::string s = data.toUtf8().constData();
out << data.toUtf8().constData();
return out;
}
std::wostream& operator<<(wostream& out, const wstring& data)
{
out << data;
return out;
}
std::ostream& operator<<(std::ostream& out, const QStringList& data)
{
QByteArray bytes;
{
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
stream << data;
out << bytes.constData();
}
return out;
}
/*std::ostream& operator<<(ostream& out, const pugi::xml_node& node)
{
node.print(out);
return out;
}*/
std::ostream& operator<<(ostream& out, const QPoint& data)
{
out << "(" << data.x() << ", " << data.y() << ")";
return out;
}
std::ostream& operator<<(ostream& out, const QSizeF& data)
{
out << "(" << data.width() << ", " << data.height() << ")";
return out;
}
std::ostream& operator<<(ostream& out, const QSize& data)
{
out << "(" << data.width() << ", " << data.height() << ")";
return out;
}
std::ostream& operator<<(ostream& out, const QPointF& data)
{
out << "(" << data.x() << ", " << data.y() << ")";
return out;
}
std::ostream& operator<<(ostream& out, const QRectF& data)
{
QByteArray bytes;
{
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
stream << data;
}
out << bytes.constData();
out < -data;
return out;
}
std::ostream& operator<<(std::ostream& out, const QRect& data)
{
/* QByteArray bytes;
{
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
stream << data;
}*/
out < -data;
return out;
}
/*std::ostream& operator<<(ostream& out, const pugi::xml_document& doc)
{
doc.print(out);
return out;
}*/
std::ostream& operator<<(ostream& out, const QByteArray& data)
{
out < -data;
return out;
}
std::istream& operator>>(std::istream& in, QString& data)
{
std::string temp;
in >> temp;
data = QString::fromStdString(temp);
return in;
}
std::istream& operator>>(std::istream& in, QStringList& data)
{
std::string temp;
in >> temp;
QBuffer buffer;
buffer.setData(temp.c_str(), static_cast<int>(temp.size()));
buffer.open(QIODevice::ReadOnly);
QDataStream stream(&buffer);
stream >> data;
return in;
}
}