~ubuntu-branches/ubuntu/vivid/openbabel/vivid-proposed

« back to all changes in this revision

Viewing changes to src/binary_io.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2002-02-01 01:19:44 UTC
  • Revision ID: james.westby@ubuntu.com-20020201011944-4a9guzcsnpezzawx
Tags: upstream-1.99
ImportĀ upstreamĀ versionĀ 1.99

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef OB_IO_BINARY_INCLUDED
 
2
#define OB_IO_BINARY_INCLUDED
 
3
 
 
4
#ifdef WIN32
 
5
#pragma warning (disable : 4786)
 
6
#endif
 
7
 
 
8
#include <vector>
 
9
#include <string>
 
10
 
 
11
#ifndef __sgi
 
12
#include <iostream>
 
13
#else
 
14
#include <iostream.h>
 
15
#endif
 
16
 
 
17
using namespace std;
 
18
 
 
19
namespace OpenBabel {
 
20
 
 
21
/* generic binary readers for basic data types */
 
22
unsigned int OB_io_read_binary(char *ccc, char *x, unsigned int size, unsigned int count);
 
23
unsigned int OB_io_read_binary(istream &, char *x, unsigned int size, unsigned int count);
 
24
 
 
25
/* generic binary writers for basic data types */
 
26
unsigned int OB_io_write_binary(char *ccc, const char *x, unsigned int size, unsigned int count);
 
27
unsigned int OB_io_write_binary(ostream &, const char *x, unsigned int size, unsigned int count);
 
28
 
 
29
/* binary readers for STL strings */
 
30
unsigned int OB_io_read_binary(char* ccc, string& str);
 
31
unsigned int OB_io_read_binary(istream& ifs, string& str);
 
32
 
 
33
/* binary writers for STL strings */
 
34
unsigned int OB_io_write_binary(char* ccc, const string& str);
 
35
unsigned int OB_io_write_binary(ostream& ofs, const string& str);
 
36
 
 
37
/* binary writers for compressed data */
 
38
unsigned int OB_io_write_binary_compressed(char*ccc, unsigned int *x, unsigned int bits, unsigned int Nvalues); //Writes 1+(bits*Nvalues)/8 bytes
 
39
unsigned int OB_io_write_binary_compressed(ostream&, unsigned int *x, unsigned int bits, unsigned int Nvalues); //Writes 1+(bits*Nvalues)/8 bytes
 
40
unsigned int OB_io_write_binary_compressed(char*ccc, float *x, unsigned int bits, unsigned int Nvalues); //Writes 9+(bits*Nvalues)/8 bytes
 
41
unsigned int OB_io_write_binary_compressed(ostream&, float *x, unsigned int bits, unsigned int Nvalues); //Writes 9+(bits*Nvalues)/8 bytes
 
42
 
 
43
/* binary readers for compressed data */
 
44
unsigned int OB_io_read_binary_compressed(char*ccc, unsigned int *x, unsigned int bits, unsigned int Nvalues); //Reads 1+(bits*Nvalues)/8 bytes
 
45
unsigned int OB_io_read_binary_compressed(istream&, unsigned int *x, unsigned int bits, unsigned int Nvalues); //Reads 1+(bits*Nvalues)/8 bytes
 
46
unsigned int OB_io_read_binary_compressed(char*ccc, float *x, unsigned int bits, unsigned int Nvalues); //Reads 9+(bits*Nvalues)/8 bytes
 
47
unsigned int OB_io_read_binary_compressed(istream&, float *x, unsigned int bits, unsigned int Nvalues); //Reads 9+(bits*Nvalues)/8 bytes
 
48
 
 
49
/* utilities for reading/writing compressed data */
 
50
unsigned int OB_io_util_calc_NumBits(unsigned int *x, unsigned int N);
 
51
unsigned int OB_io_util_calc_NumBits(float *x, unsigned int N, float res);
 
52
 
 
53
/*!
 
54
**\brief An abstract base class with binary read and write function.
 
55
**Members of this class understand how to read and write themselves
 
56
**to and from platform independent binary streams and arrays using
 
57
**the functions of this class.
 
58
*/
 
59
class OBBinaryIO {
 
60
    public:
 
61
        virtual ~OBBinaryIO() {}
 
62
        virtual unsigned int WriteBinary(char *ccc) const = 0;
 
63
        virtual unsigned int ReadBinary(char *ccc) = 0;
 
64
        virtual unsigned int WriteBinary(ostream& ostr) const = 0;
 
65
        virtual unsigned int ReadBinary(istream& istr) = 0;
 
66
        virtual unsigned int BinarySize() const = 0;
 
67
  };
 
68
 
 
69
/*!
 
70
**\brief Writes a OBBinaryIO object to a file stream, preappending
 
71
**the record with the size of the OBBinaryIO objects binary record.
 
72
*/
 
73
ostream& operator<<(ostream& ostr, const OBBinaryIO& obj);
 
74
 
 
75
/*!
 
76
**\brief Reads in a OBBinaryIO object that has the size of the 
 
77
**binary record preappended to the record.
 
78
*/
 
79
istream& operator>>(istream& istr, OBBinaryIO& obj);
 
80
 
 
81
}//End namespace OpenBabel
 
82
#endif