SNAP Library, User 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
fl.h File Reference

Go to the source code of this file.

Classes

class  TCs
class  TSOutMnp
class  TSBase
class  TSIn
class  TSOut
class  TSInOut
class  TStdIn
class  TStdOut
class  TFIn
class  TFOut
class  TFInOut
class  TMIn
class  TMOut
class  TChRet
class  TLnRet
class  TFile

Typedefs

typedef TPt< TSInPSIn
typedef TPt< TSOutPSOut
typedef TPt< TSInOutPSInOut

Enumerations

enum  TFAccess {
  faUndef, faCreate, faUpdate, faAppend,
  faRdOnly, faRestore
}

Functions

template<class T >
TSInoperator>> (TSIn &SIn, T &Val)
template<class T >
TSOutoperator<< (TSOut &SOut, const T &Val)
void RefreshFPos ()
 TFRnd (const TFRnd &)
TFRndoperator= (const TFRnd &)
 TFRnd (const TStr &_FNm, const TFAccess &FAccess, const bool &CreateIfNo=true, const int &_HdLen=-1, const int &_RecLen=-1)
static PFRnd New (const TStr &FNm, const TFAccess &FAccess, const bool &CreateIfNo=true, const int &HdLen=-1, const int &RecLen=-1)
 ~TFRnd ()
TStr GetFNm () const
void SetHdRecLen (const int &_HdLen, const int &_RecLen)
void SetFPos (const int &FPos)
void MoveFPos (const int &DFPos)
int GetFPos ()
int GetFLen ()
bool Empty ()
bool Eof ()
void SetRecN (const int &RecN)
int GetRecN ()
int GetRecs ()
void GetBf (void *Bf, const TSize &BfL)
void PutBf (const void *Bf, const TSize &BfL)
void Flush ()
void GetHd (void *Hd)
void PutHd (const void *Hd)
void GetRec (void *Rec, const int &RecN=-1)
void PutRec (const void *Rec, const int &RecN=-1)
void PutCs (const TCs &Cs)
TCs GetCs ()
void PutCh (const char &Ch)
void PutCh (const char &Ch, const int &Chs)
char GetCh ()
void PutUCh (const uchar &UCh)
uchar GetUCh ()
void PutInt (const int &Int)
int GetInt ()
void PutUInt (const uint &UInt)
uint GetUInt ()
void PutStr (const TStr &Str)
TStr GetStr (const int &StrLen)
TStr GetStr (const int &MxStrLen, bool &IsOk)
void PutSIn (const PSIn &SIn, TCs &Cs)
PSIn GetSIn (const int &SInLen, TCs &Cs)
static TStr GetStrFromFAccess (const TFAccess &FAccess)
static TFAccess GetFAccessFromStr (const TStr &Str)

Variables

ClassTP(TFRnd, PFRnd) private TSStr FNm
bool RecAct
int HdLen
int RecLen

Typedef Documentation

typedef TPt<TSIn> PSIn

Definition at line 116 of file fl.h.

typedef TPt<TSInOut> PSInOut

Definition at line 233 of file fl.h.

typedef TPt<TSOut> PSOut

Definition at line 208 of file fl.h.


Enumeration Type Documentation

enum TFAccess
Enumerator:
faUndef 
faCreate 
faUpdate 
faAppend 
faRdOnly 
faRestore 

Definition at line 341 of file fl.h.


Function Documentation

bool Empty ( )

Definition at line 509 of file fl.h.

{return GetFLen()==0;}
bool Eof ( )

Definition at line 510 of file fl.h.

{return GetFPos()==GetFLen();}
void Flush ( )
void GetBf ( void *  Bf,
const TSize BfL 
)
char GetCh ( )

Definition at line 533 of file fl.h.

{char Ch; GetBf(&Ch, sizeof(Ch)); return Ch;}
TCs GetCs ( )

Definition at line 530 of file fl.h.

{TCs Cs; GetBf(&Cs, sizeof(Cs)); return Cs;}
TFAccess TFRnd::GetFAccessFromStr ( const TStr Str) [static]

Definition at line 795 of file fl.cpp.

                                                {
  TStr UcStr=Str.GetUc();
  if (UcStr=="CREATE"){return faCreate;}
  if (UcStr=="UPDATE"){return faUpdate;}
  if (UcStr=="APPEND"){return faAppend;}
  if (UcStr=="READONLY"){return faRdOnly;}
  if (UcStr=="RESTORE"){return faRestore;}

  if (UcStr=="NEW"){return faCreate;}
  if (UcStr=="CONT"){return faUpdate;}
  if (UcStr=="CONTINUE"){return faUpdate;}
  if (UcStr=="REST"){return faRestore;}
  if (UcStr=="RESTORE"){return faRestore;}
  return faUndef;
}
int GetFLen ( )
TStr GetFNm ( ) const

Definition at line 59 of file xfl.h.

{return CurFNm;}
int GetFPos ( )
void GetHd ( void *  Hd)

Definition at line 520 of file fl.h.

                      {IAssert(RecAct);
    int FPos=GetFPos(); SetFPos(0); GetBf(Hd, HdLen); SetFPos(FPos);}
int GetInt ( )

Definition at line 537 of file fl.h.

{int Int; GetBf(&Int, sizeof(Int)); return Int;}
void GetRec ( void *  Rec,
const int &  RecN = -1 
)

Definition at line 524 of file fl.h.

                                            {
    IAssert(RecAct); if (RecN!=-1){SetRecN(RecN);} GetBf(Rec, RecLen);}
int GetRecN ( )
int GetRecs ( )

Definition at line 430 of file xmath.h.

{return Recs;}
PSIn GetSIn ( const int &  SInLen,
TCs Cs 
)
TStr GetStr ( const int &  StrLen)
TStr GetStr ( const int &  MxStrLen,
bool &  IsOk 
)
TStr TFRnd::GetStrFromFAccess ( const TFAccess FAccess) [static]

Definition at line 784 of file fl.cpp.

                                                    {
  switch (FAccess){
    case faCreate: return "Create";
    case faUpdate: return "Update";
    case faAppend: return "Append";
    case faRdOnly: return "ReadOnly";
    case faRestore: return "Restore";
    default: Fail; return TStr();
  }
}

Definition at line 535 of file fl.h.

{uchar UCh; GetBf(&UCh, sizeof(UCh)); return UCh;}

Definition at line 539 of file fl.h.

{uint UInt; GetBf(&UInt, sizeof(UInt)); return UInt;}
void TFRnd::MoveFPos ( const int &  DFPos)

Definition at line 676 of file fl.cpp.

                                    {
  EAssertR(
   fseek(FileId, DFPos, SEEK_CUR)==0,
   "Error seeking into file '"+TStr(FNm)+"'.");
}
static PFRnd New ( const TStr FNm,
const TFAccess FAccess,
const bool &  CreateIfNo = true,
const int &  HdLen = -1,
const int &  RecLen = -1 
) [static]

Definition at line 495 of file fl.h.

                                             {
    return new TFRnd(FNm, FAccess, CreateIfNo, HdLen, RecLen);}
template<class T >
TSOut& operator<< ( TSOut SOut,
const T &  Val 
)

Definition at line 211 of file fl.h.

                                            {
  Val.Save(SOut); return SOut;
}
TFRnd& operator= ( const TFRnd ) [private]
template<class T >
TSIn& operator>> ( TSIn SIn,
T &  Val 
)

Definition at line 119 of file fl.h.

                                    {
  Val.Load(SIn); return SIn;
}
void PutBf ( const void *  Bf,
const TSize BfL 
)
void PutCh ( const char &  Ch)

Definition at line 531 of file fl.h.

{PutBf(&Ch, sizeof(Ch));}
void PutCh ( const char &  Ch,
const int &  Chs 
)
void PutCs ( const TCs Cs)

Definition at line 529 of file fl.h.

{PutBf(&Cs, sizeof(Cs));}
void PutHd ( const void *  Hd)

Definition at line 522 of file fl.h.

                            {IAssert(RecAct);
    int FPos=GetFPos(); SetFPos(0); PutBf(Hd, HdLen); SetFPos(FPos);}
void PutInt ( const int &  Int)

Definition at line 536 of file fl.h.

{PutBf(&Int, sizeof(Int));}
void PutRec ( const void *  Rec,
const int &  RecN = -1 
)

Definition at line 526 of file fl.h.

                                                  {
    IAssert(RecAct); if (RecN!=-1){SetRecN(RecN);} PutBf(Rec, RecLen);}
void TFRnd::PutSIn ( const PSIn SIn,
TCs Cs 
)

Definition at line 767 of file fl.cpp.

                                          {
  int BfL=SIn->Len();
  char* Bf=new char[BfL];
  SIn->GetBf(Bf, BfL);
  Cs=TCs::GetCsFromBf(Bf, BfL);
  PutBf(Bf, BfL);
  delete[] Bf;
}
void PutStr ( const TStr Str)

Definition at line 28 of file json.h.

{JsonValType=jvtStr; Str=_Str;}
void PutUCh ( const uchar UCh)

Definition at line 534 of file fl.h.

{PutBf(&UCh, sizeof(UCh));}
void PutUInt ( const uint UInt)

Definition at line 538 of file fl.h.

{PutBf(&UInt, sizeof(UInt));}
void TFRnd::RefreshFPos ( ) [private]

Definition at line 638 of file fl.cpp.

                       {
  EAssertR(
   fseek(FileId, 0, SEEK_CUR)==0,
   "Error seeking into file '"+TStr(FNm)+"'.");
}
void SetFPos ( const int &  FPos)
void SetHdRecLen ( const int &  _HdLen,
const int &  _RecLen 
)

Definition at line 502 of file fl.h.

                                                         {
    HdLen=_HdLen; RecLen=_RecLen; RecAct=(HdLen>=0)&&(RecLen>0);}
void SetRecN ( const int &  RecN)
TFRnd ( const TFRnd ) [private]
TFRnd::TFRnd ( const TStr _FNm,
const TFAccess FAccess,
const bool &  CreateIfNo = true,
const int &  _HdLen = -1,
const int &  _RecLen = -1 
)

Definition at line 644 of file fl.cpp.

                                                               :
  FileId(NULL), FNm(_FNm.CStr()),
  RecAct(false), HdLen(_HdLen), RecLen(_RecLen){
  RecAct=(HdLen>=0)&&(RecLen>0);
  switch (FAccess){
    case faCreate: FileId=fopen(FNm.CStr(), "w+b"); break;
    case faUpdate: FileId=fopen(FNm.CStr(), "r+b"); break;
    case faAppend: FileId=fopen(FNm.CStr(), "r+b");
      if (FileId!=NULL){fseek(FileId, SEEK_END, 0);} break;
    case faRdOnly: FileId=fopen(FNm.CStr(), "rb"); break;
    default: Fail;
  }
  if ((FileId==NULL)&&(CreateIfNo)){
    FileId=fopen(FNm.CStr(), "w+b");}
  EAssertR(FileId!=NULL, "Can not open file '"+_FNm+"'.");
}

Definition at line 662 of file fl.cpp.

             {
  EAssertR(fclose(FileId)==0, "Can not close file '"+TStr(FNm)+"'.");
}

Variable Documentation

ClassTP (TFRnd, PFRnd) private TSStr FNm

Definition at line 481 of file fl.h.

int HdLen

Definition at line 486 of file fl.h.

bool RecAct

Definition at line 485 of file fl.h.

int RecLen

Definition at line 486 of file fl.h.