00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __sella__file__GZCSVFileReader_H__
00010 #define __sella__file__GZCSVFileReader_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 GZCSVFileReader;
00025 }
00026 }
00027
00031 class sella::file::GZCSVFileReader {
00032 public:
00033
00034 STANDARD_TYPEDEF(sella::file::GZCSVFileReader);
00035
00036 static const char DefaultDelimiter = 0x1e;
00037 static const char DefaultSeperator = 0x1d;
00038
00039
00040 GZCSVFileReader(const std::string & file, char delimiter = DefaultDelimiter, char seperator = DefaultSeperator) THROWS(IOException);
00041 virtual ~GZCSVFileReader() NO_EXCEPTIONS;
00042
00043
00044 void read(std::vector<std::vector<std::string>> & data) THROWS(IOException);
00045 void close(bool unlink = false) NO_EXCEPTIONS;
00046
00047 protected:
00048
00049 bool read(std::vector<std::string> & data, std::string prepend) THROWS(IOException);
00050 bool read(std::vector<std::string> & data) THROWS(IOException);
00051
00052 private:
00053 std::string filename;
00054
00055 char delimiter;
00056 char seperator;
00057
00058 int descriptor;
00059 z_stream stream;
00060
00061 uint8_t buffer[2][65536];
00062 };
00063
00064 #endif
00065
00066
00067
00068