|
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
|
#include <dt.h>
Inherited by TTypeNm< Type >.
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 |
| TStr & | operator= (const TStr &Str) |
| TStr & | operator= (const TChA &ChA) |
| TStr & | operator= (const char *CStr) |
| TStr & | operator= (const char &Ch) |
| TStr & | operator+= (const TStr &Str) |
| TStr & | operator+= (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 |
| TStr & | ToUc () |
| TStr | GetUc () const |
| int | CmpI (const TStr &Str) const |
| bool | EqI (const TStr &Str) const |
| bool | IsLc () const |
| TStr & | ToLc () |
| TStr | GetLc () const |
| TStr & | ToCap () |
| TStr | GetCap () const |
| TStr & | ToTrunc () |
| TStr | GetTrunc () const |
| TStr & | ConvUsFromYuAscii () |
| TStr | GetUsFromYuAscii () const |
| TStr & | ToHex () |
| TStr | GetHex () const |
| TStr & | FromHex () |
| 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 TStr & | GetChStr (const char &Ch) |
| static TStr & | GetDChStr (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 TRStr * | GetRStr (const char *CStr) |
Private Attributes | |
| TRStr * | RStr |
Friends | |
| TStr | operator+ (const TStr &LStr, const TStr &RStr) |
| TStr | operator+ (const TStr &LStr, const char *RCStr) |
| TStr::TStr | ( | const char & | Ch, |
| bool | |||
| ) | [inline, private] |
| TStr::TStr | ( | const char & | Ch1, |
| const char & | Ch2, | ||
| bool | |||
| ) | [inline, private] |
| TStr::TStr | ( | ) | [inline] |
| TStr::TStr | ( | const TStr & | Str | ) | [inline] |
| TStr::TStr | ( | const TChA & | ChA | ) | [inline] |
| TStr::TStr | ( | const TSStr & | SStr | ) | [inline] |
| TStr::TStr | ( | const char * | CStr | ) | [inline] |
| TStr::TStr | ( | const char & | Ch | ) | [inline, explicit] |
| TStr::TStr | ( | const TMem & | Mem | ) | [inline] |
| TStr::TStr | ( | const PSIn & | SIn | ) | [inline, explicit] |
| TStr::~TStr | ( | ) | [inline] |
| TStr::TStr | ( | TSIn & | SIn, |
| const bool & | IsSmall = false |
||
| ) | [inline, explicit] |
| TStr TStr::AddToFMid | ( | const TStr & | FNm, |
| const TStr & | ExtFMid | ||
| ) | [static] |
| int TStr::ChangeCh | ( | const char & | SrcCh, |
| const char & | DstCh, | ||
| const int & | BChN = 0 |
||
| ) |
| 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 |
||
| ) |
| int TStr::ChangeStrAll | ( | const TStr & | SrcStr, |
| const TStr & | DstStr, | ||
| const bool & | FromStartP = false |
||
| ) |
| void TStr::Clr | ( | ) | [inline] |
| int TStr::CmpI | ( | const TStr & | Str | ) | const [inline] |
Definition at line 494 of file dt.h.
{return TRStr::CmpI(CStr(), Str.CStr());}
| TStr & TStr::ConvUsFromYuAscii | ( | ) |
| 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] |
| const char* TStr::CStr | ( | ) | const [inline] |
| void TStr::DelChAll | ( | const char & | Ch | ) |
| bool TStr::DelStr | ( | const TStr & | Str | ) |
| 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 495 of file dt.h.
{return TRStr::CmpI(CStr(), Str.CStr())==0;}
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();
}
| TStr & TStr::FromHex | ( | ) |
| TStr TStr::GetCap | ( | ) | const [inline] |
| char TStr::GetCh | ( | const int & | ChN | ) | const [inline] |
| TStr & TStr::GetChStr | ( | const char & | Ch | ) | [static] |
| char* TStr::GetCStr | ( | ) | const [inline] |
| 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 |
| TStr TStr::GetFExt | ( | ) | const |
| double TStr::GetFlt | ( | ) | const [inline] |
| double TStr::GetFlt | ( | const double & | DfVal | ) | const [inline] |
| 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 |
| TStr TStr::GetFromHex | ( | ) | const [inline] |
| TStr TStr::GetHex | ( | ) | const [inline] |
| int TStr::GetHexInt | ( | ) | const [inline] |
| int TStr::GetHexInt | ( | const int & | DfVal | ) | const [inline] |
| 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] |
| int TStr::GetInt | ( | const int & | DfVal | ) | const [inline] |
| int64 TStr::GetInt64 | ( | ) | const [inline] |
| int64 TStr::GetInt64 | ( | const int64 & | DfVal | ) | const [inline] |
| TStr TStr::GetLc | ( | ) | const [inline] |
| 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] |
| 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] |
| 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] |
| TStr TStr::GetNullStr | ( | ) | [static] |
| TStr TStr::GetNumFNm | ( | const TStr & | FNm, |
| const int & | Num | ||
| ) | [static] |
| 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] |
| TStr TStr::GetStr | ( | const TStr & | Str, |
| const char * | FmtStr | ||
| ) | [static] |
| static TStr TStr::GetStr | ( | const TStr & | Str, |
| const TStr & | FmtStr | ||
| ) | [inline, static] |
| TStr TStr::GetStr | ( | const TStrV & | StrV, |
| const TStr & | DelimiterStr | ||
| ) | [static] |
| 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] |
| TStr TStr::GetTrunc | ( | ) | const [inline] |
| TStr TStr::GetUc | ( | ) | const [inline] |
| uint TStr::GetUInt | ( | ) | const [inline] |
| uint TStr::GetUInt | ( | const uint & | DfVal | ) | const [inline] |
| uint64 TStr::GetUInt64 | ( | ) | const [inline] |
| uint64 TStr::GetUInt64 | ( | const uint64 & | DfVal | ) | const [inline] |
| TStr TStr::GetUsFromYuAscii | ( | ) | const [inline] |
| TStr TStr::GetWcMatch | ( | const TStr & | WcStr, |
| const int & | StarStrN = 0 |
||
| ) | const |
| void TStr::InsStr | ( | const int & | BChN, |
| const TStr & | Str | ||
| ) |
| bool TStr::IsAbsFPath | ( | const TStr & | FPath | ) | [static] |
| bool TStr::IsBool | ( | bool & | Val | ) | const |
| bool TStr::IsChIn | ( | const char & | Ch | ) | const [inline] |
| 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] |
| bool TStr::IsFlt | ( | ) | const [inline] |
| 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] |
| bool TStr::IsHexInt | ( | ) | const [inline] |
| 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] |
| bool TStr::IsInt | ( | ) | const [inline] |
| 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] |
| bool TStr::IsInt64 | ( | ) | const [inline] |
| bool TStr::IsLc | ( | ) | const [inline] |
| bool TStr::IsPrefix | ( | const char * | Str | ) | const |
| bool TStr::IsPrefix | ( | const TStr & | Str | ) | const [inline] |
| bool TStr::IsStrIn | ( | const TStr & | Str | ) | const [inline] |
| 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] |
| bool TStr::IsUc | ( | ) | const [inline] |
| 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] |
| bool TStr::IsUInt | ( | ) | const [inline] |
| 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] |
| bool TStr::IsUInt64 | ( | ) | const [inline] |
| 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 |
| bool TStr::IsWcMatch | ( | const TStr & | WcStr, |
| const char & | StarCh, | ||
| const char & | QuestCh | ||
| ) | const |
| bool TStr::IsWcMatch | ( | const TStr & | WcStr, |
| const int & | StarStrN, | ||
| TStr & | StarStr | ||
| ) | const |
| bool TStr::IsWcMatch | ( | const TStr & | WcStr | ) | const |
| 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] |
| TStr TStr::Left | ( | const int & | EChN | ) | const [inline] |
| TStr TStr::LeftOf | ( | const char & | SplitCh | ) | const |
| TStr TStr::LeftOfLast | ( | const char & | SplitCh | ) | const |
| void TStr::Load | ( | TSIn & | SIn, |
| const bool & | IsSmall = false |
||
| ) | [inline] |
| static TStr TStr::LoadTxt | ( | const PSIn & | SIn | ) | [inline, static] |
| static TStr TStr::LoadTxt | ( | const TStr & | FNm | ) | [inline, static] |
| void TStr::LoadXml | ( | const PXmlTok & | XmlTok, |
| const TStr & | Nm | ||
| ) |
| static TStr TStr::MkClone | ( | const TStr & | Str | ) | [inline, static] |
| bool TStr::operator!= | ( | const char * | CStr | ) | const [inline] |
| const char* TStr::operator() | ( | ) | const [inline] |
| TStr TStr::operator() | ( | const int & | BChN, |
| const int & | EChNP1 | ||
| ) | const [inline] |
| TStr& TStr::operator+= | ( | const char * | CStr | ) | [inline] |
| bool TStr::operator< | ( | const TStr & | Str | ) | const [inline] |
| TStr& TStr::operator= | ( | const char * | CStr | ) | [inline] |
| TStr& TStr::operator= | ( | const char & | Ch | ) | [inline] |
| bool TStr::operator== | ( | const TStr & | Str | ) | const [inline] |
| bool TStr::operator== | ( | const char * | CStr | ) | const [inline] |
| char TStr::operator[] | ( | const int & | ChN | ) | const [inline] |
| 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] |
| TStr TStr::PutFBase | ( | const TStr & | FNm, |
| const TStr & | FBase | ||
| ) | [static] |
| TStr TStr::PutFBaseIfEmpty | ( | const TStr & | FNm, |
| const TStr & | FBase | ||
| ) | [static] |
| TStr TStr::PutFExt | ( | const TStr & | FNm, |
| const TStr & | FExt | ||
| ) | [static] |
| TStr TStr::PutFExtIfEmpty | ( | const TStr & | FNm, |
| const TStr & | FExt | ||
| ) | [static] |
| TStr TStr::Reverse | ( | ) | const [inline] |
| TStr TStr::Right | ( | const int & | BChN | ) | const [inline] |
| TStr TStr::RightOf | ( | const char & | SplitCh | ) | const |
| TStr TStr::RightOfLast | ( | const char & | SplitCh | ) | const |
| void TStr::Save | ( | TSOut & | SOut, |
| const bool & | IsSmall = false |
||
| ) | const [inline] |
| void TStr::SaveTxt | ( | const PSOut & | SOut | ) | const [inline] |
| 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 |
| 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] |
| 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 |
| void TStr::SplitOnCh | ( | TStr & | LStr, |
| const char & | SplitCh, | ||
| TStr & | RStr | ||
| ) | const |
| void TStr::SplitOnLastCh | ( | TStr & | LStr, |
| const char & | SplitCh, | ||
| TStr & | RStr | ||
| ) | const |
| 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 |
| 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;
}
| TStr & TStr::ToCap | ( | ) |
| TStr & TStr::ToHex | ( | ) |
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;
}
| TStr & TStr::ToLc | ( | ) |
| TStr & TStr::ToTrunc | ( | ) |
| TStr & TStr::ToUc | ( | ) |
TRStr* TStr::RStr [private] |