SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
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
fl.h
Go to the documentation of this file.
00001 #include "bd.h"
00002 
00004 // Forward-Definitions
00005 class TMem;
00006 class TChA;
00007 class TStr;
00008 
00010 // Check-Sum
00011 class TCs{
00012 private:
00013   static const int MxMask;
00014   int Val;
00015 public:
00016   TCs(): Val(0){}
00017   TCs(const TCs& Cs): Val(Cs.Val&MxMask){}
00018   TCs(const int& Int): Val(Int&MxMask){}
00019 
00020   TCs& operator=(const TCs& Cs){Val=Cs.Val; return *this;}
00021   bool operator==(const TCs& Cs) const {return Val==Cs.Val;}
00022   TCs& operator+=(const TCs& Cs){Val=(Val+Cs.Val)&MxMask; return *this;}
00023   TCs& operator+=(const char& Ch){Val=(Val+Ch)&MxMask; return *this;}
00024   TCs& operator+=(const int& Int){Val=(Val+Int)&MxMask; return *this;}
00025   int Get() const {return Val;}
00026 
00027   static TCs GetCsFromBf(char* Bf, const int& BfL);
00028 };
00029 
00031 // Output-stream-manipulator
00032 class TSOutMnp {
00033 public:
00034   virtual TSOut& operator()(TSOut& SOut) const=0;
00035   virtual ~TSOutMnp();
00036 };
00037 
00039 // Stream-base
00040 class TSBase{
00041 protected:
00042   TCRef CRef;
00043   TSStr SNm;
00044   TCs Cs;
00045 //protected:
00046 //  TSBase();
00047 //  TSBase(const TSBase&);
00048 //  TSBase& operator=(const TSBase&);
00049 public:
00050   TSBase(const TSStr& Nm): SNm(Nm){}
00051   virtual ~TSBase(){}
00052 
00053   virtual TStr GetSNm() const;
00054 };
00055 
00057 // Input-Stream
00058 class TSIn: virtual public TSBase{
00059 private:
00060   bool FastMode;
00061 private:
00062   TSIn(const TSIn&);
00063   TSIn& operator=(const TSIn&);
00064 public:
00065   TSIn(): TSBase("Input-Stream"), FastMode(false){}
00066   TSIn(const TStr& Str);
00067   virtual ~TSIn(){}
00068 
00069   virtual bool Eof()=0; // if end-of-file
00070   virtual int Len() const=0;  // get number of bytes till eof
00071   virtual char GetCh()=0;     // get one char and advance
00072   virtual char PeekCh()=0;    // get one char and do NOT advance
00073   virtual int GetBf(const void* Bf, const TSize& BfL)=0; // get BfL chars and advance
00074   virtual bool GetNextLnBf(TChA& LnChA)=0;  // get the next line and advance
00075   virtual void Reset(){Fail;}
00076 
00077   bool IsFastMode() const {return FastMode;}
00078   void SetFastMode(const bool& _FastMode){FastMode=_FastMode;}
00079 
00080   void LoadCs();
00081   void LoadBf(const void* Bf, const TSize& BfL){Cs+=GetBf(Bf, BfL);}
00082   void* LoadNewBf(const int& BfL){
00083     void* Bf=(void*)new char[BfL]; Cs+=GetBf(Bf, BfL); return Bf;}
00084   void Load(bool& Bool){Cs+=GetBf(&Bool, sizeof(Bool));}
00085   void Load(uchar& UCh){Cs+=GetBf(&UCh, sizeof(UCh));}
00086   void Load(char& Ch){Cs+=GetBf(&Ch, sizeof(Ch));}
00087   void Load(short& Short){Cs+=GetBf(&Short, sizeof(Short));} //J:
00088   void Load(ushort& UShort){Cs+=GetBf(&UShort, sizeof(UShort));} //J:
00089   void Load(int& Int){Cs+=GetBf(&Int, sizeof(Int));}
00090   void Load(uint& UInt){Cs+=GetBf(&UInt, sizeof(UInt));}
00091   void Load(int64& Int){Cs+=GetBf(&Int, sizeof(Int));}
00092   void Load(uint64& UInt){Cs+=GetBf(&UInt, sizeof(UInt));}
00093   void Load(double& Flt){Cs+=GetBf(&Flt, sizeof(Flt));}
00094   void Load(sdouble& SFlt){Cs+=GetBf(&SFlt, sizeof(SFlt));}
00095   void Load(ldouble& LFlt){Cs+=GetBf(&LFlt, sizeof(LFlt));}
00096   void Load(char*& CStr, const int& MxCStrLen, const int& CStrLen){
00097     CStr=new char[MxCStrLen+1]; Cs+=GetBf(CStr, CStrLen+1);}
00098   void Load(char*& CStr);
00099 
00100   TSIn& operator>>(bool& Bool){Cs+=GetBf(&Bool, sizeof(Bool)); return *this;}
00101   TSIn& operator>>(uchar& UCh){Cs+=GetBf(&UCh, sizeof(UCh)); return *this;}
00102   TSIn& operator>>(char& Ch){Cs+=GetBf(&Ch, sizeof(Ch)); return *this;}
00103   TSIn& operator>>(short& Sh){Cs+=GetBf(&Sh, sizeof(Sh)); return *this;}
00104   TSIn& operator>>(ushort& USh){Cs+=GetBf(&USh, sizeof(USh)); return *this;}
00105   TSIn& operator>>(int& Int){Cs+=GetBf(&Int, sizeof(Int)); return *this;}
00106   TSIn& operator>>(uint& UInt){Cs+=GetBf(&UInt, sizeof(UInt)); return *this;}
00107   TSIn& operator>>(int64& Int){Cs+=GetBf(&Int, sizeof(Int)); return *this;}
00108   TSIn& operator>>(uint64& UInt){Cs+=GetBf(&UInt, sizeof(UInt)); return *this;}
00109   TSIn& operator>>(float& Flt){Cs+=GetBf(&Flt, sizeof(Flt)); return *this;}
00110   TSIn& operator>>(double& Double){Cs+=GetBf(&Double, sizeof(Double)); return *this;}
00111   TSIn& operator>>(long double& LDouble){Cs+=GetBf(&LDouble, sizeof(LDouble)); return *this;}
00112 
00113   bool GetNextLn(TStr& LnStr);
00114   bool GetNextLn(TChA& LnChA);
00115 
00116   static const TPt<TSIn> StdIn;
00117   friend class TPt<TSIn>;
00118 };
00119 typedef TPt<TSIn> PSIn;
00120 
00121 template <class T>
00122 TSIn& operator>>(TSIn& SIn, T& Val) {
00123   Val.Load(SIn); return SIn;
00124 }
00125 
00127 // Output-Stream
00128 class TSOut: virtual public TSBase{
00129 private:
00130   int MxLnLen, LnLen;
00131   int UpdateLnLen(const int& StrLen, const bool& ForceInLn=false);
00132 private:
00133   TSOut(const TSIn&);
00134   TSOut& operator = (const TSOut&);
00135 public:
00136   TSOut(): TSBase("Output-Stream"), MxLnLen(-1), LnLen(0){}
00137   TSOut(const TStr& Str);
00138   virtual ~TSOut(){}
00139 
00140   void EnableLnTrunc(const int& _MxLnLen){MxLnLen=_MxLnLen;}
00141   void DisableLnTrunc(){MxLnLen=-1;}
00142 
00143   virtual int PutCh(const char& Ch)=0;
00144   virtual int PutBf(const void* LBf, const TSize& LBfL)=0;
00145   virtual void Flush()=0;
00146   virtual TFileId GetFileId() const {return NULL;}
00147 
00148   int PutMem(const TMem& Mem);
00149   int PutCh(const char& Ch, const int& Chs);
00150   int PutBool(const bool& Bool);
00151   int PutInt(const int& Int);
00152   int PutInt(const int& Int, const char* FmtStr);
00153   int PutUInt(const uint& Int);
00154   int PutUInt(const uint& Int, const char* FmtStr);
00155   int PutFlt(const double& Flt);
00156   int PutFlt(const double& Flt, const char* FmtStr);
00157   int PutStr(const char* CStr);
00158   int PutStr(const TChA& ChA);
00159   int PutStr(const TStr& Str, const char* FmtStr);
00160   int PutStr(const TStr& Str, const bool& ForceInLn=false);
00161   int PutStrLn(const TStr& Str, const bool& ForceInLn=false){
00162     int Cs=PutStr(Str,ForceInLn); Cs+=PutLn(); return Cs;}
00163   int PutStrFmt(const char *FmtStr, ...); 
00164   int PutStrFmtLn(const char *FmtStr, ...); 
00165   int PutIndent(const int& IndentLev=1);
00166   int PutLn(const int& Lns=1);
00167   int PutDosLn(const int& Lns=1);
00168   int PutSep(const int& NextStrLen=0);
00169   int PutSepLn(const int& Lns=0);
00170 
00171   void SaveCs(){Cs+=PutBf(&Cs, sizeof(Cs));}
00172   void SaveBf(const void* Bf, const TSize& BfL){Cs+=PutBf(Bf, BfL);}
00173   void Save(const bool& Bool){Cs+=PutBf(&Bool, sizeof(Bool));}
00174   void Save(const char& Ch){Cs+=PutBf(&Ch, sizeof(Ch));}
00175   void Save(const uchar& UCh){Cs+=PutBf(&UCh, sizeof(UCh));}
00176   void Save(const short& Short){Cs+=PutBf(&Short, sizeof(Short));}
00177   void Save(const ushort& UShort){Cs+=PutBf(&UShort, sizeof(UShort));}
00178   void Save(const int& Int){Cs+=PutBf(&Int, sizeof(Int));}
00179   void Save(const uint& UInt){Cs+=PutBf(&UInt, sizeof(UInt));}
00180   void Save(const int64& Int){Cs+=PutBf(&Int, sizeof(Int));}
00181   void Save(const uint64& UInt){Cs+=PutBf(&UInt, sizeof(UInt));}
00182   void Save(const double& Flt){Cs+=PutBf(&Flt, sizeof(Flt));}
00183   void Save(const sdouble& SFlt){Cs+=PutBf(&SFlt, sizeof(SFlt));}
00184   void Save(const ldouble& LFlt){Cs+=PutBf(&LFlt, sizeof(LFlt));}
00185   void Save(const char* CStr, const TSize& CStrLen){Cs+=PutBf(CStr, CStrLen+1);}
00186   void Save(const char* CStr);
00187   void Save(TSIn& SIn, const TSize& BfL=-1);
00188   void Save(const PSIn& SIn, const TSize& BfL=-1){Save(*SIn, BfL);}
00189   void Save(const void* Bf, const TSize& BfL){Cs+=PutBf(Bf, BfL);}
00190 
00191   TSOut& operator<<(const bool& Bool){Cs+=PutBf(&Bool, sizeof(Bool)); return *this;}
00192   TSOut& operator<<(const uchar& UCh){Cs+=PutBf(&UCh, sizeof(UCh)); return *this;}
00193   TSOut& operator<<(const char& Ch){Cs+=PutBf(&Ch, sizeof(Ch)); return *this;}
00194   TSOut& operator<<(const short& Sh){Cs+=PutBf(&Sh, sizeof(Sh)); return *this;}
00195   TSOut& operator<<(const ushort& USh){Cs+=PutBf(&USh, sizeof(USh)); return *this;}
00196   TSOut& operator<<(const int& Int){Cs+=PutBf(&Int, sizeof(Int)); return *this;}
00197   TSOut& operator<<(const uint& Int){Cs+=PutBf(&Int, sizeof(Int)); return *this;}
00198   TSOut& operator<<(const int64& Int){Cs+=PutBf(&Int, sizeof(Int)); return *this;}
00199   TSOut& operator<<(const uint64& UInt){Cs+=PutBf(&UInt, sizeof(UInt)); return *this;}
00200   TSOut& operator<<(const float& Flt){Cs+=PutBf(&Flt, sizeof(Flt)); return *this;}
00201   TSOut& operator<<(const double& Double){Cs+=PutBf(&Double, sizeof(Double)); return *this;}
00202   TSOut& operator<<(const long double& LDouble){Cs+=PutBf(&LDouble, sizeof(LDouble)); return *this;}
00203   TSOut& operator<<(const TSOutMnp& Mnp){return Mnp(*this);}
00204   TSOut& operator<<(TSOut&(*FuncPt)(TSOut&)){return FuncPt(*this);}
00205   TSOut& operator<<(TSIn& SIn);
00206   TSOut& operator<<(PSIn& SIn){return operator<<(*SIn);}
00207 
00208   static const TPt<TSOut> StdOut;
00209   friend class TPt<TSOut>;
00210 };
00211 typedef TPt<TSOut> PSOut;
00212 
00213 template <class T>
00214 TSOut& operator<<(TSOut& SOut, const T& Val){
00215   Val.Save(SOut); return SOut;
00216 }
00217 
00219 // Input-Output-Stream-Base
00220 class TSInOut: public TSIn, public TSOut{
00221 private:
00222   TSInOut(const TSInOut&);
00223   TSInOut& operator=(const TSInOut&);
00224 public:
00225   TSInOut(): TSBase("Input-Output-Stream"), TSIn(), TSOut() {}
00226   virtual ~TSInOut(){}
00227 
00228   virtual void SetPos(const int& Pos)=0;
00229   virtual void MovePos(const int& DPos)=0;
00230   virtual int GetPos() const=0;
00231   virtual int GetSize() const=0; // size of whole stream
00232   virtual void Clr()=0; // clear IO buffer
00233 
00234   friend class TPt<TSInOut>;
00235 };
00236 typedef TPt<TSInOut> PSInOut;
00237 
00239 // Standard-Input
00240 class TStdIn: public TSIn{
00241 private:
00242   TStdIn(const TStdIn&);
00243   TStdIn& operator=(const TStdIn&);
00244 public:
00245   TStdIn();
00246   static TPt<TSIn> New(){return new TStdIn();}
00247 
00248   bool Eof(){return feof(stdin)!=0;}
00249   int Len() const {return -1;}
00250   char GetCh(){return char(getchar());}
00251   char PeekCh(){
00252     int Ch=getchar(); ungetc(Ch, stdin); return char(Ch);}
00253   int GetBf(const void* LBf, const TSize& LBfL);
00254   void Reset(){Cs=TCs();}
00255   bool GetNextLnBf(TChA& LnChA);
00256 };
00257 
00259 // Standard-Output
00260 class TStdOut: public TSOut{
00261 private:
00262   TStdOut(const TStdOut&);
00263   TStdOut& operator=(const TStdOut&);
00264 public:
00265   TStdOut();
00266   static TPt<TSOut> New(){return new TStdOut();}
00267 
00268   int PutCh(const char& Ch){putchar(Ch); return Ch;}
00269   int PutBf(const void *LBf, const TSize& LBfL);
00270   void Flush(){fflush(stdout);}
00271 };
00272 
00274 // Input-File
00275 class TFIn: public TSIn{
00276 private:
00277   static const int MxBfL;
00278   TFileId FileId;
00279   char* Bf;
00280   int BfC, BfL;
00281 private:
00282   void SetFPos(const int& FPos) const;
00283   int GetFPos() const;
00284   int GetFLen() const;
00285   void FillBf();
00286   int FindEol(int& BfN, bool& CrEnd);
00287 private:
00288   TFIn();
00289   TFIn(const TFIn&);
00290   TFIn& operator=(const TFIn&);
00291 public:
00292   TFIn(const TStr& FNm);
00293   TFIn(const TStr& FNm, bool& OpenedP);
00294   static PSIn New(const TStr& FNm);
00295   static PSIn New(const TStr& FNm, bool& OpenedP);
00296   ~TFIn();
00297 
00298   bool Eof(){
00299     if ((BfC==BfL)&&(BfL==MxBfL)){FillBf();}
00300     return (BfC==BfL)&&(BfL<MxBfL);}
00301   int Len() const {return GetFLen()-(GetFPos()-BfL+BfC);}
00302   char GetCh(){
00303     if (BfC==BfL){if (Eof()){return 0;} return Bf[BfC++];}
00304     else {return Bf[BfC++];}}
00305   char PeekCh(){
00306     if (BfC==BfL){if (Eof()){return 0;} return Bf[BfC];}
00307     else {return Bf[BfC];}}
00308   int GetBf(const void* LBf, const TSize& LBfL);
00309   void Reset(){rewind(FileId); Cs=TCs(); BfC=BfL=-1; FillBf();}
00310   bool GetNextLnBf(TChA& LnChA);
00311 
00312   //J:not needed
00313   //TFileId GetFileId() const {return FileId;} //J:
00314   //void SetFileId(const FileId& FlId) {FileId=FlId; BfC=BfL=-1; FillBf(); } //J: for low level manipulations
00315 };
00316 
00318 // Output-File
00319 class TFOut: public TSOut{
00320 private:
00321   static const TSize MxBfL;
00322   TFileId FileId;
00323   char* Bf;
00324   TSize BfL;
00325 private:
00326   void FlushBf();
00327 private:
00328   TFOut();
00329   TFOut(const TFOut&);
00330   TFOut& operator=(const TFOut&);
00331 public:
00332   TFOut(const TStr& _FNm, const bool& Append=false);
00333   TFOut(const TStr& _FNm, const bool& Append, bool& OpenedP);
00334   static PSOut New(const TStr& FNm, const bool& Append=false);
00335   static PSOut New(const TStr& FNm, const bool& Append, bool& OpenedP);
00336   ~TFOut();
00337 
00338   int PutCh(const char& Ch);
00339   int PutBf(const void* LBf, const TSize& LBfL);
00340   void Flush();
00341 
00342   TFileId GetFileId() const {return FileId;}
00343 };
00344 
00346 // Input-Output-File
00347 typedef enum {faUndef, faCreate, faUpdate, faAppend, faRdOnly, faRestore} TFAccess;
00348 
00349 class TFInOut : public TSInOut {
00350 private:
00351   TFileId FileId;
00352 private:
00353   TFInOut();
00354   TFInOut(const TFIn&);
00355   TFInOut& operator=(const TFIn&);
00356 public:
00357   TFInOut(const TStr& FNm, const TFAccess& FAccess, const bool& CreateIfNo);
00358   static PSInOut New(const TStr& FNm, const TFAccess& FAccess, const bool& CreateIfNo);
00359   ~TFInOut() { if (FileId!=NULL) IAssert(fclose(FileId) == 0); }
00360 
00361   TStr GetFNm() const;
00362   TFileId GetFileId() const {return FileId;}
00363 
00364   bool Eof(){ return feof(FileId) != 0; }
00365   int Len() const { return GetSize() - GetPos(); } // bytes till eof
00366   char GetCh() { return char(fgetc(FileId)); }
00367   char PeekCh() { const char Ch = GetCh();  MovePos(-1);  return Ch; }
00368   int GetBf(const void* LBf, const TSize& LBfL);
00369   bool GetNextLnBf(TChA& LnChA);
00370 
00371   void SetPos(const int& Pos) { IAssert(fseek(FileId, Pos, SEEK_SET)==0); }
00372   void MovePos(const int& DPos) { IAssert(fseek(FileId, DPos, SEEK_CUR)==0); }
00373   int GetPos() const { return (int) ftell(FileId); }
00374   int GetSize() const;
00375   void Clr() { Fail; }
00376 
00377   int PutCh(const char& Ch) { return PutBf(&Ch, sizeof(Ch)); }
00378   int PutBf(const void* LBf, const TSize& LBfL);
00379   void Flush() { IAssert(fflush(FileId) == 0); }
00380 };
00381 
00383 // Input-Memory
00384 class TMIn: public TSIn{
00385 private:
00386   char* Bf;
00387   int BfC, BfL;
00388 private:
00389   TMIn();
00390   TMIn(const TMIn&);
00391   TMIn& operator=(const TMIn&);
00392 public:
00393   TMIn(const void* _Bf, const int& _BfL, const bool& TakeBf=false);
00394   TMIn(TSIn& SIn);
00395   TMIn(const char* CStr);
00396   TMIn(const TStr& Str);
00397   TMIn(const TChA& ChA);
00398   static PSIn New(const void* _Bf, const int& _BfL, const bool& TakeBf=false);
00399   static PSIn New(const char* CStr);
00400   static PSIn New(const TStr& Str);
00401   static PSIn New(const TChA& ChA);
00402   ~TMIn(){if (Bf!=NULL){delete[] Bf;}}
00403 
00404   bool Eof(){return BfC==BfL;}
00405   int Len() const {return BfL-BfC;}
00406   char GetCh();
00407   char PeekCh();
00408   int GetBf(const void* LBf, const TSize& LBfL);
00409   void Reset(){Cs=TCs(); BfC=0;}
00410   bool GetNextLnBf(TChA& LnChA);
00411 
00412   char* GetBfAddr(){return Bf;}
00413 };
00414 
00416 // Output-Memory
00417 class TMOut: public TSOut{
00418 private:
00419   char* Bf;
00420   int BfL, MxBfL;
00421   bool OwnBf;
00422   void Resize(const int& ReqLen = -1);
00423 private:
00424   TMOut(const TMOut&);
00425   TMOut& operator=(const TMOut&);
00426 public:
00427   TMOut(const int& _MxBfL=1024);
00428   static PSOut New(const int& MxBfL=1024){
00429     return PSOut(new TMOut(MxBfL));}
00430   TMOut(char* _Bf, const int& _MxBfL);
00431   ~TMOut(){if (OwnBf&&(Bf!=NULL)){delete[] Bf;}}
00432 
00433   int PutCh(const char& Ch){if (BfL==MxBfL){
00434     Resize();} return Bf[BfL++]=Ch;}
00435   int PutBf(const void* LBf, const TSize& LBfL);
00436   void AppendBf(const void* LBf, const TSize& LBfL);
00437   void Flush(){}
00438 
00439   int Len() const {return BfL;}
00440   void Clr(){BfL=0;}
00441   char GetCh(const int& ChN) const {
00442     IAssert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
00443   TStr GetAsStr() const;
00444   void CutBf(const int& CutBfL);
00445   PSIn GetSIn(const bool& IsCut=true, const int& CutBfL=-1);
00446   char* GetBfAddr() const {return Bf;}
00447 
00448   bool IsCrLfLn() const;
00449   TStr GetCrLfLn();
00450   bool IsEolnLn() const;
00451   TStr GetEolnLn(const bool& DoAddEoln, const bool& DoCutBf);
00452   void MkEolnLn();
00453 };
00454 
00456 // Character-Returner
00457 class TChRet{
00458 private:
00459   PSIn SIn;
00460   char EofCh;
00461   char Ch;
00462 private:
00463   TChRet();
00464   TChRet(const TChRet&);
00465   TChRet& operator=(const TChRet&);
00466 public:
00467   TChRet(const PSIn& _SIn, const char& _EofCh=0):
00468     SIn(_SIn), EofCh(_EofCh), Ch(_EofCh){}
00469 
00470   bool Eof() const {return Ch==EofCh;}
00471   char GetCh(){
00472     if (SIn->Eof()){return Ch=EofCh;} else {return Ch=SIn->GetCh();}}
00473   char operator()(){return Ch;}
00474 };
00475 
00477 // Line-Returner
00478 // J: after talking to BlazF -- can be removed from GLib
00479 class TLnRet{
00480 private:
00481   PSIn SIn;
00482   UndefDefaultCopyAssign(TLnRet);
00483 public:
00484   TLnRet(const PSIn& _SIn): SIn(_SIn) {}
00485 
00486   bool NextLn(TStr& LnStr);
00487 };
00488 
00490 // Random-Access-File
00491 ClassTP(TFRnd, PFRnd)//{
00492 private:
00493   TFileId FileId;
00494   TSStr FNm;
00495   bool RecAct;
00496   int HdLen, RecLen;
00497 private:
00498   void RefreshFPos();
00499 private:
00500   TFRnd(const TFRnd&);
00501   TFRnd& operator=(const TFRnd&);
00502 public:
00503   TFRnd(const TStr& _FNm, const TFAccess& FAccess,
00504    const bool& CreateIfNo=true, const int& _HdLen=-1, const int& _RecLen=-1);
00505   static PFRnd New(const TStr& FNm,
00506    const TFAccess& FAccess, const bool& CreateIfNo=true,
00507    const int& HdLen=-1, const int& RecLen=-1){
00508     return new TFRnd(FNm, FAccess, CreateIfNo, HdLen, RecLen);}
00509   ~TFRnd();
00510 
00511   TStr GetFNm() const;
00512   void SetHdRecLen(const int& _HdLen, const int& _RecLen){
00513     HdLen=_HdLen; RecLen=_RecLen; RecAct=(HdLen>=0)&&(RecLen>0);}
00514 
00515   void SetFPos(const int& FPos);
00516   void MoveFPos(const int& DFPos);
00517   int GetFPos();
00518   int GetFLen();
00519   bool Empty(){return GetFLen()==0;}
00520   bool Eof(){return GetFPos()==GetFLen();}
00521 
00522   void SetRecN(const int& RecN);
00523   int GetRecN();
00524   int GetRecs();
00525 
00526   void GetBf(void* Bf, const TSize& BfL);
00527   void PutBf(const void* Bf, const TSize& BfL);
00528   void Flush();
00529 
00530   void GetHd(void* Hd){IAssert(RecAct);
00531     int FPos=GetFPos(); SetFPos(0); GetBf(Hd, HdLen); SetFPos(FPos);}
00532   void PutHd(const void* Hd){IAssert(RecAct);
00533     int FPos=GetFPos(); SetFPos(0); PutBf(Hd, HdLen); SetFPos(FPos);}
00534   void GetRec(void* Rec, const int& RecN=-1){
00535     IAssert(RecAct); if (RecN!=-1){SetRecN(RecN);} GetBf(Rec, RecLen);}
00536   void PutRec(const void* Rec, const int& RecN=-1){
00537     IAssert(RecAct); if (RecN!=-1){SetRecN(RecN);} PutBf(Rec, RecLen);}
00538 
00539   void PutCs(const TCs& Cs){PutBf(&Cs, sizeof(Cs));}
00540   TCs GetCs(){TCs Cs; GetBf(&Cs, sizeof(Cs)); return Cs;}
00541   void PutCh(const char& Ch){PutBf(&Ch, sizeof(Ch));}
00542   void PutCh(const char& Ch, const int& Chs);
00543   char GetCh(){char Ch; GetBf(&Ch, sizeof(Ch)); return Ch;}
00544   void PutUCh(const uchar& UCh){PutBf(&UCh, sizeof(UCh));}
00545   uchar GetUCh(){uchar UCh; GetBf(&UCh, sizeof(UCh)); return UCh;}
00546   void PutInt(const int& Int){PutBf(&Int, sizeof(Int));}
00547   int GetInt(){int Int; GetBf(&Int, sizeof(Int)); return Int;}
00548   void PutUInt(const uint& UInt){PutBf(&UInt, sizeof(UInt));}
00549   uint GetUInt(){uint UInt; GetBf(&UInt, sizeof(UInt)); return UInt;}
00550   void PutStr(const TStr& Str);
00551   TStr GetStr(const int& StrLen);
00552   TStr GetStr(const int& MxStrLen, bool& IsOk);
00553   void PutSIn(const PSIn& SIn, TCs& Cs);
00554   PSIn GetSIn(const int& SInLen, TCs& Cs);
00555 
00556   static TStr GetStrFromFAccess(const TFAccess& FAccess);
00557   static TFAccess GetFAccessFromStr(const TStr& Str);
00558 };
00559 
00561 // Files
00562 class TFile{
00563 public:
00564   static const TStr TxtFExt;
00565   static const TStr HtmlFExt;
00566   static const TStr HtmFExt;
00567   static const TStr GifFExt;
00568   static const TStr JarFExt;
00569 public:
00570   static bool Exists(const TStr& FNm);
00571   static void Copy(const TStr& SrcFNm, const TStr& DstFNm, 
00572     const bool& ThrowExceptP=true, const bool& FailIfExistsP=false);
00573   static void Del(const TStr& FNm, const bool& ThrowExceptP=true);
00574   static void DelWc(const TStr& WcStr, const bool& RecurseDirP=false);
00575   static void Rename(const TStr& SrcFNm, const TStr& DstFNm);
00576   static TStr GetUniqueFNm(const TStr& FNm);
00577   static uint64 GetSize(const TStr& FNm);
00578   static uint64 GetCreateTm(const TStr& FNm);
00579   static uint64 GetLastAccessTm(const TStr& FNm);
00580   static uint64 GetLastWriteTm(const TStr& FNm);
00581 };
00582