]> Shamusworld >> Repos - guemap/blob - src/file.h
Initial commit of GUEmap v3.
[guemap] / src / file.h
1 //
2 // GUEmap
3 //
4 // (C) 1997-2007 Christopher J. Madsen
5 // (C) 2019 James Hammons
6 //
7 // GUEmap is licensed under either version 2 of the GPL, or (at your option)
8 // any later version.  See LICENSE file for details.
9 //
10 // File constants and interface of the FileReader class
11 //
12
13 #ifndef __FILE_H__
14 #define __FILE_H__
15
16 #include <string>
17 #include <stdint.h>
18 #include <stdio.h>
19
20 class MapDoc;
21
22 //
23 // Codes for GUEmap files:
24 //--------------------------------------------------------------------
25 // Normal codes:
26
27 const uint8_t
28         fcSizeMask    = 0007,
29         fcStartRecord = 0011,
30         fcEndRecord   = 0000,
31
32 //
33 // Record specific codes:
34 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
35 // Map Information:
36
37         fcMapNumRooms = 0022,
38         fcMapNumEdges = 0032,
39         fcMapName     = 0040,
40         fcMapNote     = 0050,
41         fcMapSize     = 0064,
42         fcMapNumPages = 0071,
43
44 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
45 // Page:
46
47         fcPagePosition = 0024,
48
49 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
50 // Room:
51
52         fcRoomName       = 0020,
53         fcRoomPosition = 0034,
54         fcRoomNote     = 0040,
55         fcRoomFlags    = 0051,
56
57 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
58 // Edge:
59
60         fcEdgeEnd1      = 0022,
61         fcEdgeEnd1L     = 0023,
62         fcEdgeEnd2      = 0032,
63         fcEdgeEnd2L     = 0033,
64         fcEdgeType      = 0042,
65
66 //
67 // Record codes:
68 //
69         recMap  = 1,
70         recRoom = 2,
71         recEdge = 3,
72         recPage = 4;
73
74
75 class FileReader
76 {
77         private:
78                 FILE * ar;
79                 int rcCache;
80
81         public:
82                 FileReader(FILE * archive);
83                 uint8_t byte();
84                 uint16_t word();
85                 uint32_t dword();
86                 void str(std::string &);
87                 bool boolean();
88                 void findRecord(uint8_t type);
89                 uint8_t peekNextRecord();
90                 void skipField(uint8_t fieldCode);
91 };
92
93 // Exported functions
94
95 bool ReadFile(MapDoc *, const char *);
96 bool WriteFile(MapDoc *, const char *);
97
98 #endif  // __FILE_H__
99