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
TRStr Class Reference

#include <dt.h>

List of all members.

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 331 of file dt.h.


Constructor & Destructor Documentation

TRStr::TRStr ( ) [inline]

Definition at line 336 of file dt.h.

{Refs=1; Bf=new char[0+1]; Bf[0]=0;}
TRStr::TRStr ( const int &  Len) [inline]

Definition at line 337 of file dt.h.

                       {
    IAssert(Len>=0); Refs=0; Bf=new char[Len+1]; Bf[Len]=0;}
TRStr::TRStr ( const char *  CStr) [inline]

Definition at line 339 of file dt.h.

                         {
    Refs=0; Bf=new char[strlen(CStr)+1]; strcpy(Bf, CStr);}
TRStr::TRStr ( const char *  CStr,
const int &  MxLen 
) [inline]

Definition at line 341 of file dt.h.

                                           {
    Refs=0; Bf=new char[MxLen+1]; strncpy(Bf, CStr, MxLen); Bf[MxLen]=0;}
TRStr::TRStr ( const char *  CStr1,
const char *  CStr2 
) [inline]

Definition at line 343 of file dt.h.

                                             {
    Refs=0; int CStr1Len=int(strlen(CStr1)); Bf=new char[CStr1Len+int(strlen(CStr2))+1];
    strcpy(Bf, CStr1); strcpy(Bf+CStr1Len, CStr2);}
TRStr::TRStr ( const char &  Ch) [inline]

Definition at line 346 of file dt.h.

                       {
    Refs=0; Bf=new char[1+1]; Bf[0]=Ch; Bf[1]=0;}
TRStr::TRStr ( const char &  Ch1,
const char &  Ch2 
) [inline]

Definition at line 348 of file dt.h.

                                         {
    Refs=0; Bf=new char[2+1]; Bf[0]=Ch1; Bf[1]=Ch2; Bf[2]=0;}
TRStr::~TRStr ( ) [inline]

Definition at line 350 of file dt.h.

          {
    Assert(((this!=GetNullRStr())&&(Refs==0))||((this==GetNullRStr())&&(Refs==1)));
    delete[] Bf;}
TRStr::TRStr ( TSIn SIn,
const bool &  IsSmall 
) [inline, explicit]

Definition at line 353 of file dt.h.

                                                {
    if (IsSmall){Refs=0; SIn.Load(Bf);}
    else {Refs=0; int BfL; SIn.Load(BfL); SIn.Load(Bf, BfL, BfL);}}

Member Function Documentation

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

Definition at line 675 of file dt.cpp.

                                           {
  if (!p){return r ? (*r ? -1 : 0) : 0;}
  if (!r){return (*p ? 1 : 0);}
  while (*p && *r){
    int i=int(toupper(*p++))-int(toupper(*r++));
    if (i!=0){return i;}
  }
  return int(toupper(*p++))-int(toupper(*r++));
}

Definition at line 669 of file dt.cpp.

                             {
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    Bf[ChN]=TCh::GetUsFromYuAscii(Bf[ChN]);}
}
const char* TRStr::CStr ( ) const [inline]

Definition at line 366 of file dt.h.

{return Bf;}
char* TRStr::CStr ( ) [inline]

Definition at line 367 of file dt.h.

{return Bf;}
bool TRStr::Empty ( ) const [inline]

Definition at line 368 of file dt.h.

{return Bf[0]==0;}
char TRStr::GetCh ( const int &  ChN) const [inline]

Definition at line 373 of file dt.h.

                                   {
    Assert((0<=ChN)&&(ChN<Len())); return Bf[ChN];}
int TRStr::GetMemUsed ( ) const [inline]

Definition at line 361 of file dt.h.

{return int(sizeof(int))+int(strlen(Bf));}
static TRStr* TRStr::GetNullRStr ( ) [inline, static]

Definition at line 387 of file dt.h.

                             {
    static TRStr NullRStr; Assert(NullRStr.Bf!=NULL); return &NullRStr;}
int TRStr::GetPrimHashCd ( ) const

Definition at line 685 of file dt.cpp.

int TRStr::GetSecHashCd ( ) const

Definition at line 689 of file dt.cpp.

bool TRStr::IsLc ( ) const

Definition at line 648 of file dt.cpp.

                       {
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    if (('A'<=Bf[ChN])&&(Bf[ChN]<='Z')){return false;}}
  return true;
}
bool TRStr::IsUc ( ) const

Definition at line 636 of file dt.cpp.

                       {
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    if (('a'<=Bf[ChN])&&(Bf[ChN]<='z')){return false;}}
  return true;
}
int TRStr::Len ( ) const [inline]

Definition at line 369 of file dt.h.

{return int(strlen(Bf));}
void TRStr::MkRef ( ) [inline]

Definition at line 363 of file dt.h.

{Refs++;}
TRStr& TRStr::operator= ( const TRStr ) [inline]

Definition at line 360 of file dt.h.

{Fail; return *this;}
void TRStr::PutCh ( const int &  ChN,
const char &  Ch 
) [inline]

Definition at line 371 of file dt.h.

                                            {
    Assert((0<=ChN)&&(ChN<Len())); Bf[ChN]=Ch;}
void TRStr::Save ( TSOut SOut,
const bool &  IsSmall 
) const [inline]

Definition at line 356 of file dt.h.

                                                    {
    if (IsSmall){SOut.Save(Bf);}
    else {int BfL=int(strlen(Bf)); SOut.Save(BfL); SOut.Save(Bf, BfL);}}
void TRStr::ToCap ( )

Definition at line 661 of file dt.cpp.

                 {
  int StrLen=Len();
  if (StrLen>0){
    Bf[0]=(char)toupper(Bf[0]);}
  for (int ChN=1; ChN<StrLen; ChN++){
    Bf[ChN]=(char)tolower(Bf[ChN]);}
}
void TRStr::ToLc ( )

Definition at line 655 of file dt.cpp.

                {
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    Bf[ChN]=(char)tolower(Bf[ChN]);}
}
void TRStr::ToUc ( )

Definition at line 643 of file dt.cpp.

                {
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    Bf[ChN]=(char)toupper(Bf[ChN]);}}
void TRStr::UnRef ( ) [inline]

Definition at line 364 of file dt.h.

{Assert(Refs>0); if (--Refs==0){delete this;}}

Member Data Documentation

char* TRStr::Bf

Definition at line 333 of file dt.h.

Definition at line 334 of file dt.h.


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