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