SNAP Library 2.1, Developer Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 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 
00004 //#//////////////////////////////////////////////
00013 class TZipIn : public TSIn {
00014 public:
00015   static TStr SevenZipPath;
00016 private:
00017   static TStrStrH FExtToCmdH;
00018   static const int MxBfL;
00019   #ifdef GLib_WIN
00020     HANDLE ZipStdoutRd, ZipStdoutWr;
00021   #else 
00022     FILE* ZipStdoutRd, *ZipStdoutWr;
00023   #endif
00024   uint64 FLen, CurFPos;
00025   char* Bf;
00026   int BfC, BfL;
00027 private:
00028   void FillBf();
00029   int FindEol(int& BfN);
00030   void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
00031   static void FillFExtToCmdH();
00032 private:
00033   TZipIn();
00034   TZipIn(const TZipIn&);
00035   TZipIn& operator=(const TZipIn&);
00036 public:
00037   TZipIn(const TStr& FNm);
00038   TZipIn(const TStr& FNm, bool& OpenedP);
00039   static PSIn New(const TStr& FNm);
00040   static PSIn New(const TStr& FNm, bool& OpenedP);
00041   ~TZipIn();
00042 
00043   bool Eof() { return CurFPos==FLen && BfC==BfL; }
00044   int Len() const { return int(FLen-CurFPos+BfL-BfC); }
00045   char GetCh() { if (BfC==BfL){FillBf();} return Bf[BfC++]; }
00046   char PeekCh() { if (BfC==BfL){FillBf();} return Bf[BfC]; }
00047   int GetBf(const void* LBf, const TSize& LBfL);
00048   bool GetNextLnBf(TChA& LnChA);
00049 
00050   uint64 GetFLen() const { return FLen; }
00051   uint64 GetCurFPos() const { return CurFPos; }
00052 
00054   static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
00056   static bool IsZipExt(const TStr& FNmExt);
00058   static TStr GetCmd(const TStr& ZipFNm);
00060   static uint64 GetFLen(const TStr& ZipFNm);
00061   static PSIn NewIfZip(const TStr& FNm) { return IsZipFNm(FNm) ? New(FNm) : TFIn::New(FNm); }
00062 };
00063 
00064 //#//////////////////////////////////////////////
00072 class TZipOut : public TSOut{
00073 private:
00074   static const TSize MxBfL;
00075   static TStrStrH FExtToCmdH;
00076   #ifdef GLib_WIN
00077     HANDLE ZipStdinRd, ZipStdinWr;
00078   #else 
00079     FILE *ZipStdinRd, *ZipStdinWr;
00080   #endif
00081   char* Bf;
00082   TSize BfL;
00083 private:
00084   void FlushBf();
00085   void CreateZipProcess(const TStr& Cmd, const TStr& ZipFNm);
00086   static void FillFExtToCmdH();
00087 private:
00088   TZipOut();
00089   TZipOut(const TZipOut&);
00090   TZipOut& operator=(const TZipOut&);
00091 public:
00092   TZipOut(const TStr& _FNm);
00093   static PSOut New(const TStr& FNm);
00094   ~TZipOut();
00095 
00096   int PutCh(const char& Ch);
00097   int PutBf(const void* LBf, const TSize& LBfL);
00098   void Flush();
00099 
00101   static bool IsZipFNm(const TStr& FNm) { return IsZipExt(FNm.GetFExt()); }
00103   static bool IsZipExt(const TStr& FNmExt);
00105   static TStr GetCmd(const TStr& ZipFNm);
00106   static PSOut NewIfZip(const TStr& FNm) { return IsZipFNm(FNm) ? New(FNm) : TFOut::New(FNm); }
00107 };
00108 
00109 #endif