libutil++  1.9.3
 All Classes Functions Variables
GZCSVFileWriter.h
1 /*
2 ** libutil++
3 ** $Id: GZCSVFileWriter.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__GZCSVFileWriter_H__
10 #define __sella__file__GZCSVFileWriter_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 GZCSVFileWriter;
25  }
26 }
27 
32  public:
33  // Public Type Definitions
34  STANDARD_TYPEDEF(sella::file::GZCSVFileWriter);
35 
36  static const char DefaultDelimiter = 0x1e;
37  static const char DefaultSeperator = 0x1d;
38 
39  // Constructors
40  GZCSVFileWriter(const std::string & file, char delimiter = DefaultDelimiter, char seperator = DefaultSeperator) THROWS(IOException);
41  virtual ~GZCSVFileWriter() NO_EXCEPTIONS;
42 
43  // Public Member Functions
44  void write(const std::vector<std::string> & data) THROWS(IOException);
45  void close(const std::string & rename = std::string()) THROWS(IOException);
46 
47  protected:
48  // Protected Member Functions
49  void write(uint8_t * input, ssize_t length, int flush) THROWS(IOException);
50 
51  private:
52  std::string filename;
53 
54  char delimiter;
55  char seperator;
56 
57  int descriptor;
58  z_stream stream;
59 
60  uint8_t buffer[2][65536];
61 };
62 
63 #endif
64 
65 /*
66 ** vim: noet ts=3 sw=3
67 */
A GZIP compressed CSV writer.
void write(const std::vector< std::string > &data) THROWS(IOException)
void close(const std::string &rename=std::string()) THROWS(IOException)
static const char DefaultDelimiter
The default delimiter used between the fields of a record; the ASCII record seperator character...
static const char DefaultSeperator
The default seperator used between the records of a file; the ASCII group seperator character...
GZCSVFileWriter(const std::string &file, char delimiter=DefaultDelimiter, char seperator=DefaultSeperator) THROWS(IOException)