-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwwmfile.h
More file actions
83 lines (79 loc) · 1.45 KB
/
wwmfile.h
File metadata and controls
83 lines (79 loc) · 1.45 KB
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
#ifndef wwmfile_h
#define wwmfile_h
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned short ushort;
#define FORMAT_HEADER "WWMH"
#define FORMAT_BODY "WWMB"
#define FORMAT_AUTOMATA "WWMA"
#define FORMAT_NOTES "WWMN"
#define FORMAT_ENDFILE "WWME"
typedef class WWMFormat
{
public:
//
// Versioning format and application
//
struct{
int v,s,r; //version,subversion,revision
void Reset(void){
v=s=r=0;
}
void set(int _v, int _s, int _r){
v=_v;
s=_s;
r=_r;
}
} format,app;
//
// File data
// this contains stream pointer and various positions in file
//
struct{
FILE *stream;
int position,suspense,resume;
void reset(void){
stream=NULL;
position=suspense=resume=0;
}
void resetpos(void){
position=suspense=resume=0;
}
} file;
//
// Matrix info
// this contains size of the matrixes and their pointers
//
struct{
int m,n;
uchar *cells,*notes;
void resetmatrix(void){
m=n=3;
cells=notes=NULL;
}
void setmatrix(int _m,int _n,uchar *_cells,uchar *_notes){
m=_m;
n=_n;
cells=_cells;
notes=_notes;
}
} matrix;
private:
//
// Basic writing/reading data functions
//
void ps(const char *str);
void pn(int c, uint v);
void pc(char c);
const char* gs(int c);
int gn(int c);
char gc(void);
public:
//Constructor and destructor
WWMFormat(void);
//~WWMFormat(void);
//Read and write methods
bool Read(const char *fname);
bool Write(const char *fname);
} WWMFormat;
#endif