本文整理汇总了C++中TStr::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::Empty方法的具体用法?C++ TStr::Empty怎么用?C++ TStr::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveTs
void TGnuPlot::SaveTs(const TIntKdV& KdV, const TStr& FNm, const TStr& HeadLn) {
FILE *F = fopen(FNm.CStr(), "wt");
EAssert(F);
if (! HeadLn.Empty()) fprintf(F, "# %s\n", HeadLn.CStr());
for (int i = 0; i < KdV.Len(); i++) {
fprintf(F, "%d\t%d\n", KdV[i].Key(), KdV[i].Dat()); }
fclose(F);
}
示例2: TSBase
TFIn::TFIn(const TStr& FNm, bool& OpenedP):
TSBase(FNm.CStr()), TSIn(FNm), FileId(NULL), Bf(NULL), BfC(0), BfL(0){
EAssertR(!FNm.Empty(), "Empty file-name.");
FileId=fopen(FNm.CStr(), "rb");
OpenedP=(FileId!=NULL);
if (OpenedP){
Bf=new char[MxBfL]; BfC=BfL=-1; FillBf();}
}
示例3: GetFromStrQuV
PNmObjBs TNmObjBs::GetFromStrQuV(
const TStrQuV& IdTitleSrcHtmlQuV,
const TSwSetType& SwSetType, const TStr& CustSwSetFNm,
const TStr& NrWordBsFNm, const TStr& WordTypeBsFNm, const TStr& MteFNm,
const int& MxDocs, const bool& DumpP){
// custom-stop-words
PSIn CustSwSetSIn;
if (!CustSwSetFNm.Empty()&&(TFile::Exists(CustSwSetFNm))){
CustSwSetSIn=TFIn::New(CustSwSetFNm);}
// normalized-words
PSIn NrWordBsSIn;
if (!NrWordBsFNm.Empty()&&(TFile::Exists(NrWordBsFNm))){
NrWordBsSIn=TFIn::New(NrWordBsFNm);}
// word-types
PSIn WordTypeBsSIn;
if (!WordTypeBsFNm.Empty()&&(TFile::Exists(WordTypeBsFNm))){
WordTypeBsSIn=TFIn::New(WordTypeBsFNm);}
// create named-objects-base
PNmObjBs NmObjBs=
TNmObjBs::New(SwSetType, CustSwSetSIn, NrWordBsSIn, WordTypeBsSIn, MteFNm);
// traverse compact-documents
for (int DocN=0; DocN<IdTitleSrcHtmlQuV.Len(); DocN++){
if ((MxDocs!=-1)&&(DocN>MxDocs)){break;}
TStr DocNm=IdTitleSrcHtmlQuV[DocN].Val1;
TStr TitleStr=IdTitleSrcHtmlQuV[DocN].Val2;
TStr HtmlStr=IdTitleSrcHtmlQuV[DocN].Val4;
//if (!DocNm.IsStrIn("1998-06-18-z1b9.")){continue;}
if (DumpP){
printf("===============================================\n");
printf("%s\n", DocNm.CStr());
}
// extract candidate named-objects
TStrV CandWordStrV; NmObjBs->ExtrCandWordStrV(HtmlStr, CandWordStrV, DumpP);
// extract final named-objects from candidates
TIntV NmObjIdV; NmObjBs->FilterCandToNmObjIdV(CandWordStrV, NmObjIdV, DumpP);
// create document and add named-objects
NmObjBs->AddDoc(DocNm, "", NmObjIdV);
}
// get merged named-objects
TIntV NewNmObjIdV; NmObjBs->GetMergedNmObj(NewNmObjIdV);
// apply merged named-objects
NmObjBs->PutMergedNmObj(NewNmObjIdV);
// return named-objects-base
return NmObjBs;
}
示例4: AddHitSetChA
void TWebTxtBsSrv::AddHitSetChA(
const PTxtBsRes& TxtBsRes, const TStr& RqContTypeStr,
const int& HitSetN, const int& HitSetDocs, const int& StrHitSets,
const PUrlEnv& UrlEnv, TChA& OutChA){
// get hit-set data
TStr PrevUrlStr; TStrPrV NmUrlStrPrV; TStr NextUrlStr;
TxtBsRes->GetHitSet(
HitSetN, HitSetDocs, StrHitSets, HitSetUrlFldNm, UrlEnv,
PrevUrlStr, NmUrlStrPrV, NextUrlStr);
// hit-set header
TStr HitSetHdTpl=GetTplVal(RqContTypeStr, "HitSetHd");
OutChA+=HitSetHdTpl;
// hit-set 'previous'
if (!PrevUrlStr.Empty()){
TStr HitSetPrevTpl=GetTplVal(RqContTypeStr, "HitSetPrev");
HitSetPrevTpl.ChangeStrAll(UrlMacro, PrevUrlStr);
OutChA+=HitSetPrevTpl;
}
// hit-set records
for (int NmN=0; NmN<NmUrlStrPrV.Len(); NmN++){
TStr Nm=NmUrlStrPrV[NmN].Val1;
TStr UrlStr=NmUrlStrPrV[NmN].Val2;
if (UrlStr.Empty()){
// hit-set record with name
TStr HitSetRecTpl=GetTplVal(RqContTypeStr, "HitSetRecNm");
HitSetRecTpl.ChangeStrAll(NmMacro, Nm);
OutChA+=HitSetRecTpl;
} else {
// hit-set record with linked name
TStr HitSetRecTpl=GetTplVal(RqContTypeStr, "HitSetRecLinkedNm");
HitSetRecTpl.ChangeStrAll(NmMacro, Nm);
HitSetRecTpl.ChangeStrAll(UrlMacro, UrlStr);
OutChA+=HitSetRecTpl;
}
}
// hit-set 'next'
if (!NextUrlStr.Empty()){
TStr HitSetNextTpl=GetTplVal(RqContTypeStr, "HitSetNext");
HitSetNextTpl.ChangeStrAll(UrlMacro, NextUrlStr);
OutChA+=HitSetNextTpl;
}
// hit-set footer
TStr HitSetFtTpl=GetTplVal(RqContTypeStr, "HitSetFt");
OutChA+=HitSetFtTpl;
}
示例5: Dump
/////////////////////////////////////////////////
// Connected Components
void TCnCom::Dump(const TCnComV& CnComV, const TStr& Desc) {
if (! Desc.Empty()) { printf("%s:\n", Desc.CStr()); }
for (int cc = 0; cc < CnComV.Len(); cc++) {
const TIntV& NIdV = CnComV[cc].NIdV;
printf("%d : ", NIdV.Len());
for (int i = 0; i < NIdV.Len(); i++) { printf(" %d", NIdV[i].Val); }
printf("\n");
}
}
示例6: SaveEps
void TGnuPlot::SaveEps(const TStr& FNm, const int& FontSz, const TStr& Comment) {
AddCmd(TStr::Fmt("set terminal postscript enhanced eps %d color", FontSz));
AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
Pause(false);
CreatePlotFile(Comment.Empty()? Title : Comment);
RunGnuPlot();
MoreCmds.DelLast();
MoreCmds.DelLast();
}
示例7: PlotInvParticipRat
// Inverse participation ratio: normalize EigVec to have L2=1 and then I=sum_k EigVec[i]^4
// see Spectra of "real-world" graphs: Beyond the semicircle law by Farkas, Derenyi, Barabasi and Vicsek
void PlotInvParticipRat(const PUNGraph& Graph, const int& MaxEigVecs, const int& TimeLimit, const TStr& FNmPref, TStr DescStr) {
TFltPrV EigIprV;
GetInvParticipRat(Graph, MaxEigVecs, TimeLimit, EigIprV);
if (DescStr.Empty()) { DescStr = FNmPref; }
if (EigIprV.Empty()) { DescStr+=". FAIL"; EigIprV.Add(TFltPr(-1,-1)); return; }
TGnuPlot::PlotValV(EigIprV, "eigIPR."+FNmPref, TStr::Fmt("%s. G(%d, %d). Largest eig val = %f (%d values)",
DescStr.CStr(), Graph->GetNodes(), Graph->GetEdges(), EigIprV.Last().Val1(), EigIprV.Len()),
"Eigenvalue", "Inverse Participation Ratio of corresponding Eigenvector", gpsLog10Y, false, gpwPoints);
}
示例8: GetObjHdNmV
void TExpHelp::GetObjHdNmV(const TStr& CatNm, TStrV& ObjHdNmV) const {
ObjHdNmV.Clr();
for (int ObjN=0; ObjN<ObjV.Len(); ObjN++){
TStr ObjCatNm=ObjV[ObjN]->GetCatNm();
TStr ObjHdNm=ObjV[ObjN]->GetHdItem()->GetNm();
if ((CatNm.Empty())||(CatNm=="All")||(CatNm==ObjCatNm)){
ObjHdNmV.AddUnique(ObjHdNm);}
}
ObjHdNmV.Sort();
}
示例9: FPathV
TFFile::TFFile(const TStr& _FPath, const TStr& _FExt, const bool& _RecurseP):
FPathV(), FExtV(), FBaseWc(),
CsImpP(false), RecurseP(_RecurseP), FPathN(0-1),
FFileDesc(TFFileDesc::New()), SubFFile(), CurFNm(), CurFNmN(0-1){
FPathV.Add(TStr::GetNrFPath(_FPath));
if (!_FExt.Empty()){
FExtV.Add(TStr::GetNrFExt(_FExt));
if (!CsImpP){FExtV.Last().ToUc();}
}
}
示例10: GetFldY
int TSs::GetFldY(const TStr& FldNm, const TStr& NewFldNm, const int& X) const {
for (int Y=0; Y<GetYLen(); Y++){
if (GetXLen(Y)>X){
if (GetVal(X, Y).GetTrunc()==FldNm){
if (!NewFldNm.Empty()){GetVal(X, Y)=NewFldNm;}
return Y;
}
}
}
return -1;
}
示例11: SavePng
void TGnuPlot::SavePng(const TStr& FNm, const int& SizeX, const int& SizeY, const TStr& Comment, const TStr& Terminal) {
if (Terminal.Empty()) {
//#ifdef GLib_WIN
//#ifndef GLib_MACOSX // The standard GNUPlot for MacOS does not support PNG (Jure: actually version 4.6 DOES!)
AddCmd(TStr::Fmt("set terminal png size %d,%d", SizeX, SizeY));
AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
//#else // EPS
//AddCmd("set terminal postscript eps 10 enhanced color");
//AddCmd(TStr::Fmt("set output '%s%s.eps'", FNm.GetFPath().CStr(), FNm.GetFMid().CStr()));
//#endif
} else {
AddCmd(Terminal);
AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
}
Pause(false);
CreatePlotFile(Comment.Empty()? Title : Comment);
RunGnuPlot();
MoreCmds.DelLast();
MoreCmds.DelLast();
}
示例12: Update
bool TCategorical::Update(const TStr& Val) {
if ((Type == ctOpen) && !Val.Empty()) {
// check if new value
const bool NewP = !ValSet.IsKey(Val);
// remember if new
if (NewP) { ValSet.AddKey(Val); }
// return if we increased dimensionality
return NewP;
}
// otherwise we have fixed dimensionality
return false;
}
示例13: AddFunc
//GP.AddFunc("2*x**-2+4", gpwLines, "2*x^-2+4");
int TGnuPlot::AddFunc(const TStr& FuncStr, const TGpSeriesTy& SeriesTy, const TStr& Label, const TStr& Style) {
const int Id = SeriesV.Len();
TGpSeries Plot;
Plot.SeriesTy = SeriesTy;
Plot.Label = Label;
if (! FuncStr.Empty()) { Plot.DataFNm = TStr::Fmt("f%d(x)=%s, f%d(x)", Id, FuncStr.CStr(), Id); }
else { Plot.DataFNm = TStr::Fmt("f%d(x)", Id); }
Plot.XCol = -1;
Plot.WithStyle = Style;
SeriesV.Add(Plot);
return Id;
}
示例14: main
int main(int argc, char* argv[]) {
Env = TEnv(argc, argv, TNotify::StdNotify);
Env.PrepArgs(TStr::Fmt("Motifs. build: %s, %s. Time: %s", __TIME__, __DATE__, TExeTm::GetCurTm()));
TExeTm ExeTm;
Try
const TStr InFNm = Env.GetIfArgPrefixStr("-i:", "../as20graph.txt", "Input directed graph file (single directed edge per line)");
const int MotifSz = Env.GetIfArgPrefixInt("-m:", 3, "Motif size (has to be 3 or 4)");
const bool DrawMotifs = Env.GetIfArgPrefixBool("-d:", true, "Draw motif shapes (requires GraphViz)");
TStr OutFNm = Env.GetIfArgPrefixStr("-o:", "", "Output file prefix");
if (OutFNm.Empty()) { OutFNm = InFNm.GetFMid(); }
EAssert(MotifSz==3 || MotifSz==4);
// load graph
PNGraph G;
if (InFNm.GetFExt().GetLc()==".ungraph") {
TFIn FIn(InFNm); G=TSnap::ConvertGraph<PNGraph>(TUNGraph::Load(FIn), true); }
else if (InFNm.GetFExt().GetLc()==".ngraph") {
TFIn FIn(InFNm); G=TNGraph::Load(FIn); }
else {
G = TSnap::LoadEdgeList<PNGraph>(InFNm, 0, 1); }
bool IsOk = true;
for (int nid = 0; nid < G->GetNodes(); nid++) {
if (! G->IsNode(nid)) { IsOk=false; break; } }
if (! IsOk) {
printf("Nodes of the input graph have to be numbered 0...N-1\nRenumbering nodes...\n");
PNGraph OG = G; G = TNGraph::New();
TGraphEnumUtils::GetNormalizedGraph(OG, G);
}
// G = TSnap::GenRndGnm<PNGraph>(100, Kilo(1));
// count frequency of connected subgraphs in G that have MotifSz nodes
TD34GraphCounter GraphCounter(MotifSz);
TSubGraphEnum<TD34GraphCounter> GraphEnum;
GraphEnum.GetSubGraphs(G, MotifSz, GraphCounter);
FILE *F = fopen(TStr::Fmt("%s-counts.tab", OutFNm.CStr()).CStr(), "wt");
fprintf(F, "MotifId\tNodes\tEdges\tCount\n");
for (int i = 0; i < GraphCounter.Len(); i++) {
const int gid = GraphCounter.GetId(i);
PNGraph SG = GraphCounter.GetGraph(gid);
if (DrawMotifs) {
TGraphViz::Plot(SG, gvlNeato, TStr::Fmt("%s-motif%03d.gif", OutFNm.CStr(), i),
TStr::Fmt("GId:%d Count: %llu", gid, GraphCounter.GetCnt(gid)));
}
fprintf(F, "%d\t%d\t%d\t%llu\n", gid, SG->GetNodes(), SG->GetEdges(), GraphCounter.GetCnt(gid));
}
printf("done.");
fclose(F);
Catch
printf("\nrun time: %s (%s)\n", ExeTm.GetTmStr(), TSecTm::GetCurTm().GetTmStr().CStr());
return 0;
}
示例15: SavePng
void TGnuPlot::SavePng(const TStr& FNm, const int& SizeX, const int& SizeY, const TStr& Comment, const TStr& Terminal) {
if (Terminal.Empty()) {
//#ifdef GLib_WIN
AddCmd(TStr::Fmt("set terminal png small size %d,%d", SizeX, SizeY));
AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
/**
#else // EPS
AddCmd("set terminal postscript eps 10 enhanced color");
AddCmd(TStr::Fmt("set output '%s.eps'", FNm.GetFMid().CStr()));
#endif
*/
} else {
AddCmd(Terminal);
AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
}
Pause(false);
CreatePlotFile(Comment.Empty()? Title : Comment);
RunGnuPlot();
MoreCmds.DelLast();
MoreCmds.DelLast();
}