SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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.

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.

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
TRStr::TRStr ( const char *  CStr)
inline

Definition at line 354 of file dt.h.

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.

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.

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.

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.

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.

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
TRStr::TRStr ( TSIn SIn,
const bool &  IsSmall 
)
inlineexplicit

Definition at line 368 of file dt.h.

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

Member Function Documentation

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

Definition at line 699 of file dt.cpp.

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 }
void TRStr::ConvUsFromYuAscii ( )

Definition at line 693 of file dt.cpp.

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
const char* TRStr::CStr ( ) const
inline

Definition at line 381 of file dt.h.

381 {return Bf;}
char * Bf
Definition: dt.h:348
char* TRStr::CStr ( )
inline

Definition at line 382 of file dt.h.

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

Definition at line 383 of file dt.h.

383 {return Bf[0]==0;}
char * Bf
Definition: dt.h:348
char TRStr::GetCh ( const int &  ChN) const
inline

Definition at line 388 of file dt.h.

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
int TRStr::GetMemUsed ( ) const
inline

Definition at line 376 of file dt.h.

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

Definition at line 402 of file dt.h.

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
int TRStr::GetPrimHashCd ( ) const

Definition at line 709 of file dt.cpp.

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

Definition at line 713 of file dt.cpp.

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

Definition at line 672 of file dt.cpp.

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
bool TRStr::IsUc ( ) const

Definition at line 660 of file dt.cpp.

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
int TRStr::Len ( ) const
inline

Definition at line 384 of file dt.h.

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

Definition at line 378 of file dt.h.

378 {Refs++;}
int Refs
Definition: dt.h:349
TRStr& TRStr::operator= ( const TRStr )
inline

Definition at line 375 of file dt.h.

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.

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
void TRStr::Save ( TSOut SOut,
const bool &  IsSmall 
) const
inline

Definition at line 371 of file dt.h.

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
void TRStr::ToCap ( )

Definition at line 685 of file dt.cpp.

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
void TRStr::ToLc ( )

Definition at line 679 of file dt.cpp.

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
void TRStr::ToUc ( )

Definition at line 667 of file dt.cpp.

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
void TRStr::UnRef ( )
inline

Definition at line 379 of file dt.h.

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

Member Data Documentation

char* TRStr::Bf

Definition at line 348 of file dt.h.

int TRStr::Refs

Definition at line 349 of file dt.h.


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