-
Notifications
You must be signed in to change notification settings - Fork 0
/
ugf.h
119 lines (94 loc) · 3.32 KB
/
ugf.h
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
/*
mugo, sgf editor.
Copyright (C) 2009-2010 nsase.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ugf_h__
#define __ugf_h__
#include "godata.h"
namespace go{
class ugf : public fileBase{
public:
class marker{
public:
marker(int x_, int y_, const QString& str_) : x(x_), y(y_), str(str_){}
int x;
int y;
QString str;
};
typedef QList<marker> markerList;
class stone{
public:
stone(int x_, int y_, int color_, int originalColor_ = 0) : x(x_), y(y_), color(color_), originalColor(originalColor_){}
int x;
int y;
int color;
int originalColor;
};
typedef QList<stone> stoneList;
class data{
public:
typedef QList<data> dataList;
typedef QList<dataList> branchList;
data() : x(-1), y(-1), index(0), color(go::empty){}
int x;
int y;
int index;
int color;
QString comment;
markerList markers;
stoneList stones;
branchList branches;
bool operator ==(const data& d) const{
return x == d.x && y == d.y && color == d.color;
}
};
typedef data::dataList dataList;
typedef data::branchList branchList;
virtual bool readStream(QString::iterator& first, QString::iterator last);
virtual bool saveStream(QTextStream& stream);
virtual QTextCodec* getCodec(const QByteArray&) const;
virtual bool get(go::data& data) const;
virtual bool set(const go::data& data);
private:
bool readHeader(QString::iterator& first, QString::iterator& last);
bool readRemote(QString::iterator& first, QString::iterator& last);
bool readFiles(QString::iterator& first, QString::iterator& last);
bool readData(QString::iterator& first, QString::iterator& last);
bool readFigure(QString::iterator& first, QString::iterator& last);
bool readComment(QString::iterator& first, QString::iterator& last);
bool readFig(QString::iterator& first, QString::iterator& last, int index);
bool readText(QString::iterator& first, QString::iterator& last, int index);
void replaceStone(stoneList& stones, const data& d);
bool get(dataList::const_iterator first, dataList::const_iterator last, go::nodePtr parent) const;
bool getData(const QStringList& list, data& d);
data* getNthData(int index);
dataList dataList_;
QString title;
QString place;
QString date;
QString rule;
int size;
int handicap;
double komi;
QString winner;
QString writer;
QString copyright;
QString comment;
QString whitePlayer;
QString whiteRank;
QString blackPlayer;
QString blackRank;
QString coordinateType;
};
}
#endif