-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamUtilities.h
More file actions
43 lines (35 loc) · 934 Bytes
/
StreamUtilities.h
File metadata and controls
43 lines (35 loc) · 934 Bytes
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
#ifndef STREAMUTILITIES_H
#define STREAMUTILITIES_H
#include <QSize>
#include <QTextStream>
#include <QVector3D>
#include <QDebug>
#include <QDebugStateSaver>
template<typename T>
class Eatable
{
public:
Eatable(T toEat) : m_toEat(toEat) { }
T toEat() const { return m_toEat; }
private:
T m_toEat;
};
template<typename T> Eatable<T> eat(T toEat)
{
return Eatable<T>(toEat);
}
template<typename T>
QTextStream &operator>>(QTextStream &s, Eatable<T> e)
{
T value;
s >> value;
if(value != e.toEat()) s.setStatus(QTextStream::ReadCorruptData);
return s;
}
QTextStream& operator>>(QTextStream& s, QVector3D &v);
QDebug operator<<(QDebug s, const QVector3D& v);
QTextStream& operator<<(QTextStream& s, const QVector3D& size);
QTextStream& operator>>(QTextStream& s, QSize& size);
QDebug operator<<(QDebug s, const QSize& size);
QTextStream& operator<<(QTextStream& s, const QSize& size);
#endif // STREAMUTILITIES_H