本文整理汇总了C++中TStr类的典型用法代码示例。如果您正苦于以下问题:C++ TStr类的具体用法?C++ TStr怎么用?C++ TStr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TStr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TSBase
/////////////////////////////////////////////////
// Output-Stream
TSOut::TSOut(const TStr& Str):
TSBase(Str.CStr()), MxLnLen(-1), LnLen(0){}
示例2: IsHtmlFExt
// file extensions
bool THttp::IsHtmlFExt(const TStr& FExt){
TStr UcFExt=FExt.GetUc();
return ((UcFExt==TFile::HtmlFExt.GetUc())||(UcFExt==TFile::HtmFExt.GetUc()));
}
示例3: SetChTy
/////////////////////////////////////////////////
// Tql-Lexical-Chars
void TTqlChDef::SetChTy(const TTqlLxChTy& ChTy, const TStr& Str){
for (int ChN=0; ChN<Str.Len(); ChN++){ChTyV[Str[ChN]-TCh::Mn]=TInt(ChTy);}
}
示例4: GetPrefixArgN
TStr TEnv::GetArgPostfix(const TStr& PrefixStr) const {
int ArgN = GetPrefixArgN(PrefixStr);
IAssert(ArgN != -1);
TStr ArgStr = GetArg(ArgN);
return ArgStr.GetSubStr(PrefixStr.Len(), ArgStr.Len());
}
示例5: SetLcCh
void THttpChDef::SetLcCh(const TStr& Str){
for (int ChN=1; ChN<Str.Len(); ChN++){LcChV[Str[ChN]-TCh::Mn]=TCh(Str[0]);}}
示例6: while
bool TFFile::Next(TStr& FNm){
// if need to recurse
if (!SubFFile.Empty()){
if (SubFFile->Next(FNm)){CurFNm=FNm; CurFNmN++; return true;}
else {SubFFile=NULL;}
}
// for all required file-paths
while (FPathN<FPathV.Len()){
if ((FPathN!=-1)&&(FindNextFile(FFileDesc->FFileH, &FFileDesc->FDesc))){
// next file-name available on the current file-path
TStr FBase=FFileDesc->GetFBase();
if ((RecurseP)&&(FFileDesc->IsDir())){
// file-name is directory and recursion is required
if ((FBase!=".")&&(FBase!="..")){
// directory is non-trivial - prepare sub-file-find for recursion
TStr SubFPath=FPathV[FPathN]+FBase;
TStrV SubFPathV; SubFPathV.Add(SubFPath);
SubFFile=New(SubFPathV, FExtV, FBaseWc, RecurseP);
if (SubFFile->Next(FNm)){CurFNm=FNm; CurFNmN++; return true;}
else {SubFFile=NULL;}
}
} else {
// return file-name if fits
if ((FBase!=".")&&(FBase!="..")){
FNm=FPathV[FPathN]+FBase;
TStr FExt=FNm.GetFExt(); if (!CsImpP){FExt.ToUc(); FBase.ToUc();}
if (((FExtV.Empty())||(FExtV.SearchForw(FExt)!=-1))&&
((FBaseWc.Empty())||(FBase.IsWcMatch(FBaseWc)))){
CurFNm=FNm; CurFNmN++; return true;}
}
}
} else {
// close file-find descriptor if needed
if (FPathN!=-1){
IAssert(FindClose(FFileDesc->FFileH));
FFileDesc->FFileH=INVALID_HANDLE_VALUE;
}
// find next file existing path from the input list
while ((++FPathN<FPathV.Len())&&
((FFileDesc->FFileH=FindFirstFile((FPathV[FPathN]+"*.*").CStr(),
&FFileDesc->FDesc))==INVALID_HANDLE_VALUE)){}
if ((FPathN<FPathV.Len())&&(RecurseP)&&(FFileDesc->IsDir())){
// file-path found, file-name is directory and recursion is required
TStr FBase=FFileDesc->GetFBase();
if ((FBase!=".")&&(FBase!="..")){
TStr SubFPath=FPathV[FPathN]+FBase;
TStrV SubFPathV; SubFPathV.Add(SubFPath);
SubFFile=New(SubFPathV, FExtV, FBaseWc, RecurseP);
if (SubFFile->Next(FNm)){CurFNm=FNm; CurFNmN++; return true;}
else {SubFFile=NULL;}
}
} else {
// return file-name if fits
if (FPathN<FPathV.Len()){
TStr FBase=FFileDesc->GetFBase();
if ((FBase!=".")&&(FBase!="..")){
FNm=FPathV[FPathN]+FBase;
TStr FExt=FNm.GetFExt(); if (!CsImpP){FExt.ToUc(); FBase.ToUc();}
if (((FExtV.Empty())||(FExtV.SearchForw(FExt)!=-1))&&
((FBaseWc.Empty())||(FBase.IsWcMatch(FBaseWc)))){
CurFNm=FNm; CurFNmN++; return true;
}
}
}
}
}
}
// not found
CurFNm=""; CurFNmN=-1; return false;
}
示例7: putenv
void TEnv::PutVarVal(const TStr& VarNm, const TStr& VarVal) {
const int RetVal =
putenv(TStr::Fmt("%s=%s", VarNm.CStr(), VarVal.CStr())
.CStr());
IAssert(RetVal == 0);
}
示例8: OnError
void TGgWebFetchSaver::OnError(const int&, const TStr& MsgStr){
printf("Error [Wait:%d Conn.:%d]: %s\n",
GetWaitUrls(), GetConnUrls(), MsgStr.CStr());
if (Empty()){
TSysMsg::Quit();}
}
示例9: printf
/////////////////////////////////////////////////
// Google-Focused-Crawl
PGgFCrawl TGgFCrawl::GetFCrawl(
const TStr& SrcUrlStr, const int& MxCands, const TStr& ProxyStr){
// collect related urls
printf("Expand source URL: %s\n", SrcUrlStr.CStr());
PRSet SrcUrlRSet=
TGg::WebSearch(TStr("related:")+SrcUrlStr, -1, TNotify::NullNotify, ProxyStr);
// create & prepare focused-crawl
PGgFCrawl FCrawl=TGgFCrawl::New();
FCrawl->SrcUrlStr=SrcUrlStr;
FCrawl->DstRSet=TRSet::New(SrcUrlRSet);
// fill hits
for (int HitN=0; HitN<SrcUrlRSet->GetHits(); HitN++){
if ((MxCands!=-1)&&(FCrawl->DstRSet->GetHits()>MxCands)){break;}
TStr HitUrlStr=SrcUrlRSet->GetHitUrlStr(HitN);
printf("Expand URL: %s\n", HitUrlStr.CStr());
PRSet RelUrlRSet=
TGg::WebSearch(TStr("related:")+HitUrlStr, -1, TNotify::NullNotify, ProxyStr);
FCrawl->DstRSet->Merge(RelUrlRSet);
}
// save related urls
//TRSet::SaveXml(DstRSet, OutXmlUrlFNm);
// collect related web-pages
TGgWebFetchSaver WebFetchSaver(100);
WebFetchSaver.PutProxyStr(ProxyStr);
// get source-url web-page
{bool Ok; TStr MsgStr;
TWebFetchBlocking::GetWebPg(
SrcUrlStr, Ok, MsgStr, FCrawl->SrcWebPg, NULL, ProxyStr);
if (!Ok){FCrawl->SrcWebPg=NULL;}}
// get related-urls web-page
int FetchHits=FCrawl->DstRSet->GetHits();
if ((MxCands!=-1)&&(MxCands<FetchHits)){FetchHits=MxCands;}
for (int HitN=0; HitN<FetchHits; HitN++){
TStr HitUrlStr=FCrawl->DstRSet->GetHitUrlStr(HitN);
WebFetchSaver.FetchUrl(HitUrlStr);
}
TSysMsg::Loop();
// save crawled web-pages
for (int WebPgN=0; WebPgN<WebFetchSaver.GetWebPgs(); WebPgN++){
PWebPg WebPg=WebFetchSaver.GetWebPg(WebPgN);
FCrawl->UrlStrToWebPgH.AddDat(WebPg->GetUrlStr(), WebPg);
}
// create bag-of-words
FCrawl->BowDocBs=TBowDocBs::New();
FCrawl->SrcDId=FCrawl->BowDocBs->AddHtmlDoc(
SrcUrlStr, TStrV(), FCrawl->SrcWebPg->GetHttpBodyAsStr());
for (int WebPgN=0; WebPgN<WebFetchSaver.GetWebPgs(); WebPgN++){
PWebPg WebPg=WebFetchSaver.GetWebPg(WebPgN);
FCrawl->BowDocBs->AddHtmlDoc(
WebPg->GetUrlStr(0), TStrV(), WebPg->GetHttpBodyAsStr());
}
// calculate similarities to the source document
PBowDocWgtBs BowDocWgtBs=TBowDocWgtBs::New(FCrawl->BowDocBs, bwwtNrmTFIDF);
PBowSim BowSim=TBowSim::New(bstCos);
FCrawl->SimDIdKdV; FCrawl->SumSim=0;
for (int DIdN=0; DIdN<BowDocWgtBs->GetDocs(); DIdN++){
int DId=BowDocWgtBs->GetDId(DIdN);
if (DId!=FCrawl->SrcDId){
double Sim=BowSim->GetSim(
BowDocWgtBs->GetSpV(FCrawl->SrcDId), BowDocWgtBs->GetSpV(DId));
FCrawl->SimDIdKdV.Add(TFltIntKd(Sim, DId));
FCrawl->SumSim+=Sim;
}
}
FCrawl->SimDIdKdV.Sort(false);
// set crawl ok
FCrawl->Ok=true;
// return focused-crawl
return FCrawl;
}
示例10: GetAuthNmVPubStr
void TGgSchRef::GetAuthNmVPubStr(
const TStr& AuthNmVPubStr, TStrV& AuthNmV, TStr& PubNm, TStr& PubYearStr){
// split input string into two parts
TStr AuthNmVStr; TStr PubStr;
AuthNmVPubStr.SplitOnStr(AuthNmVStr, " - ", PubStr);
// author-names string
AuthNmVStr.SplitOnAllCh(',', AuthNmV, true);
for (int AuthN=0; AuthN<AuthNmV.Len(); AuthN++){
AuthNmV[AuthN].ToTrunc();
}
if ((!AuthNmV.Empty())&&
((AuthNmV.Last().IsStrIn("..."))||(AuthNmV.Last().Len()<=2))){
AuthNmV.DelLast();
}
// publication-name & publication-year string
TStr OriginStr; TStr LinkStr;
PubStr.SplitOnStr(OriginStr, " - ", LinkStr);
OriginStr.SplitOnLastCh(PubNm, ',', PubYearStr);
PubNm.ToTrunc(); PubYearStr.ToTrunc();
if ((PubYearStr.Len()>=4)&&(PubYearStr.GetSubStr(0, 3).IsInt())){
PubYearStr=PubYearStr.GetSubStr(0, 3);
} else
if ((PubNm.Len()>=4)&&(PubNm.GetSubStr(0, 3).IsInt())){
PubYearStr=PubNm.GetSubStr(0, 3); PubNm="";
} else {
PubYearStr="";
}
}
示例11: SetAuthCrawled
void TGgSchBs::SetAuthCrawled(const TStr& AuthNm){
AuthNmToCrawlPH.AddDat(AuthNm.GetLc())=true;
}
示例12: DocStrToSylIdV
void TStrParser::DocStrToSylIdV(const TStr& _DocStr, TIntV& SyllablesIdV) {
TStr DocStr = _DocStr.GetUc(); // to upper case
Fail;
}
示例13: Rename
void TFile::Rename(const TStr& SrcFNm, const TStr& DstFNm){
EAssertR(
rename(SrcFNm.CStr(), DstFNm.CStr())==0,
"Error renaming file '"+SrcFNm+"' to "+DstFNm+"'.");
}
示例14: PutStr
void TFRnd::PutStr(const TStr& Str){
PutBf(Str.CStr(), Str.Len()+1);
}
示例15: GenDir
bool TDir::GenDir(const TStr& FPathFNm){
return CreateDirectory(FPathFNm.CStr(), NULL)!=0;
}