libutil++  1.9.3
 All Classes Functions Variables
GZCSVFileReader.h
1 /*
2 ** libutil++
3 ** $Id: GZCSVFileReader.h 1653 2016-02-28 19:54:59Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 #ifndef __sella__file__GZCSVFileReader_H__
10 #define __sella__file__GZCSVFileReader_H__
11 
12 #include "../util/CommonMacro.h"
13 #include "IOException.h"
14 
15 #include <stdint.h>
16 #include <zlib.h>
17 
18 #include <string>
19 #include <vector>
20 #include <memory>
21 
22 namespace sella {
23  namespace file {
24  class GZCSVFileReader;
25  }
26 }
27 
32  public:
33  // Public Type Definitions
34  STANDARD_TYPEDEF(sella::file::GZCSVFileReader);
35 
36  static const char DefaultDelimiter = 0x1e;
37  static const char DefaultSeperator = 0x1d;
38 
39  // Constructors
40  GZCSVFileReader(const std::string & file, char delimiter = DefaultDelimiter, char seperator = DefaultSeperator) THROWS(IOException);
41  virtual ~GZCSVFileReader() NO_EXCEPTIONS;
42 
43  // Public Member Functions
44  void read(std::vector<std::vector<std::string>> & data) THROWS(IOException);
45  void close(bool unlink = false) NO_EXCEPTIONS;
46 
47  protected:
48  // Protected Member Functions
49  bool read(std::vector<std::string> & data, std::string prepend) THROWS(IOException);
50  bool read(std::vector<std::string> & data) THROWS(IOException);
51 
52  private:
53  std::string filename;
54 
55  char delimiter;
56  char seperator;
57 
58  int descriptor;
59  z_stream stream;
60 
61  uint8_t buffer[2][65536];
62 };
63 
64 #endif
65 
66 /*
67 ** vim: noet ts=3 sw=3
68 */
static const char DefaultDelimiter
The default delimiter used between the fields of a record; the ASCII record seperator character...
A GZIP compressed CSV reader.
GZCSVFileReader(const std::string &file, char delimiter=DefaultDelimiter, char seperator=DefaultSeperator) THROWS(IOException)
void close(bool unlink=false) NO_EXCEPTIONS
void read(std::vector< std::vector< std::string >> &data) THROWS(IOException)
static const char DefaultSeperator
The default seperator used between the records of a file; the ASCII group seperator character...