source: gsdl/trunk/trunk/mgpp/lib/bitio_m_mem.h@ 16583

Last change on this file since 16583 was 16583, checked in by davidb, 16 years ago

Undoing change commited in r16582

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/**************************************************************************
2 *
3 * bitio_m_mem.h -- Macros for bitio to memory
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 **************************************************************************
21 *
22 * This file contains macros for doing bitwise input and output on an array
23 * of chars. These routines are faster than the ones in "mems" files. But
24 * with these routines you cannot mix reads and writes on the array of chars,
25 * or multiple write, at the same time and guarantee them to work, also you
26 * cannot seek to a point and do a write. The decode routine can detect when
27 * you run off the end of the array and will produce an approate error
28 * message, and the encode routine will stop when it gets to the end of the
29 * character array.
30 *
31 **************************************************************************/
32
33#ifndef H_BITIO_M_MEM
34#define H_BITIO_M_MEM
35
36#include "bitio_m_abstract.h"
37
38
39class mem_bitio_buffer : public bitio_buffer {
40protected:
41 unsigned char *pos;
42 unsigned char *base;
43 int remaining;
44 unsigned char buffer;
45 unsigned char btg;
46
47public:
48 mem_bitio_buffer ();
49 mem_bitio_buffer (unsigned char *buffer, int size);
50 void seek (unsigned long topos);
51 void error ();
52 long add00 (long b);
53 long addff (long b);
54 int bit ();
55 void done ();
56
57 void encodeStart ();
58 void encodeBit (int bit);
59 void encodeDone () { flush(); }
60 int encodeVerify ();
61 int encodeLength ();
62 void flush ();
63};
64
65
66/*
67#define ENCODE_START(p,r) \
68 { \
69 mem_bitio_buffer buffer(p, r); \
70 buffer.encodeStart();
71
72#define ENCODE_CONTINUE(b) \
73 { \
74 mem_bitio_buffer buffer; \
75 buffer.unpause(b);
76
77#define ENCODE_PAUSE(b) buffer.pause(&b);}
78
79#define ENCODE_FLUSH buffer.flush()
80
81#define ENCODE_DONE buffer.flush();}
82
83
84#define DECODE_START(p,r) \
85 { \
86 mem_bitio_buffer buffer(p,r);
87
88#define DECODE_CONTINUE(b) \
89 { \
90 mem_bitio_buffer buffer; \
91 buffer.unpause(b);
92
93#define DECODE_ADD_FF(b) b = buffer.addff(b)
94
95#define DECODE_ADD_00(b) b = buffer.add00(b)
96
97#define DECODE_BIT buffer.bit()
98
99#define DECODE_DONE buffer.done();}
100
101#define DECODE_PAUSE(b) buffer.pause(&b);}
102*/
103
104#endif
Note: See TracBrowser for help on using the repository browser.