SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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
TRStr Class Reference

#include <dt.h>

Public Member Functions

 TRStr ()
 
 TRStr (const int &Len)
 
 TRStr (const char *CStr)
 
 TRStr (const char *CStr, const int &MxLen)
 
 TRStr (const char *CStr1, const char *CStr2)
 
 TRStr (const char &Ch)
 
 TRStr (const char &Ch1, const char &Ch2)
 
 ~TRStr ()
 
 TRStr (TSIn &SIn, const bool &IsSmall)
 
void Save (TSOut &SOut, const bool &IsSmall) const
 
TRStroperator= (const TRStr &)
 
int GetMemUsed () const
 
void MkRef ()
 
void UnRef ()
 
const char * CStr () const
 
char * CStr ()
 
bool Empty () const
 
int Len () const
 
void PutCh (const int &ChN, const char &Ch)
 
char GetCh (const int &ChN) const
 
bool IsUc () const
 
void ToUc ()
 
bool IsLc () const
 
void ToLc ()
 
void ToCap ()
 
void ConvUsFromYuAscii ()
 
int GetPrimHashCd () const
 
int GetSecHashCd () const
 

Static Public Member Functions

static int CmpI (const char *CStr1, const char *CStr2)
 
static TRStrGetNullRStr ()
 

Public Attributes

char * Bf
 
int Refs
 

Detailed Description

Definition at line 346 of file dt.h.

Constructor & Destructor Documentation

TRStr::TRStr ( )
inline

Definition at line 351 of file dt.h.

References Bf, and Refs.

351 {Refs=1; Bf=new char[0+1]; Bf[0]=0;}
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::TRStr ( const int &  Len)
inline

Definition at line 352 of file dt.h.

References Bf, IAssert, Len(), and Refs.

352  {
353  IAssert(Len>=0); Refs=0; Bf=new char[Len+1]; Bf[Len]=0;}
#define IAssert(Cond)
Definition: bd.h:262
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384
int Refs
Definition: dt.h:349

Here is the call graph for this function:

TRStr::TRStr ( const char *  CStr)
inline

Definition at line 354 of file dt.h.

References Bf, and Refs.

354  {
355  Refs=0; Bf=new char[strlen(CStr)+1]; strcpy(Bf, CStr);}
const char * CStr() const
Definition: dt.h:381
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::TRStr ( const char *  CStr,
const int &  MxLen 
)
inline

Definition at line 356 of file dt.h.

References Bf, and Refs.

356  {
357  Refs=0; Bf=new char[MxLen+1]; strncpy(Bf, CStr, MxLen); Bf[MxLen]=0;}
const char * CStr() const
Definition: dt.h:381
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::TRStr ( const char *  CStr1,
const char *  CStr2 
)
inline

Definition at line 358 of file dt.h.

References Bf, and Refs.

358  {
359  Refs=0; int CStr1Len=int(strlen(CStr1)); Bf=new char[CStr1Len+int(strlen(CStr2))+1];
360  strcpy(Bf, CStr1); strcpy(Bf+CStr1Len, CStr2);}
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::TRStr ( const char &  Ch)
inline

Definition at line 361 of file dt.h.

References Bf, and Refs.

361  {
362  Refs=0; Bf=new char[1+1]; Bf[0]=Ch; Bf[1]=0;}
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::TRStr ( const char &  Ch1,
const char &  Ch2 
)
inline

Definition at line 363 of file dt.h.

References Bf, and Refs.

363  {
364  Refs=0; Bf=new char[2+1]; Bf[0]=Ch1; Bf[1]=Ch2; Bf[2]=0;}
char * Bf
Definition: dt.h:348
int Refs
Definition: dt.h:349
TRStr::~TRStr ( )
inline

Definition at line 365 of file dt.h.

References Assert, Bf, GetNullRStr(), and Refs.

365  {
366  Assert(((this!=GetNullRStr())&&(Refs==0))||((this==GetNullRStr())&&(Refs==1)));
367  delete[] Bf;}
char * Bf
Definition: dt.h:348
static TRStr * GetNullRStr()
Definition: dt.h:402
#define Assert(Cond)
Definition: bd.h:251
int Refs
Definition: dt.h:349

Here is the call graph for this function:

TRStr::TRStr ( TSIn SIn,
const bool &  IsSmall 
)
inlineexplicit

Definition at line 368 of file dt.h.

References Bf, TSIn::Load(), and Refs.

368  {
369  if (IsSmall){Refs=0; SIn.Load(Bf);}
370  else {Refs=0; int BfL; SIn.Load(BfL); SIn.Load(Bf, BfL, BfL);}}
char * Bf
Definition: dt.h:348
void Load(bool &Bool)
Definition: fl.h:84
int Refs
Definition: dt.h:349

Here is the call graph for this function:

Member Function Documentation

int TRStr::CmpI ( const char *  CStr1,
const char *  CStr2 
)
static

Definition at line 699 of file dt.cpp.

Referenced by TStr::CmpI(), and TStr::EqI().

699  {
700  if (!p){return r ? (*r ? -1 : 0) : 0;}
701  if (!r){return (*p ? 1 : 0);}
702  while (*p && *r){
703  int i=int(toupper(*p++))-int(toupper(*r++));
704  if (i!=0){return i;}
705  }
706  return int(toupper(*p++))-int(toupper(*r++));
707 }

Here is the caller graph for this function:

void TRStr::ConvUsFromYuAscii ( )

Definition at line 693 of file dt.cpp.

References Bf, TCh::GetUsFromYuAscii(), and Len().

Referenced by TStr::ConvUsFromYuAscii().

693  {
694  int StrLen=Len();
695  for (int ChN=0; ChN<StrLen; ChN++){
696  Bf[ChN]=TCh::GetUsFromYuAscii(Bf[ChN]);}
697 }
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384
static char GetUsFromYuAscii(const char &Ch)
Definition: dt.cpp:1885

Here is the call graph for this function:

Here is the caller graph for this function:

const char* TRStr::CStr ( ) const
inline

Definition at line 381 of file dt.h.

References Bf.

Referenced by TStr::ChangeChAll(), TStr::ConvUsFromYuAscii(), TStr::CStr(), TStr::operator!=(), TStr::operator()(), TStr::operator+=(), TStr::operator<(), TStr::operator==(), TStr::Optimize(), TStr::PutCh(), TStr::ToCap(), TStr::ToLc(), and TStr::ToUc().

381 {return Bf;}
char * Bf
Definition: dt.h:348

Here is the caller graph for this function:

char* TRStr::CStr ( )
inline

Definition at line 382 of file dt.h.

References Bf.

382 {return Bf;}
char * Bf
Definition: dt.h:348
bool TRStr::Empty ( ) const
inline

Definition at line 383 of file dt.h.

References Bf.

Referenced by TStr::Empty().

383 {return Bf[0]==0;}
char * Bf
Definition: dt.h:348

Here is the caller graph for this function:

char TRStr::GetCh ( const int &  ChN) const
inline

Definition at line 388 of file dt.h.

References Assert, Bf, and Len().

Referenced by TStr::GetCh(), and TStr::operator[]().

388  {
389  Assert((0<=ChN)&&(ChN<Len())); return Bf[ChN];}
char * Bf
Definition: dt.h:348
#define Assert(Cond)
Definition: bd.h:251
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

int TRStr::GetMemUsed ( ) const
inline

Definition at line 376 of file dt.h.

References Bf.

Referenced by TStr::GetMemUsed().

376 {return int(sizeof(int))+int(strlen(Bf));}
char * Bf
Definition: dt.h:348

Here is the caller graph for this function:

static TRStr* TRStr::GetNullRStr ( )
inlinestatic

Definition at line 402 of file dt.h.

References Assert, and Bf.

Referenced by TStr::Clr(), TStr::GetRStr(), TStr::Optimize(), TStr::TStr(), and ~TRStr().

402  {
403  static TRStr NullRStr; Assert(NullRStr.Bf!=NULL); return &NullRStr;}
char * Bf
Definition: dt.h:348
#define Assert(Cond)
Definition: bd.h:251
Definition: dt.h:346

Here is the caller graph for this function:

int TRStr::GetPrimHashCd ( ) const

Definition at line 709 of file dt.cpp.

References Bf, and TStrHashF_DJB::GetPrimHashCd().

Referenced by TStr::GetPrimHashCd().

709  {
711 }
char * Bf
Definition: dt.h:348
static int GetPrimHashCd(const char *p)
Definition: hash.h:1253

Here is the call graph for this function:

Here is the caller graph for this function:

int TRStr::GetSecHashCd ( ) const

Definition at line 713 of file dt.cpp.

References Bf, and TStrHashF_DJB::GetSecHashCd().

Referenced by TStr::GetSecHashCd().

713  {
715 }
static int GetSecHashCd(const char *p)
Definition: hash.h:1256
char * Bf
Definition: dt.h:348

Here is the call graph for this function:

Here is the caller graph for this function:

bool TRStr::IsLc ( ) const

Definition at line 672 of file dt.cpp.

References Bf, and Len().

Referenced by TStr::IsLc().

672  {
673  int StrLen=Len();
674  for (int ChN=0; ChN<StrLen; ChN++){
675  if (('A'<=Bf[ChN])&&(Bf[ChN]<='Z')){return false;}}
676  return true;
677 }
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

bool TRStr::IsUc ( ) const

Definition at line 660 of file dt.cpp.

References Bf, and Len().

Referenced by TStr::IsUc().

660  {
661  int StrLen=Len();
662  for (int ChN=0; ChN<StrLen; ChN++){
663  if (('a'<=Bf[ChN])&&(Bf[ChN]<='z')){return false;}}
664  return true;
665 }
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

int TRStr::Len ( ) const
inline

Definition at line 384 of file dt.h.

References Bf.

Referenced by ConvUsFromYuAscii(), GetCh(), IsLc(), IsUc(), TStr::Len(), PutCh(), ToCap(), ToLc(), ToUc(), and TRStr().

384 {return int(strlen(Bf));}
char * Bf
Definition: dt.h:348

Here is the caller graph for this function:

void TRStr::MkRef ( )
inline

Definition at line 378 of file dt.h.

References Refs.

Referenced by TStr::ChangeChAll(), TStr::Clr(), TStr::ConvUsFromYuAscii(), TStr::operator+=(), TStr::operator=(), TStr::Optimize(), TStr::PutCh(), TStr::ToCap(), TStr::ToLc(), TStr::ToUc(), and TStr::TStr().

378 {Refs++;}
int Refs
Definition: dt.h:349

Here is the caller graph for this function:

TRStr& TRStr::operator= ( const TRStr )
inline

Definition at line 375 of file dt.h.

References Fail.

375 {Fail; return *this;}
#define Fail
Definition: bd.h:238
void TRStr::PutCh ( const int &  ChN,
const char &  Ch 
)
inline

Definition at line 386 of file dt.h.

References Assert, Bf, and Len().

Referenced by TStr::PutCh().

386  {
387  Assert((0<=ChN)&&(ChN<Len())); Bf[ChN]=Ch;}
char * Bf
Definition: dt.h:348
#define Assert(Cond)
Definition: bd.h:251
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

void TRStr::Save ( TSOut SOut,
const bool &  IsSmall 
) const
inline

Definition at line 371 of file dt.h.

References Bf, and TSOut::Save().

Referenced by TStr::Save().

371  {
372  if (IsSmall){SOut.Save(Bf);}
373  else {int BfL=int(strlen(Bf)); SOut.Save(BfL); SOut.Save(Bf, BfL);}}
char * Bf
Definition: dt.h:348
void Save(const bool &Bool)
Definition: fl.h:173

Here is the call graph for this function:

Here is the caller graph for this function:

void TRStr::ToCap ( )

Definition at line 685 of file dt.cpp.

References Bf, and Len().

Referenced by TStr::ToCap().

685  {
686  int StrLen=Len();
687  if (StrLen>0){
688  Bf[0]=(char)toupper(Bf[0]);}
689  for (int ChN=1; ChN<StrLen; ChN++){
690  Bf[ChN]=(char)tolower(Bf[ChN]);}
691 }
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

void TRStr::ToLc ( )

Definition at line 679 of file dt.cpp.

References Bf, and Len().

Referenced by TStr::ToLc().

679  {
680  int StrLen=Len();
681  for (int ChN=0; ChN<StrLen; ChN++){
682  Bf[ChN]=(char)tolower(Bf[ChN]);}
683 }
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

void TRStr::ToUc ( )

Definition at line 667 of file dt.cpp.

References Bf, and Len().

Referenced by TStr::ToUc().

667  {
668  int StrLen=Len();
669  for (int ChN=0; ChN<StrLen; ChN++){
670  Bf[ChN]=(char)toupper(Bf[ChN]);}}
char * Bf
Definition: dt.h:348
int Len() const
Definition: dt.h:384

Here is the call graph for this function:

Here is the caller graph for this function:

void TRStr::UnRef ( )
inline

Definition at line 379 of file dt.h.

References Assert, and Refs.

Referenced by TStr::ChangeChAll(), TStr::Clr(), TStr::ConvUsFromYuAscii(), TStr::operator+=(), TStr::operator=(), TStr::Optimize(), TStr::PutCh(), TStr::ToCap(), TStr::ToLc(), TStr::ToUc(), and TStr::~TStr().

379 {Assert(Refs>0); if (--Refs==0){delete this;}}
#define Assert(Cond)
Definition: bd.h:251
int Refs
Definition: dt.h:349

Here is the caller graph for this function:

Member Data Documentation

int TRStr::Refs

Definition at line 349 of file dt.h.

Referenced by MkRef(), TRStr(), UnRef(), and ~TRStr().


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