-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
glassfileio.h
93 lines (67 loc) · 3.61 KB
/
glassfileio.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
#ifndef GLASSFILEIO_H
#define GLASSFILEIO_H
#include <map>
#include <vector>
#include <jsoncpp/include/json/json.h>
#include "shape.h"
#include "canetemplate.h"
#include "pickuptemplate.h"
#include "piecetemplate.h"
#include "subpickuptemplate.h"
class QString;
class QBuffer;
class GlassColor;
class Cane;
class Pickup;
class Piece;
using std::map;
using std::vector;
using std::string;
// returns whether the read or write succeeded (true) or ran into issues (false)
bool writeColorFile(QString filename, QString collectionName, vector<GlassColor*>& colors);
bool readColorFile(QString filename, QString& collectionName, vector<GlassColor*>& colors);
bool writeGlassFile(QString filename, vector<GlassColor*>& colors, vector<Cane*>& canes, vector<Piece*>& pieces);
bool writeGlassFile(QBuffer& buffer, vector<GlassColor*>& colors, vector<Cane*>& canes, vector<Piece*>& pieces);
bool readGlassFile(QString filename, vector<GlassColor*>& colors, vector<Cane*>& canes, vector<Piece*>& pieces);
namespace GlassFileIOInternal
{
void writeJsonToFile(QString& filename, Json::Value& root);
void writeJsonToBuffer(QBuffer& buffer, Json::Value& root);
void writeDocumentation(string& filename, Json::Value& root);
GlassColor* safeColorMap(map<unsigned int, GlassColor*>& colorMap, unsigned int index);
Cane* safeCaneMap(map<unsigned int, Cane*>& caneMap, unsigned int index);
void writeBuildInformation(Json::Value& root);
void readBuildInformation(Json::Value& root, unsigned int& revision, string& date);
string orientationToString(enum PickupCaneOrientation ori);
enum PickupCaneOrientation stringToOrientation(string s);
string geometricShapeToString(enum GeometricShape shape);
enum GeometricShape stringToGeometricShape(string id);
string idAndNameToString(unsigned int id, string name);
unsigned int stringToId(string s);
string pullTemplateToString(enum CaneTemplate::Type type);
enum CaneTemplate::Type stringToCaneTemplate(string s);
string pickupTemplateToString(enum PickupTemplate::Type type);
enum PickupTemplate::Type stringToPickupTemplate(string s);
string pieceTemplateToString(enum PieceTemplate::Type type);
enum PieceTemplate::Type stringToPieceTemplate(string s);
void writeColor(Json::Value& root, GlassColor* color, unsigned int colorIndex);
GlassColor* readColor(Json::Value& root, string rootname);
void writeColors(Json::Value& root, vector<GlassColor*>& colors);
void readColors(Json::Value& root, map<unsigned int, GlassColor*>& colorMap, vector<GlassColor*>& readColors);
void writeCane(Json::Value& root, Cane* cane, unsigned int caneIndex, map<const Cane*, unsigned int>& caneMap,
map<const GlassColor*, unsigned int>& colorMap);
Cane* readCane(string canename, Json::Value& root, map<unsigned int, GlassColor*>& colorMap);
void writeCanes(Json::Value& root, vector<Cane*>& canes, vector<GlassColor*>& colors);
void readCaneSubcanes(Json::Value& caneRoot, Cane* cane, map<unsigned int, Cane*>& caneMap);
void readCanes(Json::Value& root, map<unsigned int, Cane*>& caneMap, map<unsigned int, GlassColor*>& colorMap,
vector<Cane*>& readPlans);
void writePiece(Json::Value& root, Piece* piece, unsigned int pieceIndex, map<Cane*, unsigned int>& caneMap,
map<GlassColor*, unsigned int>& colorMap);
Piece* readPiece(string piecename, Json::Value& root, map<unsigned int, Cane*>& caneMap,
map<unsigned int, GlassColor*>& colorMap);
void writePieces(Json::Value& root, vector<Piece*>& pieces, vector<Cane*>& canes,
vector<GlassColor*>& colors);
void readPieces(Json::Value& root, map<unsigned int, Cane*>& caneMap, map<unsigned int, GlassColor*>& colorMap,
vector<Piece*>& readPieces);
}
#endif