ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/cdbfasta/gcdbz.h
Revision: 8
Committed: Mon Mar 22 22:11:25 2010 UTC (12 years, 4 months ago) by gpertea
File size: 1901 byte(s)
Log Message:
added cdbfasta source files

Line File contents
1 #ifndef _GCDBZ_H
2 #define _GCDBZ_H
3
4 #define GCDBZ_SBUF_LEN 8192
5 #define GCDBZ_LBUF_LEN 8192*2
6 #include "gcdb.h"
7 #include <zlib.h>
8 #include <stdio.h>
9
10 class GCdbz {
11 private:
12 char lbuf[GCDBZ_LBUF_LEN]; //larger buffer
13 char sbuf[GCDBZ_SBUF_LEN]; //smaller buffer
14 char* defline; //defline copy storage -- compression only
15 int defline_cap; //currently allocated length of defline
16 int defline_len; //currently used length of defline
17 z_stream zstream; // de/compression stream
18 FILE* zf; //compressed file, could be input or output
19 bool uncompress; // compression or decompression
20 long zpos; //current position in zf
21 int zrecsize; // the size of the compressed record
22 bool in_defline;
23 bool zclosed; // if compress_end() was issued or not!
24 void begin_defline() { defline_len=0;
25 in_defline=true; } // initialize the defline storage
26 void extend_defline(int ch); //append character ch to defline
27 //reallocating as necessary
28 void end_defline() { defline[defline_len]='\0';
29 in_defline=false; } // add \0
30 public:
31 GCdbz(FILE* af, bool dc = false, int zrsize=0);
32 ~GCdbz();
33 void compress_start();
34 void compress_end();
35 char* compress(GReadBuf *readbuf, char* delim);
36 // returns a pointer to the defline copy or
37 // NULL if nothing was compressed;
38 // (getZRecSize should be called to find out the
39 // actual number of compressed bytes written to zf)
40 int getZRecSize() { return zrecsize; }
41 //to be called AFTER compress()
42 long getZRecPos() { return zpos; }
43 //to be called BEFORE compress()
44 FILE* getZFile() { return zf; }
45 void decomp_start(int zrsize);
46 void decomp_end();
47 int decompress(FILE* outf, int csize=0, int zfofs=-1);
48 // uncompress csize bytes from zf, from optional offset zfofs,
49 // and send the uncompressed stream to outf
50 };
51
52
53
54
55
56 #endif