当前位置: 首页>>代码示例>>C++>>正文


C++ TStr::IsInt方法代码示例

本文整理汇总了C++中TStr::IsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::IsInt方法的具体用法?C++ TStr::IsInt怎么用?C++ TStr::IsInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TStr的用法示例。


在下文中一共展示了TStr::IsInt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Split

void TFtrGenSparseNumeric::Split(
        const TStr& Str, int& Id, TStr& Val) const {

    if (!Str.IsChIn(':')) { TExcept::Throw("Wrong sparse numeric '" + Str + "'!"); }
    //split
    TStr IdStr; Str.SplitOnCh(IdStr, ':', Val);
    // parse id
    if (!IdStr.IsInt(Id)) { TExcept::Throw("Wrong sparse numeric '" + Str + "'!"); }
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:9,代码来源:ftrgen.cpp

示例2: 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();
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:6,代码来源:sappsrv.cpp

示例3: OnHttpRq

void TWebTxtBsSrv::OnHttpRq(const int& SockId, const PHttpRq& HttpRq){
  // request parameters
  TStr RqContTypeStr=THttp::TextHtmlFldVal;
  PUrlEnv UrlEnv;
  TStr QueryStr; TStr EQueryStr;
  TStr HitSetStr; TStr AcceptStr;
  // prepare & extract search-environment
  if (HttpRq->IsOk()){
    // prepare search-environment
    PUrl Url=HttpRq->GetUrl();
    UrlEnv=HttpRq->GetUrlEnv();
    // if empty search-environment and url-path is not empty
    if (UrlEnv->Empty()&&
     (Url->GetPathSegs()>0)&&(!Url->GetPathSeg(0).Empty())){
      // get document name
      TStr DocNm=Url->GetPathSeg(Url->GetPathSegs()-1);
      if (WebTxtBs->GetTxtBs()->IsDoc(DocNm)){
        // document exists in text-base
        TStr DocStr=WebTxtBs->GetTxtBs()->GetDocStr(DocNm);
        PSIn HttpBodySIn=TMIn::New(DocStr);
        PHttpResp HttpResp=
         THttpResp::New(THttp::OkStatusCd, RqContTypeStr, false, HttpBodySIn);
        SendHttpResp(SockId, HttpResp);
      } else {
        // ordinary http request
        TWebSrv::OnHttpRq(SockId, HttpRq);
      }
      // end if no search request
      return;
    }
    // extract fields from search-environment
    QueryStr=UrlEnv->GetVal(QueryUrlFldNm).GetTrunc();
    EQueryStr=THtmlLx::GetEscapedStr(QueryStr);
    HitSetStr=UrlEnv->GetVal(HitSetUrlFldNm).GetTrunc();
    AcceptStr=UrlEnv->GetVal(AcceptUrlFldNm).GetTrunc();
    if (AcceptStr.Empty()){RqContTypeStr=GetRqContType(HttpRq);}
    else {RqContTypeStr=AcceptStr;}
  }

  // hit-set
  int HitSetN=1;
  HitSetStr.IsInt(true, 1, TInt::Mx, HitSetN);
  int HitSetDocs=GetVarVal(RqContTypeStr, "HitSetDocs").GetInt();
  int StrHitSets=GetVarVal(RqContTypeStr, "StrHitSets").GetInt();

  // output buffer
  TChA OutChA(10000);
  // header
  TStr HdTpl=GetTplVal(RqContTypeStr, "Header");
  HdTpl.ChangeStrAll(QueryMacro, EQueryStr);
  OutChA+=HdTpl;
  // html body
  if (HttpRq->IsOk()){
    if (!QueryStr.Empty()){
      // execute query
      PTxtBsRes TxtBsRes=WebTxtBs->Search(QueryStr);
      TStr EWixExpStr=THtmlLx::GetEscapedStr(TxtBsRes->GetWixExpStr());
      // log string
      TChA QueryInfoChA;
      QueryInfoChA+="Query: "+QueryStr;
      //QueryInfoChA+=" ["+GetPeerNm(SockId)+"]";
      QueryInfoChA+=" ["+TSecTm::GetCurTm().GetStr()+"]";
      TNotify::OnNotify(Notify, ntInfo, QueryInfoChA);
      SLog->PutStr(QueryInfoChA); SLog->PutLn(); SLog->Flush();
      // query-results processing
      if (TxtBsRes->IsOk()){
        // result header
        TStr ResultHdTpl=GetTplVal(RqContTypeStr, "ResultHd");
        ResultHdTpl.ChangeStrAll(QueryMacro, EWixExpStr);
        ResultHdTpl.ChangeStrAll(HitsMacro, TInt::GetStr(TxtBsRes->GetDocs()));
        OutChA+=ResultHdTpl;
        // result records
        int MnDocN; int MxDocN;
        TxtBsRes->GetHitSetMnMxDocN(HitSetN, HitSetDocs, MnDocN, MxDocN);
        for (int DocN=MnDocN; DocN<=MxDocN; DocN++){
          // get result document data
          int MxDocTitleLen=GetVarVal(RqContTypeStr, "MxDocTitleLen").GetInt();
          int MxDocCtxLen=GetVarVal(RqContTypeStr, "MxDocCtxLen").GetInt();
          TStr DocNm; TStr DocTitleStr; TStr DocStr; TStr DocCtxStr;
          TxtBsRes->GetDocInfo(DocN, MxDocTitleLen, MxDocCtxLen,
           DocNm, DocTitleStr, DocStr, DocCtxStr);
          if (DocTitleStr.Empty()){DocTitleStr=DocNm;}
          // result record
          TStr ResultRecTpl=GetTplVal(RqContTypeStr, "ResultRec");
          ResultRecTpl.ChangeStrAll(HitNumMacro, TInt::GetStr(DocN+1));
          ResultRecTpl.ChangeStrAll(DocAddrMacro, DocNm);
          ResultRecTpl.ChangeStrAll(DocTitleMacro, DocTitleStr);
          ResultRecTpl.ChangeStrAll(DocCtxMacro, DocCtxStr);
          OutChA+=ResultRecTpl;
        }
        // result footer
        TStr ResultFtTpl=GetTplVal(RqContTypeStr, "ResultFt");
        OutChA+=ResultFtTpl;
        // hit-set
        AddHitSetChA(TxtBsRes, RqContTypeStr, HitSetN, HitSetDocs, StrHitSets,
         UrlEnv, OutChA);
      } else {
        // bad query
        TStr BadQueryTpl=GetTplVal(RqContTypeStr, "BadQuery");
        BadQueryTpl.ChangeStrAll(QueryMacro, EWixExpStr);
//.........这里部分代码省略.........
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:101,代码来源:webtxtbs.cpp

示例4: LoadTxt

// load from allactors.zip that was prepared by Brad Malin in 2005
PImdbNet TImdbNet::LoadTxt(const TStr& ActorFNm) {
  PImdbNet Net = TImdbNet::New();
  TStrV ColV;
  char line [2024];
  int NLines=0, DupEdge=0, Year, Position, ActorNId, MovieNId;
  TIntH ActorNIdH;
  THash<TIntPr, TInt> MovieNIdH;
  FILE *F = fopen(ActorFNm.CStr(), "rt");  fgets(line, 2024, F);
  while (! feof(F)) {
    memset(line, 0, 2024);
    fgets(line, 2024, F);
    if (strlen(line) == 0) break;
    TStr(line).SplitOnAllCh('|', ColV, false);  IAssert(ColV.Len() == 7);
    const int NameStrId = Net->AddStr(ColV[0].GetTrunc().GetLc()+" "+ColV[1].GetTrunc().GetLc());
    const int MovieStrId = Net->AddStr(ColV[2].GetTrunc().GetLc());
    TStr YearStr = ColV[3].GetTrunc();
    if (YearStr.Len() > 4) YearStr = YearStr.GetSubStr(0, 3);
    Year = 1;  YearStr.IsInt(Year);
    const TMovieTy MovieTy = TImdbNet::GetMovieTy(ColV[4]);
    Position = TInt::Mx;  ColV[5].GetTrunc().IsInt(Position);
    IAssert(ColV[6].GetTrunc()[0] == 'M' || ColV[6].GetTrunc()[0]=='F');
    const bool IsMale = ColV[6].GetTrunc()[0] == 'M';
    // create nodes  
    if (ActorNIdH.IsKey(NameStrId)) { 
      ActorNId = ActorNIdH.GetDat(NameStrId); }
    else { 
      ActorNId = Net->AddNode(-1, TImdbNode(NameStrId, Year, Position, IsMale));
      ActorNIdH.AddDat(NameStrId, ActorNId);
    }
    if (MovieNIdH.IsKey(TIntPr(MovieStrId, Year))) {
      MovieNId = MovieNIdH.GetDat(TIntPr(MovieStrId, Year)); }
    else {
      MovieNId = Net->AddNode(-1, TImdbNode(NameStrId, Year, MovieTy)); 
      MovieNIdH.AddDat(TIntPr(MovieStrId, Year), MovieNId); 
    }
    if (! Net->IsEdge(ActorNId, MovieNId)) { 
      Net->AddEdge(ActorNId, MovieNId); }
    else { DupEdge++; }
    if (++NLines % 100000 == 0) printf("\r  %dk  ", NLines/1000);
  }
  fclose(F);
  printf("duplicate edges: %d\n", DupEdge);
  printf("nodes:  %d\n", Net->GetNodes());
  printf("edges:  %d\n", Net->GetEdges());
  printf("actors: %d\n", ActorNIdH.Len());
  printf("movies: %d\n", MovieNIdH.Len());
  // set the actor year to the year of his first movie
  int NUpdates=0;
  for (TNet::TNodeI NI = Net->BegNI(); NI < Net->EndNI(); NI++) {
    if (NI().IsActor()) {
      int MinYear = NI().GetYear();
      for (int e = 0; e < NI.GetOutDeg(); e++) {
        const TImdbNode& NodeDat = Net->GetNDat(NI.GetOutNId(e));
        if (NodeDat.IsMovie()) MinYear = TMath::Mn(MinYear, NodeDat.GetYear());
      }
      if (NI().Year != MinYear) NUpdates++;
      NI().Year = MinYear;
    }
  }
  printf("updated actor times: %d\n", NUpdates);
  return Net;
}
开发者ID:SherlockYang,项目名称:Archive,代码行数:63,代码来源:imdbnet.cpp


注:本文中的TStr::IsInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。