SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMOut Class Reference

#include <fl.h>

Inherits TSOut.

Public Member Functions

 TMOut (const int &_MxBfL=1024)
 
 TMOut (char *_Bf, const int &_MxBfL)
 
 ~TMOut ()
 
int PutCh (const char &Ch)
 
int PutBf (const void *LBf, const TSize &LBfL)
 
void AppendBf (const void *LBf, const TSize &LBfL)
 
void Flush ()
 
int Len () const
 
void Clr ()
 
char GetCh (const int &ChN) const
 
TStr GetAsStr () const
 
void CutBf (const int &CutBfL)
 
PSIn GetSIn (const bool &IsCut=true, const int &CutBfL=-1)
 
char * GetBfAddr () const
 
bool IsCrLfLn () const
 
TStr GetCrLfLn ()
 
bool IsEolnLn () const
 
TStr GetEolnLn (const bool &DoAddEoln, const bool &DoCutBf)
 
void MkEolnLn ()
 
- Public Member Functions inherited from TSOut
 TSOut ()
 
 TSOut (const TStr &Str)
 
virtual ~TSOut ()
 
void EnableLnTrunc (const int &_MxLnLen)
 
void DisableLnTrunc ()
 
virtual TFileId GetFileId () const
 
int PutMem (const TMem &Mem)
 
int PutCh (const char &Ch, const int &Chs)
 
int PutBool (const bool &Bool)
 
int PutInt (const int &Int)
 
int PutInt (const int &Int, const char *FmtStr)
 
int PutUInt (const uint &Int)
 
int PutUInt (const uint &Int, const char *FmtStr)
 
int PutFlt (const double &Flt)
 
int PutFlt (const double &Flt, const char *FmtStr)
 
int PutStr (const char *CStr)
 
int PutStr (const TChA &ChA)
 
int PutStr (const TStr &Str, const char *FmtStr)
 
int PutStr (const TStr &Str, const bool &ForceInLn=false)
 
int PutStrLn (const TStr &Str, const bool &ForceInLn=false)
 
int PutStrFmt (const char *FmtStr,...)
 
int PutStrFmtLn (const char *FmtStr,...)
 
int PutIndent (const int &IndentLev=1)
 
int PutLn (const int &Lns=1)
 
int PutDosLn (const int &Lns=1)
 
int PutSep (const int &NextStrLen=0)
 
int PutSepLn (const int &Lns=0)
 
void SaveCs ()
 
void SaveBf (const void *Bf, const TSize &BfL)
 
void Save (const bool &Bool)
 
void Save (const char &Ch)
 
void Save (const uchar &UCh)
 
void Save (const short &Short)
 
void Save (const ushort &UShort)
 
void Save (const int &Int)
 
void Save (const uint &UInt)
 
void Save (const int64 &Int)
 
void Save (const uint64 &UInt)
 
void Save (const double &Flt)
 
void Save (const sdouble &SFlt)
 
void Save (const ldouble &LFlt)
 
void Save (const char *CStr, const TSize &CStrLen)
 
void Save (const char *CStr)
 
void Save (TSIn &SIn, const TSize &BfL=-1)
 
void Save (const PSIn &SIn, const TSize &BfL=-1)
 
void Save (const void *Bf, const TSize &BfL)
 
TSOutoperator<< (const bool &Bool)
 
TSOutoperator<< (const uchar &UCh)
 
TSOutoperator<< (const char &Ch)
 
TSOutoperator<< (const short &Sh)
 
TSOutoperator<< (const ushort &USh)
 
TSOutoperator<< (const int &Int)
 
TSOutoperator<< (const uint &Int)
 
TSOutoperator<< (const int64 &Int)
 
TSOutoperator<< (const uint64 &UInt)
 
TSOutoperator<< (const float &Flt)
 
TSOutoperator<< (const double &Double)
 
TSOutoperator<< (const long double &LDouble)
 
TSOutoperator<< (const TSOutMnp &Mnp)
 
TSOutoperator<< (TSOut &(*FuncPt)(TSOut &))
 
TSOutoperator<< (TSIn &SIn)
 
TSOutoperator<< (PSIn &SIn)
 
- Public Member Functions inherited from TSBase
 TSBase (const TSStr &Nm)
 
virtual ~TSBase ()
 
virtual TStr GetSNm () const
 

Static Public Member Functions

static PSOut New (const int &MxBfL=1024)
 

Private Member Functions

void Resize (const int &ReqLen=-1)
 
 TMOut (const TMOut &)
 
TMOutoperator= (const TMOut &)
 

Private Attributes

char * Bf
 
int BfL
 
int MxBfL
 
bool OwnBf
 

Additional Inherited Members

- Static Public Attributes inherited from TSOut
static const TPt< TSOutStdOut =PSOut(new TStdOut())
 
- Protected Attributes inherited from TSBase
TCRef CRef
 
TSStr SNm
 
TCs Cs
 

Detailed Description

Definition at line 417 of file fl.h.

Constructor & Destructor Documentation

TMOut::TMOut ( const TMOut )
private
TMOut::TMOut ( const int &  _MxBfL = 1024)

Definition at line 625 of file fl.cpp.

625  :
626  TSBase("Output-Memory"), TSOut("Output-Memory"),
627  Bf(NULL), BfL(0), MxBfL(0), OwnBf(true){
628  MxBfL=_MxBfL>0?_MxBfL:1024;
629  Bf=new char[MxBfL];
630 }
int BfL
Definition: fl.h:420
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:420
bool OwnBf
Definition: fl.h:421
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:419
TMOut::TMOut ( char *  _Bf,
const int &  _MxBfL 
)

Definition at line 632 of file fl.cpp.

632  :
633  TSBase("Output-Memory"), TSOut("Output-Memory"),
634  Bf(_Bf), BfL(0), MxBfL(_MxBfL), OwnBf(false){}
int BfL
Definition: fl.h:420
TSBase(const TSStr &Nm)
Definition: fl.h:50
int MxBfL
Definition: fl.h:420
bool OwnBf
Definition: fl.h:421
TSOut()
Definition: fl.h:136
char * Bf
Definition: fl.h:419
TMOut::~TMOut ( )
inline

Definition at line 431 of file fl.h.

431 {if (OwnBf&&(Bf!=NULL)){delete[] Bf;}}
bool OwnBf
Definition: fl.h:421
char * Bf
Definition: fl.h:419

Member Function Documentation

void TMOut::AppendBf ( const void *  LBf,
const TSize LBfL 
)

Definition at line 636 of file fl.cpp.

636  {
637  Resize(Len() + (int)LBfL);
638  memcpy(Bf + BfL, LBf, LBfL);
639  BfL += (int)LBfL;
640 }
int BfL
Definition: fl.h:420
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:610
char * Bf
Definition: fl.h:419
int Len() const
Definition: fl.h:439
void TMOut::Clr ( )
inline

Definition at line 440 of file fl.h.

440 {BfL=0;}
int BfL
Definition: fl.h:420
void TMOut::CutBf ( const int &  CutBfL)

Definition at line 660 of file fl.cpp.

660  {
661  IAssert((0<=CutBfL)&&(CutBfL<=BfL));
662  if (CutBfL==BfL){BfL=0;}
663  else {memmove(Bf, Bf+CutBfL, BfL-CutBfL); BfL=BfL-CutBfL;}
664 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
char * Bf
Definition: fl.h:419
void TMOut::Flush ( )
inlinevirtual

Implements TSOut.

Definition at line 437 of file fl.h.

437 {}
TStr TMOut::GetAsStr ( ) const

Definition at line 654 of file fl.cpp.

654  {
655  TChA ChA(BfL);
656  for (int BfC=0; BfC<BfL; BfC++){ChA+=Bf[BfC];}
657  return ChA;
658 }
int BfL
Definition: fl.h:420
Definition: dt.h:201
char * Bf
Definition: fl.h:419
char* TMOut::GetBfAddr ( ) const
inline

Definition at line 446 of file fl.h.

446 {return Bf;}
char * Bf
Definition: fl.h:419
char TMOut::GetCh ( const int &  ChN) const
inline

Definition at line 441 of file fl.h.

441  {
442  IAssert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
char * Bf
Definition: fl.h:419
TStr TMOut::GetCrLfLn ( )

Definition at line 686 of file fl.cpp.

686  {
687  IAssert(IsCrLfLn());
688  TChA Ln;
689  for (int BfC=0; BfC<BfL; BfC++){
690  char Ch=Bf[BfC];
691  if ((Ch==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){
692  Ln+=TCh::CrCh; Ln+=TCh::LfCh; CutBf(BfC+1+1); break;
693  } else {
694  Ln+=Ch;
695  }
696  }
697  return Ln;
698 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
void CutBf(const int &CutBfL)
Definition: fl.cpp:660
static const char LfCh
Definition: dt.h:945
Definition: dt.h:201
static const char CrCh
Definition: dt.h:946
bool IsCrLfLn() const
Definition: fl.cpp:680
char * Bf
Definition: fl.h:419
TStr TMOut::GetEolnLn ( const bool &  DoAddEoln,
const bool &  DoCutBf 
)

Definition at line 707 of file fl.cpp.

707  {
708  IAssert(IsEolnLn());
709  int LnChs=0; TChA Ln;
710  for (int BfC=0; BfC<BfL; BfC++){
711  char Ch=Bf[BfC];
712  if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
713  LnChs++; if (DoAddEoln){Ln+=Ch;}
714  if (BfC+1<BfL){
715  char NextCh=Bf[BfC+1];
716  if (((Ch==TCh::CrCh)&&(NextCh==TCh::LfCh))||
717  ((Ch==TCh::LfCh)&&(NextCh==TCh::CrCh))){
718  LnChs++; if (DoAddEoln){Ln+=NextCh;}
719  }
720  }
721  break;
722  } else {
723  LnChs++; Ln+=Ch;
724  }
725  }
726  if (DoCutBf){
727  CutBf(LnChs);
728  }
729  return Ln;
730 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
bool IsEolnLn() const
Definition: fl.cpp:700
void CutBf(const int &CutBfL)
Definition: fl.cpp:660
static const char LfCh
Definition: dt.h:945
Definition: dt.h:201
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:419
PSIn TMOut::GetSIn ( const bool &  IsCut = true,
const int &  CutBfL = -1 
)

Definition at line 666 of file fl.cpp.

666  {
667  IAssert((CutBfL==-1)||((0<=CutBfL)));
668  int SInBfL= (CutBfL==-1) ? BfL : TInt::GetMn(BfL, CutBfL);
669  PSIn SIn;
670  if (OwnBf&&IsCut&&(SInBfL==BfL)){
671  SIn=PSIn(new TMIn(Bf, SInBfL, true));
672  Bf=NULL; BfL=MxBfL=0; OwnBf=true;
673  } else {
674  SIn=PSIn(new TMIn(Bf, SInBfL, false));
675  if (IsCut){CutBf(SInBfL);}
676  }
677  return SIn;
678 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
void CutBf(const int &CutBfL)
Definition: fl.cpp:660
Definition: fl.h:384
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1088
int MxBfL
Definition: fl.h:420
bool OwnBf
Definition: fl.h:421
Definition: bd.h:196
TPt< TSIn > PSIn
Definition: fl.h:119
char * Bf
Definition: fl.h:419
bool TMOut::IsCrLfLn ( ) const

Definition at line 680 of file fl.cpp.

680  {
681  for (int BfC=0; BfC<BfL; BfC++){
682  if ((Bf[BfC]==TCh::CrCh)&&((BfC+1<BfL)&&(Bf[BfC+1]==TCh::LfCh))){return true;}}
683  return false;
684 }
int BfL
Definition: fl.h:420
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:419
bool TMOut::IsEolnLn ( ) const

Definition at line 700 of file fl.cpp.

700  {
701  for (int BfC=0; BfC<BfL; BfC++){
702  if ((Bf[BfC]==TCh::CrCh)||(Bf[BfC]==TCh::LfCh)){return true;}
703  }
704  return false;
705 }
int BfL
Definition: fl.h:420
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946
char * Bf
Definition: fl.h:419
int TMOut::Len ( ) const
inline

Definition at line 439 of file fl.h.

439 {return BfL;}
int BfL
Definition: fl.h:420
void TMOut::MkEolnLn ( )

Definition at line 732 of file fl.cpp.

732  {
733  if (!IsEolnLn()){
735 }
int PutCh(const char &Ch)
Definition: fl.h:433
bool IsEolnLn() const
Definition: fl.cpp:700
static const char LfCh
Definition: dt.h:945
static const char CrCh
Definition: dt.h:946
static PSOut TMOut::New ( const int &  MxBfL = 1024)
inlinestatic

Definition at line 428 of file fl.h.

428  {
429  return PSOut(new TMOut(MxBfL));}
TMOut(const TMOut &)
int MxBfL
Definition: fl.h:420
TPt< TSOut > PSOut
Definition: fl.h:211
TMOut& TMOut::operator= ( const TMOut )
private
int TMOut::PutBf ( const void *  LBf,
const TSize LBfL 
)
virtual

Implements TSOut.

Definition at line 642 of file fl.cpp.

642  {
643  int LBfS=0;
644  if (TSize(BfL+LBfL)>TSize(MxBfL)){
645  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
646  LBfS+=PutCh(((char*)LBf)[LBfC]);}
647  } else {
648  for (TSize LBfC=0; LBfC<LBfL; LBfC++){
649  LBfS+=(Bf[BfL++]=((char*)LBf)[LBfC]);}
650  }
651  return LBfS;
652 }
int BfL
Definition: fl.h:420
int PutCh(const char &Ch)
Definition: fl.h:433
size_t TSize
Definition: bd.h:58
int MxBfL
Definition: fl.h:420
char * Bf
Definition: fl.h:419
int TMOut::PutCh ( const char &  Ch)
inlinevirtual

Implements TSOut.

Definition at line 433 of file fl.h.

433  {if (BfL==MxBfL){
434  Resize();} return Bf[BfL++]=Ch;}
int BfL
Definition: fl.h:420
int MxBfL
Definition: fl.h:420
void Resize(const int &ReqLen=-1)
Definition: fl.cpp:610
char * Bf
Definition: fl.h:419
void TMOut::Resize ( const int &  ReqLen = -1)
private

Definition at line 610 of file fl.cpp.

610  {
611  IAssert(OwnBf&&(BfL==MxBfL || ReqLen >= 0));
612  if (Bf==NULL){
613  IAssert(MxBfL==0);
614  if (ReqLen < 0) Bf=new char[MxBfL=1024];
615  else Bf=new char[MxBfL=ReqLen];
616  } else {
617  if (ReqLen < 0){ MxBfL*=2; }
618  else if (ReqLen < MxBfL){ return; } // nothing to do
619  else { MxBfL=(2*MxBfL < ReqLen ? ReqLen : 2*MxBfL); }
620  char* NewBf=new char[MxBfL];
621  memmove(NewBf, Bf, BfL); delete[] Bf; Bf=NewBf;
622  }
623 }
#define IAssert(Cond)
Definition: bd.h:262
int BfL
Definition: fl.h:420
int MxBfL
Definition: fl.h:420
bool OwnBf
Definition: fl.h:421
char * Bf
Definition: fl.h:419

Member Data Documentation

char* TMOut::Bf
private

Definition at line 419 of file fl.h.

int TMOut::BfL
private

Definition at line 420 of file fl.h.

int TMOut::MxBfL
private

Definition at line 420 of file fl.h.

bool TMOut::OwnBf
private

Definition at line 421 of file fl.h.


The documentation for this class was generated from the following files: