2 * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
4 * ShapeFusion is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * ShapeFusion is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with ShapeFusion; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // GenericEndianBuffer
23 #ifndef GENERICENDIANBUFFER_H
24 #define GENERICENDIANBUFFER_H
26 class GenericEndianBuffer {
34 // self-allocate data buffer
35 GenericEndianBuffer(unsigned int _size);
36 // use a pre-allocated buffer
37 GenericEndianBuffer(unsigned char *_data, unsigned int _size);
38 ~GenericEndianBuffer(void);
39 // set access position
40 void Position(unsigned int pos);
41 // return access position
42 unsigned int Position(void) const;
43 // read values, advance position accordingly
45 unsigned char ReadUChar(void);
46 void ReadBlock(unsigned long _size, unsigned char *dest);
47 // write values, advance position accordingly
48 void WriteChar(char v);
49 void WriteUChar(unsigned char v);
50 void Write4CharCode(char c1, char c2, char c3, char c4);
51 void WriteBlock(unsigned long _size, const void *src);
52 void WriteZeroes(unsigned int n);
54 unsigned char *Data(void) const;
55 unsigned int Size(void) const;
57 unsigned long CalculateCRC() const;