source: trunk/gsdl/src/mgpp/lib/bitio_m_stdio.h@ 855

Last change on this file since 855 was 855, checked in by sjboddie, 24 years ago

Rodgers new C++ mg

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/**************************************************************************
2 *
3 * bitio_m_stdio.h -- Macros for bitio to a file
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: bitio_m_stdio.h 855 2000-01-14 02:17:52Z sjboddie $
21 *
22 **************************************************************************
23 *
24 * This file contains macros for doing bitwise input and output on a FILE*.
25 * With these routines you cannot mix reads and writes on the FILE,
26 * or multiple writes, at the same time and guarantee them to work, also you
27 * cannot seek to a point and do a write. The decode routine can detect when
28 * you run off the end of the file and will produce an approate error message.
29 *
30 *
31 **************************************************************************/
32
33#ifndef H_BITIO_M_STDIO
34#define H_BITIO_M_STDIO
35
36#include "bitio_m_abstract.h"
37
38
39class stdio_bitio_buffer : public bitio_buffer {
40protected:
41 FILE *file;
42 unsigned char buffer;
43 unsigned char btg;
44 unsigned long bytesWritten;
45
46public:
47 stdio_bitio_buffer (FILE *f = NULL);
48
49 void attachFile (FILE *f);
50
51 unsigned char GetBtg () { return btg; }
52 unsigned long GetBytesWritten () { return bytesWritten; }
53
54 void seek (unsigned long byte, unsigned char bit);
55 void seek (unsigned long topos);
56 void error();
57 long add00(long b);
58 long addff(long b);
59 int bit();
60 int bitOffset() { return btg; }
61 void done();
62
63 void encodeStart();
64 void encodeBit(int bit);
65 void encodeDone();
66};
67
68
69/*#define ENCODE_START(f) \
70 { \
71 stdio_bitio_buffer buffer(f); \
72 buffer.encodeStart();
73
74#define ENCODE_CONTINUE(b) \
75 { \
76 stdio_bitio_buffer buffer; \
77 buffer.unpause(b);
78
79#define ENCODE_PAUSE(b) buffer.pause(&b);}
80
81#define ENCODE_DONE buffer.encodeDone();}
82
83#define DECODE_START(f) \
84 { \
85 stdio_bitio_buffer buffer(f);
86
87#define DECODE_CONTINUE(b) \
88 { \
89 stdio_bitio_buffer buffer; \
90 buffer.unpause(b);
91
92#define DECODE_ADD_FF(b) b = buffer.addff(b)
93
94#define DECODE_ADD_00(b) b = buffer.add00(b)
95
96#define DECODE_BIT buffer.bit()
97
98#define DECODE_DONE buffer.done();}
99
100#define DECODE_PAUSE(b) buffer.pause(&b);}
101*/
102
103#endif
Note: See TracBrowser for help on using the repository browser.