source: trunk/gsdl/src/mgpp/lib/bitio_m_mems.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_mems.h -- Macros for bitio to memory (random access)
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_mems.h 855 2000-01-14 02:17:52Z sjboddie $
21 *
22 **************************************************************************
23 *
24 * This file contains macros for doing bitwise input and output on an array
25 * of chars. These routines are slower than the ones in "mem" files. but
26 * with these routines you can mix reads and writes, or multiple writes, on
27 * the array of chars at the same time and guarantee them to work, also you
28 * can seek to a point and do a write. The decode and encode macros cannot
29 * detect when the end off the character is reached and just continue
30 * processing.
31 *
32 **************************************************************************/
33
34#ifndef H_BITIO_M_MEMS
35#define H_BITIO_M_MEMS
36
37#include "bitio_m_abstract.h"
38
39
40class mems_bitio_buffer : public bitio_buffer {
41protected:
42 unsigned char *base;
43 unsigned long pos;
44
45public:
46 mems_bitio_buffer();
47 mems_bitio_buffer(unsigned char *readbuffer, long _pos);
48 void seek(unsigned long topos);
49 void error();
50 long add00(long b);
51 long addff(long b);
52 int bit();
53 // int bitOffset();
54 void done();
55
56 unsigned long position();
57
58 void encodeStart();
59 void encodeBit(int b);
60 void encodeDone();
61 void flush();
62};
63
64
65/*#define ENCODE_START(b,p) \
66 { \
67 mems_bitio_buffer buffer(b, p);
68
69#define ENCODE_CONTINUE(b) \
70 { \
71 mems_bitio_buffer buffer; \
72 buffer.unpause(b);
73
74#define ENCODE_PAUSE(b) buffer.pause(&b);}
75
76#define ENCODE_FLUSH buffer.flush();
77
78
79#define ENCODE_DONE buffer.encodeDone();}
80
81
82#define DECODE_START(b,p) \
83 { \
84 mems_bitio_buffer buffer(b, p);
85
86#define DECODE_CONTINUE(b) \
87 { \
88 mems_bitio_buffer buffer; \
89 buffer.unpause(b);
90
91#define DECODE_ADD_FF(b) b = buffer.addff(b);
92
93#define DECODE_ADD_00(b) b = buffer.add00(b);
94
95#define DECODE_BIT buffer.bit()
96
97#define DECODE_DONE buffer.done();}
98
99#define DECODE_PAUSE(b) buffer.pause(&b);}
100*/
101
102#endif
Note: See TracBrowser for help on using the repository browser.