File: zed.h

package info (click to toggle)
plink 1.07%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,040 kB
  • sloc: cpp: 69,728; makefile: 123; sh: 12
file content (74 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __ZED_H__
#define __ZED_H__

#include <cstring>
#include <vector>
#include <fstream>


#ifdef WITH_ZLIB
#include "zfstream.h"
#endif

using namespace std;

// A lightweight wrapper around zfstream wrapper to zlib

const int MAX_LINE_LENGTH = 1000000;

class ZInput
{
  string filename;
  bool compressed;  
  char buf[MAX_LINE_LENGTH];

#ifdef WITH_ZLIB
  gzifstream zinf;
#else
  ifstream zinf;
#endif

  ifstream inf;

 public:
  ZInput(string, bool);
  ZInput();
  void open(string, bool);
  char readChar();
  string readLine();
  vector<string> tokenizeLine();
  void close();
  bool endOfFile();
  void unbuffered();
};

class ZOutput
{

#ifdef WITH_ZLIB
  gzofstream zoutf;
#else
  ofstream zoutf;
#endif

  ofstream outf;

  string filename;
  bool compressed;
  char buf[MAX_LINE_LENGTH];
 public:
  ZOutput(string, bool);
  ZOutput();
  void open(string,bool);
  void write(string);
  ZOutput & operator<< (const string & s) { write(s); return *this; }
  void writeLine(string);
  void close();
  void unbuffered();
};

void fileCompress();
void fileUncompress();


#endif