本文整理汇总了C++中TStr::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::GetInt方法的具体用法?C++ TStr::GetInt怎么用?C++ TStr::GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::GetInt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIfArgPrefixInt
int TEnv::GetIfArgPrefixInt(const TStr& PrefixStr,
const int& DfVal,
const TStr& DNm) const {
if (Env.GetArgs() <= MnArgs) {
// 'usage' argument message
if (!SilentP) {
printf(" %s%s (default:%d)\n", PrefixStr.CStr(),
DNm.CStr(), DfVal);
}
return DfVal;
} else {
// argument & value message
int Val;
if (Env.IsArgPrefix(PrefixStr)) {
TStr ValStr = Env.GetArgPostfix(PrefixStr);
Val = ValStr.GetInt(DfVal);
} else {
Val = DfVal;
}
TStr MsgStr =
DNm + " (" + PrefixStr + ")=" + TInt::GetStr(Val);
if (!SilentP) {
TNotify::OnStatus(Notify, MsgStr);
}
return Val;
}
}
示例2: ParseArgument
int ParseArgument(const TStr& arg, const TStr& argType, PyObject** argPy)
{
if (argType == "int")
{
*argPy = PyLong_FromLong(arg.GetInt());
}
else if (argType == "double")
{
*argPy = PyFloat_FromDouble(arg.GetFlt());
}
else if (argType == "string")
{
*argPy = PyUnicode_FromString(arg.CStr());
}
if (!*argPy) {
fprintf(stderr, "Cannot convert argument\n");
return 0;
}
return 1;
}
示例3: OnGetHost
void TWebPgFetchEvent::OnGetHost(const PSockHost& SockHost) {
if (SockHost->IsOk()){
UrlStrV.Add(CurUrl->GetUrlStr());
OppSockClosed=false;
SockMem.Clr();
Sock=TSock::New(this);
int PortN;
if (ProxyStr.Empty()){
PortN=CurUrl->GetPortN();
} else {
TStr ProxyHostNm; TStr PortNStr;
ProxyStr.SplitOnCh(ProxyHostNm, ':', PortNStr);
PortN=PortNStr.GetInt(80);
}
Sock->PutTimeOut(TimeOutMSecs);
Sock->Connect(SockHost, PortN);
} else {
OnFetchError("Invalid Host");
}
}
示例4: GetFldInt
int TSAppSrvFun::GetFldInt(const TStrKdV& FldNmValPrV, const TStr& FldNm, const int& DefInt) {
if (!IsFldNm(FldNmValPrV, FldNm)) { return DefInt; }
TStr IntStr = GetFldVal(FldNmValPrV, FldNm, "");
EAssertR(IntStr.IsInt(), "Parameter '" + FldNm + "' not a number");
return IntStr.GetInt();
}
示例5: main
int main(int argc, char* argv[]) {
Env = TEnv(argc, argv, TNotify::StdNotify);
Env.PrepArgs(TStr::Fmt("\nNETINF. build: %s, %s. Time: %s", __TIME__, __DATE__, TExeTm::GetCurTm()));
TExeTm ExeTm;
Try
const TStr InFNm = Env.GetIfArgPrefixStr("-i:", "example-cascades.txt", "Input cascades (one file)");
const TStr GroundTruthFNm = Env.GetIfArgPrefixStr("-n:", "example-network.txt", "Input ground-truth network (one file)");
const TStr OutFNm = Env.GetIfArgPrefixStr("-o:", "network", "Output file name(s) prefix");
const TStr Iters = Env.GetIfArgPrefixStr("-e:", "5", "Number of iterations");
const double alpha = Env.GetIfArgPrefixFlt("-a:", 1.0, "Alpha for transmission model");
const int Model = Env.GetIfArgPrefixInt("-m:", 0, "0:exponential, 1:power law, 2:rayleigh");
const int Top =Env.GetIfArgPrefixInt("-t:", 10, "select top k as friends");
const int TakeAdditional = Env.GetIfArgPrefixInt("-s:", 1, "How much additional files to create?\n\
1:info about each edge, 2:objective function value (+upper bound), 3:Precision-recall plot, 4:all-additional-files (default:1)\n");
bool ComputeBound = false, ComputeInfo = false; bool CompareGroundTruth = false;
switch (TakeAdditional) {
case 1 : ComputeInfo = true; break;
case 2 : ComputeBound = true; break;
case 3 : CompareGroundTruth = true; break;
case 4 :
ComputeInfo = true;
// ComputeBound = true;
CompareGroundTruth = true; break;
default: FailR("Bad -s: parameter.");
}
TNetInfBs NIB(ComputeBound, CompareGroundTruth, Top);
printf("\nLoading input cascades: %s\n", InFNm.CStr());
// load cascade from file
TFIn FIn(InFNm);
NIB.LoadCascadesTxt(FIn, Model, alpha);
// load ground truth network
if (CompareGroundTruth) {
TFIn FInG(GroundTruthFNm);
NIB.LoadGroundTruthTxt(FInG);
}
NIB.Init();
printf("cascades:%d nodes:%d potential edges:%d\nRunning NETINF...\n", NIB.GetCascs(), NIB.GetNodes(), NIB.CascPerEdge.Len());
NIB.GreedyOpt(Iters.GetInt());
// plot showing precision/recall using groundtruth
if (CompareGroundTruth)
TGnuPlot::PlotValV(NIB.PrecisionRecall, TStr::Fmt("%s-precision-recall", OutFNm.CStr()), "Precision Recall", "Recall",
"Precision", gpsAuto, false, gpwLinesPoints, false);
// plot objective function
if (ComputeBound) {
TFltPrV Gains;
for (int i=0; i<NIB.EdgeInfoH.Len(); i++)
Gains.Add(TFltPr((double)(i+1), NIB.EdgeInfoH[i].MarginalGain));
TGnuPlot::PlotValV(Gains, TStr::Fmt("%s-objective", OutFNm.CStr()), "Objective Function", "Iters", "Objective Function");
}
// save network in plain text
NIB.SavePlaneTextNet(TStr::Fmt("%s.txt", OutFNm.CStr()));
// save edge info
if (ComputeInfo)
NIB.SaveEdgeInfo(TStr::Fmt("%s-edge.info", OutFNm.CStr()));
// save obj+bound info
if (ComputeBound)
NIB.SaveObjInfo(TStr::Fmt("%s-obj", OutFNm.CStr()));
Catch
printf("\nrun time: %s (%s)\n", ExeTm.GetTmStr(), TSecTm::GetCurTm().GetTmStr().CStr());
return 0;
}