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