forked from mrkite/TerraFirma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworldheader.h
77 lines (66 loc) · 1.52 KB
/
worldheader.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
/** @Copyright 2015 seancode */
#ifndef WORLDHEADER_H_
#define WORLDHEADER_H_
#include <QString>
#include <QHash>
#include <QList>
#include <QJsonObject>
#include <QSharedPointer>
#include "./handle.h"
class WorldHeader {
public:
class Header {
public:
Header();
virtual ~Header();
int toInt() const;
double toDouble() const;
int length() const;
QSharedPointer<Header> at(int i) const;
void setData(quint64 v);
void setData(QString s);
void append(quint64 v);
void append(QString s);
private:
quint64 dint;
double ddbl;
QString dstr;
QList<QSharedPointer<Header>> arr;
};
WorldHeader();
virtual ~WorldHeader();
void init();
void load(QSharedPointer<Handle> reader, int version);
QSharedPointer<Header> operator[](QString const &key) const;
bool is(QString const &key) const;
int treeStyle(int x) const;
class InitException {
public:
explicit InitException(QString const reason) : reason(reason) {}
QString reason;
};
private:
QHash<QString, QSharedPointer<Header>> data;
struct Field {
enum Type {
BOOLEAN,
BYTE,
INT16,
INT32,
INT64,
FLOAT32,
FLOAT64,
STRING,
ARRAY_BYTE,
ARRAY_INT32,
ARRAY_STRING
};
explicit Field(QJsonObject const &data);
QString name;
Type type;
int length, minVersion;
QString dynamicLength;
};
QList<Field> fields;
};
#endif // WORLDHEADER_H_