~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes

« back to all changes in this revision

Viewing changes to src/myfile.h

  • Committer: sirver
  • Date: 2002-02-05 20:54:08 UTC
  • Revision ID: git-v1:df384fd3a5e53be1f37803d1c0381fa993844bf5
Initial revision


git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@2 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001 by Holger Rapp 
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef __S__MYFILE_H
 
21
#define __S__MYFILE_H
 
22
 
 
23
#include <stdio.h>
 
24
 
 
25
/** class File
 
26
 *
 
27
 * this works for binary files
 
28
 * 
 
29
 */
 
30
class File {
 
31
                  public:
 
32
                                         enum State {
 
33
                                                                NOTHING, 
 
34
                                                                OPEN,
 
35
                                                                WRITES,
 
36
                                                                READS,
 
37
                                                                CLOSE,
 
38
                                                                END_OF_FILE
 
39
                                         };
 
40
 
 
41
                                         enum For {
 
42
                                                                READ,
 
43
                                                                WRITE
 
44
                                         };
 
45
 
 
46
                                         // Constructor, Deconstructor
 
47
                                         File(void);
 
48
                                         virtual ~File(void);
 
49
 
 
50
                                         // File specific functions
 
51
                                         virtual void open(const char*,  For)=0;
 
52
                                         virtual void close()=0;
 
53
                                         virtual int read(char*, int)=0;
 
54
                                         virtual int write(char*, int)=0;
 
55
                                         
 
56
                                         // Common functions
 
57
                                         State get_state();
 
58
 
 
59
                  protected:
 
60
                                         void set_state(State);
 
61
 
 
62
                  private:
 
63
                                         // This functions can't be called with files
 
64
                                         File& operator=(const File&);
 
65
                                         File(const File&);
 
66
 
 
67
                                         State st;
 
68
}; 
 
69
 
 
70
/** A Ascii file is a file containing nothing but ascii letters
 
71
 *
 
72
 * This class makes sure that ascii files are treated the same under 
 
73
 * Windows and Unix
 
74
 *
 
75
 * A Ascii File can also be read linewise
 
76
 */
 
77
class Ascii_file : public File {
 
78
                  public:
 
79
                                         Ascii_file();
 
80
                                         ~Ascii_file();
 
81
                                         
 
82
                                         void read_line(char*, unsigned int);
 
83
                                         
 
84
                                         void open(const char*, For);
 
85
                                         void close(void);
 
86
                                         int read(char*, int);
 
87
                                         int write(char*, int);
 
88
        
 
89
                  private:
 
90
                                         FILE* f;
 
91
};
 
92
 
 
93
/** class Binary_file
 
94
 *
 
95
 * Binary files are just normal files. nothing special about them
 
96
 */
 
97
class Binary_file : public File {
 
98
                  public:
 
99
                                         Binary_file();
 
100
                                         ~Binary_file();
 
101
                                         
 
102
                                         void open(const char*, For);
 
103
                                         void close(void);
 
104
                                         int read(char*, int);
 
105
                                         int write(char*, int);
 
106
 
 
107
                  private:
 
108
                                         FILE* f;
 
109
};
 
110
 
 
111
 
 
112
#endif /* __S__MYFILE_H */