]> 4ch.mooo.com Git - 16.git/blob - 16/adplug/libbinio-1.4/src/binfile.h
Please enter the commit message for your changes. Lines starting
[16.git] / 16 / adplug / libbinio-1.4 / src / binfile.h
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  * 
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * Lesser General Public License for more details.
11  * 
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  *
16  * binfile.h - Binary file I/O
17  * Copyright (C) 2002, 2003 Simon Peter <dn.tlp@gmx.net>
18  */
19
20 #ifndef H_BINIO_BINFILE
21 #define H_BINIO_BINFILE
22
23 #include <stdio.h>
24
25 #include "binio.h"
26
27 class binfbase: virtual public binio
28 {
29 public:
30   typedef enum {
31     Append      = 1 << 0,
32     NoCreate    = 1 << 1
33   } ModeFlags;
34
35   typedef int Mode;
36
37   binfbase();
38   virtual ~binfbase();
39
40   virtual void open(const char *filename, const Mode mode) = 0;
41 #if BINIO_ENABLE_STRING
42   virtual void open(const std::string &filename, const Mode mode) = 0;
43 #endif
44   void close();
45
46   virtual void seek(long pos, Offset offs = Set);
47   virtual long pos();
48
49 protected:
50   FILE *f;
51 };
52
53 class binifstream: public binistream, virtual public binfbase
54 {
55 public:
56   binifstream();
57   binifstream(const char *filename, const Mode mode = NoCreate);
58 #if BINIO_ENABLE_STRING
59   binifstream(const std::string &filename, const Mode mode = NoCreate);
60 #endif
61
62   virtual ~binifstream();
63
64   virtual void open(const char *filename, const Mode mode = NoCreate);
65 #if BINIO_ENABLE_STRING
66   virtual void open(const std::string &filename, const Mode mode = NoCreate);
67 #endif
68
69 protected:
70   virtual Byte getByte();
71 };
72
73 class binofstream: public binostream, virtual public binfbase
74 {
75 public:
76   binofstream();
77   binofstream(const char *filename, const Mode mode = 0);
78 #if BINIO_ENABLE_STRING
79   binofstream(const std::string &filename, const Mode mode = 0);
80 #endif
81
82   virtual ~binofstream();
83
84   virtual void open(const char *filename, const Mode mode = 0);
85 #if BINIO_ENABLE_STRING
86   virtual void open(const std::string &filename, const Mode mode = 0);
87 #endif
88
89 protected:
90   virtual void putByte(Byte b);
91 };
92
93 class binfstream: public binifstream, public binofstream
94 {
95 public:
96   binfstream();
97   binfstream(const char *filename, const Mode mode = 0);
98 #if BINIO_ENABLE_STRING
99   binfstream(const std::string &filename, const Mode mode = 0);
100 #endif
101
102   virtual ~binfstream();
103
104   virtual void open(const char *filename, const Mode mode = 0);
105 #if BINIO_ENABLE_STRING
106   virtual void open(const std::string &filename, const Mode mode = 0);
107 #endif
108 };
109
110 #endif