00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __sella__file__GZCSVFileWriter_H__
00010 #define __sella__file__GZCSVFileWriter_H__
00011
00012 #include "../util/CommonMacro.h"
00013 #include "IOException.h"
00014
00015 #include <stdint.h>
00016 #include <zlib.h>
00017
00018 #include <string>
00019 #include <vector>
00020 #include <memory>
00021
00022 namespace sella {
00023 namespace file {
00024 class GZCSVFileWriter;
00025 }
00026 }
00027
00031 class sella::file::GZCSVFileWriter {
00032 public:
00033
00034 STANDARD_TYPEDEF(sella::file::GZCSVFileWriter);
00035
00036 static const char DefaultDelimiter = 0x1e;
00037 static const char DefaultSeperator = 0x1d;
00038
00039
00040 GZCSVFileWriter(const std::string & file, char delimiter = DefaultDelimiter, char seperator = DefaultSeperator) THROWS(IOException);
00041 virtual ~GZCSVFileWriter() NO_EXCEPTIONS;
00042
00043
00044 void write(const std::vector<std::string> & data) THROWS(IOException);
00045 void close(const std::string & rename = std::string()) THROWS(IOException);
00046
00047 protected:
00048
00049 void write(uint8_t * input, ssize_t length, int flush) THROWS(IOException);
00050
00051 private:
00052 std::string filename;
00053
00054 char delimiter;
00055 char seperator;
00056
00057 int descriptor;
00058 z_stream stream;
00059
00060 uint8_t buffer[2][65536];
00061 };
00062
00063 #endif
00064
00065
00066
00067