SNAP Library, Developer Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
zipfl.h
Go to the documentation of this file.
00001 #ifndef zipfl_h
00002 #define zipfl_h
00003 
00012 class TZipIn : public TSIn {
00013 private:
00014   static TStrStrH FExtToCmdH;
00015   static const int MxBfL;
00016   #ifdef GLib_WIN
00017     HANDLE ZipStdoutRd, ZipStdoutWr;
00018   #else 
00019     FILE* ZipStdoutRd, *ZipStdoutWr;
00020   #endif
00021   uint64 FLen, CurFPos;
00022   char* Bf;
00023   int BfC, BfL;
00024 private:
00025   void FillBf();
00026   void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
00027   static void FillFExtToCmdH();
00028 private:
00029   TZipIn();
00030   TZipIn(const TZipIn&);
00031   TZipIn& operator=(const TZipIn&);
00032 public:
00033   TZipIn(const TStr& FNm);
00034   TZipIn(const TStr& FNm, bool& OpenedP);
00035   static PSIn New(const TStr& FNm);
00036   static PSIn New(const TStr& FNm, bool& OpenedP);
00037   ~TZipIn();
00038 
00039   bool Eof() { return CurFPos==FLen && BfC==BfL; }
00040   int Len() const { return int(FLen-CurFPos+BfL-BfC); }
00041   char GetCh() { if (BfC==BfL){FillBf();} return Bf[BfC++]; }
00042   char PeekCh() { if (BfC==BfL){FillBf();} return Bf[BfC]; }
00043   int GetBf(const void* LBf, const TSize& LBfL);
00044 
00045   uint64 GetFLen() const { return FLen; }
00046   uint64 GetCurFPos() const { return CurFPos; }
00047 
00049   static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
00051   static bool IsZipExt(const TStr& FNmExt);
00053   static TStr GetCmd(const TStr& ZipFNm);
00055   static uint64 GetFLen(const TStr& ZipFNm);
00056 };
00057 
00065 class TZipOut : public TSOut{
00066 private:
00067   static const TSize MxBfL;
00068   static TStrStrH FExtToCmdH;
00069   #ifdef GLib_WIN
00070     HANDLE ZipStdinRd, ZipStdinWr;
00071   #else 
00072     FILE *ZipStdinRd, *ZipStdinWr;
00073   #endif
00074   char* Bf;
00075   TSize BfL;
00076 private:
00077   void FlushBf();
00078   void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
00079   static void FillFExtToCmdH();
00080 private:
00081   TZipOut();
00082   TZipOut(const TZipOut&);
00083   TZipOut& operator=(const TZipOut&);
00084 public:
00085   TZipOut(const TStr& _FNm);
00086   static PSOut New(const TStr& FNm);
00087   ~TZipOut();
00088 
00089   int PutCh(const char& Ch);
00090   int PutBf(const void* LBf, const TSize& LBfL);
00091   void Flush();
00092 
00094   static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
00096   static bool IsZipExt(const TStr& FNmExt);
00098   static TStr GetCmd(const TStr& ZipFNm);
00099 };
00100 
00101 #endif