source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mgpp/lib/bitio_m_mem.h@ 23508

Last change on this file since 23508 was 23508, checked in by sjm84, 13 years ago

Committing 64 bit changes into the branch

  • 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#include "mglong.h"
38
39
40class mem_bitio_buffer : public bitio_buffer {
41protected:
42 unsigned char *pos;
43 unsigned char *base;
44 int remaining;
45 unsigned char buffer;
46 unsigned char btg;
47
48public:
49 mem_bitio_buffer ();
50 mem_bitio_buffer (unsigned char *buffer, int size);
51 void seek (mg_u_long topos);
52 void error ();
53 mg_s_long add00 (mg_s_long b);
54 mg_s_long addff (mg_s_long b);
55 int bit ();
56 void done ();
57
58 void encodeStart ();
59 void encodeBit (int bit);
60 void encodeDone () { flush(); }
61 int encodeVerify ();
62 int encodeLength ();
63 void flush ();
64};
65
66
67/*
68#define ENCODE_START(p,r) \
69 { \
70 mem_bitio_buffer buffer(p, r); \
71 buffer.encodeStart();
72
73#define ENCODE_CONTINUE(b) \
74 { \
75 mem_bitio_buffer buffer; \
76 buffer.unpause(b);
77
78#define ENCODE_PAUSE(b) buffer.pause(&b);}
79
80#define ENCODE_FLUSH buffer.flush()
81
82#define ENCODE_DONE buffer.flush();}
83
84
85#define DECODE_START(p,r) \
86 { \
87 mem_bitio_buffer buffer(p,r);
88
89#define DECODE_CONTINUE(b) \
90 { \
91 mem_bitio_buffer buffer; \
92 buffer.unpause(b);
93
94#define DECODE_ADD_FF(b) b = buffer.addff(b)
95
96#define DECODE_ADD_00(b) b = buffer.add00(b)
97
98#define DECODE_BIT buffer.bit()
99
100#define DECODE_DONE buffer.done();}
101
102#define DECODE_PAUSE(b) buffer.pause(&b);}
103*/
104
105#endif
Note: See TracBrowser for help on using the repository browser.