SNAP Library 2.1, User Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TStr Class Reference

#include <dt.h>

Inherited by TTypeNm< Type >.

List of all members.

Public Member Functions

 TStr ()
 TStr (const TStr &Str)
 TStr (const TChA &ChA)
 TStr (const TSStr &SStr)
 TStr (const char *CStr)
 TStr (const char &Ch)
 TStr (const TMem &Mem)
 TStr (const PSIn &SIn)
 ~TStr ()
 TStr (TSIn &SIn, const bool &IsSmall=false)
void Load (TSIn &SIn, const bool &IsSmall=false)
void Save (TSOut &SOut, const bool &IsSmall=false) const
void LoadXml (const PXmlTok &XmlTok, const TStr &Nm)
void SaveXml (TSOut &SOut, const TStr &Nm) const
TStroperator= (const TStr &Str)
TStroperator= (const TChA &ChA)
TStroperator= (const char *CStr)
TStroperator= (const char &Ch)
TStroperator+= (const TStr &Str)
TStroperator+= (const char *CStr)
bool operator== (const TStr &Str) const
bool operator== (const char *CStr) const
bool operator!= (const char *CStr) const
bool operator< (const TStr &Str) const
char operator[] (const int &ChN) const
int GetMemUsed () const
char * operator() ()
const char * operator() () const
char * CStr ()
const char * CStr () const
void PutCh (const int &ChN, const char &Ch)
char GetCh (const int &ChN) const
char LastCh () const
void Clr ()
int Len () const
bool Empty () const
bool IsUc () const
TStrToUc ()
TStr GetUc () const
int CmpI (const TStr &Str) const
bool EqI (const TStr &Str) const
bool IsLc () const
TStrToLc ()
TStr GetLc () const
TStrToCap ()
TStr GetCap () const
TStrToTrunc ()
TStr GetTrunc () const
TStrConvUsFromYuAscii ()
TStr GetUsFromYuAscii () const
TStrToHex ()
TStr GetHex () const
TStrFromHex ()
TStr GetFromHex () const
TStr GetSubStr (const int &BChN, const int &EChN) const
TStr GetSubStr (const int &BChN) const
void InsStr (const int &BChN, const TStr &Str)
void DelChAll (const char &Ch)
void DelSubStr (const int &BChN, const int &EChN)
bool DelStr (const TStr &Str)
TStr LeftOf (const char &SplitCh) const
TStr LeftOfLast (const char &SplitCh) const
TStr RightOf (const char &SplitCh) const
TStr RightOfLast (const char &SplitCh) const
void SplitOnCh (TStr &LStr, const char &SplitCh, TStr &RStr) const
void SplitOnLastCh (TStr &LStr, const char &SplitCh, TStr &RStr) const
void SplitOnAllCh (const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
void SplitOnAllAnyCh (const TStr &SplitChStr, TStrV &StrV, const bool &SkipEmpty=true) const
void SplitOnWs (TStrV &StrV) const
void SplitOnNonAlNum (TStrV &StrV) const
void SplitOnStr (const TStr &SplitStr, TStrV &StrV) const
void SplitOnStr (TStr &LeftStr, const TStr &MidStr, TStr &RightStr) const
TStr Mid (const int &BChN, const int &Chs) const
TStr Mid (const int &BChN) const
TStr Left (const int &EChN) const
TStr Right (const int &BChN) const
TStr Slice (int BChN, int EChNP1) const
TStr operator() (const int &BChN, const int &EChNP1) const
int CountCh (const char &Ch, const int &BChN=0) const
int SearchCh (const char &Ch, const int &BChN=0) const
int SearchChBack (const char &Ch, int BChN=-1) const
int SearchStr (const TStr &Str, const int &BChN=0) const
bool IsChIn (const char &Ch) const
bool IsStrIn (const TStr &Str) const
bool IsPrefix (const char *Str) const
bool IsPrefix (const TStr &Str) const
bool IsSuffix (const char *Str) const
bool IsSuffix (const TStr &Str) const
int ChangeCh (const char &SrcCh, const char &DstCh, const int &BChN=0)
int ChangeChAll (const char &SrcCh, const char &DstCh)
int ChangeStr (const TStr &SrcStr, const TStr &DstStr, const int &BChN=0)
int ChangeStrAll (const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
TStr Reverse () const
int GetPrimHashCd () const
int GetSecHashCd () const
bool IsBool (bool &Val) const
bool IsInt (const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
bool IsInt (int &Val) const
bool IsInt () const
int GetInt () const
int GetInt (const int &DfVal) const
bool IsUInt (const bool &Check, const uint &MnVal, const uint &MxVal, uint &Val) const
bool IsUInt (uint &Val) const
bool IsUInt () const
uint GetUInt () const
uint GetUInt (const uint &DfVal) const
bool IsInt64 (const bool &Check, const int64 &MnVal, const int64 &MxVal, int64 &Val) const
bool IsInt64 (int64 &Val) const
bool IsInt64 () const
int64 GetInt64 () const
int64 GetInt64 (const int64 &DfVal) const
bool IsUInt64 (const bool &Check, const uint64 &MnVal, const uint64 &MxVal, uint64 &Val) const
bool IsUInt64 (uint64 &Val) const
bool IsUInt64 () const
uint64 GetUInt64 () const
uint64 GetUInt64 (const uint64 &DfVal) const
bool IsHexInt (const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
bool IsHexInt (int &Val) const
bool IsHexInt () const
int GetHexInt () const
int GetHexInt (const int &DfVal) const
bool IsHexInt64 (const bool &Check, const int64 &MnVal, const int64 &MxVal, int64 &Val) const
bool IsHexInt64 (int64 &Val) const
bool IsHexInt64 () const
int64 GetHexInt64 () const
int64 GetHexInt64 (const int64 &DfVal) const
bool IsFlt (const bool &Check, const double &MnVal, const double &MxVal, double &Val, const char &DecDelimCh='.') const
bool IsFlt (double &Val) const
bool IsFlt () const
double GetFlt () const
double GetFlt (const double &DfVal) const
bool IsWord (const bool &WsPrefixP=true, const bool &FirstUcAllowedP=true) const
bool IsWs () const
bool IsWcMatch (const int &StrBChN, const TStr &WcStr, const int &WcStrBChN, TStrV &StarStrV, const char &StarCh='*', const char &QuestCh='?') const
bool IsWcMatch (const TStr &WcStr, TStrV &StarStrV, const char &StarCh='*', const char &QuestCh='?') const
bool IsWcMatch (const TStr &WcStr, const char &StarCh, const char &QuestCh) const
bool IsWcMatch (const TStr &WcStr, const int &StarStrN, TStr &StarStr) const
bool IsWcMatch (const TStr &WcStr) const
TStr GetWcMatch (const TStr &WcStr, const int &StarStrN=0) const
TStr GetFPath () const
TStr GetFBase () const
TStr GetFMid () const
TStr GetFExt () const
void SaveTxt (const PSOut &SOut) const
void SaveTxt (const TStr &FNm) const
TStr GetStr () const
char * GetCStr () const

Static Public Member Functions

static TStr GetNrFPath (const TStr &FPath)
static TStr GetNrFMid (const TStr &FMid)
static TStr GetNrFExt (const TStr &FExt)
static TStr GetNrNumFExt (const int &FExtN)
static TStr GetNrFNm (const TStr &FNm)
static TStr GetNrAbsFPath (const TStr &FPath, const TStr &BaseFPath=TStr())
static bool IsAbsFPath (const TStr &FPath)
static TStr PutFExt (const TStr &FNm, const TStr &FExt)
static TStr PutFExtIfEmpty (const TStr &FNm, const TStr &FExt)
static TStr PutFBase (const TStr &FNm, const TStr &FBase)
static TStr PutFBaseIfEmpty (const TStr &FNm, const TStr &FBase)
static TStr AddToFMid (const TStr &FNm, const TStr &ExtFMid)
static TStr GetNumFNm (const TStr &FNm, const int &Num)
static TStr GetFNmStr (const TStr &Str, const bool &AlNumOnlyP=true)
static TStr LoadTxt (const PSIn &SIn)
static TStr LoadTxt (const TStr &FNm)
static TStrGetChStr (const char &Ch)
static TStrGetDChStr (const char &Ch1, const char &Ch2)
static TStr GetStr (const TStr &Str, const char *FmtStr)
static TStr GetStr (const TStr &Str, const TStr &FmtStr)
static TStr GetStr (const TStrV &StrV, const TStr &DelimiterStr)
static TStr Fmt (const char *FmtStr,...)
static TStr GetSpaceStr (const int &Spaces)
static TStr MkClone (const TStr &Str)
static TStr GetNullStr ()

Private Member Functions

 TStr (const char &Ch, bool)
 TStr (const char &Ch1, const char &Ch2, bool)
void Optimize ()

Static Private Member Functions

static TRStrGetRStr (const char *CStr)

Private Attributes

TRStrRStr

Friends

TStr operator+ (const TStr &LStr, const TStr &RStr)
TStr operator+ (const TStr &LStr, const char *RCStr)

Detailed Description

Definition at line 412 of file dt.h.


Constructor & Destructor Documentation

TStr::TStr ( const char &  Ch,
bool   
) [inline, private]

Definition at line 416 of file dt.h.

                            {
    RStr=new TRStr(Ch); RStr->MkRef();}
TStr::TStr ( const char &  Ch1,
const char &  Ch2,
bool   
) [inline, private]

Definition at line 418 of file dt.h.

                                              {
    RStr=new TRStr(Ch1, Ch2); RStr->MkRef();}
TStr::TStr ( ) [inline]

Definition at line 423 of file dt.h.

TStr::TStr ( const TStr Str) [inline]

Definition at line 424 of file dt.h.

{RStr=Str.RStr; RStr->MkRef();}
TStr::TStr ( const TChA ChA) [inline]

Definition at line 425 of file dt.h.

{RStr=GetRStr(ChA.CStr()); RStr->MkRef();}
TStr::TStr ( const TSStr SStr) [inline]

Definition at line 426 of file dt.h.

{RStr=GetRStr(SStr.CStr()); RStr->MkRef();}
TStr::TStr ( const char *  CStr) [inline]

Definition at line 427 of file dt.h.

TStr::TStr ( const char &  Ch) [inline, explicit]

Definition at line 428 of file dt.h.

TStr::TStr ( const TMem Mem) [inline]

Definition at line 429 of file dt.h.

                       {
    RStr=new TRStr(Mem.Len()); RStr->MkRef();
    memcpy(CStr(), Mem(), Mem.Len()); Optimize();}
TStr::TStr ( const PSIn SIn) [inline, explicit]

Definition at line 432 of file dt.h.

                                {
    int SInLen=SIn->Len(); RStr=new TRStr(SInLen); RStr->MkRef();
    SIn->GetBf(CStr(), SInLen); Optimize();}
TStr::~TStr ( ) [inline]

Definition at line 435 of file dt.h.

{RStr->UnRef();}
TStr::TStr ( TSIn SIn,
const bool &  IsSmall = false 
) [inline, explicit]

Definition at line 436 of file dt.h.

                                                     :
    RStr(new TRStr(SIn, IsSmall)){RStr->MkRef(); Optimize();}

Member Function Documentation

TStr TStr::AddToFMid ( const TStr FNm,
const TStr ExtFMid 
) [static]

Definition at line 1523 of file dt.cpp.

                                                        {
  return FNm.GetFPath()+FNm.GetFMid()+ExtFMid+FNm.GetFExt();
}
int TStr::ChangeCh ( const char &  SrcCh,
const char &  DstCh,
const int &  BChN = 0 
)

Definition at line 1107 of file dt.cpp.

                                                                       {
  int ChN=SearchCh(SrcCh, BChN);
  if (ChN!=-1){PutCh(ChN, DstCh);}
  return ChN;
}
int TStr::ChangeChAll ( const char &  SrcCh,
const char &  DstCh 
)

Definition at line 1113 of file dt.cpp.

                                                         {
  int FirstChN=SearchCh(SrcCh);
  if (FirstChN==-1){
    return 0;
  } else {
    TRStr* NewRStr=new TRStr(RStr->CStr());
    RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
    char* ThisBf=CStr(); int StrLen=Len(); int Changes=0;
    for (int ChN=FirstChN; ChN<StrLen; ChN++){
      // slow: if (GetCh(ChN)==SrcCh){RStr->PutCh(ChN, DstCh); Changes++;}
      if (ThisBf[ChN]==SrcCh){ThisBf[ChN]=DstCh; Changes++;}
    }
    Optimize();
    return Changes;
  }
}
int TStr::ChangeStr ( const TStr SrcStr,
const TStr DstStr,
const int &  BChN = 0 
)

Definition at line 1130 of file dt.cpp.

                                                                          {
  int ChN=SearchStr(SrcStr, BChN);
  if (ChN==-1){
    return -1;
  } else {
    DelSubStr(ChN, ChN+SrcStr.Len()-1);
    InsStr(ChN, DstStr);
    return ChN;
  }
}
int TStr::ChangeStrAll ( const TStr SrcStr,
const TStr DstStr,
const bool &  FromStartP = false 
)

Definition at line 1141 of file dt.cpp.

                                                                                    {
  const int DstStrLen=DstStr.Len();
  int Changes=0-1; int BChN=0-DstStrLen;
  do {
    Changes++;
    if (FromStartP){BChN=0-DstStrLen;}
    BChN+=DstStrLen;
    BChN=ChangeStr(SrcStr, DstStr, BChN);
  } while (BChN!=-1);
  return Changes;
}
void TStr::Clr ( ) [inline]

Definition at line 486 of file dt.h.

int TStr::CmpI ( const TStr Str) const [inline]

Definition at line 494 of file dt.h.

{return TRStr::CmpI(CStr(), Str.CStr());}

Definition at line 779 of file dt.cpp.

                             {
  TRStr* NewRStr=new TRStr(RStr->CStr()); NewRStr->ConvUsFromYuAscii();
  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
  Optimize(); return *this;
}
int TStr::CountCh ( const char &  Ch,
const int &  BChN = 0 
) const

Definition at line 1033 of file dt.cpp.

                                                       {
  const int ThisLen=Len();
  const char* ThisBf=CStr();
  int Chs=0;
  for (int ChN=TInt::GetMx(BChN, 0); ChN<ThisLen; ChN++){
    if (ThisBf[ChN]==Ch){Chs++;}
  }
  return Chs;
}
char* TStr::CStr ( ) [inline]

Definition at line 476 of file dt.h.

{return RStr->CStr();}
const char* TStr::CStr ( ) const [inline]

Definition at line 477 of file dt.h.

{return RStr->CStr();}
void TStr::DelChAll ( const char &  Ch)

Definition at line 840 of file dt.cpp.

                                 {
  TChA ChA(*this);
  int ChN=ChA.SearchCh(Ch);
  while (ChN!=-1){
    ChA.Del(ChN);
    ChN=ChA.SearchCh(Ch);
  }
  *this=ChA;
}
bool TStr::DelStr ( const TStr Str)

Definition at line 863 of file dt.cpp.

                                {
  int ChN=SearchStr(Str);
  if (ChN==-1){
    return false;
  } else {
    DelSubStr(ChN, ChN+Str.Len()-1);
    return true;
  }
}
void TStr::DelSubStr ( const int &  BChN,
const int &  EChN 
)

Definition at line 850 of file dt.cpp.

                                                      {
  int BChN=TInt::GetMx(_BChN, 0);
  int EChN=TInt::GetMn(_EChN, Len()-1);
  int Chs=Len()-(EChN-BChN+1);
  if (Chs==0){Clr();}
  else if (Chs<Len()){
    char* Bf=new char[Chs+1]; strncpy(Bf, CStr(), BChN);
    strncpy(Bf+BChN, CStr()+EChN+1, Len()-EChN-1); Bf[Chs]=0;
    TStr Str(Bf); delete[] Bf;
    *this=Str;
  }
}
bool TStr::Empty ( ) const [inline]

Definition at line 488 of file dt.h.

{return RStr->Empty();}
bool TStr::EqI ( const TStr Str) const [inline]

Definition at line 495 of file dt.h.

{return TRStr::CmpI(CStr(), Str.CStr())==0;}
TStr TStr::Fmt ( const char *  FmtStr,
  ... 
) [static]

Definition at line 1599 of file dt.cpp.

                                     {
  char Bf[10*1024];
  va_list valist;
  va_start(valist, FmtStr);
  const int RetVal=vsnprintf(Bf, 10*1024-2, FmtStr, valist);
  va_end(valist);
  return RetVal!=-1 ? TStr(Bf) : TStr::GetNullStr();
}

Definition at line 798 of file dt.cpp.

                   {
  int StrLen=Len(); IAssert(StrLen%2==0);
  TChA ChA; int ChN=0;
  while (ChN<StrLen){
    char MshCh=RStr->Bf[ChN]; ChN++;
    char LshCh=RStr->Bf[ChN]; ChN++;
    uchar Ch=uchar(TCh::GetHex(MshCh)*16+TCh::GetHex(LshCh));
    ChA+=Ch;
  }
  *this=ChA;
  return *this;
}
TStr TStr::GetCap ( ) const [inline]

Definition at line 502 of file dt.h.

{return TStr(*this).ToCap();}
char TStr::GetCh ( const int &  ChN) const [inline]

Definition at line 483 of file dt.h.

{return RStr->GetCh(ChN);}
TStr & TStr::GetChStr ( const char &  Ch) [static]

Definition at line 1551 of file dt.cpp.

                                  {
  static char MnCh=char(CHAR_MIN);
  static char MxCh=char(CHAR_MAX);
  static int Chs=int(MxCh)-int(MnCh)+1;
  static TStrV ChStrV;
  if (ChStrV.Empty()){
    ChStrV.Gen(Chs);
    for (int ChN=0; ChN<Chs; ChN++){
      ChStrV[ChN]=TStr(char(MnCh+ChN), true);}
  }
  return ChStrV[int(Ch-MnCh)];
}
char* TStr::GetCStr ( ) const [inline]

Definition at line 686 of file dt.h.

                        {
    char* Bf=new char[Len()+1]; strcpy(Bf, CStr()); return Bf;}
TStr & TStr::GetDChStr ( const char &  Ch1,
const char &  Ch2 
) [static]

Definition at line 1564 of file dt.cpp.

                                                     {
  Fail; // temporary
  static TStrVV DChStrVV;
  if (DChStrVV.Empty()){
    DChStrVV.Gen(TCh::Vals, TCh::Vals);
    for (int Ch1N=0; Ch1N<TCh::Vals; Ch1N++){
      for (int Ch2N=0; Ch2N<TCh::Vals; Ch2N++){
        DChStrVV.At(Ch1N, Ch2N)=
         TStr(char(TCh::Mn+Ch1N), char(TCh::Mn+Ch2N), true);
      }
    }
  }
  return DChStrVV.At(int(Ch1-TCh::Mn), int(Ch2-TCh::Mn));
}
TStr TStr::GetFBase ( ) const

Definition at line 1396 of file dt.cpp.

                          {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=ThisLen-1;
  while ((ChN>=0)&&(ThisBf[ChN]!='/')&&(ThisBf[ChN]!='\\')){ChN--;}
  return GetSubStr(ChN+1, ThisLen);
}
TStr TStr::GetFExt ( ) const

Definition at line 1421 of file dt.cpp.

                         {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=ThisLen-1;
  while ((ChN>=0)&&(ThisBf[ChN]!='/')&&(ThisBf[ChN]!='\\')&&
   (ThisBf[ChN]!='.')){ChN--;}
  if ((ChN>=0)&&(ThisBf[ChN]=='.')){return GetSubStr(ChN, Len());}
  else {return TStr();}
}
double TStr::GetFlt ( ) const [inline]

Definition at line 629 of file dt.h.

                        {
    double Val; IAssert(IsFlt(false, 0, 0, Val)); return Val;}
double TStr::GetFlt ( const double &  DfVal) const [inline]

Definition at line 631 of file dt.h.

                                           {
    double Val; if (IsFlt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
TStr TStr::GetFMid ( ) const

Definition at line 1403 of file dt.cpp.

                         {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=ThisLen-1;
  while ((ChN>=0)&&(ThisBf[ChN]!='/')&&(ThisBf[ChN]!='\\')&&(ThisBf[ChN]!='.')){
    ChN--;}
  if (ChN<0){
    return *this;
  } else {
    if (ThisBf[ChN]=='.'){
      int EChN= --ChN;
      while ((ChN>=0)&&(ThisBf[ChN]!='/')&&(ThisBf[ChN]!='\\')){ChN--;}
      return GetSubStr(ChN+1, EChN);
    } else {
      return GetSubStr(ChN+1, ThisLen);
    }
  }
}
TStr TStr::GetFNmStr ( const TStr Str,
const bool &  AlNumOnlyP = true 
) [static]

Definition at line 1531 of file dt.cpp.

                                                           {
  TChA FNm=Str;
  for (int ChN=0; ChN<FNm.Len(); ChN++){
    uchar Ch=FNm[ChN];
    if (AlNumOnlyP){
      if (
       (('0'<=Ch)&&(Ch<='9'))||
       (('A'<=Ch)&&(Ch<='Z'))||
       (('a'<=Ch)&&(Ch<='z'))||
       (Ch=='-')||(Ch=='_')){}
      else {Ch='_';}
    } else {
      if ((Ch<=' ')||(Ch=='/')||(Ch=='\\')||(Ch==':')||(Ch=='.')){
        Ch='_';}
    }
    FNm.PutCh(ChN, Ch);
  }
  return FNm;
}
TStr TStr::GetFPath ( ) const

Definition at line 1389 of file dt.cpp.

                          {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=ThisLen-1;
  while ((ChN>=0)&&(ThisBf[ChN]!='/')&&(ThisBf[ChN]!='\\')){ChN--;}
  return GetSubStr(0, ChN);
}
TStr TStr::GetFromHex ( ) const [inline]

Definition at line 514 of file dt.h.

{return TStr(*this).FromHex();}
TStr TStr::GetHex ( ) const [inline]

Definition at line 512 of file dt.h.

{return TStr(*this).ToHex();}
int TStr::GetHexInt ( ) const [inline]

Definition at line 612 of file dt.h.

                        {
    int Val; IAssert(IsHexInt(false, 0, 0, Val)); return Val;}
int TStr::GetHexInt ( const int &  DfVal) const [inline]

Definition at line 614 of file dt.h.

                                        {
    int Val; if (IsHexInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
int64 TStr::GetHexInt64 ( ) const [inline]

Definition at line 620 of file dt.h.

                            {
    int64 Val; IAssert(IsHexInt64(false, 0, 0, Val)); return Val;}
int64 TStr::GetHexInt64 ( const int64 DfVal) const [inline]

Definition at line 622 of file dt.h.

                                              {
    int64 Val; if (IsHexInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
int TStr::GetInt ( ) const [inline]

Definition at line 579 of file dt.h.

{int Val; IAssertR(IsInt(false, 0, 0, Val), *this); return Val;}
int TStr::GetInt ( const int &  DfVal) const [inline]

Definition at line 580 of file dt.h.

                                     {
    int Val; if (IsInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
int64 TStr::GetInt64 ( ) const [inline]

Definition at line 595 of file dt.h.

                         {
    int64 Val; IAssert(IsInt64(false, 0, 0, Val)); return Val;}
int64 TStr::GetInt64 ( const int64 DfVal) const [inline]

Definition at line 597 of file dt.h.

                                           {
    int64 Val; if (IsInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
TStr TStr::GetLc ( ) const [inline]

Definition at line 499 of file dt.h.

{return TStr(*this).ToLc();}
int TStr::GetMemUsed ( ) const [inline]

Definition at line 472 of file dt.h.

{return int(sizeof(TRStr*)+RStr->GetMemUsed());}
TStr TStr::GetNrAbsFPath ( const TStr FPath,
const TStr BaseFPath = TStr() 
) [static]

Definition at line 1471 of file dt.cpp.

                                                                {
  TStr NrBaseFPath;
  if (BaseFPath.Empty()){
    NrBaseFPath=GetNrFPath(TDir::GetCurDir());
  } else {
    NrBaseFPath=GetNrFPath(BaseFPath);
  }
  IAssert(IsAbsFPath(NrBaseFPath));
  TStr NrFPath=GetNrFPath(FPath);
  TStr NrAbsFPath;
  if (IsAbsFPath(NrFPath)){
    NrAbsFPath=NrFPath;
  } else {
    NrAbsFPath=GetNrFPath(NrBaseFPath+NrFPath);
  }
  NrAbsFPath.ChangeStrAll("/./", "/");
  NrAbsFPath.ChangeStrAll("\\.\\", "\\");
  return NrAbsFPath;
}
TStr TStr::GetNrFExt ( const TStr FExt) [static]

Definition at line 1455 of file dt.cpp.

                                    {
  if (FExt.Empty()||(FExt[0]=='.')){return FExt;}
  else {return TStr(".")+FExt;}
}
TStr TStr::GetNrFMid ( const TStr FMid) [static]

Definition at line 1445 of file dt.cpp.

                                    {
  TChA NrFMid;
  int FMidLen=FMid.Len();
  for (int ChN=0; ChN<FMidLen; ChN++){
    char Ch=FMid[ChN];
    if (TCh::IsAlNum(Ch)){NrFMid+=Ch;} else {NrFMid+='_';}
  }
  return NrFMid;
}
TStr TStr::GetNrFNm ( const TStr FNm) [static]

Definition at line 1467 of file dt.cpp.

                                  {
  return GetNrFPath(FNm.GetFPath())+FNm.GetFMid()+GetNrFExt(FNm.GetFExt());
}
TStr TStr::GetNrFPath ( const TStr FPath) [static]

Definition at line 1430 of file dt.cpp.

                                      {
  TChA NrFPath(FPath.Len()+4); NrFPath+=FPath;
  NrFPath.ChangeCh('\\', '/');
  if (NrFPath.Empty()){NrFPath="./";}
  if ((NrFPath.Len()>=2)&&isalpha(NrFPath[0])&&(NrFPath[1]==':')){
    if (NrFPath.Len()==2){NrFPath+="./";}
    if ((NrFPath[2]!='.')&&(NrFPath[2]!='/')){NrFPath.Ins(2, "./");}
    if (NrFPath[NrFPath.Len()-1]!='/'){NrFPath+="/";}
  } else {
    if ((NrFPath[0]!='.')&&(NrFPath[0]!='/')){NrFPath.Ins(0, "./");}
    if (NrFPath[NrFPath.Len()-1]!='/'){NrFPath+="/";}
  }
  return NrFPath;
}
TStr TStr::GetNrNumFExt ( const int &  FExtN) [static]

Definition at line 1460 of file dt.cpp.

                                       {
  TStr FExtNStr=TInt::GetStr(FExtN);
  while (FExtNStr.Len()<3){
    FExtNStr=TStr("0")+FExtNStr;}
  return FExtNStr;
}
TStr TStr::GetNullStr ( ) [static]

Definition at line 1626 of file dt.cpp.

                     {
  static TStr NullStr="";
  return NullStr;
}
TStr TStr::GetNumFNm ( const TStr FNm,
const int &  Num 
) [static]

Definition at line 1527 of file dt.cpp.

                                                   {
  return FNm.GetFPath()+FNm.GetFMid()+TInt::GetStr(Num, "%03d")+FNm.GetFExt();
}
int TStr::GetPrimHashCd ( ) const [inline]

Definition at line 570 of file dt.h.

{return RStr->GetPrimHashCd();}
TRStr * TStr::GetRStr ( const char *  CStr) [static, private]

Definition at line 719 of file dt.cpp.

                                    {
  int CStrLen;
  if (CStr==NULL){CStrLen=0;} else {CStrLen=int(strlen(CStr));}
  if (CStrLen==0){return TRStr::GetNullRStr();}
  // next lines are not multi-threading safe
  //else if (CStrLen==1){return GetChStr(CStr[0]).RStr;}
  //else if (CStrLen==2){return GetDChStr(CStr[0], CStr[1]).RStr;}
  else {return new TRStr(CStr);}
}
int TStr::GetSecHashCd ( ) const [inline]

Definition at line 571 of file dt.h.

{return RStr->GetSecHashCd();}
TStr TStr::GetSpaceStr ( const int &  Spaces) [static]

Definition at line 1608 of file dt.cpp.

                                       {
  static TStrV SpaceStrV;
  if (SpaceStrV.Len()==0){
    for (int SpaceStrN=0; SpaceStrN<10; SpaceStrN++){
      TChA SpaceChA;
      for (int ChN=0; ChN<SpaceStrN; ChN++){SpaceChA+=' ';}
      SpaceStrV.Add(SpaceChA);
    }
  }
  if ((0<=Spaces)&&(Spaces<SpaceStrV.Len())){
    return SpaceStrV[Spaces];
  } else {
    TChA SpaceChA;
    for (int ChN=0; ChN<Spaces; ChN++){SpaceChA+=' ';}
    return SpaceChA;
  }
}
TStr TStr::GetStr ( ) const [inline]

Definition at line 679 of file dt.h.

{return *this;}
TStr TStr::GetStr ( const TStr Str,
const char *  FmtStr 
) [static]

Definition at line 1579 of file dt.cpp.

                                                    {
  if (FmtStr==NULL){
    return Str;
  } else {
    char Bf[1000];
    sprintf(Bf, FmtStr, Str.CStr());
    return TStr(Bf);
  }
}
static TStr TStr::GetStr ( const TStr Str,
const TStr FmtStr 
) [inline, static]

Definition at line 681 of file dt.h.

                                                         {
    return GetStr(Str, FmtStr.CStr());}
TStr TStr::GetStr ( const TStrV StrV,
const TStr DelimiterStr 
) [static]

Definition at line 1589 of file dt.cpp.

                                                            {
  if (StrV.Empty()){return TStr();}
  TChA ResStr=StrV[0];
  for (int StrN=1; StrN<StrV.Len(); StrN++){
    ResStr+=DelimiterStr;
    ResStr+=StrV[StrN];
  }
  return ResStr;
}
TStr TStr::GetSubStr ( const int &  BChN,
const int &  EChN 
) const

Definition at line 811 of file dt.cpp.

                                                             {
  int StrLen=Len();
  int BChN=TInt::GetMx(_BChN, 0);
  int EChN=TInt::GetMn(_EChN, StrLen-1);
  int Chs=EChN-BChN+1;
  if (Chs<=0){return TStr();}
  else if (Chs==StrLen){return *this;}
  else {
    char* Bf=new char[Chs+1]; strncpy(Bf, CStr()+BChN, Chs); Bf[Chs]=0;
    TStr Str(Bf); delete[] Bf;
    return Str;
  }
}
TStr TStr::GetSubStr ( const int &  BChN) const [inline]

Definition at line 517 of file dt.h.

{ return GetSubStr(BChN, Len()-1); }
TStr TStr::GetTrunc ( ) const [inline]

Definition at line 506 of file dt.h.

{return TStr(*this).ToTrunc();}
TStr TStr::GetUc ( ) const [inline]

Definition at line 493 of file dt.h.

{return TStr(*this).ToUc();}
uint TStr::GetUInt ( ) const [inline]

Definition at line 587 of file dt.h.

{uint Val; IAssert(IsUInt(false, 0, 0, Val)); return Val;}
uint TStr::GetUInt ( const uint DfVal) const [inline]

Definition at line 588 of file dt.h.

                                        {
    uint Val; if (IsUInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
uint64 TStr::GetUInt64 ( ) const [inline]

Definition at line 604 of file dt.h.

                           {
    uint64 Val; IAssert(IsUInt64(false, 0, 0, Val)); return Val;}
uint64 TStr::GetUInt64 ( const uint64 DfVal) const [inline]

Definition at line 606 of file dt.h.

                                              {
    uint64 Val; if (IsUInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
TStr TStr::GetUsFromYuAscii ( ) const [inline]

Definition at line 509 of file dt.h.

{return TStr(*this).ConvUsFromYuAscii();}
TStr TStr::GetWcMatch ( const TStr WcStr,
const int &  StarStrN = 0 
) const

Definition at line 1379 of file dt.cpp.

                                                                  {
  TStrV StarStrV;
  if (IsWcMatch(WcStr, StarStrV)&&(StarStrV.Len()>=StarStrN)){
    IAssert(StarStrN>=0);
    return StarStrV[StarStrV.Len()-StarStrN-1];
  } else {
    return "";
  }
}
void TStr::InsStr ( const int &  BChN,
const TStr Str 
)

Definition at line 825 of file dt.cpp.

                                                 {
  int ThisLen=Len();
  IAssert((0<=BChN)&&(BChN<=ThisLen));
  TStr NewStr;
  if (BChN==0){
    NewStr=Str+*this;
  } else
  if (BChN==ThisLen){
    NewStr=*this+Str;
  } else {
    NewStr=GetSubStr(0, BChN-1)+Str+GetSubStr(BChN, ThisLen-1);
  }
  *this=NewStr;
}
bool TStr::IsAbsFPath ( const TStr FPath) [static]

Definition at line 1491 of file dt.cpp.

                                      {
  if ((FPath.Len()>=3)&&isalpha(FPath[0])&&(FPath[1]==':')&&
   ((FPath[2]=='/')||(FPath[2]=='\\'))){
    return true;
  }
  return false;
}
bool TStr::IsBool ( bool &  Val) const

Definition at line 1153 of file dt.cpp.

                                 {
  if (operator==("T")){Val=true; return true;}
  else if (operator==("F")){Val=false; return true;}
  else {return false;}
}
bool TStr::IsChIn ( const char &  Ch) const [inline]

Definition at line 554 of file dt.h.

{return SearchCh(Ch)!=-1;}
bool TStr::IsFlt ( const bool &  Check,
const double &  MnVal,
const double &  MxVal,
double &  Val,
const char &  DecDelimCh = '.' 
) const

Definition at line 1265 of file dt.cpp.

                                            {
  // parsing format {ws} [+/-] +{d} ([.]{d}) ([E|e] [+/-] +{d})
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if ((Ch()=='+')||(Ch()=='-')){Ch.GetCh();}
  if (!TCh::IsNum(Ch())&&Ch()!=DecDelimCh){return false;}
  while (TCh::IsNum(Ch.GetCh())){}
  if (Ch()==DecDelimCh){
    Ch.GetCh();
    while (TCh::IsNum(Ch.GetCh())){}
  }
  if ((Ch()=='e')||(Ch()=='E')){
    Ch.GetCh();
    if ((Ch()=='+')||(Ch()=='-')){Ch.GetCh();}
    if (!TCh::IsNum(Ch())){return false;}
    while (TCh::IsNum(Ch.GetCh())){}
  }
  if (!Ch.Eof()){return false;}
  double _Val=atof(CStr());
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){
    return false;
  } else {
    Val=_Val; return true;
  }
}
bool TStr::IsFlt ( double &  Val) const [inline]

Definition at line 627 of file dt.h.

{return IsFlt(false, 0, 0, Val);}
bool TStr::IsFlt ( ) const [inline]

Definition at line 628 of file dt.h.

{double Val; return IsFlt(false, 0, 0, Val);}
bool TStr::IsHexInt ( const bool &  Check,
const int &  MnVal,
const int &  MxVal,
int &  Val 
) const

Definition at line 1190 of file dt.cpp.

                                                                                          {
  // parsing format {ws} [+/-][0x] +{XXX}
  int _Val=0;
  bool Minus=false;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Minus=false; Ch.GetCh();}
  if (Ch()=='-'){Minus=true; Ch.GetCh();}
  if (Ch()=='0'){
    Ch.GetCh();
    if (tolower(Ch())=='x' ){
      Ch.GetCh(); if (Ch.Eof()){return false;}
    }
  }
  if (!Ch.Eof() && !TCh::IsHex(Ch())){return false;}
  if (!Ch.Eof()) _Val = TCh::GetHex(Ch());
  while (TCh::IsHex(Ch.GetCh())){_Val=16*_Val+TCh::GetHex(Ch());}
  if (Minus){_Val=-_Val;}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsHexInt ( int &  Val) const [inline]

Definition at line 610 of file dt.h.

{return IsHexInt(false, 0, 0, Val);}
bool TStr::IsHexInt ( ) const [inline]

Definition at line 611 of file dt.h.

{int Val; return IsHexInt(false, 0, 0, Val);}
bool TStr::IsHexInt64 ( const bool &  Check,
const int64 MnVal,
const int64 MxVal,
int64 Val 
) const

Definition at line 1243 of file dt.cpp.

                                                                              {
  // parsing format {ws} [+/-][0x] +{XXX}
  int64 _Val=0;
  bool Minus=false;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Minus=false; Ch.GetCh();}
  if (Ch()=='-'){Minus=true; Ch.GetCh();}
  if (Ch()=='0'){
    Ch.GetCh();
    if (tolower(Ch())=='x' ){
      Ch.GetCh(); if (Ch.Eof()){return false;}
    }
  }
  if (!Ch.Eof()) _Val=TCh::GetHex(Ch());
  while (TCh::IsHex(Ch.GetCh())){_Val=16*_Val+TCh::GetHex(Ch());}
  if (Minus){_Val=-_Val;}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsHexInt64 ( int64 Val) const [inline]

Definition at line 618 of file dt.h.

{return IsHexInt64(false, 0, 0, Val);}
bool TStr::IsHexInt64 ( ) const [inline]

Definition at line 619 of file dt.h.

{int64 Val; return IsHexInt64(false, 0, 0, Val);}
bool TStr::IsInt ( const bool &  Check,
const int &  MnVal,
const int &  MxVal,
int &  Val 
) const

Definition at line 1159 of file dt.cpp.

                                                                        {
  // parsing format {ws} [+/-] +{ddd}
  int _Val=0;
  bool Minus=false;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Minus=false; Ch.GetCh();}
  if (Ch()=='-'){Minus=true; Ch.GetCh();}
  if (!TCh::IsNum(Ch())){return false;}
  _Val=TCh::GetNum(Ch());
  while (TCh::IsNum(Ch.GetCh())){_Val=10*_Val+TCh::GetNum(Ch());}
  if (Minus){_Val=-_Val;}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsInt ( int &  Val) const [inline]

Definition at line 577 of file dt.h.

{return IsInt(false, 0, 0, Val);}
bool TStr::IsInt ( ) const [inline]

Definition at line 578 of file dt.h.

{int Val; return IsInt(false, 0, 0, Val);}
bool TStr::IsInt64 ( const bool &  Check,
const int64 MnVal,
const int64 MxVal,
int64 Val 
) const

Definition at line 1212 of file dt.cpp.

                                                                              {
  // parsing format {ws} [+/-] +{ddd}
  int64 _Val=0;
  bool Minus=false;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Minus=false; Ch.GetCh();}
  if (Ch()=='-'){Minus=true; Ch.GetCh();}
  if (!TCh::IsNum(Ch())){return false;}
  _Val=TCh::GetNum(Ch());
  while (TCh::IsNum(Ch.GetCh())){_Val=10*_Val+TCh::GetNum(Ch());}
  if (Minus){_Val=-_Val;}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsInt64 ( int64 Val) const [inline]

Definition at line 593 of file dt.h.

{return IsInt64(false, 0, 0, Val);}
bool TStr::IsInt64 ( ) const [inline]

Definition at line 594 of file dt.h.

{int64 Val; return IsInt64(false, 0, 0, Val);}
bool TStr::IsLc ( ) const [inline]

Definition at line 497 of file dt.h.

{return RStr->IsLc();}
bool TStr::IsPrefix ( const char *  Str) const

Definition at line 1081 of file dt.cpp.

                                         {
        size_t len = strlen(Str);
        size_t thisLen = Len();
        if (len > thisLen) {
                return false;
        } else {
                size_t minLen = min(len, thisLen);
                int cmp = strncmp(Str, RStr->Bf, minLen);
                return cmp == 0;
        }
}
bool TStr::IsPrefix ( const TStr Str) const [inline]

Definition at line 557 of file dt.h.

                                       {
    return IsPrefix(Str.CStr());}
bool TStr::IsStrIn ( const TStr Str) const [inline]

Definition at line 555 of file dt.h.

{return SearchStr(Str)!=-1;}
bool TStr::IsSuffix ( const char *  Str) const

Definition at line 1093 of file dt.cpp.

                                         {
        size_t len = strlen(Str);
        size_t thisLen = Len();
        if (len > thisLen) {
                // too long to be a suffix anyway
                return false;
        } else {
                // move to the point in the buffer where we would expect the suffix to be
                const char *ending = RStr->Bf + thisLen - len;
                int cmp = strncmp(Str, ending, len);
                return cmp == 0;
        }
}
bool TStr::IsSuffix ( const TStr Str) const [inline]

Definition at line 560 of file dt.h.

                                       {
    return IsSuffix(Str.CStr());}
bool TStr::IsUc ( ) const [inline]

Definition at line 491 of file dt.h.

{return RStr->IsUc();}
bool TStr::IsUInt ( const bool &  Check,
const uint MnVal,
const uint MxVal,
uint Val 
) const

Definition at line 1176 of file dt.cpp.

                                                                           {
  // parsing format {ws} [+]{ddd}
  uint _Val=0;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Ch.GetCh();}
  if (!TCh::IsNum(Ch())){return false;}
  _Val=TCh::GetNum(Ch());
  while (TCh::IsNum(Ch.GetCh())){_Val=10*_Val+TCh::GetNum(Ch());}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsUInt ( uint Val) const [inline]

Definition at line 585 of file dt.h.

{return IsUInt(false, 0, 0, Val);}
bool TStr::IsUInt ( ) const [inline]

Definition at line 586 of file dt.h.

{uint Val; return IsUInt(false, 0, 0, Val);}
bool TStr::IsUInt64 ( const bool &  Check,
const uint64 MnVal,
const uint64 MxVal,
uint64 Val 
) const

Definition at line 1229 of file dt.cpp.

                                                                                 {
  // parsing format {ws} [+]{ddd}
  uint64 _Val=0;
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  if (Ch()=='+'){Ch.GetCh();}
  if (!TCh::IsNum(Ch())){return false;}
  _Val=TCh::GetNum(Ch());
  while (TCh::IsNum(Ch.GetCh())){_Val=10*_Val+TCh::GetNum(Ch());}
  if (Check&&((_Val<MnVal)||(_Val>MxVal))){return false;}
  if (Ch.Eof()){Val=_Val; return true;} else {return false;}
}
bool TStr::IsUInt64 ( uint64 Val) const [inline]

Definition at line 602 of file dt.h.

{return IsUInt64(false, 0, 0, Val);}
bool TStr::IsUInt64 ( ) const [inline]

Definition at line 603 of file dt.h.

{uint64 Val; return IsUInt64(false, 0, 0, Val);}
bool TStr::IsWcMatch ( const int &  StrBChN,
const TStr WcStr,
const int &  WcStrBChN,
TStrV StarStrV,
const char &  StarCh = '*',
const char &  QuestCh = '?' 
) const

Definition at line 1311 of file dt.cpp.

                                                {
  int StrLen=Len(); int WcStrLen=WcStr.Len();
  int StrChN=StrBChN; int WcStrChN=WcStrBChN;
  while ((StrChN<StrLen)&&(WcStrChN<WcStrLen)){
    if ((WcStr[WcStrChN]==QuestCh)||(GetCh(StrChN)==WcStr[WcStrChN])){
      StrChN++; WcStrChN++;
    } else
    if (WcStr[WcStrChN]==StarCh){
      TChA StarChA; // string substituted by star character
      for (int AfterStrChN=StrChN; AfterStrChN<=StrLen; AfterStrChN++){
        if (AfterStrChN>StrChN){
          StarChA+=GetCh(AfterStrChN-1);}
        if (IsWcMatch(AfterStrChN, WcStr, WcStrChN+1, StarStrV, StarCh, QuestCh)){
          StarStrV.Add(StarChA); return true;
        }
      }
      return false;
    } else {
      return false;
    }
  }
  if (StrChN==StrLen){
    for (int AfterWcStrChN=WcStrChN; AfterWcStrChN<WcStrLen; AfterWcStrChN++){
      if (WcStr[AfterWcStrChN]!=StarCh){return false;}}
    return true;
  } else {
    return false;
  }
}
bool TStr::IsWcMatch ( const TStr WcStr,
TStrV StarStrV,
const char &  StarCh = '*',
const char &  QuestCh = '?' 
) const

Definition at line 1343 of file dt.cpp.

                                                                                    {
  bool WcMatch=IsWcMatch(0, WcStr, 0, StarStrV, StarCh, QuestCh);
  if (WcMatch){
    StarStrV.Reverse();
    return true;
  } else {
    return false;
  }
}
bool TStr::IsWcMatch ( const TStr WcStr,
const char &  StarCh,
const char &  QuestCh 
) const

Definition at line 1354 of file dt.cpp.

                                                                   {
  TStrV StarStrV;
  return IsWcMatch(0, WcStr, 0, StarStrV, StarCh, QuestCh);
}
bool TStr::IsWcMatch ( const TStr WcStr,
const int &  StarStrN,
TStr StarStr 
) const

Definition at line 1360 of file dt.cpp.

                                                                                {
  TStrV StarStrV;
  if (IsWcMatch(WcStr, StarStrV)){
    if (StarStrV.Len()>StarStrN){
      StarStr=StarStrV[StarStrV.Len()-StarStrN-1];
    } else {
      StarStr="";
    }
    return true;
  } else {
    return false;
  }
}
bool TStr::IsWcMatch ( const TStr WcStr) const

Definition at line 1374 of file dt.cpp.

                                            {
  TStrV StarStrV;
  return IsWcMatch(0, WcStr, 0, StarStrV);
}
bool TStr::IsWord ( const bool &  WsPrefixP = true,
const bool &  FirstUcAllowedP = true 
) const

Definition at line 1292 of file dt.cpp.

                                                                          {
  // parsing format {ws} (A-Z,a-z) *{A-Z,a-z,0-9}
  TChRet Ch(TStrIn::New(*this));
  if (WsPrefixP){while (TCh::IsWs(Ch.GetCh())){}}
  else {Ch.GetCh();}
  if (!TCh::IsAlpha(Ch())){return false;}
  else if (!FirstUcAllowedP&&(TCh::IsUc(Ch()))){return false;}
  while (TCh::IsAlNum(Ch.GetCh())){}
  if (!Ch.Eof()){return false;}
  return true;
}
bool TStr::IsWs ( ) const

Definition at line 1304 of file dt.cpp.

                      {
  // if string is just a bunch of whitespace chars
  TChRet Ch(TStrIn::New(*this));
  while (TCh::IsWs(Ch.GetCh())){}
  return Ch.Eof();
}
char TStr::LastCh ( ) const [inline]

Definition at line 484 of file dt.h.

{return GetCh(Len()-1);}
TStr TStr::Left ( const int &  EChN) const [inline]

Definition at line 545 of file dt.h.

{ return EChN>0 ? GetSubStr(0, EChN-1) : GetSubStr(0, Len()+EChN-1);}
TStr TStr::LeftOf ( const char &  SplitCh) const

Definition at line 873 of file dt.cpp.

                                           {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=0;
  while ((ChN<ThisLen)&&(ThisBf[ChN]!=SplitCh)){ChN++;}
  return (ChN==ThisLen) ? "" : GetSubStr(0, ChN-1);
}
TStr TStr::LeftOfLast ( const char &  SplitCh) const

Definition at line 880 of file dt.cpp.

                                               {
  const char* ThisBf=CStr();
  int ChN=Len()-1;
  while ((ChN>=0)&&(ThisBf[ChN]!=SplitCh)){ChN--;}
  return (ChN==-1) ? "" : GetSubStr(0, ChN-1);
}
int TStr::Len ( ) const [inline]

Definition at line 487 of file dt.h.

{return RStr->Len();}
void TStr::Load ( TSIn SIn,
const bool &  IsSmall = false 
) [inline]

Definition at line 438 of file dt.h.

                                                 {
    *this=TStr(SIn, IsSmall);}
static TStr TStr::LoadTxt ( const PSIn SIn) [inline, static]

Definition at line 667 of file dt.h.

                                      {
    return TStr(SIn);}
static TStr TStr::LoadTxt ( const TStr FNm) [inline, static]

Definition at line 669 of file dt.h.

                                      {
    PSIn SIn=TFIn::New(FNm); return LoadTxt(SIn);}
void TStr::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)

Definition at line 740 of file dt.cpp.

                                                       {
  XLoadHd(Nm);
  TStr TokStr=XmlTok->GetTokStr(false);
  operator=(TokStr);
}
TStr TStr::Mid ( const int &  BChN,
const int &  Chs 
) const [inline]

Definition at line 539 of file dt.h.

{ return GetSubStr(BChN, BChN+Chs-1); }
TStr TStr::Mid ( const int &  BChN) const [inline]

Definition at line 540 of file dt.h.

{return GetSubStr(BChN, Len()-1); }
static TStr TStr::MkClone ( const TStr Str) [inline, static]

Definition at line 689 of file dt.h.

{return TStr(Str.CStr());}
bool TStr::operator!= ( const char *  CStr) const [inline]

Definition at line 467 of file dt.h.

                                          {
    return strcmp(RStr->CStr(), CStr)!=0;}
char* TStr::operator() ( ) [inline]

Definition at line 474 of file dt.h.

{return RStr->CStr();}
const char* TStr::operator() ( ) const [inline]

Definition at line 475 of file dt.h.

{return RStr->CStr();}
TStr TStr::operator() ( const int &  BChN,
const int &  EChNP1 
) const [inline]

Definition at line 548 of file dt.h.

{return Slice(BChN, EChNP1);}
TStr& TStr::operator+= ( const TStr Str) [inline]

Definition at line 453 of file dt.h.

                                   {
    TRStr* NewRStr=new TRStr(RStr->CStr(), Str.RStr->CStr());
    RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
    Optimize(); return *this;}
TStr& TStr::operator+= ( const char *  CStr) [inline]

Definition at line 457 of file dt.h.

                                    {
    TRStr* NewRStr=new TRStr(RStr->CStr(), CStr);
    RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
    Optimize(); return *this;}
bool TStr::operator< ( const TStr Str) const [inline]

Definition at line 469 of file dt.h.

                                        {
    return strcmp(RStr->CStr(), Str.RStr->CStr())<0;}
TStr& TStr::operator= ( const TStr Str) [inline]

Definition at line 445 of file dt.h.

                                  {
    if (this!=&Str){RStr->UnRef(); RStr=Str.RStr; RStr->MkRef();} return *this;}
TStr& TStr::operator= ( const TChA ChA) [inline]

Definition at line 447 of file dt.h.

                                  {
    RStr->UnRef(); RStr=GetRStr(ChA.CStr()); RStr->MkRef(); return *this;}
TStr& TStr::operator= ( const char *  CStr) [inline]

Definition at line 449 of file dt.h.

                                   {
    RStr->UnRef(); RStr=GetRStr(CStr); RStr->MkRef(); return *this;}
TStr& TStr::operator= ( const char &  Ch) [inline]

Definition at line 451 of file dt.h.

                                 {
    RStr->UnRef(); RStr=GetChStr(Ch).RStr; RStr->MkRef(); return *this;}
bool TStr::operator== ( const TStr Str) const [inline]

Definition at line 461 of file dt.h.

                                         {
    return (RStr==Str.RStr)||(strcmp(RStr->CStr(), Str.RStr->CStr())==0);}
bool TStr::operator== ( const char *  CStr) const [inline]

Definition at line 463 of file dt.h.

                                          {
    return strcmp(RStr->CStr(), CStr)==0;}
char TStr::operator[] ( const int &  ChN) const [inline]

Definition at line 471 of file dt.h.

{return RStr->GetCh(ChN);}
void TStr::Optimize ( ) [private]

Definition at line 729 of file dt.cpp.

                   {
  char* CStr=RStr->CStr(); int CStrLen=int(strlen(CStr));
  TRStr* NewRStr;
  if (CStrLen==0){NewRStr=TRStr::GetNullRStr();}
  // next lines are not multi-threading safe
  //else if (CStrLen==1){NewRStr=GetChStr(CStr[0]).RStr;}
  //else if (CStrLen==2){NewRStr=GetDChStr(CStr[0], CStr[1]).RStr;}
  else {NewRStr=RStr;}
  NewRStr->MkRef(); RStr->UnRef(); RStr=NewRStr;
}
void TStr::PutCh ( const int &  ChN,
const char &  Ch 
) [inline]

Definition at line 479 of file dt.h.

                                            {
    TRStr* NewRStr=new TRStr(RStr->CStr());
    RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
    RStr->PutCh(ChN, Ch); Optimize();}
TStr TStr::PutFBase ( const TStr FNm,
const TStr FBase 
) [static]

Definition at line 1511 of file dt.cpp.

                                                     {
  return FNm.GetFPath()+FBase;
}
TStr TStr::PutFBaseIfEmpty ( const TStr FNm,
const TStr FBase 
) [static]

Definition at line 1515 of file dt.cpp.

                                                            {
  if (FNm.GetFBase().Empty()){
    return FNm.GetFPath()+FBase;
  } else {
    return FNm;
  }
}
TStr TStr::PutFExt ( const TStr FNm,
const TStr FExt 
) [static]

Definition at line 1499 of file dt.cpp.

                                                   {
  return FNm.GetFPath()+FNm.GetFMid()+FExt;
}
TStr TStr::PutFExtIfEmpty ( const TStr FNm,
const TStr FExt 
) [static]

Definition at line 1503 of file dt.cpp.

                                                          {
  if (FNm.GetFExt().Empty()){
    return FNm.GetFPath()+FNm.GetFMid()+FExt;
  } else {
    return FNm;
  }
}
TStr TStr::Reverse ( ) const [inline]

Definition at line 567 of file dt.h.

                       {
    TChA ChA(*this); ChA.Reverse(); return ChA;}
TStr TStr::Right ( const int &  BChN) const [inline]

Definition at line 546 of file dt.h.

{return BChN>=0 ? GetSubStr(BChN, Len()-1) : GetSubStr(Len()+BChN, Len()-1);}
TStr TStr::RightOf ( const char &  SplitCh) const

Definition at line 887 of file dt.cpp.

                                            {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=0;
  while ((ChN<ThisLen)&&(ThisBf[ChN]!=SplitCh)){ChN++;}
  return (ChN==ThisLen) ? "" : GetSubStr(ChN+1, ThisLen-1);
}
TStr TStr::RightOfLast ( const char &  SplitCh) const

Definition at line 894 of file dt.cpp.

                                                {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=Len()-1;
  while ((ChN>=0)&&(ThisBf[ChN]!=SplitCh)){ChN--;}
  return (ChN==-1) ? "" : GetSubStr(ChN+1, ThisLen-1);
}
void TStr::Save ( TSOut SOut,
const bool &  IsSmall = false 
) const [inline]

Definition at line 440 of file dt.h.

                                                          {
    RStr->Save(SOut, IsSmall);}
void TStr::SaveTxt ( const PSOut SOut) const [inline]

Definition at line 671 of file dt.h.

                                        {
    SOut->SaveBf(CStr(), Len());}
void TStr::SaveTxt ( const TStr FNm) const [inline]

Definition at line 673 of file dt.h.

                                      {
    PSOut SOut=TFOut::New(FNm); SaveTxt(SOut);}
void TStr::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 746 of file dt.cpp.

                                                    {
  TStr XmlStr=TXmlLx::GetXmlStrFromPlainStr(*this);
  if (XmlStr.Empty()){XSaveBETag(Nm);}
  else {XSaveHd(Nm); SOut.PutStr(XmlStr);}
}
int TStr::SearchCh ( const char &  Ch,
const int &  BChN = 0 
) const

Definition at line 1043 of file dt.cpp.

                                                        {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=TInt::GetMx(BChN, 0);
  while (ChN<ThisLen){
    if (ThisBf[ChN]==Ch){return ChN;}
    ChN++;
  }
  return -1;
}
int TStr::SearchChBack ( const char &  Ch,
int  BChN = -1 
) const

Definition at line 1053 of file dt.cpp.

                                                     {
  const int StrLen=Len();
  if (BChN==-1||BChN>=StrLen){BChN=StrLen-1;}
  const char* ThisBf=CStr();
  const char* Pt=ThisBf + BChN;
  while (Pt>=ThisBf) {
    if (*Pt==Ch){return (int)(Pt-ThisBf);}
    Pt--;
  }
  return -1;
}
int TStr::SearchStr ( const TStr Str,
const int &  BChN = 0 
) const

Definition at line 1065 of file dt.cpp.

                                                          {
  int NrBChN=TInt::GetMx(BChN, 0);
  const char* StrPt=strstr((const char*)CStr()+NrBChN, Str.CStr());
  if (StrPt==NULL){return -1;}
  else {return int(StrPt-CStr());}
/*  // slow implementation
  int ThisLen=Len(); int StrLen=Str.Len();
  int ChN=TInt::GetMx(BChN, 0);
  while (ChN<ThisLen-StrLen+1){
    if (strncmp(CStr()+ChN, Str.CStr(), StrLen)==0){
      return ChN;}
    ChN++;
  }
  return -1;*/
}
TStr TStr::Slice ( int  BChN,
int  EChNP1 
) const [inline]

Definition at line 547 of file dt.h.

{ if(BChN<0){BChN=Len()+BChN;} if(EChNP1<=0){EChNP1=Len()+EChNP1;} return GetSubStr(BChN, EChNP1-1); }
void TStr::SplitOnAllAnyCh ( const TStr SplitChStr,
TStrV StrV,
const bool &  SkipEmpty = true 
) const

Definition at line 944 of file dt.cpp.

                                                                   {
  // reset string output-vector
  StrV.Clr();
  // prepare working-copy of string
  char* Bf=new char[Len()+1];
  strcpy(Bf, CStr());
  char* CurStrBf=Bf; // pointer to current string
  // prepare pointer to split-char-string
  const char* SplitChBf=SplitChStr.CStr();
  forever{
    char* BfC=CurStrBf; // set the counter for working-string
    while (*BfC!=0){
      const char* SplitChBfC=SplitChBf; // set counter for split-char-string
      while ((*SplitChBfC!=0)&&(*SplitChBfC!=*BfC)){SplitChBfC++;}
      if (*SplitChBfC!=0){break;} // if split-char found
      BfC++;
    }
    bool IsEnd=(*BfC==0);
    *BfC=0;
    if ((BfC>CurStrBf)||(!SkipEmpty)){StrV.Add(TStr(CurStrBf));}
    if (IsEnd){break;}
    CurStrBf=BfC+1;
  }
  // delete working-copy
  delete[] Bf;
}
void TStr::SplitOnAllCh ( const char &  SplitCh,
TStrV StrV,
const bool &  SkipEmpty = true 
) const

Definition at line 926 of file dt.cpp.

                                                                {
  StrV.Clr();
  char* Bf=new char[Len()+1];
  strcpy(Bf, CStr());
  char* CurStrBf=Bf;
  forever{
    char* BfC=CurStrBf;
    while ((*BfC!=0)&&(*BfC!=SplitCh)){BfC++;}
    bool IsEnd=(*BfC=='\0');
    *BfC=0;
    if ((BfC>CurStrBf)||(!SkipEmpty)){StrV.Add(TStr(CurStrBf));}
    if (IsEnd){break;}
    CurStrBf=BfC+1;
  }
  delete[] Bf;
}
void TStr::SplitOnCh ( TStr LStr,
const char &  SplitCh,
TStr RStr 
) const

Definition at line 901 of file dt.cpp.

                                                                      {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=0;
  while ((ChN<ThisLen)&&(ThisBf[ChN]!=SplitCh)){ChN++;}
  if (ChN==ThisLen){
    LStr=GetSubStr(0, ThisLen-1); RStr="";
  } else {
    LStr=GetSubStr(0, ChN-1); RStr=GetSubStr(ChN+1, ThisLen-1);
  }
}
void TStr::SplitOnLastCh ( TStr LStr,
const char &  SplitCh,
TStr RStr 
) const

Definition at line 912 of file dt.cpp.

                                                                          {
  int ThisLen=Len(); const char* ThisBf=CStr();
  int ChN=Len()-1;
  while ((ChN>=0)&&(ThisBf[ChN]!=SplitCh)){ChN--;}
  if (ChN==-1){
    LStr=""; RStr=*this;
  } else
  if (ChN==0){
    LStr=""; RStr=GetSubStr(1, ThisLen-1);
  } else {
    LStr=GetSubStr(0, ChN-1); RStr=GetSubStr(ChN+1, ThisLen-1);
  }
}
void TStr::SplitOnNonAlNum ( TStrV StrV) const

Definition at line 990 of file dt.cpp.

                                            {
  StrV.Clr();
  char* Bf=new char[Len()+1];
  strcpy(Bf, CStr());
  char* StrBf=Bf;
  forever{
    while ((*StrBf!=0)&&(!TCh::IsAlNum(*StrBf))){StrBf++;}
    char* BfC=StrBf;
    while ((*BfC!=0)&&(TCh::IsAlNum(*BfC))){BfC++;}
    bool IsEnd=(*BfC=='\0');
    *BfC=0;
    if (BfC>StrBf){StrV.Add(TStr(StrBf));}
    if (IsEnd){break;}
    StrBf=BfC+1;
  }
  delete[] Bf;
}
void TStr::SplitOnStr ( const TStr SplitStr,
TStrV StrV 
) const

Definition at line 1008 of file dt.cpp.

                                                             {
  StrV.Clr();
  int SplitStrLen=SplitStr.Len();
  int PrevChN=0; int ChN=0;
  while ((ChN=SearchStr(SplitStr, ChN))!=-1){
    // extract & add string
    TStr SubStr=GetSubStr(PrevChN, ChN-1);
    StrV.Add(SubStr);
    PrevChN=ChN=ChN+SplitStrLen;
  }
  // add last string
  TStr LastSubStr=GetSubStr(PrevChN, Len()-1);
  StrV.Add(LastSubStr);
}
void TStr::SplitOnStr ( TStr LeftStr,
const TStr MidStr,
TStr RightStr 
) const

Definition at line 1023 of file dt.cpp.

                                                                             {
  const int ChN=SearchStr(MidStr);
  if (ChN==-1){
    LeftStr=*this; RightStr=GetNullStr();
  } else {
    LeftStr=GetSubStr(0, ChN-1);
    RightStr=GetSubStr(ChN+MidStr.Len(), Len()-1);
  }
}
void TStr::SplitOnWs ( TStrV StrV) const

Definition at line 972 of file dt.cpp.

                                      {
  StrV.Clr();
  char* Bf=new char[Len()+1];
  strcpy(Bf, CStr());
  char* StrBf=Bf;
  forever{
    while ((*StrBf!=0)&&(TCh::IsWs(*StrBf))){StrBf++;}
    char* BfC=StrBf;
    while ((*BfC!=0)&&(!TCh::IsWs(*BfC))){BfC++;}
    bool IsEnd=(*BfC=='\0');
    *BfC=0;
    if (BfC>StrBf){StrV.Add(TStr(StrBf));}
    if (IsEnd){break;}
    StrBf=BfC+1;
  }
  delete[] Bf;
}

Definition at line 764 of file dt.cpp.

                 {
  TRStr* NewRStr=new TRStr(RStr->CStr()); NewRStr->ToCap();
  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
  Optimize(); return *this;
}

Definition at line 785 of file dt.cpp.

                 {
  TChA ChA;
  int StrLen=Len();
  for (int ChN=0; ChN<StrLen; ChN++){
    uchar Ch=uchar(RStr->Bf[ChN]);
    char MshCh=TCh::GetHexCh((Ch/16)%16);
    char LshCh=TCh::GetHexCh(Ch%16);
    ChA+=MshCh; ChA+=LshCh;
  }
  *this=ChA;
  return *this;
}

Definition at line 758 of file dt.cpp.

                {
  TRStr* NewRStr=new TRStr(RStr->CStr()); NewRStr->ToLc();
  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
  Optimize(); return *this;
}

Definition at line 770 of file dt.cpp.

                   {
  int ThisLen=Len(); char* ThisBf=CStr();
  int BChN=0; int EChN=ThisLen-1;
  while ((BChN<ThisLen)&&TCh::IsWs(ThisBf[BChN])){BChN++;}
  while ((EChN>=0)&&TCh::IsWs(ThisBf[EChN])){EChN--;}
  *this=GetSubStr(BChN, EChN);
  return *this;
}

Definition at line 752 of file dt.cpp.

                {
  TRStr* NewRStr=new TRStr(RStr->CStr()); NewRStr->ToUc();
  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
  Optimize(); return *this;
}

Friends And Related Function Documentation

TStr operator+ ( const TStr LStr,
const TStr RStr 
) [friend]

Definition at line 1631 of file dt.cpp.

                                                  {
  if (LStr.Empty()){return RStr;}
  else if (RStr.Empty()){return LStr;}
  else {return TStr(LStr)+=RStr;}
}
TStr operator+ ( const TStr LStr,
const char *  RCStr 
) [friend]

Definition at line 1637 of file dt.cpp.

                                                   {
  return TStr(LStr)+=RCStr;
}

Member Data Documentation

TRStr* TStr::RStr [private]

Definition at line 414 of file dt.h.


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